Annotation of gcc/c-decl.c, revision 1.1.1.1

1.1       root        1: /* Process declarations and variables for C compiler.
                      2:    Copyright (C) 1988, 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: 
                     20: 
                     21: /* Process declarations and symbol lookup for C front end.
                     22:    Also constructs types; the standard scalar types at initialization,
                     23:    and structure, union, array and enum types when they are declared.  */
                     24: 
                     25: /* ??? not all decl nodes are given the most useful possible
                     26:    line numbers.  For example, the CONST_DECLs for enum values.  */
                     27: 
                     28: #include "config.h"
                     29: #include "tree.h"
                     30: #include "flags.h"
                     31: #include "c-tree.h"
                     32: #include "c-lex.h"
                     33: #include <stdio.h>
                     34: 
                     35: /* In grokdeclarator, distinguish syntactic contexts of declarators.  */
                     36: enum decl_context
                     37: { NORMAL,                      /* Ordinary declaration */
                     38:   FUNCDEF,                     /* Function definition */
                     39:   PARM,                                /* Declaration of parm before function body */
                     40:   FIELD,                       /* Declaration inside struct or union */
                     41:   BITFIELD,                    /* Likewise but with specified width */
                     42:   TYPENAME};                   /* Typename (inside cast or sizeof)  */
                     43: 
                     44: #undef NULL
                     45: #define NULL 0
                     46: 
                     47: #ifndef CHAR_TYPE_SIZE
                     48: #define CHAR_TYPE_SIZE BITS_PER_UNIT
                     49: #endif
                     50: 
                     51: #ifndef SHORT_TYPE_SIZE
                     52: #define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2))
                     53: #endif
                     54: 
                     55: #ifndef INT_TYPE_SIZE
                     56: #define INT_TYPE_SIZE BITS_PER_WORD
                     57: #endif
                     58: 
                     59: #ifndef LONG_TYPE_SIZE
                     60: #define LONG_TYPE_SIZE BITS_PER_WORD
                     61: #endif
                     62: 
                     63: #ifndef LONG_LONG_TYPE_SIZE
                     64: #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
                     65: #endif
                     66: 
                     67: #ifndef WCHAR_UNSIGNED
                     68: #define WCHAR_UNSIGNED 0
                     69: #endif
                     70: 
                     71: #ifndef FLOAT_TYPE_SIZE
                     72: #define FLOAT_TYPE_SIZE BITS_PER_WORD
                     73: #endif
                     74: 
                     75: #ifndef DOUBLE_TYPE_SIZE
                     76: #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
                     77: #endif
                     78: 
                     79: #ifndef LONG_DOUBLE_TYPE_SIZE
                     80: #define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
                     81: #endif
                     82: 
                     83: /* We let tm.h override the types used here, to handle trivial differences
                     84:    such as the choice of unsigned int or long unsigned int for size_t.
                     85:    When machines start needing nontrivial differences in the size type,
                     86:    it would be best to do something here to figure out automatically
                     87:    from other information what type to use.  */
                     88: 
                     89: #ifndef SIZE_TYPE
                     90: #define SIZE_TYPE "long unsigned int"
                     91: #endif
                     92: 
                     93: #ifndef PTRDIFF_TYPE
                     94: #define PTRDIFF_TYPE "long int"
                     95: #endif
                     96: 
                     97: #ifndef WCHAR_TYPE
                     98: #define WCHAR_TYPE "int"
                     99: #endif
                    100: 
                    101: /* a node which has tree code ERROR_MARK, and whose type is itself.
                    102:    All erroneous expressions are replaced with this node.  All functions
                    103:    that accept nodes as arguments should avoid generating error messages
                    104:    if this node is one of the arguments, since it is undesirable to get
                    105:    multiple error messages from one error in the input.  */
                    106: 
                    107: tree error_mark_node;
                    108: 
                    109: /* INTEGER_TYPE and REAL_TYPE nodes for the standard data types */
                    110: 
                    111: tree short_integer_type_node;
                    112: tree integer_type_node;
                    113: tree long_integer_type_node;
                    114: tree long_long_integer_type_node;
                    115: 
                    116: tree short_unsigned_type_node;
                    117: tree unsigned_type_node;
                    118: tree long_unsigned_type_node;
                    119: tree long_long_unsigned_type_node;
                    120: 
                    121: tree ptrdiff_type_node;
                    122: 
                    123: tree unsigned_char_type_node;
                    124: tree signed_char_type_node;
                    125: tree char_type_node;
                    126: tree wchar_type_node;
                    127: tree signed_wchar_type_node;
                    128: tree unsigned_wchar_type_node;
                    129: 
                    130: tree float_type_node;
                    131: tree double_type_node;
                    132: tree long_double_type_node;
                    133: 
                    134: /* a VOID_TYPE node.  */
                    135: 
                    136: tree void_type_node;
                    137: 
                    138: /* Nodes for types `void *' and `const void *'.  */
                    139: 
                    140: tree ptr_type_node, const_ptr_type_node;
                    141: 
                    142: /* Nodes for types `char *' and `const char *'.  */
                    143: 
                    144: tree string_type_node, const_string_type_node;
                    145: 
                    146: /* Type `char[256]' or something like it.
                    147:    Used when an array of char is needed and the size is irrelevant.  */
                    148: 
                    149: tree char_array_type_node;
                    150: 
                    151: /* Type `int[256]' or something like it.
                    152:    Used when an array of int needed and the size is irrelevant.  */
                    153: 
                    154: tree int_array_type_node;
                    155: 
                    156: /* Type `wchar_t[256]' or something like it.
                    157:    Used when a wide string literal is created.  */
                    158: 
                    159: tree wchar_array_type_node;
                    160: 
                    161: /* type `int ()' -- used for implicit declaration of functions.  */
                    162: 
                    163: tree default_function_type;
                    164: 
                    165: /* function types `double (double)' and `double (double, double)', etc.  */
                    166: 
                    167: tree double_ftype_double, double_ftype_double_double;
                    168: tree int_ftype_int, long_ftype_long;
                    169: 
                    170: /* Function type `void (void *, void *, int)' and similar ones */
                    171: 
                    172: tree void_ftype_ptr_ptr_int, int_ftype_ptr_ptr_int, void_ftype_ptr_int_int;
                    173: 
                    174: /* Function type `char *(char *, char *)' and similar ones */
                    175: tree string_ftype_ptr_ptr, int_ftype_string_string;
                    176: 
                    177: /* Function type `size_t (const char *)' */
                    178: tree sizet_ftype_string;
                    179: 
                    180: /* Function type `int (const void *, const void *, size_t)' */
                    181: tree int_ftype_cptr_cptr_sizet;
                    182: 
                    183: /* Two expressions that are constants with value zero.
                    184:    The first is of type `int', the second of type `void *'.  */
                    185: 
                    186: tree integer_zero_node;
                    187: tree null_pointer_node;
                    188: 
                    189: /* A node for the integer constant 1.  */
                    190: 
                    191: tree integer_one_node;
                    192: 
                    193: /* Nonzero if we have seen an invalid cross reference
                    194:    to a struct, union, or enum, but not yet printed the message.  */
                    195: 
                    196: tree pending_invalid_xref;
                    197: /* File and line to appear in the eventual error message.  */
                    198: char *pending_invalid_xref_file;
                    199: int pending_invalid_xref_line;
                    200: 
                    201: /* While defining an enum type, this is 1 plus the last enumerator
                    202:    constant value.  */
                    203: 
                    204: static tree enum_next_value;
                    205: 
                    206: /* Parsing a function declarator leaves a list of parameter names
                    207:    or a chain or parameter decls here.  */
                    208: 
                    209: static tree last_function_parms;
                    210: 
                    211: /* Parsing a function declarator leaves here a chain of structure
                    212:    and enum types declared in the parmlist.  */
                    213: 
                    214: static tree last_function_parm_tags;
                    215: 
                    216: /* After parsing the declarator that starts a function definition,
                    217:    `start_function' puts here the list of parameter names or chain of decls.
                    218:    `store_parm_decls' finds it here.  */
                    219: 
                    220: static tree current_function_parms;
                    221: 
                    222: /* Similar, for last_function_parm_tags.  */
                    223: static tree current_function_parm_tags;
                    224: 
                    225: /* A list (chain of TREE_LIST nodes) of all LABEL_DECLs in the function
                    226:    that have names.  Here so we can clear out their names' definitions
                    227:    at the end of the function.  */
                    228: 
                    229: tree named_labels;
                    230: 
                    231: /* A list of LABEL_DECLs from outer contexts that are currently shadowed.  */
                    232: 
                    233: static tree shadowed_labels;
                    234: 
                    235: /* Nonzero when store_parm_decls is called indicates a varargs function.
                    236:    Value not meaningful after store_parm_decls.  */
                    237: 
                    238: static int c_function_varargs;
                    239: 
                    240: /* The FUNCTION_DECL for the function currently being compiled,
                    241:    or 0 if between functions.  */
                    242: tree current_function_decl;
                    243: 
                    244: /* Set to 0 at beginning of a function definition, set to 1 if
                    245:    a return statement that specifies a return value is seen.  */
                    246: 
                    247: int current_function_returns_value;
                    248: 
                    249: /* Set to 0 at beginning of a function definition, set to 1 if
                    250:    a return statement with no argument is seen.  */
                    251: 
                    252: int current_function_returns_null;
                    253: 
                    254: /* Set to nonzero by `grokdeclarator' for a function
                    255:    whose return type is defaulted, if warnings for this are desired.  */
                    256: 
                    257: static int warn_about_return_type;
                    258: 
                    259: /* Nonzero when starting a function delcared `extern inline'.  */
                    260: 
                    261: static int current_extern_inline;
                    262: 
                    263: /* For each binding contour we allocate a binding_level structure
                    264:  * which records the names defined in that contour.
                    265:  * Contours include:
                    266:  *  0) the global one
                    267:  *  1) one for each function definition,
                    268:  *     where internal declarations of the parameters appear.
                    269:  *  2) one for each compound statement,
                    270:  *     to record its declarations.
                    271:  *
                    272:  * The current meaning of a name can be found by searching the levels from
                    273:  * the current one out to the global one.
                    274:  */
                    275: 
                    276: /* Note that the information in the `names' component of the global contour
                    277:    is duplicated in the IDENTIFIER_GLOBAL_VALUEs of all identifiers.  */
                    278: 
                    279: struct binding_level
                    280:   {
                    281:     /* A chain of _DECL nodes for all variables, constants, functions,
                    282:        and typedef types.  These are in the reverse of the order supplied.
                    283:      */
                    284:     tree names;
                    285: 
                    286:     /* A list of structure, union and enum definitions,
                    287:      * for looking up tag names.
                    288:      * It is a chain of TREE_LIST nodes, each of whose TREE_PURPOSE is a name,
                    289:      * or NULL_TREE; and whose TREE_VALUE is a RECORD_TYPE, UNION_TYPE,
                    290:      * or ENUMERAL_TYPE node.
                    291:      */
                    292:     tree tags;
                    293: 
                    294:     /* For each level, a list of shadowed outer-level local definitions
                    295:        to be restored when this level is popped.
                    296:        Each link is a TREE_LIST whose TREE_PURPOSE is an identifier and
                    297:        whose TREE_VALUE is its old definition (a kind of ..._DECL node).  */
                    298:     tree shadowed;
                    299: 
                    300:     /* For each level (except not the global one),
                    301:        a chain of BLOCK nodes for all the levels
                    302:        that were entered and exited one level down.  */
                    303:     tree blocks;
                    304: 
                    305:     /* The binding level which this one is contained in (inherits from).  */
                    306:     struct binding_level *level_chain;
                    307: 
                    308:     /* Nonzero for the level that holds the parameters of a function.  */
                    309:     /* 2 for a definition, 1 for a declaration.  */
                    310:     char parm_flag;
                    311: 
                    312:     /* Nonzero if this level "doesn't exist" for tags.  */
                    313:     char tag_transparent;
                    314: 
                    315:     /* Nonzero if sublevels of this level "don't exist" for tags.
                    316:        This is set in the parm level of a function definition
                    317:        while reading the function body, so that the outermost block
                    318:        of the function body will be tag-transparent.  */
                    319:     char subblocks_tag_transparent;
                    320: 
                    321:     /* Nonzero means make a BLOCK for this level regardless of all else.  */
                    322:     char keep;
                    323: 
                    324:     /* Nonzero means make a BLOCK if this level has any subblocks.  */
                    325:     char keep_if_subblocks;
                    326: 
                    327:     /* Number of decls in `names' that have incomplete 
                    328:        structure or union types.  */
                    329:     int n_incomplete;
                    330: 
                    331:     /* A list of decls giving the (reversed) specified order of parms,
                    332:        not including any forward-decls in the parmlist.
                    333:        This is so we can put the parms in proper order for assign_parms.  */
                    334:     tree parm_order;
                    335:   };
                    336: 
                    337: #define NULL_BINDING_LEVEL (struct binding_level *) NULL
                    338:   
                    339: /* The binding level currently in effect.  */
                    340: 
                    341: static struct binding_level *current_binding_level;
                    342: 
                    343: /* A chain of binding_level structures awaiting reuse.  */
                    344: 
                    345: static struct binding_level *free_binding_level;
                    346: 
                    347: /* The outermost binding level, for names of file scope.
                    348:    This is created when the compiler is started and exists
                    349:    through the entire run.  */
                    350: 
                    351: static struct binding_level *global_binding_level;
                    352: 
                    353: /* Binding level structures are initialized by copying this one.  */
                    354: 
                    355: static struct binding_level clear_binding_level
                    356:   = {NULL, NULL, NULL, NULL, NULL, 0, 0, 0};
                    357: 
                    358: /* Nonzero means unconditionally make a BLOCK for the next level pushed.  */
                    359: 
                    360: static int keep_next_level_flag;
                    361: 
                    362: /* Nonzero means make a BLOCK for the next level pushed
                    363:    if it has subblocks.  */
                    364: 
                    365: static int keep_next_if_subblocks;
                    366:   
                    367: /* The chain of outer levels of label scopes.
                    368:    This uses the same data structure used for binding levels,
                    369:    but it works differently: each link in the chain records
                    370:    saved values of named_labels and shadowed_labels for
                    371:    a label binding level outside the current one.  */
                    372: 
                    373: static struct binding_level *label_level_chain;
                    374: 
                    375: /* Forward declarations.  */
                    376: 
                    377: static tree grokparms (), grokdeclarator ();
                    378: tree pushdecl ();
                    379: static tree builtin_function ();
                    380: 
                    381: static tree lookup_tag ();
                    382: static tree lookup_tag_reverse ();
                    383: static tree lookup_name_current_level ();
                    384: static char *redeclaration_error_message ();
                    385: static void layout_array_type ();
                    386: 
                    387: /* C-specific option variables.  */
                    388: 
                    389: /* Nonzero means allow type mismatches in conditional expressions;
                    390:    just make their values `void'.   */
                    391: 
                    392: int flag_cond_mismatch;
                    393: 
                    394: /* Nonzero means give `double' the same size as `float'.  */
                    395: 
                    396: int flag_short_double;
                    397: 
                    398: /* Nonzero means don't recognize the keyword `asm'.  */
                    399: 
                    400: int flag_no_asm;
                    401: 
                    402: /* Nonzero means don't recognize the non-ANSI builtin functions.  */
                    403: 
                    404: int flag_no_builtin;
                    405: 
                    406: /* Nonzero means do some things the same way PCC does.  */
                    407: 
                    408: int flag_traditional;
                    409: 
                    410: /* Nonzero means to treat bitfields as signed unless they say `unsigned'.  */
                    411: 
                    412: int flag_signed_bitfields = 1;
                    413: 
                    414: /* Nonzero means handle `#ident' directives.  0 means ignore them.  */
                    415: 
                    416: int flag_no_ident = 0;
                    417: 
                    418: /* Nonzero means warn about implicit declarations.  */
                    419: 
                    420: int warn_implicit;
                    421: 
                    422: /* Nonzero means give string constants the type `const char *'
                    423:    to get extra warnings from them.  These warnings will be too numerous
                    424:    to be useful, except in thoroughly ANSIfied programs.  */
                    425: 
                    426: int warn_write_strings;
                    427: 
                    428: /* Nonzero means warn about pointer casts that can drop a type qualifier
                    429:    from the pointer target type.  */
                    430: 
                    431: int warn_cast_qual;
                    432: 
                    433: /* Warn about traditional constructs whose meanings changed in ANSI C.  */
                    434: 
                    435: int warn_traditional;
                    436: 
                    437: /* Nonzero means warn about sizeof(function) or addition/subtraction
                    438:    of function pointers.  */
                    439: 
                    440: int warn_pointer_arith;
                    441: 
                    442: /* Nonzero means warn for non-prototype function decls
                    443:    or non-prototyped defs without previous prototype.  */
                    444: 
                    445: int warn_strict_prototypes;
                    446: 
                    447: /* Nonzero means warn for any global function def
                    448:    without separate previous prototype decl.  */
                    449: 
                    450: int warn_missing_prototypes;
                    451: 
                    452: /* Nonzero means warn about multiple (redundant) decls for the same single
                    453:    variable or function.  */
                    454: 
                    455: int warn_redundant_decls = 0;
                    456: 
                    457: /* Nonzero means warn about extern declarations of objects not at
                    458:    file-scope level and about *all* declarations of functions (whether
                    459:    extern or static) not at file-scope level.  Note that we exclude
                    460:    implicit function declarations.  To get warnings about those, use
                    461:    -Wimplicit.  */
                    462: 
                    463: int warn_nested_externs = 0;
                    464: 
                    465: /* Warn about *printf or *scanf format/argument anomalies. */
                    466: 
                    467: int warn_format;
                    468: 
                    469: /* Warn about a subscript that has type char.  */
                    470: 
                    471: int warn_char_subscripts = 0;
                    472: 
                    473: /* Warn if a type conversion is done that might have confusing results.  */
                    474: 
                    475: int warn_conversion;
                    476: 
                    477: /* Warn if adding () is suggested.  */
                    478: 
                    479: int warn_parentheses = 1;
                    480: 
                    481: /* Nonzero means `$' can be in an identifier.
                    482:    See cccp.c for reasons why this breaks some obscure ANSI C programs.  */
                    483: 
                    484: #ifndef DOLLARS_IN_IDENTIFIERS
                    485: #define DOLLARS_IN_IDENTIFIERS 1
                    486: #endif
                    487: int dollars_in_ident = DOLLARS_IN_IDENTIFIERS > 1;
                    488: 
                    489: char *language_string = "GNU C";
                    490: 
                    491: /* Decode the string P as a language-specific option for C.
                    492:    Return 1 if it is recognized (and handle it);
                    493:    return 0 if not recognized.  */
                    494:    
                    495: int
                    496: c_decode_option (p)
                    497:      char *p;
                    498: {
                    499:   if (!strcmp (p, "-ftraditional") || !strcmp (p, "-traditional"))
                    500:     {
                    501:       flag_traditional = 1;
                    502:       flag_writable_strings = 1;
                    503: #if DOLLARS_IN_IDENTIFIERS > 0
                    504:       dollars_in_ident = 1;
                    505: #endif
                    506:     }
                    507:   else if (!strcmp (p, "-fnotraditional"))
                    508:     ;
                    509:   else if (!strcmp (p, "-fsigned-char"))
                    510:     flag_signed_char = 1;
                    511:   else if (!strcmp (p, "-funsigned-char"))
                    512:     flag_signed_char = 0;
                    513:   else if (!strcmp (p, "-fno-signed-char"))
                    514:     flag_signed_char = 0;
                    515:   else if (!strcmp (p, "-fno-unsigned-char"))
                    516:     flag_signed_char = 1;
                    517:   else if (!strcmp (p, "-fsigned-bitfields"))
                    518:     flag_signed_bitfields = 1;
                    519:   else if (!strcmp (p, "-funsigned-bitfields"))
                    520:     flag_signed_bitfields = 0;
                    521:   else if (!strcmp (p, "-fno-signed-bitfields"))
                    522:     flag_signed_bitfields = 0;
                    523:   else if (!strcmp (p, "-fno-unsigned-bitfields"))
                    524:     flag_signed_bitfields = 1;
                    525:   else if (!strcmp (p, "-fshort-enums"))
                    526:     flag_short_enums = 1;
                    527:   else if (!strcmp (p, "-fno-short-enums"))
                    528:     flag_short_enums = 0;
                    529:   else if (!strcmp (p, "-fcond-mismatch"))
                    530:     flag_cond_mismatch = 1;
                    531:   else if (!strcmp (p, "-fno-cond-mismatch"))
                    532:     flag_cond_mismatch = 0;
                    533:   else if (!strcmp (p, "-fshort-double"))
                    534:     flag_short_double = 1;
                    535:   else if (!strcmp (p, "-fno-short-double"))
                    536:     flag_short_double = 0;
                    537:   else if (!strcmp (p, "-fasm"))
                    538:     flag_no_asm = 0;
                    539:   else if (!strcmp (p, "-fno-asm"))
                    540:     flag_no_asm = 1;
                    541:   else if (!strcmp (p, "-fbuiltin"))
                    542:     flag_no_builtin = 0;
                    543:   else if (!strcmp (p, "-fno-builtin"))
                    544:     flag_no_builtin = 1;
                    545:   else if (!strcmp (p, "-fno-ident"))
                    546:     flag_no_ident = 1;
                    547:   else if (!strcmp (p, "-fident"))
                    548:     flag_no_ident = 0;
                    549:   else if (!strcmp (p, "-ansi"))
                    550:     flag_no_asm = 1, flag_no_builtin = 1, dollars_in_ident = 0;
                    551:   else if (!strcmp (p, "-Wimplicit"))
                    552:     warn_implicit = 1;
                    553:   else if (!strcmp (p, "-Wno-implicit"))
                    554:     warn_implicit = 0;
                    555:   else if (!strcmp (p, "-Wwrite-strings"))
                    556:     warn_write_strings = 1;
                    557:   else if (!strcmp (p, "-Wno-write-strings"))
                    558:     warn_write_strings = 0;
                    559:   else if (!strcmp (p, "-Wcast-qual"))
                    560:     warn_cast_qual = 1;
                    561:   else if (!strcmp (p, "-Wno-cast-qual"))
                    562:     warn_cast_qual = 0;
                    563:   else if (!strcmp (p, "-Wpointer-arith"))
                    564:     warn_pointer_arith = 1;
                    565:   else if (!strcmp (p, "-Wno-pointer-arith"))
                    566:     warn_pointer_arith = 0;
                    567:   else if (!strcmp (p, "-Wstrict-prototypes"))
                    568:     warn_strict_prototypes = 1;
                    569:   else if (!strcmp (p, "-Wno-strict-prototypes"))
                    570:     warn_strict_prototypes = 0;
                    571:   else if (!strcmp (p, "-Wmissing-prototypes"))
                    572:     warn_missing_prototypes = 1;
                    573:   else if (!strcmp (p, "-Wno-missing-prototypes"))
                    574:     warn_missing_prototypes = 0;
                    575:   else if (!strcmp (p, "-Wredundant-decls"))
                    576:     warn_redundant_decls = 1;
                    577:   else if (!strcmp (p, "-Wnoredundant-decls"))
                    578:     warn_redundant_decls = 0;
                    579:   else if (!strcmp (p, "-Wnested-externs"))
                    580:     warn_nested_externs = 1;
                    581:   else if (!strcmp (p, "-Wno-nested-externs"))
                    582:     warn_nested_externs = 0;
                    583:   else if (!strcmp (p, "-Wtraditional"))
                    584:     warn_traditional = 1;
                    585:   else if (!strcmp (p, "-Wno-traditional"))
                    586:     warn_traditional = 0;
                    587:   else if (!strcmp (p, "-Wformat"))
                    588:     warn_format = 1;
                    589:   else if (!strcmp (p, "-Wno-format"))
                    590:     warn_format = 0;
                    591:   else if (!strcmp (p, "-Wchar-subscripts"))
                    592:     warn_char_subscripts = 1;
                    593:   else if (!strcmp (p, "-Wno-char-subscripts"))
                    594:     warn_char_subscripts = 0;
                    595:   else if (!strcmp (p, "-Wconversion"))
                    596:     warn_conversion = 1;
                    597:   else if (!strcmp (p, "-Wno-conversion"))
                    598:     warn_conversion = 0;
                    599:   else if (!strcmp (p, "-Wparentheses"))
                    600:     warn_parentheses = 1;
                    601:   else if (!strcmp (p, "-Wno-parentheses"))
                    602:     warn_parentheses = 0;
                    603:   else if (!strcmp (p, "-Wcomment"))
                    604:     ; /* cpp handles this one.  */
                    605:   else if (!strcmp (p, "-Wno-comment"))
                    606:     ; /* cpp handles this one.  */
                    607:   else if (!strcmp (p, "-Wcomments"))
                    608:     ; /* cpp handles this one.  */
                    609:   else if (!strcmp (p, "-Wno-comments"))
                    610:     ; /* cpp handles this one.  */
                    611:   else if (!strcmp (p, "-Wtrigraphs"))
                    612:     ; /* cpp handles this one.  */
                    613:   else if (!strcmp (p, "-Wno-trigraphs"))
                    614:     ; /* cpp handles this one.  */
                    615:   else if (!strcmp (p, "-Wall"))
                    616:     {
                    617:       extra_warnings = 1;
                    618:       warn_uninitialized = 1;
                    619:       warn_implicit = 1;
                    620:       warn_return_type = 1;
                    621:       warn_unused = 1;
                    622:       warn_switch = 1;
                    623:       warn_format = 1;
                    624:       warn_char_subscripts = 1;
                    625:     }
                    626:   else
                    627:     return 0;
                    628: 
                    629:   return 1;
                    630: }
                    631: 
                    632: /* Hooks for print_node.  */
                    633: 
                    634: void
                    635: print_lang_decl ()
                    636: {
                    637: }
                    638: 
                    639: void
                    640: print_lang_type ()
                    641: {
                    642: }
                    643: 
                    644: void
                    645: print_lang_identifier (file, node, indent)
                    646:      FILE *file;
                    647:      tree node;
                    648:      int indent;
                    649: {
                    650:   print_node (file, "global", IDENTIFIER_GLOBAL_VALUE (node), indent + 4);
                    651:   print_node (file, "local", IDENTIFIER_LOCAL_VALUE (node), indent + 4);
                    652:   print_node (file, "label", IDENTIFIER_LABEL_VALUE (node), indent + 4);
                    653:   print_node (file, "implicit", IDENTIFIER_IMPLICIT_DECL (node), indent + 4);
                    654:   print_node (file, "error locus", IDENTIFIER_ERROR_LOCUS (node), indent + 4);
                    655: }
                    656: 
                    657: /* Create a new `struct binding_level'.  */
                    658: 
                    659: static
                    660: struct binding_level *
                    661: make_binding_level ()
                    662: {
                    663:   /* NOSTRICT */
                    664:   return (struct binding_level *) xmalloc (sizeof (struct binding_level));
                    665: }
                    666: 
                    667: /* Nonzero if we are currently in the global binding level.  */
                    668: 
                    669: int
                    670: global_bindings_p ()
                    671: {
                    672:   return current_binding_level == global_binding_level;
                    673: }
                    674: 
                    675: void
                    676: keep_next_level ()
                    677: {
                    678:   keep_next_level_flag = 1;
                    679: }
                    680: 
                    681: /* Nonzero if the current level needs to have a BLOCK made.  */
                    682: 
                    683: int
                    684: kept_level_p ()
                    685: {
                    686:   return ((current_binding_level->keep_if_subblocks
                    687:           && current_binding_level->blocks != 0)
                    688:          || current_binding_level->keep
                    689:          || current_binding_level->names != 0
                    690:          || (current_binding_level->tags != 0
                    691:              && !current_binding_level->tag_transparent));
                    692: }
                    693: 
                    694: /* Identify this binding level as a level of parameters.
                    695:    DEFINITION_FLAG is 1 for a definition, 0 for a declaration.  */
                    696: 
                    697: void
                    698: declare_parm_level (definition_flag)
                    699:      int definition_flag;
                    700: {
                    701:   current_binding_level->parm_flag = 1 + definition_flag;
                    702: }
                    703: 
                    704: /* Nonzero if currently making parm declarations.  */
                    705: 
                    706: int
                    707: in_parm_level_p ()
                    708: {
                    709:   return current_binding_level->parm_flag;
                    710: }
                    711: 
                    712: /* Enter a new binding level.
                    713:    If TAG_TRANSPARENT is nonzero, do so only for the name space of variables,
                    714:    not for that of tags.  */
                    715: 
                    716: void
                    717: pushlevel (tag_transparent)
                    718:      int tag_transparent;
                    719: {
                    720:   register struct binding_level *newlevel = NULL_BINDING_LEVEL;
                    721: 
                    722:   /* If this is the top level of a function,
                    723:      just make sure that NAMED_LABELS is 0.  */
                    724: 
                    725:   if (current_binding_level == global_binding_level)
                    726:     {
                    727:       named_labels = 0;
                    728:     }
                    729: 
                    730:   /* Reuse or create a struct for this binding level.  */
                    731: 
                    732:   if (free_binding_level)
                    733:     {
                    734:       newlevel = free_binding_level;
                    735:       free_binding_level = free_binding_level->level_chain;
                    736:     }
                    737:   else
                    738:     {
                    739:       newlevel = make_binding_level ();
                    740:     }
                    741: 
                    742:   /* Add this level to the front of the chain (stack) of levels that
                    743:      are active.  */
                    744: 
                    745:   *newlevel = clear_binding_level;
                    746:   newlevel->tag_transparent
                    747:     = (tag_transparent
                    748:        || (current_binding_level
                    749:           ? current_binding_level->subblocks_tag_transparent
                    750:           : 0));
                    751:   newlevel->level_chain = current_binding_level;
                    752:   current_binding_level = newlevel;
                    753:   newlevel->keep = keep_next_level_flag;
                    754:   keep_next_level_flag = 0;
                    755:   newlevel->keep_if_subblocks = keep_next_if_subblocks;
                    756:   keep_next_if_subblocks = 0;
                    757: }
                    758: 
                    759: /* Exit a binding level.
                    760:    Pop the level off, and restore the state of the identifier-decl mappings
                    761:    that were in effect when this level was entered.
                    762: 
                    763:    If KEEP is nonzero, this level had explicit declarations, so
                    764:    and create a "block" (a BLOCK node) for the level
                    765:    to record its declarations and subblocks for symbol table output.
                    766: 
                    767:    If FUNCTIONBODY is nonzero, this level is the body of a function,
                    768:    so create a block as if KEEP were set and also clear out all
                    769:    label names.
                    770: 
                    771:    If REVERSE is nonzero, reverse the order of decls before putting
                    772:    them into the BLOCK.  */
                    773: 
                    774: tree
                    775: poplevel (keep, reverse, functionbody)
                    776:      int keep;
                    777:      int reverse;
                    778:      int functionbody;
                    779: {
                    780:   register tree link;
                    781:   /* The chain of decls was accumulated in reverse order.
                    782:      Put it into forward order, just for cleanliness.  */
                    783:   tree decls;
                    784:   tree tags = current_binding_level->tags;
                    785:   tree subblocks = current_binding_level->blocks;
                    786:   tree block = 0;
                    787:   tree decl;
                    788: 
                    789:   keep |= current_binding_level->keep;
                    790: 
                    791:   /* This warning is turned off because it causes warnings for
                    792:      declarations like `extern struct foo *x'.  */
                    793: #if 0
                    794:   /* Warn about incomplete structure types in this level.  */
                    795:   for (link = tags; link; link = TREE_CHAIN (link))
                    796:     if (TYPE_SIZE (TREE_VALUE (link)) == 0)
                    797:       {
                    798:        tree type = TREE_VALUE (link);
                    799:        char *errmsg;
                    800:        switch (TREE_CODE (type))
                    801:          {
                    802:          case RECORD_TYPE:
                    803:            errmsg = "`struct %s' incomplete in scope ending here";
                    804:            break;
                    805:          case UNION_TYPE:
                    806:            errmsg = "`union %s' incomplete in scope ending here";
                    807:            break;
                    808:          case ENUMERAL_TYPE:
                    809:            errmsg = "`enum %s' incomplete in scope ending here";
                    810:            break;
                    811:          }
                    812:        if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
                    813:          error (errmsg, IDENTIFIER_POINTER (TYPE_NAME (type)));
                    814:        else
                    815:          /* If this type has a typedef-name, the TYPE_NAME is a TYPE_DECL.  */
                    816:          error (errmsg, IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
                    817:       }
                    818: #endif /* 0 */
                    819: 
                    820:   /* Get the decls in the order they were written.
                    821:      Usually current_binding_level->names is in reverse order.
                    822:      But parameter decls were previously put in forward order.  */
                    823: 
                    824:   if (reverse)
                    825:     current_binding_level->names
                    826:       = decls = nreverse (current_binding_level->names);
                    827:   else
                    828:     decls = current_binding_level->names;
                    829: 
                    830:   /* Output any nested inline functions within this block
                    831:      if they weren't already output.  */
                    832: 
                    833:   for (decl = decls; decl; decl = TREE_CHAIN (decl))
                    834:     if (TREE_CODE (decl) == FUNCTION_DECL
                    835:        && ! TREE_ASM_WRITTEN (decl)
                    836:        && DECL_INITIAL (decl) != 0
                    837:        && TREE_ADDRESSABLE (decl))
                    838:       output_inline_function (decl);
                    839: 
                    840:   /* If there were any declarations or structure tags in that level,
                    841:      or if this level is a function body,
                    842:      create a BLOCK to record them for the life of this function.  */
                    843: 
                    844:   if (keep || functionbody
                    845:       || (current_binding_level->keep_if_subblocks && subblocks != 0))
                    846:     block = build_block (keep ? decls : 0, keep ? tags : 0,
                    847:                         subblocks, 0, 0);
                    848: 
                    849:   /* In each subblock, record that this is its superior.  */
                    850: 
                    851:   for (link = subblocks; link; link = TREE_CHAIN (link))
                    852:     BLOCK_SUPERCONTEXT (link) = block;
                    853: 
                    854:   /* Clear out the meanings of the local variables of this level.  */
                    855: 
                    856:   for (link = decls; link; link = TREE_CHAIN (link))
                    857:     {
                    858:       if (DECL_NAME (link) != 0)
                    859:        {
                    860:          /* If the ident. was used or addressed via a local extern decl,
                    861:             don't forget that fact.  */
                    862:          if (TREE_EXTERNAL (link))
                    863:            {
                    864:              if (TREE_USED (link))
                    865:                TREE_USED (DECL_NAME (link)) = 1;
                    866:              if (TREE_ADDRESSABLE (link))
                    867:                TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (link)) = 1;
                    868:            }
                    869:          IDENTIFIER_LOCAL_VALUE (DECL_NAME (link)) = 0;
                    870:        }
                    871:     }
                    872: 
                    873:   /* Restore all name-meanings of the outer levels
                    874:      that were shadowed by this level.  */
                    875: 
                    876:   for (link = current_binding_level->shadowed; link; link = TREE_CHAIN (link))
                    877:     IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
                    878: 
                    879:   /* If the level being exited is the top level of a function,
                    880:      check over all the labels, and clear out the current
                    881:      (function local) meanings of their names.  */
                    882: 
                    883:   if (functionbody)
                    884:     {
                    885:       /* If this is the top level block of a function,
                    886:         the vars are the function's parameters.
                    887:         Don't leave them in the BLOCK because they are
                    888:         found in the FUNCTION_DECL instead.  */
                    889: 
                    890:       BLOCK_VARS (block) = 0;
                    891: 
                    892:       /* Clear out the definitions of all label names,
                    893:         since their scopes end here,
                    894:         and add them to BLOCK_VARS.  */
                    895: 
                    896:       for (link = named_labels; link; link = TREE_CHAIN (link))
                    897:        {
                    898:          register tree label = TREE_VALUE (link);
                    899: 
                    900:          if (DECL_INITIAL (label) == 0)
                    901:            {
                    902:              error_with_decl (label, "label `%s' used but not defined");
                    903:              /* Avoid crashing later.  */
                    904:              define_label (input_filename, lineno,
                    905:                            DECL_NAME (label));
                    906:            }
                    907:          else if (warn_unused && !TREE_USED (label))
                    908:            warning_with_decl (label, "label `%s' defined but not used");
                    909:          IDENTIFIER_LABEL_VALUE (DECL_NAME (label)) = 0;
                    910: 
                    911:          /* Put the labels into the "variables" of the
                    912:             top-level block, so debugger can see them.  */
                    913:          TREE_CHAIN (label) = BLOCK_VARS (block);
                    914:          BLOCK_VARS (block) = label;
                    915:        }
                    916:     }
                    917: 
                    918:   /* Pop the current level, and free the structure for reuse.  */
                    919: 
                    920:   {
                    921:     register struct binding_level *level = current_binding_level;
                    922:     current_binding_level = current_binding_level->level_chain;
                    923: 
                    924:     level->level_chain = free_binding_level;
                    925:     free_binding_level = level;
                    926:   }
                    927: 
                    928:   /* Dispose of the block that we just made inside some higher level.  */
                    929:   if (functionbody)
                    930:     DECL_INITIAL (current_function_decl) = block;
                    931:   else if (block)
                    932:     current_binding_level->blocks
                    933:       = chainon (current_binding_level->blocks, block);
                    934:   /* If we did not make a block for the level just exited,
                    935:      any blocks made for inner levels
                    936:      (since they cannot be recorded as subblocks in that level)
                    937:      must be carried forward so they will later become subblocks
                    938:      of something else.  */
                    939:   else if (subblocks)
                    940:     current_binding_level->blocks
                    941:       = chainon (current_binding_level->blocks, subblocks);
                    942: 
                    943:   /* Set the TYPE_CONTEXTs for all of the tagged types belonging to this
                    944:      binding contour so that they point to the appropriate construct, i.e.
                    945:      either to the current FUNCTION_DECL node, or else to the BLOCK node
                    946:      we just constructed.
                    947: 
                    948:      Note that for tagged types whose scope is just the formal parameter
                    949:      list for some function type specification, we can't properly set
                    950:      their TYPE_CONTEXTs here, because we don't have a pointer to the
                    951:      appropriate FUNCTION_TYPE node readily available to us.  For those
                    952:      cases, the TYPE_CONTEXTs of the relevant tagged type nodes get set
                    953:      in `grokdeclarator' as soon as we have created the FUNCTION_TYPE
                    954:      node which will represent the "scope" for these "parameter list local"
                    955:      tagged types.
                    956:   */
                    957: 
                    958:   if (functionbody)
                    959:     for (link = tags; link; link = TREE_CHAIN (link))
                    960:       TYPE_CONTEXT (TREE_VALUE (link)) = current_function_decl;
                    961:   else if (block)
                    962:     for (link = tags; link; link = TREE_CHAIN (link))
                    963:       TYPE_CONTEXT (TREE_VALUE (link)) = block;
                    964: 
                    965:   if (block)
                    966:     TREE_USED (block) = 1;
                    967:   return block;
                    968: }
                    969: 
                    970: void
                    971: push_label_level ()
                    972: {
                    973:   register struct binding_level *newlevel;
                    974: 
                    975:   /* Reuse or create a struct for this binding level.  */
                    976: 
                    977:   if (free_binding_level)
                    978:     {
                    979:       newlevel = free_binding_level;
                    980:       free_binding_level = free_binding_level->level_chain;
                    981:     }
                    982:   else
                    983:     {
                    984:       newlevel = make_binding_level ();
                    985:     }
                    986: 
                    987:   /* Add this level to the front of the chain (stack) of label levels.  */
                    988: 
                    989:   newlevel->level_chain = label_level_chain;
                    990:   label_level_chain = newlevel;
                    991: 
                    992:   newlevel->names = named_labels;
                    993:   newlevel->shadowed = shadowed_labels;
                    994:   named_labels = 0;
                    995:   shadowed_labels = 0;
                    996: }
                    997: 
                    998: void
                    999: pop_label_level ()
                   1000: {
                   1001:   register struct binding_level *level = label_level_chain;
                   1002:   tree link, prev;
                   1003: 
                   1004:   /* Clear out the definitions of the declared labels in this level.
                   1005:      Leave in the list any ordinary, non-declared labels.  */
                   1006:   for (link = named_labels, prev = 0; link;)
                   1007:     {
                   1008:       if (C_DECLARED_LABEL_FLAG (TREE_VALUE (link)))
                   1009:        {
                   1010:          if (DECL_SOURCE_LINE (TREE_VALUE (link)) == 0)
                   1011:            {
                   1012:              error_with_decl ("label `%s' used but not defined",
                   1013:                               TREE_VALUE (link));
                   1014:              /* Avoid crashing later.  */
                   1015:              define_label (input_filename, lineno,
                   1016:                            DECL_NAME (TREE_VALUE (link)));
                   1017:            }
                   1018:          else if (warn_unused && !TREE_USED (TREE_VALUE (link)))
                   1019:            warning_with_decl (TREE_VALUE (link), 
                   1020:                               "label `%s' defined but not used");
                   1021:          IDENTIFIER_LABEL_VALUE (DECL_NAME (TREE_VALUE (link))) = 0;
                   1022: 
                   1023:          /* Delete this element from the list.  */
                   1024:          link = TREE_CHAIN (link);
                   1025:          if (prev)
                   1026:            TREE_CHAIN (prev) = link;
                   1027:          else
                   1028:            named_labels = link;
                   1029:        }
                   1030:       else
                   1031:        {
                   1032:          prev = link;
                   1033:          link = TREE_CHAIN (link);
                   1034:        }
                   1035:     }
                   1036: 
                   1037:   /* Bring back all the labels that were shadowed.  */
                   1038:   for (link = shadowed_labels; link; link = TREE_CHAIN (link))
                   1039:     if (DECL_NAME (TREE_VALUE (link)) != 0)
                   1040:       IDENTIFIER_LABEL_VALUE (DECL_NAME (TREE_VALUE (link)))
                   1041:        = TREE_VALUE (link);
                   1042: 
                   1043:   named_labels = chainon (named_labels, level->names);
                   1044:   shadowed_labels = level->shadowed;
                   1045: 
                   1046:   /* Pop the current level, and free the structure for reuse.  */
                   1047:   label_level_chain = label_level_chain->level_chain;
                   1048:   level->level_chain = free_binding_level;
                   1049:   free_binding_level = level;
                   1050: }
                   1051: 
                   1052: /* Push a definition or a declaration of struct, union or enum tag "name".
                   1053:    "type" should be the type node.
                   1054:    We assume that the tag "name" is not already defined.
                   1055: 
                   1056:    Note that the definition may really be just a forward reference.
                   1057:    In that case, the TYPE_SIZE will be zero.  */
                   1058: 
                   1059: void
                   1060: pushtag (name, type)
                   1061:      tree name, type;
                   1062: {
                   1063:   register struct binding_level *b;
                   1064: 
                   1065:   /* Find the proper binding level for this type tag.  */
                   1066: 
                   1067:   for (b = current_binding_level; b->tag_transparent; b = b->level_chain)
                   1068:     continue;
                   1069: 
                   1070:   if (name)
                   1071:     {
                   1072:       /* Record the identifier as the type's name if it has none.  */
                   1073: 
                   1074:       if (TYPE_NAME (type) == 0)
                   1075:        TYPE_NAME (type) = name;
                   1076: 
                   1077:       if (b == global_binding_level)
                   1078:        b->tags = perm_tree_cons (name, type, b->tags);
                   1079:       else
                   1080:        b->tags = saveable_tree_cons (name, type, b->tags);
                   1081:     }
                   1082: 
                   1083:   /* Create a fake NULL-named TYPE_DECL node whose TREE_TYPE will be the
                   1084:      tagged type we just added to the current binding level.  This fake
                   1085:      NULL-named TYPE_DECL node helps dwarfout.c to know when it needs
                   1086:      to output a a representation of a tagged type, and it also gives
                   1087:      us a convenient place to record the "scope start" address for the
                   1088:      tagged type.  */
                   1089: 
                   1090:   TYPE_STUB_DECL (type) = pushdecl (build_decl (TYPE_DECL, NULL, type));
                   1091: }
                   1092: 
                   1093: /* Handle when a new declaration NEWDECL
                   1094:    has the same name as an old one OLDDECL
                   1095:    in the same binding contour.
                   1096:    Prints an error message if appropriate.
                   1097: 
                   1098:    If safely possible, alter OLDDECL to look like NEWDECL, and return 1.
                   1099:    Otherwise, return 0.  */
                   1100: 
                   1101: static int
                   1102: duplicate_decls (newdecl, olddecl)
                   1103:      register tree newdecl, olddecl;
                   1104: {
                   1105:   int types_match = comptypes (TREE_TYPE (newdecl), TREE_TYPE (olddecl));
                   1106:   int new_is_definition = (TREE_CODE (newdecl) == FUNCTION_DECL
                   1107:                           && DECL_INITIAL (newdecl) != 0);
                   1108: 
                   1109:   if (TREE_CODE (TREE_TYPE (newdecl)) == ERROR_MARK
                   1110:       || TREE_CODE (TREE_TYPE (olddecl)) == ERROR_MARK)
                   1111:     types_match = 0;
                   1112: 
                   1113:   /* New decl is completely inconsistent with the old one =>
                   1114:      tell caller to replace the old one.
                   1115:      This is always an error except in the case of shadowing a builtin.  */
                   1116:   if (TREE_CODE (olddecl) != TREE_CODE (newdecl))
                   1117:     {
                   1118:       if (TREE_CODE (olddecl) == FUNCTION_DECL
                   1119:          && DECL_BUILT_IN (olddecl))
                   1120:        {
                   1121:          /* If you declare a built-in function name as static, the
                   1122:             built-in definition is overridden,
                   1123:             but optionally warn this was a bad choice of name.  */
                   1124:          if (!TREE_PUBLIC (newdecl))
                   1125:            {
                   1126:              if (warn_shadow)
                   1127:                warning_with_decl (newdecl, "shadowing built-in function `%s'");
                   1128:            }
                   1129:          /* Likewise, if the built-in is not ansi, then programs can
                   1130:             overide it even globally without an error.  */
                   1131:          else if (DECL_BUILT_IN_NONANSI (olddecl))
                   1132:            warning_with_decl (newdecl,
                   1133:                               "built-in function `%s' declared as non-function");
                   1134:          else
                   1135:            error_with_decl (newdecl,
                   1136:                             "built-in function `%s' declared as non-function");
                   1137:        }
                   1138:       else if (TREE_CODE (olddecl) == FUNCTION_DECL
                   1139:               && DECL_BUILT_IN_NONANSI (olddecl))
                   1140:        {
                   1141:          /* If overriding decl is static,
                   1142:             optionally warn this was a bad choice of name.  */
                   1143:          if (!TREE_PUBLIC (newdecl))
                   1144:            {
                   1145:              if (warn_shadow)
                   1146:                warning_with_decl (newdecl, "shadowing library function `%s'");
                   1147:            }
                   1148:          /* Otherwise, always warn.  */
                   1149:          else
                   1150:            warning_with_decl (newdecl,
                   1151:                               "library function `%s' declared as non-function");
                   1152:        }
                   1153:       else
                   1154:        {
                   1155:          error_with_decl (newdecl, "`%s' redeclared as different kind of symbol");
                   1156:          error_with_decl (olddecl, "previous declaration of `%s'");
                   1157:        }
                   1158: 
                   1159:       return 0;
                   1160:     }
                   1161: 
                   1162:   /* For real parm decl following a forward decl,
                   1163:      return 1 so old decl will be reused.  */
                   1164:   if (types_match && TREE_CODE (newdecl) == PARM_DECL
                   1165:       && TREE_ASM_WRITTEN (olddecl) && ! TREE_ASM_WRITTEN (newdecl))
                   1166:     return 1;
                   1167: 
                   1168:   /* The new declaration is the same kind of object as the old one.
                   1169:      The declarations may partially match.  Print warnings if they don't
                   1170:      match enough.  Ultimately, copy most of the information from the new
                   1171:      decl to the old one, and keep using the old one.  */
                   1172: 
                   1173:   if (flag_traditional && TREE_CODE (newdecl) == FUNCTION_DECL
                   1174:       && IDENTIFIER_IMPLICIT_DECL (DECL_NAME (newdecl)) == olddecl
                   1175:       && DECL_INITIAL (olddecl) == 0)
                   1176:     /* If -traditional, avoid error for redeclaring fcn
                   1177:        after implicit decl.  */
                   1178:     ;
                   1179:   else if (TREE_CODE (olddecl) == FUNCTION_DECL
                   1180:           && DECL_BUILT_IN (olddecl))
                   1181:     {
                   1182:       if (!TREE_PUBLIC (newdecl))
                   1183:        {
                   1184:          /* If you declare a built-in function name as static, the
                   1185:             built-in definition is overridden,
                   1186:             but optionally warn this was a bad choice of name.  */
                   1187:          if (warn_shadow)
                   1188:            warning_with_decl (newdecl, "shadowing built-in function `%s'");
                   1189:          /* Discard the old built-in function.  */
                   1190:          return 0;
                   1191:        }
                   1192:       else if (!types_match)
                   1193:        warning_with_decl (newdecl, "conflicting types for built-in function `%s'");
                   1194:     }
                   1195:   else if (TREE_CODE (olddecl) == FUNCTION_DECL
                   1196:           && DECL_BUILT_IN_NONANSI (olddecl))
                   1197:     {
                   1198:       if (!TREE_PUBLIC (newdecl))
                   1199:        {
                   1200:          /* If you declare a built-in function name as static, the
                   1201:             built-in definition is overridden,
                   1202:             but optionally warn this was a bad choice of name.  */
                   1203:          if (warn_shadow)
                   1204:            warning_with_decl (newdecl, "shadowing library function `%s'");
                   1205:          /* Discard the old built-in function.  */
                   1206:          return 0;
                   1207:        }
                   1208:       else if (!types_match)
                   1209:        warning_with_decl (newdecl, "conflicting types for library function `%s'");
                   1210:     }
                   1211:   else if (!types_match
                   1212:           /* Permit char *foo (int, ...); followed by char *foo ();
                   1213:              if not pedantic.  */
                   1214:           && ! (TREE_CODE (olddecl) == FUNCTION_DECL
                   1215:                 && ! pedantic
                   1216:                 /* Return types must still match.  */
                   1217:                 && comptypes (TREE_TYPE (TREE_TYPE (olddecl)),
                   1218:                               TREE_TYPE (TREE_TYPE (newdecl)))
                   1219:                 && TYPE_ARG_TYPES (TREE_TYPE (newdecl)) == 0))
                   1220:     {
                   1221:       error_with_decl (newdecl, "conflicting types for `%s'");
                   1222:       /* Check for function type mismatch
                   1223:         involving an empty arglist vs a nonempty one.  */
                   1224:       if (TREE_CODE (olddecl) == FUNCTION_DECL
                   1225:          && comptypes (TREE_TYPE (TREE_TYPE (olddecl)),
                   1226:                        TREE_TYPE (TREE_TYPE (newdecl)))
                   1227:          && ((TYPE_ARG_TYPES (TREE_TYPE (olddecl)) == 0
                   1228:               && DECL_INITIAL (olddecl) == 0)
                   1229:              ||
                   1230:              (TYPE_ARG_TYPES (TREE_TYPE (newdecl)) == 0
                   1231:               && DECL_INITIAL (newdecl) == 0)))
                   1232:        {
                   1233:          /* Classify the problem further.  */
                   1234:          register tree t = TYPE_ARG_TYPES (TREE_TYPE (olddecl));
                   1235:          if (t == 0)
                   1236:            t = TYPE_ARG_TYPES (TREE_TYPE (newdecl));
                   1237:          for (; t; t = TREE_CHAIN (t))
                   1238:            {
                   1239:              register tree type = TREE_VALUE (t);
                   1240: 
                   1241:              if (TREE_CHAIN (t) == 0 && type != void_type_node)
                   1242:                {
                   1243:                  error ("A parameter list with an ellipsis can't match");
                   1244:                  error ("an empty parameter name list declaration.");
                   1245:                  break;
                   1246:                }
                   1247: 
                   1248:              if (type == float_type_node
                   1249:                  || (TREE_CODE (type) == INTEGER_TYPE
                   1250:                      && (TYPE_PRECISION (type)
                   1251:                          < TYPE_PRECISION (integer_type_node))))
                   1252:                {
                   1253:                  error ("An argument type that has a default promotion");
                   1254:                  error ("can't match an empty parameter name list declaration.");
                   1255:                  break;
                   1256:                }
                   1257:            }
                   1258:        }
                   1259:       error_with_decl (olddecl, "previous declaration of `%s'");
                   1260:     }
                   1261:   else
                   1262:     {
                   1263:       char *errmsg = redeclaration_error_message (newdecl, olddecl);
                   1264:       if (errmsg)
                   1265:        {
                   1266:          error_with_decl (newdecl, errmsg);
                   1267:          error_with_decl (olddecl,
                   1268:                           "`%s' previously declared here");
                   1269:        }
                   1270:       else if (TREE_CODE (olddecl) == FUNCTION_DECL
                   1271:               && DECL_INITIAL (olddecl) != 0
                   1272:               && TYPE_ARG_TYPES (TREE_TYPE (olddecl)) == 0
                   1273:               && TYPE_ARG_TYPES (TREE_TYPE (newdecl)) != 0)
                   1274:        {
                   1275:          register tree type, parm;
                   1276:          register int nargs;
                   1277:          /* Prototype decl follows defn w/o prototype.  */
                   1278: 
                   1279:          for (parm = TYPE_ACTUAL_ARG_TYPES (TREE_TYPE (olddecl)),
                   1280:               type = TYPE_ARG_TYPES (TREE_TYPE (newdecl)),
                   1281:               nargs = 1;
                   1282:               (TREE_VALUE (parm) != void_type_node
                   1283:                || TREE_VALUE (type) != void_type_node);
                   1284:               parm = TREE_CHAIN (parm), type = TREE_CHAIN (type), nargs++)
                   1285:            {
                   1286:              if (TREE_VALUE (parm) == void_type_node
                   1287:                  || TREE_VALUE (type) == void_type_node)
                   1288:                {
                   1289:                  errmsg = "prototype for `%s' follows and number of arguments";
                   1290:                  break;
                   1291:                }
                   1292:              /* Type for passing arg must be consistent
                   1293:                 with that declared for the arg.  */
                   1294:              if (! comptypes (TREE_VALUE (parm), TREE_VALUE (type))
                   1295:                  /* If -traditional, allow `unsigned int' instead of `int'
                   1296:                     in the prototype.  */
                   1297:                  && (! (flag_traditional
                   1298:                         && TREE_VALUE (parm) == integer_type_node
                   1299:                         && TREE_VALUE (type) == unsigned_type_node)))
                   1300:                {
                   1301:                  errmsg = "prototype for `%s' follows and argument %d";
                   1302:                  break;
                   1303:                }
                   1304:            }
                   1305:          if (errmsg)
                   1306:            {
                   1307:              error_with_decl (newdecl, errmsg, nargs);
                   1308:              error_with_decl (olddecl,
                   1309:                               "doesn't match non-prototype definition here");
                   1310:            }
                   1311:          else
                   1312:            {
                   1313:              warning_with_decl (newdecl, "prototype for `%s' follows");
                   1314:              warning_with_decl (olddecl, "non-prototype definition here");
                   1315:            }
                   1316:        }
                   1317:       /* Warn if function is now inline
                   1318:         but was previously declared not inline and has been called.  */
                   1319:       else
                   1320:        {
                   1321:          if (TREE_CODE (olddecl) == FUNCTION_DECL
                   1322:              && ! TREE_INLINE (olddecl) && TREE_INLINE (newdecl)
                   1323:              && TREE_USED (olddecl))
                   1324:            warning_with_decl (newdecl,
                   1325:                               "`%s' declared inline after being called");
                   1326:          if (TREE_CODE (olddecl) == FUNCTION_DECL
                   1327:              && TREE_INLINE (olddecl) != TREE_INLINE (newdecl))
                   1328:            warning_with_decl (newdecl,
                   1329:                               "`%s' declarations disagree about `inline'");
                   1330:          /* It is nice to warn when a function is declared
                   1331:             global first and then static.  */
                   1332:          if (TREE_CODE (olddecl) == FUNCTION_DECL
                   1333:              && TREE_PUBLIC (olddecl)
                   1334:              && !TREE_PUBLIC (newdecl))
                   1335:            warning_with_decl (newdecl, "static declaration for `%s' follows non-static");
                   1336: 
                   1337:          /* These bits are logically part of the type.  */
                   1338:          if (pedantic
                   1339:              && (TREE_READONLY (newdecl) != TREE_READONLY (olddecl)
                   1340:                  || TREE_THIS_VOLATILE (newdecl) != TREE_THIS_VOLATILE (olddecl)))
                   1341:            pedwarn_with_decl (newdecl, "type qualifiers for `%s' conflict with previous decl");
                   1342:        }
                   1343:     }
                   1344: 
                   1345:   /* Copy all the DECL_... slots specified in the new decl
                   1346:      except for any that we copy here from the old type.  */
                   1347: 
                   1348:   if (types_match)
                   1349:     {
                   1350:       tree oldtype = TREE_TYPE (olddecl);
                   1351:       /* Merge the data types specified in the two decls.  */
                   1352:       if (TREE_CODE (newdecl) != FUNCTION_DECL || !DECL_BUILT_IN (olddecl))
                   1353:        TREE_TYPE (newdecl)
                   1354:          = TREE_TYPE (olddecl)
                   1355:            = common_type (TREE_TYPE (newdecl), TREE_TYPE (olddecl));
                   1356: 
                   1357:       /* Lay the type out, unless already done.  */
                   1358:       if (oldtype != TREE_TYPE (newdecl))
                   1359:        {
                   1360:          if (TREE_TYPE (newdecl) != error_mark_node)
                   1361:            layout_type (TREE_TYPE (newdecl));
                   1362:          if (TREE_CODE (newdecl) != FUNCTION_DECL
                   1363:              && TREE_CODE (newdecl) != TYPE_DECL
                   1364:              && TREE_CODE (newdecl) != CONST_DECL)
                   1365:            layout_decl (newdecl, 0);
                   1366:        }
                   1367:       else
                   1368:        {
                   1369:          /* Since the type is OLDDECL's, make OLDDECL's size go with.  */
                   1370:          DECL_SIZE (newdecl) = DECL_SIZE (olddecl);
                   1371:          if (DECL_ALIGN (olddecl) > DECL_ALIGN (newdecl))
                   1372:            DECL_ALIGN (newdecl) = DECL_ALIGN (olddecl);
                   1373:        }
                   1374: 
                   1375:       /* Merge the type qualifiers.  */
                   1376:       if (DECL_BUILT_IN_NONANSI (olddecl) && TREE_THIS_VOLATILE (olddecl)
                   1377:          && !TREE_THIS_VOLATILE (newdecl))
                   1378:        TREE_THIS_VOLATILE (olddecl) = 0;
                   1379:       if (TREE_READONLY (newdecl))
                   1380:        TREE_READONLY (olddecl) = 1;
                   1381:       if (TREE_THIS_VOLATILE (newdecl))
                   1382:        TREE_THIS_VOLATILE (olddecl) = 1;
                   1383: 
                   1384:       /* Keep source location of definition rather than declaration.  */
                   1385:       if (DECL_INITIAL (newdecl) == 0 && DECL_INITIAL (olddecl) != 0)
                   1386:        {
                   1387:          DECL_SOURCE_LINE (newdecl) = DECL_SOURCE_LINE (olddecl);
                   1388:          DECL_SOURCE_FILE (newdecl) = DECL_SOURCE_FILE (olddecl);
                   1389:        }
                   1390: 
                   1391:       /* Merge the initialization information.  */
                   1392:       if (DECL_INITIAL (newdecl) == 0)
                   1393:        DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
                   1394:       /* Keep the old rtl since we can safely use it.  */
                   1395:       DECL_RTL (newdecl) = DECL_RTL (olddecl);
                   1396:     }
                   1397:   /* If cannot merge, then use the new type and qualifiers,
                   1398:      and don't preserve the old rtl.  */
                   1399:   else
                   1400:     {
                   1401:       TREE_TYPE (olddecl) = TREE_TYPE (newdecl);
                   1402:       TREE_READONLY (olddecl) = TREE_READONLY (newdecl);
                   1403:       TREE_THIS_VOLATILE (olddecl) = TREE_THIS_VOLATILE (newdecl);
                   1404:       TREE_SIDE_EFFECTS (olddecl) = TREE_SIDE_EFFECTS (newdecl);
                   1405:     }
                   1406: 
                   1407:   /* Merge the storage class information.  */
                   1408:   /* For functions, static overrides non-static.  */
                   1409:   if (TREE_CODE (newdecl) == FUNCTION_DECL)
                   1410:     {
                   1411:       TREE_PUBLIC (newdecl) &= TREE_PUBLIC (olddecl);
                   1412:       /* This is since we don't automatically
                   1413:         copy the attributes of NEWDECL into OLDDECL.  */
                   1414:       TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
                   1415:       /* If this clears `static', clear it in the identifier too.  */
                   1416:       if (! TREE_PUBLIC (olddecl))
                   1417:        TREE_PUBLIC (DECL_NAME (olddecl)) = 0;
                   1418:     }
                   1419:   if (TREE_EXTERNAL (newdecl))
                   1420:     {
                   1421:       TREE_STATIC (newdecl) = TREE_STATIC (olddecl);
                   1422:       TREE_EXTERNAL (newdecl) = TREE_EXTERNAL (olddecl);
                   1423:       /* An extern decl does not override previous storage class.  */
                   1424:       TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
                   1425:     }
                   1426:   else
                   1427:     {
                   1428:       TREE_STATIC (olddecl) = TREE_STATIC (newdecl);
                   1429:       TREE_EXTERNAL (olddecl) = 0;
                   1430:       TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
                   1431:     }
                   1432:   /* If either decl says `inline', this fn is inline,
                   1433:      unless its definition was passed already.  */
                   1434:   if (TREE_INLINE (newdecl) && DECL_INITIAL (olddecl) == 0)
                   1435:     TREE_INLINE (olddecl) = 1;
                   1436: 
                   1437:   /* Get rid of any built-in function if new arg types don't match it
                   1438:      or if we have a function definition.  */
                   1439:   if (TREE_CODE (newdecl) == FUNCTION_DECL
                   1440:       && DECL_BUILT_IN (olddecl)
                   1441:       && (!types_match || new_is_definition))
                   1442:     {
                   1443:       TREE_TYPE (olddecl) = TREE_TYPE (newdecl);
                   1444:       DECL_BUILT_IN (olddecl) = 0;
                   1445:     }
                   1446: 
                   1447:   /* If redeclaring a builtin function, and not a definition,
                   1448:      it stays built in.
                   1449:      Also preserve various other info from the definition.  */
                   1450:   if (TREE_CODE (newdecl) == FUNCTION_DECL && !new_is_definition)
                   1451:     {
                   1452:       if (DECL_BUILT_IN (olddecl))
                   1453:        {
                   1454:          DECL_BUILT_IN (newdecl) = 1;
                   1455:          DECL_SET_FUNCTION_CODE (newdecl, DECL_FUNCTION_CODE (olddecl));
                   1456:        }
                   1457:       else
                   1458:        DECL_FRAME_SIZE (newdecl) = DECL_FRAME_SIZE (olddecl);
                   1459: 
                   1460:       DECL_RESULT (newdecl) = DECL_RESULT (olddecl);
                   1461:       DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
                   1462:       DECL_SAVED_INSNS (newdecl) = DECL_SAVED_INSNS (olddecl);
                   1463:       DECL_ARGUMENTS (newdecl) = DECL_ARGUMENTS (olddecl);
                   1464:     }
                   1465: 
                   1466:   bcopy ((char *) newdecl + sizeof (struct tree_common),
                   1467:         (char *) olddecl + sizeof (struct tree_common),
                   1468:         sizeof (struct tree_decl) - sizeof (struct tree_common));
                   1469: 
                   1470:   return 1;
                   1471: }
                   1472: 
                   1473: /* Record a decl-node X as belonging to the current lexical scope.
                   1474:    Check for errors (such as an incompatible declaration for the same
                   1475:    name already seen in the same scope).
                   1476: 
                   1477:    Returns either X or an old decl for the same name.
                   1478:    If an old decl is returned, it may have been smashed
                   1479:    to agree with what X says.  */
                   1480: 
                   1481: tree
                   1482: pushdecl (x)
                   1483:      tree x;
                   1484: {
                   1485:   register tree t;
                   1486:   register tree name = DECL_NAME (x);
                   1487:   register struct binding_level *b = current_binding_level;
                   1488: 
                   1489:   DECL_CONTEXT (x) = current_function_decl;
                   1490:   /* A local declaration for a function doesn't constitute nesting.  */
                   1491:   if (TREE_CODE (x) == FUNCTION_DECL && DECL_INITIAL (x) == 0)
                   1492:     DECL_CONTEXT (x) = 0;
                   1493: 
                   1494:   if (warn_nested_externs && TREE_EXTERNAL (x) && b != global_binding_level
                   1495:       && x != IDENTIFIER_IMPLICIT_DECL (name))
                   1496:     warning ("nested extern declaration of `%s'", IDENTIFIER_POINTER (name));
                   1497: 
                   1498:   if (name)
                   1499:     {
                   1500:       char *file;
                   1501:       int line;
                   1502: 
                   1503:       t = lookup_name_current_level (name);
                   1504:       if (t != 0 && t == error_mark_node)
                   1505:        /* error_mark_node is 0 for a while during initialization!  */
                   1506:        {
                   1507:          t = 0;
                   1508:          error_with_decl (x, "`%s' used prior to declaration");
                   1509:        }
                   1510: 
                   1511:       if (t != 0)
                   1512:        {
                   1513:          file = DECL_SOURCE_FILE (t);
                   1514:          line = DECL_SOURCE_LINE (t);
                   1515:        }
                   1516: 
                   1517:       if (t != 0 && duplicate_decls (x, t))
                   1518:        {
                   1519:          if (TREE_CODE (t) == PARM_DECL)
                   1520:            {
                   1521:              /* Don't allow more than one "real" duplicate
                   1522:                 of a forward parm decl.  */
                   1523:              TREE_ASM_WRITTEN (t) = TREE_ASM_WRITTEN (x);
                   1524:              return t;
                   1525:            }
                   1526:          /* If this decl is `static' and an implicit decl was seen previously,
                   1527:             warn.  But don't complain if -traditional,
                   1528:             since traditional compilers don't complain.  */
                   1529:          if (!flag_traditional && TREE_PUBLIC (name)
                   1530:              && ! TREE_PUBLIC (x) && ! TREE_EXTERNAL (x)
                   1531:              /* We used to warn also for explicit extern followed by static,
                   1532:                 but sometimes you need to do it that way.  */
                   1533:              && IDENTIFIER_IMPLICIT_DECL (name) != 0)
                   1534:            {
                   1535:              pedwarn ("`%s' was declared implicitly `extern' and later `static'",
                   1536:                       IDENTIFIER_POINTER (name));
                   1537:              pedwarn_with_file_and_line (file, line,
                   1538:                                          "previous declaration of `%s'",
                   1539:                                          IDENTIFIER_POINTER (name));
                   1540:            }
                   1541:          if (warn_redundant_decls && line != 0)
                   1542:            {
                   1543:              warning ("redundant redeclaration of `%s' in same scope",
                   1544:                       IDENTIFIER_POINTER (name));
                   1545:              warning_with_file_and_line (file, line,
                   1546:                                          "previous declaration of `%s'",
                   1547:                                          IDENTIFIER_POINTER (name));
                   1548:            }
                   1549:          return t;
                   1550:        }
                   1551: 
                   1552:       /* If declaring a type as a typedef, and the type has no known
                   1553:         typedef name, install this TYPE_DECL as its typedef name.  If
                   1554:          generating prototypes, *don't* assign the current name to the
                   1555:          existing type node, but rather give the name its own associated
                   1556:          type node.  This new type node is created as a type variant of
                   1557:          the existing type node, but it is essentially identical to the
                   1558:          existing one.  Obviously, we don't generate these type variants
                   1559:          if the node that we are working on is a standard type and it has
                   1560:          not yet been assigned a name.  In that case we must allow the
                   1561:          standard type to given its standard name (by the compiler).
                   1562:          Since all standard types are effectively declared at line zero
                   1563:          in the source file, we can easily check to see if we are working
                   1564:          on a standard type by checking the current value of lineno.  */
                   1565: 
                   1566:       if (TREE_CODE (x) == TYPE_DECL)
                   1567:         {
                   1568:           if (DECL_SOURCE_LINE (x) == 0 || !flag_gen_aux_info)
                   1569:             {
                   1570:              if (TYPE_NAME (TREE_TYPE (x)) == 0)
                   1571:                TYPE_NAME (TREE_TYPE (x)) = x;
                   1572:             }
                   1573:           else
                   1574:             {
                   1575:               tree tt = TREE_TYPE (x);
                   1576: 
                   1577:               tt = c_build_type_variant (tt,
                   1578:                                         TYPE_READONLY (tt), TYPE_VOLATILE (tt));
                   1579:               TYPE_NAME (tt) = x;
                   1580:               TREE_TYPE (x) = tt;
                   1581:             }
                   1582:         }
                   1583: 
                   1584:       /* Multiple external decls of the same identifier ought to match.  */
                   1585: 
                   1586:       if (TREE_EXTERNAL (x) && IDENTIFIER_GLOBAL_VALUE (name) != 0
                   1587:          && (TREE_EXTERNAL (IDENTIFIER_GLOBAL_VALUE (name))
                   1588:              || TREE_PUBLIC (IDENTIFIER_GLOBAL_VALUE (name)))
                   1589:          /* We get warnings about inline functions where they are defined.
                   1590:             Avoid duplicate warnings where they are used.  */
                   1591:          && !TREE_INLINE (x))
                   1592:        {
                   1593:          if (! comptypes (TREE_TYPE (x),
                   1594:                           TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (name))))
                   1595:            {
                   1596:              pedwarn_with_decl (x,
                   1597:                                 "type mismatch with previous external decl");
                   1598:              pedwarn_with_decl (IDENTIFIER_GLOBAL_VALUE (name),
                   1599:                                 "previous external decl of `%s'");
                   1600:            }
                   1601:        }
                   1602: 
                   1603:       /* If a function has had an implicit declaration, and then is defined,
                   1604:         make sure they are compatible.  */
                   1605: 
                   1606:       if (IDENTIFIER_IMPLICIT_DECL (name) != 0
                   1607:          && IDENTIFIER_GLOBAL_VALUE (name) == 0
                   1608:          && TREE_CODE (x) == FUNCTION_DECL
                   1609:          && ! comptypes (TREE_TYPE (x),
                   1610:                          TREE_TYPE (IDENTIFIER_IMPLICIT_DECL (name))))
                   1611:        {
                   1612:          warning_with_decl (x, "type mismatch with previous implicit declaration");
                   1613:          warning_with_decl (x, "previous implicit declaration of `%s'");
                   1614:        }
                   1615: 
                   1616:       /* In PCC-compatibility mode, extern decls of vars with no current decl
                   1617:         take effect at top level no matter where they are.  */
                   1618:       if (flag_traditional && TREE_EXTERNAL (x)
                   1619:          && lookup_name (name) == 0)
                   1620:        {
                   1621:          tree type = TREE_TYPE (x);
                   1622: 
                   1623:          /* But don't do this if the type contains temporary nodes.  */
                   1624:          while (type)
                   1625:            {
                   1626:              if (type == error_mark_node)
                   1627:                break;
                   1628:              if (! TREE_PERMANENT (type))
                   1629:                {
                   1630:                  warning_with_decl (x, "type of external `%s' is not global");
                   1631:                  /* By exiting the loop early, we leave TYPE nonzero,
                   1632:                     and thus prevent globalization of the decl.  */
                   1633:                  break;
                   1634:                }
                   1635:              else if (TREE_CODE (type) == FUNCTION_TYPE
                   1636:                       && TYPE_ARG_TYPES (type) != 0)
                   1637:                /* The types might not be truly local,
                   1638:                   but the list of arg types certainly is temporary.
                   1639:                   Since prototypes are nontraditional,
                   1640:                   ok not to do the traditional thing.  */
                   1641:                break;
                   1642:              type = TREE_TYPE (type);
                   1643:            }
                   1644: 
                   1645:          if (type == 0)
                   1646:            b = global_binding_level;
                   1647:        }
                   1648: 
                   1649:       /* This name is new in its binding level.
                   1650:         Install the new declaration and return it.  */
                   1651:       if (b == global_binding_level)
                   1652:        {
                   1653:          /* Install a global value.  */
                   1654:          
                   1655:          /* If the first global decl has external linkage,
                   1656:             warn if we later see static one.  */
                   1657:          if (IDENTIFIER_GLOBAL_VALUE (name) == 0 && TREE_PUBLIC (x))
                   1658:            TREE_PUBLIC (name) = 1;
                   1659: 
                   1660:          IDENTIFIER_GLOBAL_VALUE (name) = x;
                   1661: 
                   1662:          /* Don't forget if the function was used via an implicit decl.  */
                   1663:          if (IDENTIFIER_IMPLICIT_DECL (name)
                   1664:              && TREE_USED (IDENTIFIER_IMPLICIT_DECL (name)))
                   1665:            TREE_USED (x) = 1, TREE_USED (name) = 1;
                   1666: 
                   1667:          /* Don't forget if its address was taken in that way.  */
                   1668:          if (IDENTIFIER_IMPLICIT_DECL (name)
                   1669:              && TREE_ADDRESSABLE (IDENTIFIER_IMPLICIT_DECL (name)))
                   1670:            TREE_ADDRESSABLE (x) = 1;
                   1671: 
                   1672:          /* Warn about mismatches against previous implicit decl.  */
                   1673:          if (IDENTIFIER_IMPLICIT_DECL (name) != 0
                   1674:              /* If this real decl matches the implicit, don't complain.  */
                   1675:              && ! (TREE_CODE (x) == FUNCTION_DECL
                   1676:                    && TREE_TYPE (TREE_TYPE (x)) == integer_type_node))
                   1677:            pedwarn ("`%s' was previously implicitly declared to return `int'",
                   1678:                     IDENTIFIER_POINTER (name));
                   1679: 
                   1680:          /* If this decl is `static' and an `extern' was seen previously,
                   1681:             that is erroneous.  */
                   1682:          if (TREE_PUBLIC (name)
                   1683:              && ! TREE_PUBLIC (x) && ! TREE_EXTERNAL (x))
                   1684:            {
                   1685:              if (IDENTIFIER_IMPLICIT_DECL (name))
                   1686:                pedwarn ("`%s' was declared implicitly `extern' and later `static'",
                   1687:                         IDENTIFIER_POINTER (name));
                   1688:              else
                   1689:                pedwarn ("`%s' was declared `extern' and later `static'",
                   1690:                         IDENTIFIER_POINTER (name));
                   1691:            }
                   1692:        }
                   1693:       else
                   1694:        {
                   1695:          /* Here to install a non-global value.  */
                   1696:          tree oldlocal = IDENTIFIER_LOCAL_VALUE (name);
                   1697:          tree oldglobal = IDENTIFIER_GLOBAL_VALUE (name);
                   1698:          IDENTIFIER_LOCAL_VALUE (name) = x;
                   1699: 
                   1700:          /* If this is an extern function declaration, see if we
                   1701:             have a global definition for the function.  */
                   1702:          if (oldlocal == 0
                   1703:              && TREE_EXTERNAL (x) && !TREE_INLINE (x)
                   1704:              && oldglobal != 0
                   1705:              && TREE_CODE (x) == FUNCTION_DECL
                   1706:              && TREE_CODE (oldglobal) == FUNCTION_DECL)
                   1707:            {
                   1708:              /* We have one.  Their types must agree.  */
                   1709:              if (! comptypes (TREE_TYPE (x),
                   1710:                               TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (name))))
                   1711:                pedwarn_with_decl (x, "local declaration of `%s' doesn't match global one");
                   1712:              /* If the global one is inline, make the local one inline.  */
                   1713:              else if (TREE_INLINE (oldglobal)
                   1714:                       || DECL_BUILT_IN (oldglobal)
                   1715:                       || (TYPE_ARG_TYPES (TREE_TYPE (oldglobal)) != 0
                   1716:                           && TYPE_ARG_TYPES (TREE_TYPE (x)) == 0))
                   1717:                IDENTIFIER_LOCAL_VALUE (name) = oldglobal;
                   1718:            }
                   1719: 
                   1720: #if 0 /* This case is probably sometimes the right thing to do.  */
                   1721:          /* If we have a local external declaration,
                   1722:             then any file-scope declaration should not
                   1723:             have been static.  */
                   1724:          if (oldlocal == 0 && oldglobal != 0
                   1725:              && !TREE_PUBLIC (oldglobal)
                   1726:              && TREE_EXTERNAL (x) && TREE_PUBLIC (x))
                   1727:            warning ("`%s' locally external but globally static",
                   1728:                     IDENTIFIER_POINTER (name));
                   1729: #endif
                   1730: 
                   1731:          /* If we have a local external declaration,
                   1732:             and no file-scope declaration has yet been seen,
                   1733:             then if we later have a file-scope decl it must not be static.  */
                   1734:          if (oldlocal == 0
                   1735:              && oldglobal == 0
                   1736:              && TREE_EXTERNAL (x)
                   1737:              && TREE_PUBLIC (x))
                   1738:            {
                   1739:              TREE_PUBLIC (name) = 1;
                   1740:            }
                   1741: 
                   1742:          /* Warn if shadowing an argument at the top level of the body.  */
                   1743:          if (oldlocal != 0 && !TREE_EXTERNAL (x)
                   1744:              /* This warning doesn't apply to the parms of a nested fcn.  */
                   1745:              && ! current_binding_level->parm_flag
                   1746:              /* Check that this is one level down from the parms.  */
                   1747:              && current_binding_level->level_chain->parm_flag
                   1748:              /* Check that the decl being shadowed
                   1749:                 comes from the parm level, one level up.  */
                   1750:              && chain_member (oldlocal, current_binding_level->level_chain->names))
                   1751:            {
                   1752:              if (TREE_CODE (oldlocal) == PARM_DECL)
                   1753:                pedwarn ("declaration of `%s' shadows a parameter",
                   1754:                         IDENTIFIER_POINTER (name));
                   1755:              else
                   1756:                pedwarn ("declaration of `%s' shadows a symbol from the parameter list",
                   1757:                         IDENTIFIER_POINTER (name));
                   1758:            }
                   1759: 
                   1760:          /* Maybe warn if shadowing something else.  */
                   1761:          else if (warn_shadow && !TREE_EXTERNAL (x)
                   1762:                   /* No shadow warnings for vars made for inlining.  */
                   1763:                   && ! DECL_FROM_INLINE (x))
                   1764:            {
                   1765:              char *warnstring = 0;
                   1766: 
                   1767:              if (TREE_CODE (x) == PARM_DECL
                   1768:                  && current_binding_level->parm_flag == 1)
                   1769:                /* Don't warn about the parm names in a declaration.  */
                   1770:                ;
                   1771:              else if (oldlocal != 0 && TREE_CODE (oldlocal) == PARM_DECL)
                   1772:                warnstring = "declaration of `%s' shadows a parameter";
                   1773:              else if (oldlocal != 0)
                   1774:                warnstring = "declaration of `%s' shadows previous local";
                   1775:              else if (IDENTIFIER_GLOBAL_VALUE (name) != 0
                   1776:                       && IDENTIFIER_GLOBAL_VALUE (name) != error_mark_node)
                   1777:                warnstring = "declaration of `%s' shadows global declaration";
                   1778: 
                   1779:              if (warnstring)
                   1780:                warning (warnstring, IDENTIFIER_POINTER (name));
                   1781:            }
                   1782: 
                   1783:          /* If storing a local value, there may already be one (inherited).
                   1784:             If so, record it for restoration when this binding level ends.  */
                   1785:          if (oldlocal != 0)
                   1786:            b->shadowed = tree_cons (name, oldlocal, b->shadowed);
                   1787:        }
                   1788: 
                   1789:       /* Keep count of variables in this level with incomplete type.  */
                   1790:       if (TYPE_SIZE (TREE_TYPE (x)) == 0)
                   1791:        ++b->n_incomplete;
                   1792:     }
                   1793: 
                   1794:   /* Put decls on list in reverse order.
                   1795:      We will reverse them later if necessary.  */
                   1796:   TREE_CHAIN (x) = b->names;
                   1797:   b->names = x;
                   1798: 
                   1799:   return x;
                   1800: }
                   1801: 
                   1802: /* Like pushdecl, only it places X in GLOBAL_BINDING_LEVEL, if appropriate.  */
                   1803: 
                   1804: tree
                   1805: pushdecl_top_level (x)
                   1806:      tree x;
                   1807: {
                   1808:   register tree t;
                   1809:   register struct binding_level *b = current_binding_level;
                   1810: 
                   1811:   current_binding_level = global_binding_level;
                   1812:   t = pushdecl (x);
                   1813:   current_binding_level = b;
                   1814:   return t;
                   1815: }
                   1816: 
                   1817: /* Generate an implicit declaration for identifier FUNCTIONID
                   1818:    as a function of type int ().  Print a warning if appropriate.  */
                   1819: 
                   1820: tree
                   1821: implicitly_declare (functionid)
                   1822:      tree functionid;
                   1823: {
                   1824:   register tree decl;
                   1825:   int traditional_warning = 0;
                   1826:   /* Only one "implicit declaration" warning per identifier.  */
                   1827:   int implicit_warning;
                   1828: 
                   1829:   /* Save the decl permanently so we can warn if definition follows.  */
                   1830:   push_obstacks_nochange ();
                   1831:   end_temporary_allocation ();
                   1832: 
                   1833:   /* We used to reuse an old implicit decl here,
                   1834:      but this loses with inline functions because it can clobber
                   1835:      the saved decl chains.  */
                   1836: /*  if (IDENTIFIER_IMPLICIT_DECL (functionid) != 0)
                   1837:     decl = IDENTIFIER_IMPLICIT_DECL (functionid);
                   1838:   else  */
                   1839:     decl = build_decl (FUNCTION_DECL, functionid, default_function_type);
                   1840: 
                   1841:   /* Warn of implicit decl following explicit local extern decl.
                   1842:      This is probably a program designed for traditional C.  */
                   1843:   if (TREE_PUBLIC (functionid) && IDENTIFIER_GLOBAL_VALUE (functionid) == 0)
                   1844:     traditional_warning = 1;
                   1845: 
                   1846:   /* Warn once of an implicit declaration.  */
                   1847:   implicit_warning = (IDENTIFIER_IMPLICIT_DECL (functionid) == 0);
                   1848: 
                   1849:   TREE_EXTERNAL (decl) = 1;
                   1850:   TREE_PUBLIC (decl) = 1;
                   1851: 
                   1852:   /* Record that we have an implicit decl and this is it.  */
                   1853:   IDENTIFIER_IMPLICIT_DECL (functionid) = decl;
                   1854: 
                   1855:   /* ANSI standard says implicit declarations are in the innermost block.
                   1856:      So we record the decl in the standard fashion.
                   1857:      If flag_traditional is set, pushdecl does it top-level.  */
                   1858:   pushdecl (decl);
                   1859: 
                   1860:   /* This is a no-op in c-lang.c or something real in objc-actions.c.  */
                   1861:   maybe_objc_check_decl (decl);
                   1862: 
                   1863:   rest_of_decl_compilation (decl, 0, 0, 0);
                   1864: 
                   1865:   if (warn_implicit && implicit_warning)
                   1866:     warning ("implicit declaration of function `%s'",
                   1867:             IDENTIFIER_POINTER (functionid));
                   1868:   else if (warn_traditional && traditional_warning)
                   1869:     warning ("function `%s' was previously declared within a block",
                   1870:             IDENTIFIER_POINTER (functionid));
                   1871: 
                   1872:   /* Write a record describing this implicit function declaration to the
                   1873:      prototypes file (if requested).  */
                   1874: 
                   1875:   gen_aux_info_record (decl, 0, 1, 0);
                   1876: 
                   1877:   pop_obstacks ();
                   1878: 
                   1879:   return decl;
                   1880: }
                   1881: 
                   1882: /* Return zero if the declaration NEWDECL is valid
                   1883:    when the declaration OLDDECL (assumed to be for the same name)
                   1884:    has already been seen.
                   1885:    Otherwise return an error message format string with a %s
                   1886:    where the identifier should go.  */
                   1887: 
                   1888: static char *
                   1889: redeclaration_error_message (newdecl, olddecl)
                   1890:      tree newdecl, olddecl;
                   1891: {
                   1892:   if (TREE_CODE (newdecl) == TYPE_DECL)
                   1893:     {
                   1894:       if (flag_traditional && TREE_TYPE (newdecl) == TREE_TYPE (olddecl))
                   1895:        return 0;
                   1896:       return "redefinition of `%s'";
                   1897:     }
                   1898:   else if (TREE_CODE (newdecl) == FUNCTION_DECL)
                   1899:     {
                   1900:       /* Declarations of functions can insist on internal linkage
                   1901:         but they can't be inconsistent with internal linkage,
                   1902:         so there can be no error on that account.
                   1903:         However defining the same name twice is no good.  */
                   1904:       if (DECL_INITIAL (olddecl) != 0 && DECL_INITIAL (newdecl) != 0
                   1905:          /* However, defining once as extern inline and a second
                   1906:             time in another way is ok.  */
                   1907:          && !(TREE_INLINE (olddecl) && TREE_EXTERNAL (olddecl)
                   1908:               && !(TREE_INLINE (newdecl) && TREE_EXTERNAL (newdecl))))
                   1909:        return "redefinition of `%s'";
                   1910:       return 0;
                   1911:     }
                   1912:   else if (current_binding_level == global_binding_level)
                   1913:     {
                   1914:       /* Objects declared at top level:  */
                   1915:       /* If at least one is a reference, it's ok.  */
                   1916:       if (TREE_EXTERNAL (newdecl) || TREE_EXTERNAL (olddecl))
                   1917:        return 0;
                   1918:       /* Reject two definitions.  */
                   1919:       if (DECL_INITIAL (olddecl) != 0 && DECL_INITIAL (newdecl) != 0)
                   1920:        return "redefinition of `%s'";
                   1921:       /* Now we have two tentative defs, or one tentative and one real def.  */
                   1922:       /* Insist that the linkage match.  */
                   1923:       if (TREE_PUBLIC (olddecl) != TREE_PUBLIC (newdecl))
                   1924:        return "conflicting declarations of `%s'";
                   1925:       return 0;
                   1926:     }
                   1927:   else if (current_binding_level->parm_flag
                   1928:           && TREE_ASM_WRITTEN (olddecl) && !TREE_ASM_WRITTEN (newdecl))
                   1929:     return 0;
                   1930:   else
                   1931:     {
                   1932:       /* Objects declared with block scope:  */
                   1933:       /* Reject two definitions, and reject a definition
                   1934:         together with an external reference.  */
                   1935:       if (!(TREE_EXTERNAL (newdecl) && TREE_EXTERNAL (olddecl)))
                   1936:        return "redeclaration of `%s'";
                   1937:       return 0;
                   1938:     }
                   1939: }
                   1940: 
                   1941: /* Get the LABEL_DECL corresponding to identifier ID as a label.
                   1942:    Create one if none exists so far for the current function.
                   1943:    This function is called for both label definitions and label references.  */
                   1944: 
                   1945: tree
                   1946: lookup_label (id)
                   1947:      tree id;
                   1948: {
                   1949:   register tree decl = IDENTIFIER_LABEL_VALUE (id);
                   1950: 
                   1951:   /* Use a label already defined or ref'd with this name.  */
                   1952:   if (decl != 0)
                   1953:     {
                   1954:       /* But not if it is inherited and wasn't declared to be inheritable.  */
                   1955:       if (DECL_CONTEXT (decl) != current_function_decl
                   1956:          && ! C_DECLARED_LABEL_FLAG (decl))
                   1957:        return shadow_label (id);
                   1958:       return decl;
                   1959:     }
                   1960: 
                   1961:   decl = build_decl (LABEL_DECL, id, void_type_node);
                   1962: 
                   1963:   /* A label not explicitly declared must be local to where it's ref'd.  */
                   1964:   DECL_CONTEXT (decl) = current_function_decl;
                   1965: 
                   1966:   DECL_MODE (decl) = VOIDmode;
                   1967: 
                   1968:   /* Say where one reference is to the label,
                   1969:      for the sake of the error if it is not defined.  */
                   1970:   DECL_SOURCE_LINE (decl) = lineno;
                   1971:   DECL_SOURCE_FILE (decl) = input_filename;
                   1972: 
                   1973:   IDENTIFIER_LABEL_VALUE (id) = decl;
                   1974: 
                   1975:   named_labels = tree_cons (NULL_TREE, decl, named_labels);
                   1976: 
                   1977:   return decl;
                   1978: }
                   1979: 
                   1980: /* Make a label named NAME in the current function,
                   1981:    shadowing silently any that may be inherited from containing functions
                   1982:    or containing scopes.
                   1983: 
                   1984:    Note that valid use, if the label being shadowed
                   1985:    comes from another scope in the same function,
                   1986:    requires calling declare_nonlocal_label right away.  */
                   1987: 
                   1988: tree
                   1989: shadow_label (name)
                   1990:      tree name;
                   1991: {
                   1992:   register tree decl = IDENTIFIER_LABEL_VALUE (name);
                   1993: 
                   1994:   if (decl != 0)
                   1995:     {
                   1996:       shadowed_labels = tree_cons (NULL_TREE, decl, shadowed_labels);
                   1997:       IDENTIFIER_LABEL_VALUE (name) = decl = 0;
                   1998:     }
                   1999: 
                   2000:   return lookup_label (name);
                   2001: }
                   2002: 
                   2003: /* Define a label, specifying the location in the source file.
                   2004:    Return the LABEL_DECL node for the label, if the definition is valid.
                   2005:    Otherwise return 0.  */
                   2006: 
                   2007: tree
                   2008: define_label (filename, line, name)
                   2009:      char *filename;
                   2010:      int line;
                   2011:      tree name;
                   2012: {
                   2013:   tree decl = lookup_label (name);
                   2014: 
                   2015:   /* If label with this name is known from an outer context, shadow it.  */
                   2016:   if (decl != 0 && DECL_CONTEXT (decl) != current_function_decl)
                   2017:     {
                   2018:       shadowed_labels = tree_cons (NULL_TREE, decl, shadowed_labels);
                   2019:       IDENTIFIER_LABEL_VALUE (name) = 0;
                   2020:       decl = lookup_label (name);
                   2021:     }
                   2022: 
                   2023:   if (DECL_INITIAL (decl) != 0)
                   2024:     {
                   2025:       error_with_decl (decl, "duplicate label `%s'");
                   2026:       return 0;
                   2027:     }
                   2028:   else
                   2029:     {
                   2030:       /* Mark label as having been defined.  */
                   2031:       DECL_INITIAL (decl) = error_mark_node;
                   2032:       /* Say where in the source.  */
                   2033:       DECL_SOURCE_FILE (decl) = filename;
                   2034:       DECL_SOURCE_LINE (decl) = line;
                   2035:       return decl;
                   2036:     }
                   2037: }
                   2038: 
                   2039: /* Return the list of declarations of the current level.
                   2040:    Note that this list is in reverse order unless/until
                   2041:    you nreverse it; and when you do nreverse it, you must
                   2042:    store the result back using `storedecls' or you will lose.  */
                   2043: 
                   2044: tree
                   2045: getdecls ()
                   2046: {
                   2047:   return current_binding_level->names;
                   2048: }
                   2049: 
                   2050: /* Return the list of type-tags (for structs, etc) of the current level.  */
                   2051: 
                   2052: tree
                   2053: gettags ()
                   2054: {
                   2055:   return current_binding_level->tags;
                   2056: }
                   2057: 
                   2058: /* Store the list of declarations of the current level.
                   2059:    This is done for the parameter declarations of a function being defined,
                   2060:    after they are modified in the light of any missing parameters.  */
                   2061: 
                   2062: static void
                   2063: storedecls (decls)
                   2064:      tree decls;
                   2065: {
                   2066:   current_binding_level->names = decls;
                   2067: }
                   2068: 
                   2069: /* Similarly, store the list of tags of the current level.  */
                   2070: 
                   2071: static void
                   2072: storetags (tags)
                   2073:      tree tags;
                   2074: {
                   2075:   current_binding_level->tags = tags;
                   2076: }
                   2077: 
                   2078: /* Given NAME, an IDENTIFIER_NODE,
                   2079:    return the structure (or union or enum) definition for that name.
                   2080:    Searches binding levels from BINDING_LEVEL up to the global level.
                   2081:    If THISLEVEL_ONLY is nonzero, searches only the specified context
                   2082:    (but skips any tag-transparent contexts to find one that is
                   2083:    meaningful for tags).
                   2084:    CODE says which kind of type the caller wants;
                   2085:    it is RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE.
                   2086:    If the wrong kind of type is found, an error is reported.  */
                   2087: 
                   2088: static tree
                   2089: lookup_tag (code, name, binding_level, thislevel_only)
                   2090:      enum tree_code code;
                   2091:      struct binding_level *binding_level;
                   2092:      tree name;
                   2093:      int thislevel_only;
                   2094: {
                   2095:   register struct binding_level *level;
                   2096: 
                   2097:   for (level = binding_level; level; level = level->level_chain)
                   2098:     {
                   2099:       register tree tail;
                   2100:       for (tail = level->tags; tail; tail = TREE_CHAIN (tail))
                   2101:        {
                   2102:          if (TREE_PURPOSE (tail) == name)
                   2103:            {
                   2104:              if (TREE_CODE (TREE_VALUE (tail)) != code)
                   2105:                {
                   2106:                  /* Definition isn't the kind we were looking for.  */
                   2107:                  pending_invalid_xref = name;
                   2108:                  pending_invalid_xref_file = input_filename;
                   2109:                  pending_invalid_xref_line = lineno;
                   2110:                }
                   2111:              return TREE_VALUE (tail);
                   2112:            }
                   2113:        }
                   2114:       if (thislevel_only && ! level->tag_transparent)
                   2115:        return NULL_TREE;
                   2116:     }
                   2117:   return NULL_TREE;
                   2118: }
                   2119: 
                   2120: /* Print an error message now
                   2121:    for a recent invalid struct, union or enum cross reference.
                   2122:    We don't print them immediately because they are not invalid
                   2123:    when used in the `struct foo;' construct for shadowing.  */
                   2124: 
                   2125: void
                   2126: pending_xref_error ()
                   2127: {
                   2128:   if (pending_invalid_xref != 0)
                   2129:     error_with_file_and_line (pending_invalid_xref_file,
                   2130:                              pending_invalid_xref_line,
                   2131:                              "`%s' defined as wrong kind of tag",
                   2132:                              IDENTIFIER_POINTER (pending_invalid_xref));
                   2133:   pending_invalid_xref = 0;
                   2134: }
                   2135: 
                   2136: /* Given a type, find the tag that was defined for it and return the tag name.
                   2137:    Otherwise return 0.  */
                   2138: 
                   2139: static tree
                   2140: lookup_tag_reverse (type)
                   2141:      tree type;
                   2142: {
                   2143:   register struct binding_level *level;
                   2144: 
                   2145:   for (level = current_binding_level; level; level = level->level_chain)
                   2146:     {
                   2147:       register tree tail;
                   2148:       for (tail = level->tags; tail; tail = TREE_CHAIN (tail))
                   2149:        {
                   2150:          if (TREE_VALUE (tail) == type)
                   2151:            return TREE_PURPOSE (tail);
                   2152:        }
                   2153:     }
                   2154:   return NULL_TREE;
                   2155: }
                   2156: 
                   2157: /* Look up NAME in the current binding level and its superiors
                   2158:    in the namespace of variables, functions and typedefs.
                   2159:    Return a ..._DECL node of some kind representing its definition,
                   2160:    or return 0 if it is undefined.  */
                   2161: 
                   2162: tree
                   2163: lookup_name (name)
                   2164:      tree name;
                   2165: {
                   2166:   register tree val;
                   2167:   if (current_binding_level != global_binding_level
                   2168:       && IDENTIFIER_LOCAL_VALUE (name))
                   2169:     val = IDENTIFIER_LOCAL_VALUE (name);
                   2170:   else
                   2171:     val = IDENTIFIER_GLOBAL_VALUE (name);
                   2172:   return val;
                   2173: }
                   2174: 
                   2175: /* Similar to `lookup_name' but look only at current binding level.  */
                   2176: 
                   2177: static tree
                   2178: lookup_name_current_level (name)
                   2179:      tree name;
                   2180: {
                   2181:   register tree t;
                   2182: 
                   2183:   if (current_binding_level == global_binding_level)
                   2184:     return IDENTIFIER_GLOBAL_VALUE (name);
                   2185: 
                   2186:   if (IDENTIFIER_LOCAL_VALUE (name) == 0)
                   2187:     return 0;
                   2188: 
                   2189:   for (t = current_binding_level->names; t; t = TREE_CHAIN (t))
                   2190:     if (DECL_NAME (t) == name)
                   2191:       break;
                   2192: 
                   2193:   return t;
                   2194: }
                   2195: 
                   2196: /* Create the predefined scalar types of C,
                   2197:    and some nodes representing standard constants (0, 1, (void *)0).
                   2198:    Initialize the global binding level.
                   2199:    Make definitions for built-in primitive functions.  */
                   2200: 
                   2201: void
                   2202: init_decl_processing ()
                   2203: {
                   2204:   register tree endlink;
                   2205:   /* Either char* or void*.  */
                   2206:   tree traditional_ptr_type_node;
                   2207:   /* Data type of memcpy.  */
                   2208:   tree memcpy_ftype;
                   2209:   int wchar_type_size;
                   2210:   tree temp;
                   2211: 
                   2212:   current_function_decl = NULL;
                   2213:   named_labels = NULL;
                   2214:   current_binding_level = NULL_BINDING_LEVEL;
                   2215:   free_binding_level = NULL_BINDING_LEVEL;
                   2216:   pushlevel (0);       /* make the binding_level structure for global names */
                   2217:   global_binding_level = current_binding_level;
                   2218: 
                   2219:   /* Define `int' and `char' first so that dbx will output them first.  */
                   2220: 
                   2221:   integer_type_node = make_signed_type (INT_TYPE_SIZE);
                   2222:   pushdecl (build_decl (TYPE_DECL, ridpointers[(int) RID_INT],
                   2223:                        integer_type_node));
                   2224: 
                   2225:   /* Define `char', which is like either `signed char' or `unsigned char'
                   2226:      but not the same as either.  */
                   2227: 
                   2228:   char_type_node =
                   2229:     (flag_signed_char
                   2230:      ? make_signed_type (CHAR_TYPE_SIZE)
                   2231:      : make_unsigned_type (CHAR_TYPE_SIZE));
                   2232:   pushdecl (build_decl (TYPE_DECL, get_identifier ("char"),
                   2233:                        char_type_node));
                   2234: 
                   2235:   long_integer_type_node = make_signed_type (LONG_TYPE_SIZE);
                   2236:   pushdecl (build_decl (TYPE_DECL, get_identifier ("long int"),
                   2237:                        long_integer_type_node));
                   2238: 
                   2239:   unsigned_type_node = make_unsigned_type (INT_TYPE_SIZE);
                   2240:   pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned int"),
                   2241:                        unsigned_type_node));
                   2242: 
                   2243:   long_unsigned_type_node = make_unsigned_type (LONG_TYPE_SIZE);
                   2244:   pushdecl (build_decl (TYPE_DECL, get_identifier ("long unsigned int"),
                   2245:                        long_unsigned_type_node));
                   2246: 
                   2247:   /* `unsigned long' is the standard type for sizeof.
                   2248:      Traditionally, use a signed type.
                   2249:      Note that stddef.h uses `unsigned long',
                   2250:      and this must agree, even of long and int are the same size.  */
                   2251:   if (flag_traditional)
                   2252:     sizetype = long_integer_type_node;
                   2253:   else
                   2254:     sizetype
                   2255:       = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (SIZE_TYPE)));
                   2256: 
                   2257:   ptrdiff_type_node
                   2258:     = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (PTRDIFF_TYPE)));
                   2259: 
                   2260:   TREE_TYPE (TYPE_SIZE (integer_type_node)) = sizetype;
                   2261:   TREE_TYPE (TYPE_SIZE (char_type_node)) = sizetype;
                   2262:   TREE_TYPE (TYPE_SIZE (unsigned_type_node)) = sizetype;
                   2263:   TREE_TYPE (TYPE_SIZE (long_unsigned_type_node)) = sizetype;
                   2264:   TREE_TYPE (TYPE_SIZE (long_integer_type_node)) = sizetype;
                   2265: 
                   2266:   error_mark_node = make_node (ERROR_MARK);
                   2267:   TREE_TYPE (error_mark_node) = error_mark_node;
                   2268: 
                   2269:   short_integer_type_node = make_signed_type (SHORT_TYPE_SIZE);
                   2270:   pushdecl (build_decl (TYPE_DECL, get_identifier ("short int"),
                   2271:                        short_integer_type_node));
                   2272: 
                   2273:   long_long_integer_type_node = make_signed_type (LONG_LONG_TYPE_SIZE);
                   2274:   pushdecl (build_decl (TYPE_DECL, get_identifier ("long long int"),
                   2275:                        long_long_integer_type_node));
                   2276: 
                   2277:   short_unsigned_type_node = make_unsigned_type (SHORT_TYPE_SIZE);
                   2278:   pushdecl (build_decl (TYPE_DECL, get_identifier ("short unsigned int"),
                   2279:                        short_unsigned_type_node));
                   2280: 
                   2281:   long_long_unsigned_type_node = make_unsigned_type (LONG_LONG_TYPE_SIZE);
                   2282:   pushdecl (build_decl (TYPE_DECL, get_identifier ("long long unsigned int"),
                   2283:                        long_long_unsigned_type_node));
                   2284: 
                   2285:   /* Define both `signed char' and `unsigned char'.  */
                   2286:   signed_char_type_node = make_signed_type (CHAR_TYPE_SIZE);
                   2287:   pushdecl (build_decl (TYPE_DECL, get_identifier ("signed char"),
                   2288:                        signed_char_type_node));
                   2289: 
                   2290:   unsigned_char_type_node = make_unsigned_type (CHAR_TYPE_SIZE);
                   2291:   pushdecl (build_decl (TYPE_DECL, get_identifier ("unsigned char"),
                   2292:                        unsigned_char_type_node));
                   2293: 
                   2294:   float_type_node = make_node (REAL_TYPE);
                   2295:   TYPE_PRECISION (float_type_node) = FLOAT_TYPE_SIZE;
                   2296:   pushdecl (build_decl (TYPE_DECL, ridpointers[(int) RID_FLOAT],
                   2297:                        float_type_node));
                   2298:   layout_type (float_type_node);
                   2299: 
                   2300:   double_type_node = make_node (REAL_TYPE);
                   2301:   if (flag_short_double)
                   2302:     TYPE_PRECISION (double_type_node) = FLOAT_TYPE_SIZE;
                   2303:   else
                   2304:     TYPE_PRECISION (double_type_node) = DOUBLE_TYPE_SIZE;
                   2305:   pushdecl (build_decl (TYPE_DECL, ridpointers[(int) RID_DOUBLE],
                   2306:                        double_type_node));
                   2307:   layout_type (double_type_node);
                   2308: 
                   2309:   long_double_type_node = make_node (REAL_TYPE);
                   2310:   TYPE_PRECISION (long_double_type_node) = LONG_DOUBLE_TYPE_SIZE;
                   2311:   pushdecl (build_decl (TYPE_DECL, get_identifier ("long double"),
                   2312:                        long_double_type_node));
                   2313:   layout_type (long_double_type_node);
                   2314: 
                   2315:   wchar_type_node
                   2316:     = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (WCHAR_TYPE)));
                   2317:   wchar_type_size = TYPE_PRECISION (wchar_type_node);
                   2318:   signed_wchar_type_node = type_for_size (wchar_type_size, 0);
                   2319:   unsigned_wchar_type_node = type_for_size (wchar_type_size, 1);
                   2320: 
                   2321:   integer_zero_node = build_int_2 (0, 0);
                   2322:   TREE_TYPE (integer_zero_node) = integer_type_node;
                   2323:   integer_one_node = build_int_2 (1, 0);
                   2324:   TREE_TYPE (integer_one_node) = integer_type_node;
                   2325: 
                   2326:   size_zero_node = build_int_2 (0, 0);
                   2327:   TREE_TYPE (size_zero_node) = sizetype;
                   2328:   size_one_node = build_int_2 (1, 0);
                   2329:   TREE_TYPE (size_one_node) = sizetype;
                   2330: 
                   2331:   void_type_node = make_node (VOID_TYPE);
                   2332:   pushdecl (build_decl (TYPE_DECL,
                   2333:                        ridpointers[(int) RID_VOID], void_type_node));
                   2334:   layout_type (void_type_node);        /* Uses integer_zero_node */
                   2335:   /* We are not going to have real types in C with less than byte alignment,
                   2336:      so we might as well not have any types that claim to have it.  */
                   2337:   TYPE_ALIGN (void_type_node) = BITS_PER_UNIT;
                   2338: 
                   2339:   null_pointer_node = build_int_2 (0, 0);
                   2340:   TREE_TYPE (null_pointer_node) = build_pointer_type (void_type_node);
                   2341:   layout_type (TREE_TYPE (null_pointer_node));
                   2342: 
                   2343:   string_type_node = build_pointer_type (char_type_node);
                   2344:   const_string_type_node
                   2345:     = build_pointer_type (build_type_variant (char_type_node, 1, 0));
                   2346: 
                   2347:   /* make a type for arrays of 256 characters.
                   2348:      256 is picked randomly because we have a type for integers from 0 to 255.
                   2349:      With luck nothing will ever really depend on the length of this
                   2350:      array type.  */
                   2351:   char_array_type_node
                   2352:     = build_array_type (char_type_node, unsigned_char_type_node);
                   2353:   /* Likewise for arrays of ints.  */
                   2354:   int_array_type_node
                   2355:     = build_array_type (integer_type_node, unsigned_char_type_node);
                   2356:   /* This is for wide string constants.  */
                   2357:   wchar_array_type_node
                   2358:     = build_array_type (wchar_type_node, unsigned_char_type_node);
                   2359: 
                   2360:   default_function_type
                   2361:     = build_function_type (integer_type_node, NULL_TREE);
                   2362: 
                   2363:   ptr_type_node = build_pointer_type (void_type_node);
                   2364:   const_ptr_type_node
                   2365:     = build_pointer_type (build_type_variant (void_type_node, 1, 0));
                   2366: 
                   2367:   endlink = tree_cons (NULL_TREE, void_type_node, NULL_TREE);
                   2368: 
                   2369:   double_ftype_double
                   2370:     = build_function_type (double_type_node,
                   2371:                           tree_cons (NULL_TREE, double_type_node, endlink));
                   2372: 
                   2373:   double_ftype_double_double
                   2374:     = build_function_type (double_type_node,
                   2375:                           tree_cons (NULL_TREE, double_type_node,
                   2376:                                      tree_cons (NULL_TREE,
                   2377:                                                 double_type_node, endlink)));
                   2378: 
                   2379:   int_ftype_int
                   2380:     = build_function_type (integer_type_node,
                   2381:                           tree_cons (NULL_TREE, integer_type_node, endlink));
                   2382: 
                   2383:   long_ftype_long
                   2384:     = build_function_type (long_integer_type_node,
                   2385:                           tree_cons (NULL_TREE,
                   2386:                                      long_integer_type_node, endlink));
                   2387: 
                   2388:   void_ftype_ptr_ptr_int
                   2389:     = build_function_type (void_type_node,
                   2390:                           tree_cons (NULL_TREE, ptr_type_node,
                   2391:                                      tree_cons (NULL_TREE, ptr_type_node,
                   2392:                                                 tree_cons (NULL_TREE,
                   2393:                                                            integer_type_node,
                   2394:                                                            endlink))));
                   2395: 
                   2396:   int_ftype_cptr_cptr_sizet
                   2397:     = build_function_type (integer_type_node,
                   2398:                           tree_cons (NULL_TREE, const_ptr_type_node,
                   2399:                                      tree_cons (NULL_TREE, const_ptr_type_node,
                   2400:                                                 tree_cons (NULL_TREE,
                   2401:                                                            sizetype,
                   2402:                                                            endlink))));
                   2403: 
                   2404:   void_ftype_ptr_int_int
                   2405:     = build_function_type (void_type_node,
                   2406:                           tree_cons (NULL_TREE, ptr_type_node,
                   2407:                                      tree_cons (NULL_TREE, integer_type_node,
                   2408:                                                 tree_cons (NULL_TREE,
                   2409:                                                            integer_type_node,
                   2410:                                                            endlink))));
                   2411: 
                   2412:   string_ftype_ptr_ptr         /* strcpy prototype */
                   2413:     = build_function_type (string_type_node,
                   2414:                           tree_cons (NULL_TREE, string_type_node,
                   2415:                                      tree_cons (NULL_TREE,
                   2416:                                                 const_string_type_node,
                   2417:                                                 endlink)));
                   2418: 
                   2419:   int_ftype_string_string      /* strcmp prototype */
                   2420:     = build_function_type (integer_type_node,
                   2421:                           tree_cons (NULL_TREE, const_string_type_node,
                   2422:                                      tree_cons (NULL_TREE,
                   2423:                                                 const_string_type_node,
                   2424:                                                 endlink)));
                   2425: 
                   2426:   sizet_ftype_string           /* strlen prototype */
                   2427:     = build_function_type (sizetype,
                   2428:                           tree_cons (NULL_TREE, const_string_type_node,
                   2429:                                      endlink));
                   2430: 
                   2431:   traditional_ptr_type_node
                   2432:     = (flag_traditional ? string_type_node : ptr_type_node);
                   2433: 
                   2434:   memcpy_ftype /* memcpy prototype */
                   2435:     = build_function_type (traditional_ptr_type_node,
                   2436:                           tree_cons (NULL_TREE, ptr_type_node,
                   2437:                                      tree_cons (NULL_TREE, const_ptr_type_node,
                   2438:                                                 tree_cons (NULL_TREE,
                   2439:                                                            sizetype,
                   2440:                                                            endlink))));
                   2441: 
                   2442:   /* ``integer_tpe_node'' mispelling corrected: North-Keys 30 Mar 91 */
                   2443:   builtin_function ("__builtin_constant_p",
                   2444:                    build_function_type (integer_type_node, endlink),
                   2445:                    BUILT_IN_CONSTANT_P, 0);
                   2446: 
                   2447:   builtin_function ("__builtin_return_address",
                   2448:                    build_function_type (integer_type_node, 
                   2449:                                         tree_cons (NULL_TREE,
                   2450:                                                    unsigned_type_node,
                   2451:                                                    endlink)),
                   2452:                    BUILT_IN_RETURN_ADDRESS, 0);
                   2453: 
                   2454:   builtin_function ("__builtin_frame_address",
                   2455:                    build_function_type (integer_type_node, 
                   2456:                                         tree_cons (NULL_TREE,
                   2457:                                                    unsigned_type_node,
                   2458:                                                    endlink)),
                   2459:                    BUILT_IN_FRAME_ADDRESS, 0);
                   2460: 
                   2461:   builtin_function ("__builtin_alloca",
                   2462:                    build_function_type (ptr_type_node,
                   2463:                                         tree_cons (NULL_TREE,
                   2464:                                                    sizetype,
                   2465:                                                    endlink)),
                   2466:                    BUILT_IN_ALLOCA, "alloca");
                   2467:   if (! flag_no_builtin)
                   2468:     {
                   2469:       tree exit_type;
                   2470:       temp = builtin_function ("alloca",
                   2471:                               build_function_type (ptr_type_node,
                   2472:                                                    tree_cons (NULL_TREE,
                   2473:                                                               sizetype,
                   2474:                                                               endlink)),
                   2475:                               BUILT_IN_ALLOCA, 0);
                   2476:       /* Suppress error if redefined as a non-function.  */
                   2477:       DECL_BUILT_IN_NONANSI (temp) = 1;
                   2478:       /* Declare these functions volatile
                   2479:         to avoid spurious "control drops through" warnings.  */
                   2480:       /* Don't specify the argument types, to avoid errors
                   2481:         from certain code which isn't valid in ANSI but which exists.  */
                   2482:       temp = builtin_function ("abort",
                   2483:                               build_function_type (void_type_node, 0),
                   2484:                               NOT_BUILT_IN, 0);
                   2485:       TREE_THIS_VOLATILE (temp) = 1;
                   2486:       TREE_SIDE_EFFECTS (temp) = 1;
                   2487:       /* Suppress error if redefined as a non-function.  */
                   2488:       DECL_BUILT_IN_NONANSI (temp) = 1;
                   2489:       exit_type = build_function_type (void_type_node, 0);
                   2490:       temp = builtin_function ("exit", exit_type, NOT_BUILT_IN, 0);
                   2491:       TREE_THIS_VOLATILE (temp) = 1;
                   2492:       TREE_SIDE_EFFECTS (temp) = 1;
                   2493:       /* Suppress error if redefined as a non-function.  */
                   2494:       DECL_BUILT_IN_NONANSI (temp) = 1;
                   2495:       temp = builtin_function ("_exit", exit_type, NOT_BUILT_IN, 0);
                   2496:       TREE_THIS_VOLATILE (temp) = 1;
                   2497:       TREE_SIDE_EFFECTS (temp) = 1;
                   2498:       /* Suppress error if redefined as a non-function.  */
                   2499:       DECL_BUILT_IN_NONANSI (temp) = 1;
                   2500:     }
                   2501: 
                   2502:   builtin_function ("__builtin_abs", int_ftype_int, BUILT_IN_ABS, 0);
                   2503:   builtin_function ("__builtin_fabs", double_ftype_double, BUILT_IN_FABS, 0);
                   2504:   builtin_function ("__builtin_labs", long_ftype_long, BUILT_IN_LABS, 0);
                   2505:   builtin_function ("__builtin_ffs", int_ftype_int, BUILT_IN_FFS, 0);
                   2506:   builtin_function ("__builtin_saveregs", default_function_type,
                   2507:                    BUILT_IN_SAVEREGS, 0);
                   2508: /* EXPAND_BUILTIN_VARARGS is obsolete.  */
                   2509: #if 0
                   2510:   builtin_function ("__builtin_varargs",
                   2511:                    build_function_type (ptr_type_node,
                   2512:                                         tree_cons (NULL_TREE,
                   2513:                                                    integer_type_node,
                   2514:                                                    endlink)),
                   2515:                    BUILT_IN_VARARGS, 0);
                   2516: #endif
                   2517:   builtin_function ("__builtin_classify_type", default_function_type,
                   2518:                    BUILT_IN_CLASSIFY_TYPE, 0);
                   2519:   builtin_function ("__builtin_next_arg",
                   2520:                    build_function_type (ptr_type_node, endlink),
                   2521:                    BUILT_IN_NEXT_ARG, 0);
                   2522:   builtin_function ("__builtin_args_info",
                   2523:                    build_function_type (integer_type_node,
                   2524:                                         tree_cons (NULL_TREE,
                   2525:                                                    integer_type_node,
                   2526:                                                    endlink)),
                   2527:                    BUILT_IN_ARGS_INFO, 0);
                   2528: 
                   2529:   /* Currently under experimentation.  */
                   2530:   builtin_function ("__builtin_memcpy", memcpy_ftype,
                   2531:                    BUILT_IN_MEMCPY, "memcpy");
                   2532:   builtin_function ("__builtin_memcmp", int_ftype_cptr_cptr_sizet,
                   2533:                    BUILT_IN_MEMCMP, "memcmp");
                   2534:   builtin_function ("__builtin_strcmp", int_ftype_string_string,
                   2535:                    BUILT_IN_STRCMP, "strcmp");
                   2536:   builtin_function ("__builtin_strcpy", string_ftype_ptr_ptr,
                   2537:                    BUILT_IN_STRCPY, "strcpy");
                   2538:   builtin_function ("__builtin_strlen", sizet_ftype_string,
                   2539:                    BUILT_IN_STRLEN, "strlen");
                   2540:   /* In an ANSI C program, it is okay to supply built-in meanings
                   2541:      for these functions, since applications cannot validly use them
                   2542:      with any other meaning.
                   2543:      However, a traditional C program can do so.  */
                   2544:   if (!flag_traditional)
                   2545:     {
                   2546:       builtin_function ("abs", int_ftype_int, BUILT_IN_ABS, 0);
                   2547:       builtin_function ("fabs", double_ftype_double, BUILT_IN_FABS, 0);
                   2548:       builtin_function ("labs", long_ftype_long, BUILT_IN_LABS, 0);
                   2549:       builtin_function ("memcpy", memcpy_ftype, BUILT_IN_MEMCPY, 0);
                   2550:       builtin_function ("memcmp", int_ftype_cptr_cptr_sizet, BUILT_IN_MEMCMP, 0);
                   2551:       builtin_function ("strcmp", int_ftype_string_string, BUILT_IN_STRCMP, 0);
                   2552:       builtin_function ("strcpy", string_ftype_ptr_ptr, BUILT_IN_STRCPY, 0);
                   2553:       builtin_function ("strlen", sizet_ftype_string, BUILT_IN_STRLEN, 0);
                   2554:     }
                   2555: 
                   2556: #if 0
                   2557:   /* Support for these has not been written in either expand_builtin
                   2558:      or build_function_call.  */
                   2559:   builtin_function ("__builtin_div", default_ftype, BUILT_IN_DIV, 0);
                   2560:   builtin_function ("__builtin_ldiv", default_ftype, BUILT_IN_LDIV, 0);
                   2561:   builtin_function ("__builtin_ffloor", double_ftype_double, BUILT_IN_FFLOOR, 0);
                   2562:   builtin_function ("__builtin_fceil", double_ftype_double, BUILT_IN_FCEIL, 0);
                   2563:   builtin_function ("__builtin_fmod", double_ftype_double_double, BUILT_IN_FMOD, 0);
                   2564:   builtin_function ("__builtin_frem", double_ftype_double_double, BUILT_IN_FREM, 0);
                   2565:   builtin_function ("__builtin_memset", ptr_ftype_ptr_int_int, BUILT_IN_MEMSET, 0);
                   2566:   builtin_function ("__builtin_fsqrt", double_ftype_double, BUILT_IN_FSQRT, 0);
                   2567:   builtin_function ("__builtin_getexp", double_ftype_double, BUILT_IN_GETEXP, 0);
                   2568:   builtin_function ("__builtin_getman", double_ftype_double, BUILT_IN_GETMAN, 0);
                   2569: #endif
                   2570: 
                   2571:   start_identifier_warnings ();
                   2572: 
                   2573:   init_format_info_table ();
                   2574: }
                   2575: 
                   2576: /* Return a definition for a builtin function named NAME and whose data type
                   2577:    is TYPE.  TYPE should be a function type with argument types.
                   2578:    FUNCTION_CODE tells later passes how to compile calls to this function.
                   2579:    See tree.h for its possible values.
                   2580: 
                   2581:    If LIBRARY_NAME is nonzero, use that for DECL_ASSEMBLER_NAME,
                   2582:    the name to be called if we can't opencode the function.  */
                   2583: 
                   2584: static tree
                   2585: builtin_function (name, type, function_code, library_name)
                   2586:      char *name;
                   2587:      tree type;
                   2588:      enum built_in_function function_code;
                   2589:      char *library_name;
                   2590: {
                   2591:   tree decl = build_decl (FUNCTION_DECL, get_identifier (name), type);
                   2592:   TREE_EXTERNAL (decl) = 1;
                   2593:   TREE_PUBLIC (decl) = 1;
                   2594:   if (library_name)
                   2595:     DECL_ASSEMBLER_NAME (decl) = get_identifier (library_name);
                   2596:   make_decl_rtl (decl, 0, 1);
                   2597:   pushdecl (decl);
                   2598:   if (function_code != NOT_BUILT_IN)
                   2599:     {
                   2600:       DECL_BUILT_IN (decl) = 1;
                   2601:       DECL_SET_FUNCTION_CODE (decl, function_code);
                   2602:     }
                   2603: 
                   2604:   return decl;
                   2605: }
                   2606: 
                   2607: /* Called when a declaration is seen that contains no names to declare.
                   2608:    If its type is a reference to a structure, union or enum inherited
                   2609:    from a containing scope, shadow that tag name for the current scope
                   2610:    with a forward reference.
                   2611:    If its type defines a new named structure or union
                   2612:    or defines an enum, it is valid but we need not do anything here.
                   2613:    Otherwise, it is an error.  */
                   2614: 
                   2615: void
                   2616: shadow_tag (declspecs)
                   2617:      tree declspecs;
                   2618: {
                   2619:   int found_tag = 0;
                   2620:   int warned = 0;
                   2621:   register tree link;
                   2622: 
                   2623:   pending_invalid_xref = 0;
                   2624: 
                   2625:   for (link = declspecs; link; link = TREE_CHAIN (link))
                   2626:     {
                   2627:       register tree value = TREE_VALUE (link);
                   2628:       register enum tree_code code = TREE_CODE (value);
                   2629: 
                   2630:       if (code == RECORD_TYPE || code == UNION_TYPE || code == ENUMERAL_TYPE)
                   2631:        /* Used to test also that TYPE_SIZE (value) != 0.
                   2632:           That caused warning for `struct foo;' at top level in the file.  */
                   2633:        {
                   2634:          register tree name = lookup_tag_reverse (value);
                   2635:          register tree t;
                   2636: 
                   2637:          found_tag++;
                   2638: 
                   2639:          if (name == 0)
                   2640:            {
                   2641:              if (code != ENUMERAL_TYPE)        /* Empty unnamed enum OK */
                   2642:                {
                   2643:                  pedwarn ("unnamed struct/union that defines no instances");
                   2644:                  warned = 1;
                   2645:                }
                   2646:            }
                   2647:          else
                   2648:            {
                   2649:              t = lookup_tag (code, name, current_binding_level, 1);
                   2650: 
                   2651:              if (t == 0)
                   2652:                {
                   2653:                  t = make_node (code);
                   2654:                  pushtag (name, t);
                   2655:                }
                   2656:            }
                   2657:        }
                   2658:       else
                   2659:        {
                   2660:          if (!warned)
                   2661:            warning ("useless keyword or type name in empty declaration");
                   2662:          warned = 1;
                   2663:        }
                   2664:     }
                   2665: 
                   2666:   if (!warned)
                   2667:     {
                   2668:       if (found_tag > 1)
                   2669:        error ("two types specified in one empty declaration");
                   2670:       if (found_tag == 0)
                   2671:        pedwarn ("empty declaration");
                   2672:     }
                   2673: }
                   2674: 
                   2675: /* Decode a "typename", such as "int **", returning a ..._TYPE node.  */
                   2676: 
                   2677: tree
                   2678: groktypename (typename)
                   2679:      tree typename;
                   2680: {
                   2681:   if (TREE_CODE (typename) != TREE_LIST)
                   2682:     return typename;
                   2683:   return grokdeclarator (TREE_VALUE (typename),
                   2684:                         TREE_PURPOSE (typename),
                   2685:                         TYPENAME, 0);
                   2686: }
                   2687: 
                   2688: /* Return a PARM_DECL node for a given pair of specs and declarator.  */
                   2689: 
                   2690: tree
                   2691: groktypename_in_parm_context (typename)
                   2692:      tree typename;
                   2693: {
                   2694:   if (TREE_CODE (typename) != TREE_LIST)
                   2695:     return typename;
                   2696:   return grokdeclarator (TREE_VALUE (typename),
                   2697:                         TREE_PURPOSE (typename),
                   2698:                         PARM, 0);
                   2699: }
                   2700: 
                   2701: /* Decode a declarator in an ordinary declaration or data definition.
                   2702:    This is called as soon as the type information and variable name
                   2703:    have been parsed, before parsing the initializer if any.
                   2704:    Here we create the ..._DECL node, fill in its type,
                   2705:    and put it on the list of decls for the current context.
                   2706:    The ..._DECL node is returned as the value.
                   2707: 
                   2708:    Exception: for arrays where the length is not specified,
                   2709:    the type is left null, to be filled in by `finish_decl'.
                   2710: 
                   2711:    Function definitions do not come here; they go to start_function
                   2712:    instead.  However, external and forward declarations of functions
                   2713:    do go through here.  Structure field declarations are done by
                   2714:    grokfield and not through here.  */
                   2715: 
                   2716: /* Set this to zero to debug not using the temporary obstack
                   2717:    to parse initializers.  */
                   2718: int debug_temp_inits = 1;
                   2719: 
                   2720: tree
                   2721: start_decl (declarator, declspecs, initialized)
                   2722:      tree declspecs, declarator;
                   2723:      int initialized;
                   2724: {
                   2725:   register tree decl = grokdeclarator (declarator, declspecs,
                   2726:                                       NORMAL, initialized);
                   2727:   register tree tem;
                   2728:   int init_written = initialized;
                   2729: 
                   2730:   /* The corresponding pop_obstacks is in finish_decl.  */
                   2731:   push_obstacks_nochange ();
                   2732: 
                   2733:   if (initialized)
                   2734:     /* Is it valid for this decl to have an initializer at all?
                   2735:        If not, set INITIALIZED to zero, which will indirectly
                   2736:        tell `finish_decl' to ignore the initializer once it is parsed.  */
                   2737:     switch (TREE_CODE (decl))
                   2738:       {
                   2739:       case TYPE_DECL:
                   2740:        /* typedef foo = bar  means give foo the same type as bar.
                   2741:           We haven't parsed bar yet, so `finish_decl' will fix that up.
                   2742:           Any other case of an initialization in a TYPE_DECL is an error.  */
                   2743:        if (pedantic || list_length (declspecs) > 1)
                   2744:          {
                   2745:            error ("typedef `%s' is initialized",
                   2746:                   IDENTIFIER_POINTER (DECL_NAME (decl)));
                   2747:            initialized = 0;
                   2748:          }
                   2749:        break;
                   2750: 
                   2751:       case FUNCTION_DECL:
                   2752:        error ("function `%s' is initialized like a variable",
                   2753:               IDENTIFIER_POINTER (DECL_NAME (decl)));
                   2754:        initialized = 0;
                   2755:        break;
                   2756: 
                   2757:       case PARM_DECL:
                   2758:        /* DECL_INITIAL in a PARM_DECL is really DECL_ARG_TYPE.  */
                   2759:        error ("parameter `%s' is initialized",
                   2760:               IDENTIFIER_POINTER (DECL_NAME (decl)));
                   2761:        initialized = 0;
                   2762:        break;
                   2763: 
                   2764:       default:
                   2765:        /* Don't allow initializations for incomplete types
                   2766:           except for arrays which might be completed by the initialization.  */
                   2767:        if (TYPE_SIZE (TREE_TYPE (decl)) != 0)
                   2768:          {
                   2769:            /* A complete type is ok if size is fixed.  */
                   2770: 
                   2771:            if (TREE_CODE (TYPE_SIZE (TREE_TYPE (decl))) != INTEGER_CST
                   2772:                || C_DECL_VARIABLE_SIZE (decl))
                   2773:              {
                   2774:                error ("variable-sized object may not be initialized");
                   2775:                initialized = 0;
                   2776:              }
                   2777:          }
                   2778:        else if (TREE_CODE (TREE_TYPE (decl)) != ARRAY_TYPE)
                   2779:          {
                   2780:            error ("variable `%s' has initializer but incomplete type",
                   2781:                   IDENTIFIER_POINTER (DECL_NAME (decl)));
                   2782:            initialized = 0;
                   2783:          }
                   2784:        else if (TYPE_SIZE (TREE_TYPE (TREE_TYPE (decl))) == 0)
                   2785:          {
                   2786:            error ("elements of array `%s' have incomplete type",
                   2787:                   IDENTIFIER_POINTER (DECL_NAME (decl)));
                   2788:            initialized = 0;
                   2789:          }
                   2790:       }
                   2791: 
                   2792:   if (initialized)
                   2793:     {
                   2794: #if 0  /* Seems redundant with grokdeclarator.  */
                   2795:       if (current_binding_level != global_binding_level
                   2796:          && TREE_EXTERNAL (decl)
                   2797:          && TREE_CODE (decl) != FUNCTION_DECL)
                   2798:        warning ("declaration of `%s' has `extern' and is initialized",
                   2799:                 IDENTIFIER_POINTER (DECL_NAME (decl)));
                   2800: #endif
                   2801:       TREE_EXTERNAL (decl) = 0;
                   2802:       if (current_binding_level == global_binding_level)
                   2803:        TREE_STATIC (decl) = 1;
                   2804: 
                   2805:       /* Tell `pushdecl' this is an initialized decl
                   2806:         even though we don't yet have the initializer expression.
                   2807:         Also tell `finish_decl' it may store the real initializer.  */
                   2808:       DECL_INITIAL (decl) = error_mark_node;
                   2809:     }
                   2810: 
                   2811:   /* If this is a function declaration, write a record describing it to the
                   2812:      prototypes file (if requested).  */
                   2813: 
                   2814:   if (TREE_CODE (decl) == FUNCTION_DECL)
                   2815:     gen_aux_info_record (decl, 0, 0, TYPE_ARG_TYPES (TREE_TYPE (decl)) != 0);
                   2816: 
                   2817:   /* Add this decl to the current binding level.
                   2818:      TEM may equal DECL or it may be a previous decl of the same name.  */
                   2819:   tem = pushdecl (decl);
                   2820: 
                   2821:   /* For a local variable, define the RTL now.  */
                   2822:   if (current_binding_level != global_binding_level
                   2823:       /* But not if this is a duplicate decl
                   2824:         and we preserved the rtl from the previous one
                   2825:         (which may or may not happen).  */
                   2826:       && DECL_RTL (tem) == 0)
                   2827:     {
                   2828:       if (TYPE_SIZE (TREE_TYPE (tem)) != 0)
                   2829:        expand_decl (tem);
                   2830:       else if (TREE_CODE (TREE_TYPE (tem)) == ARRAY_TYPE
                   2831:               && DECL_INITIAL (tem) != 0)
                   2832:        expand_decl (tem);
                   2833:     }
                   2834: 
                   2835:   if (init_written)
                   2836:     {
                   2837:       /* When parsing and digesting the initializer,
                   2838:         use temporary storage.  Do this even if we will ignore the value.  */
                   2839:       if (current_binding_level == global_binding_level && debug_temp_inits)
                   2840:        temporary_allocation ();
                   2841:     }
                   2842: 
                   2843:   return tem;
                   2844: }
                   2845: 
                   2846: /* Finish processing of a declaration;
                   2847:    install its initial value.
                   2848:    If the length of an array type is not known before,
                   2849:    it must be determined now, from the initial value, or it is an error.  */
                   2850: 
                   2851: void
                   2852: finish_decl (decl, init, asmspec_tree)
                   2853:      tree decl, init;
                   2854:      tree asmspec_tree;
                   2855: {
                   2856:   register tree type = TREE_TYPE (decl);
                   2857:   int was_incomplete = (DECL_SIZE (decl) == 0);
                   2858:   int temporary = allocation_temporary_p ();
                   2859:   char *asmspec = 0;
                   2860: 
                   2861:   if (asmspec_tree)
                   2862:     asmspec = TREE_STRING_POINTER (asmspec_tree);
                   2863: 
                   2864:   /* If `start_decl' didn't like having an initialization, ignore it now.  */
                   2865: 
                   2866:   if (init != 0 && DECL_INITIAL (decl) == 0)
                   2867:     init = 0;
                   2868:   /* Don't crash if parm is initialized.  */
                   2869:   if (TREE_CODE (decl) == PARM_DECL)
                   2870:     init = 0;
                   2871: 
                   2872:   if (init)
                   2873:     {
                   2874:       if (TREE_CODE (decl) != TYPE_DECL)
                   2875:        store_init_value (decl, init);
                   2876:       else
                   2877:        {
                   2878:          /* typedef foo = bar; store the type of bar as the type of foo.  */
                   2879:          TREE_TYPE (decl) = TREE_TYPE (init);
                   2880:          DECL_INITIAL (decl) = init = 0;
                   2881:        }
                   2882:     }
                   2883: 
                   2884:   /* For top-level declaration, the initial value was read in
                   2885:      the temporary obstack.  MAXINDEX, rtl, etc. to be made below
                   2886:      must go in the permanent obstack; but don't discard the
                   2887:      temporary data yet.  */
                   2888: 
                   2889:   if (current_binding_level == global_binding_level && temporary)
                   2890:     end_temporary_allocation ();
                   2891: 
                   2892:   /* Deduce size of array from initialization, if not already known */
                   2893: 
                   2894:   if (TREE_CODE (type) == ARRAY_TYPE
                   2895:       && TYPE_DOMAIN (type) == 0
                   2896:       && TREE_CODE (decl) != TYPE_DECL)
                   2897:     {
                   2898:       int do_default
                   2899:        = (TREE_STATIC (decl)
                   2900:           /* Even if pedantic, an external linkage array
                   2901:              may have incomplete type at first.  */
                   2902:           ? pedantic && !TREE_PUBLIC (decl)
                   2903:           : !TREE_EXTERNAL (decl));
                   2904:       int failure
                   2905:        = complete_array_type (type, DECL_INITIAL (decl), do_default);
                   2906: 
                   2907:       /* Get the completed type made by complete_array_type.  */
                   2908:       type = TREE_TYPE (decl);
                   2909: 
                   2910:       if (failure == 1)
                   2911:        error_with_decl (decl, "initializer fails to determine size of `%s'");
                   2912: 
                   2913:       if (failure == 2)
                   2914:        {
                   2915:          if (do_default)
                   2916:            error_with_decl (decl, "array size missing in `%s'");
                   2917:          else if (!pedantic && TREE_STATIC (decl))
                   2918:            TREE_EXTERNAL (decl) = 1;
                   2919:        }
                   2920: 
                   2921:       if (pedantic && TYPE_DOMAIN (type) != 0
                   2922:          && tree_int_cst_lt (TYPE_MAX_VALUE (TYPE_DOMAIN (type)),
                   2923:                              integer_zero_node))
                   2924:        error_with_decl (decl, "zero-size array `%s'");
                   2925: 
                   2926:       layout_decl (decl, 0);
                   2927:     }
                   2928: 
                   2929:   if (TREE_CODE (decl) == VAR_DECL)
                   2930:     {
                   2931:       if (TREE_STATIC (decl) && DECL_SIZE (decl) == 0)
                   2932:        {
                   2933:          /* A static variable with an incomplete type:
                   2934:             that is an error if it is initialized or `static'.
                   2935:             Otherwise, let it through, but if it is not `extern'
                   2936:             then it may cause an error message later.  */
                   2937:          if (! (TREE_PUBLIC (decl) && DECL_INITIAL (decl) == 0))
                   2938:            error_with_decl (decl, "storage size of `%s' isn't known");
                   2939:        }
                   2940:       else if (!TREE_EXTERNAL (decl) && DECL_SIZE (decl) == 0)
                   2941:        {
                   2942:          /* An automatic variable with an incomplete type:
                   2943:             that is an error.  */
                   2944:          error_with_decl (decl, "storage size of `%s' isn't known");
                   2945:          TREE_TYPE (decl) = error_mark_node;
                   2946:        }
                   2947: 
                   2948:       if ((TREE_EXTERNAL (decl) || TREE_STATIC (decl))
                   2949:          && DECL_SIZE (decl) != 0
                   2950:          && TREE_CODE (DECL_SIZE (decl)) != INTEGER_CST)
                   2951:        error_with_decl (decl, "storage size of `%s' isn't constant");
                   2952:     }
                   2953: 
                   2954:   /* Output the assembler code and/or RTL code for variables and functions,
                   2955:      unless the type is an undefined structure or union.
                   2956:      If not, it will get done when the type is completed.  */
                   2957: 
                   2958:   if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL)
                   2959:     {
                   2960:       if (flag_traditional && allocation_temporary_p ())
                   2961:        {
                   2962:          push_obstacks_nochange ();
                   2963:          end_temporary_allocation ();
                   2964:          /* This is a no-op in c-lang.c or something real in objc-actions.c.  */
                   2965:          maybe_objc_check_decl (decl);
                   2966:          rest_of_decl_compilation (decl, asmspec,
                   2967:                                    current_binding_level == global_binding_level,
                   2968:                                    0);
                   2969:          pop_obstacks ();
                   2970:        }
                   2971:       else
                   2972:        {
                   2973:          /* This is a no-op in c-lang.c or something real in objc-actions.c.  */
                   2974:          maybe_objc_check_decl (decl);
                   2975:          rest_of_decl_compilation (decl, asmspec,
                   2976:                                    current_binding_level == global_binding_level,
                   2977:                                    0);
                   2978:        }
                   2979:       if (current_binding_level != global_binding_level)
                   2980:        {
                   2981:          /* Recompute the RTL of a local array now
                   2982:             if it used to be an incomplete type.  */
                   2983:          if (was_incomplete
                   2984:              && ! TREE_STATIC (decl) && ! TREE_EXTERNAL (decl))
                   2985:            {
                   2986:              /* If we used it already as memory, it must stay in memory.  */
                   2987:              TREE_ADDRESSABLE (decl) = TREE_USED (decl);
                   2988:              /* If it's still incomplete now, no init will save it.  */
                   2989:              if (DECL_SIZE (decl) == 0)
                   2990:                DECL_INITIAL (decl) = 0;
                   2991:              expand_decl (decl);
                   2992:            }
                   2993:          /* Compute and store the initial value.  */
                   2994:          expand_decl_init (decl);
                   2995:        }
                   2996:     }
                   2997: 
                   2998:   if (TREE_CODE (decl) == TYPE_DECL)
                   2999:     {
                   3000:       /* This is a no-op in c-lang.c or something real in objc-actions.c.  */
                   3001:       maybe_objc_check_decl (decl);
                   3002:       rest_of_decl_compilation (decl, 0,
                   3003:                                current_binding_level == global_binding_level,
                   3004:                                0);
                   3005:     }
                   3006: 
                   3007:   if (temporary && TREE_PERMANENT (decl))
                   3008:     {
                   3009:       /* We need to remember that this array HAD an initialization,
                   3010:         but discard the actual temporary nodes,
                   3011:         since we can't have a permanent node keep pointing to them.  */
                   3012:       if (DECL_INITIAL (decl) != 0)
                   3013:        DECL_INITIAL (decl) = error_mark_node;
                   3014:     }
                   3015: 
                   3016:   /* Resume permanent allocation, if not within a function.  */
                   3017:   /* The corresponding push_obstacks_nochange is in start_decl,
                   3018:      and in push_parm_decl and in grokfield.  */
                   3019:   pop_obstacks ();
                   3020:   if (current_binding_level == global_binding_level && temporary)
                   3021:     /* Actually free the temporary space that we no longer need.  */
                   3022:     permanent_allocation ();
                   3023: 
                   3024:   /* At the end of a declaration, throw away any variable type sizes
                   3025:      of types defined inside that declaration.  There is no use
                   3026:      computing them in the following function definition.  */
                   3027:   if (current_binding_level == global_binding_level)
                   3028:     get_pending_sizes ();
                   3029: }
                   3030: 
                   3031: /* If DECL has a cleanup, build and return that cleanup here.
                   3032:    This is a callback called by expand_expr.  */
                   3033: 
                   3034: tree
                   3035: maybe_build_cleanup (decl)
                   3036:      tree decl;
                   3037: {
                   3038:   /* There are no cleanups in C.  */
                   3039:   return NULL_TREE;
                   3040: }
                   3041: 
                   3042: /* Given a parsed parameter declaration,
                   3043:    decode it into a PARM_DECL and push that on the current binding level.
                   3044:    Also, for the sake of forward parm decls,
                   3045:    record the given order of parms in `parm_order'.  */
                   3046: 
                   3047: void
                   3048: push_parm_decl (parm)
                   3049:      tree parm;
                   3050: {
                   3051:   tree decl;
                   3052: 
                   3053:   /* The corresponding pop_obstacks is in finish_decl.  */
                   3054:   push_obstacks_nochange ();
                   3055: 
                   3056:   decl = grokdeclarator (TREE_VALUE (parm), TREE_PURPOSE (parm), PARM, 0);
                   3057:   decl = pushdecl (decl);
                   3058: 
                   3059:   current_binding_level->parm_order
                   3060:     = tree_cons (NULL_TREE, decl, current_binding_level->parm_order);
                   3061: 
                   3062:   /* Add this decl to the current binding level.  */
                   3063:   finish_decl (decl, NULL_TREE, NULL_TREE);
                   3064: }
                   3065: 
                   3066: /* Clear the given order of parms in `parm_order'.
                   3067:    Used at start of parm list,
                   3068:    and also at semicolon terminating forward decls.  */
                   3069: 
                   3070: void
                   3071: clear_parm_order ()
                   3072: {
                   3073:   current_binding_level->parm_order = NULL_TREE;
                   3074: }
                   3075: 
                   3076: /* Make TYPE a complete type based on INITIAL_VALUE.
                   3077:    Return 0 if successful, 1 if INITIAL_VALUE can't be decyphered,
                   3078:    2 if there was no information (in which case assume 1 if DO_DEFAULT).  */
                   3079: 
                   3080: int
                   3081: complete_array_type (type, initial_value, do_default)
                   3082:      tree type;
                   3083:      tree initial_value;
                   3084:      int do_default;
                   3085: {
                   3086:   register tree maxindex = NULL_TREE;
                   3087:   int value = 0;
                   3088: 
                   3089:   if (initial_value)
                   3090:     {
                   3091:       /* Note MAXINDEX  is really the maximum index,
                   3092:         one less than the size.  */
                   3093:       if (TREE_CODE (initial_value) == STRING_CST)
                   3094:        {
                   3095:          int eltsize
                   3096:            = int_size_in_bytes (TREE_TYPE (TREE_TYPE (initial_value)));
                   3097:          maxindex = build_int_2 (TREE_STRING_LENGTH (initial_value) / eltsize - 1, 0);
                   3098:        }
                   3099:       else if (TREE_CODE (initial_value) == CONSTRUCTOR)
                   3100:        {
                   3101:          register int nelts
                   3102:            = list_length (CONSTRUCTOR_ELTS (initial_value));
                   3103:          maxindex = build_int_2 (nelts - 1, 0);
                   3104:        }
                   3105:       else
                   3106:        {
                   3107:          /* Make an error message unless that happened already.  */
                   3108:          if (initial_value != error_mark_node)
                   3109:            value = 1;
                   3110: 
                   3111:          /* Prevent further error messages.  */
                   3112:          maxindex = build_int_2 (1, 0);
                   3113:        }
                   3114:     }
                   3115: 
                   3116:   if (!maxindex)
                   3117:     {
                   3118:       if (do_default)
                   3119:        maxindex = build_int_2 (1, 0);
                   3120:       value = 2;
                   3121:     }
                   3122: 
                   3123:   if (maxindex)
                   3124:     {
                   3125:       TYPE_DOMAIN (type) = build_index_type (maxindex);
                   3126:       if (!TREE_TYPE (maxindex))
                   3127:        TREE_TYPE (maxindex) = TYPE_DOMAIN (type);
                   3128:     }
                   3129: 
                   3130:   /* Lay out the type now that we can get the real answer.  */
                   3131: 
                   3132:   layout_type (type);
                   3133: 
                   3134:   return value;
                   3135: }
                   3136: 
                   3137: /* Given declspecs and a declarator,
                   3138:    determine the name and type of the object declared
                   3139:    and construct a ..._DECL node for it.
                   3140:    (In one case we can return a ..._TYPE node instead.
                   3141:     For invalid input we sometimes return 0.)
                   3142: 
                   3143:    DECLSPECS is a chain of tree_list nodes whose value fields
                   3144:     are the storage classes and type specifiers.
                   3145: 
                   3146:    DECL_CONTEXT says which syntactic context this declaration is in:
                   3147:      NORMAL for most contexts.  Make a VAR_DECL or FUNCTION_DECL or TYPE_DECL.
                   3148:      FUNCDEF for a function definition.  Like NORMAL but a few different
                   3149:       error messages in each case.  Return value may be zero meaning
                   3150:       this definition is too screwy to try to parse.
                   3151:      PARM for a parameter declaration (either within a function prototype
                   3152:       or before a function body).  Make a PARM_DECL, or return void_type_node.
                   3153:      TYPENAME if for a typename (in a cast or sizeof).
                   3154:       Don't make a DECL node; just return the ..._TYPE node.
                   3155:      FIELD for a struct or union field; make a FIELD_DECL.
                   3156:      BITFIELD for a field with specified width.
                   3157:    INITIALIZED is 1 if the decl has an initializer.
                   3158: 
                   3159:    In the TYPENAME case, DECLARATOR is really an absolute declarator.
                   3160:    It may also be so in the PARM case, for a prototype where the
                   3161:    argument type is specified but not the name.
                   3162: 
                   3163:    This function is where the complicated C meanings of `static'
                   3164:    and `extern' are intrepreted.  */
                   3165: 
                   3166: static tree
                   3167: grokdeclarator (declarator, declspecs, decl_context, initialized)
                   3168:      tree declspecs;
                   3169:      tree declarator;
                   3170:      enum decl_context decl_context;
                   3171:      int initialized;
                   3172: {
                   3173:   int specbits = 0;
                   3174:   tree spec;
                   3175:   tree type = NULL_TREE;
                   3176:   int longlong = 0;
                   3177:   int constp;
                   3178:   int volatilep;
                   3179:   int inlinep;
                   3180:   int explicit_int = 0;
                   3181:   int explicit_char = 0;
                   3182:   tree typedef_decl = 0;
                   3183:   char *name;
                   3184:   tree typedef_type = 0;
                   3185:   int funcdef_flag = 0;
                   3186:   enum tree_code innermost_code = ERROR_MARK;
                   3187:   int bitfield = 0;
                   3188:   int variable_size = 0;
                   3189: 
                   3190:   if (decl_context == BITFIELD)
                   3191:     bitfield = 1, decl_context = FIELD;
                   3192: 
                   3193:   if (decl_context == FUNCDEF)
                   3194:     funcdef_flag = 1, decl_context = NORMAL;
                   3195: 
                   3196:   push_obstacks_nochange ();
                   3197: 
                   3198:   if (flag_traditional && allocation_temporary_p ())
                   3199:     end_temporary_allocation ();
                   3200: 
                   3201:   /* Look inside a declarator for the name being declared
                   3202:      and get it as a string, for an error message.  */
                   3203:   {
                   3204:     register tree decl = declarator;
                   3205:     name = 0;
                   3206: 
                   3207:     while (decl)
                   3208:       switch (TREE_CODE (decl))
                   3209:        {
                   3210:        case ARRAY_REF:
                   3211:        case INDIRECT_REF:
                   3212:        case CALL_EXPR:
                   3213:          innermost_code = TREE_CODE (decl);
                   3214:          decl = TREE_OPERAND (decl, 0);
                   3215:          break;
                   3216: 
                   3217:        case IDENTIFIER_NODE:
                   3218:          name = IDENTIFIER_POINTER (decl);
                   3219:          decl = 0;
                   3220:          break;
                   3221: 
                   3222:        default:
                   3223:          abort ();
                   3224:        }
                   3225:     if (name == 0)
                   3226:       name = "type name";
                   3227:   }
                   3228: 
                   3229:   /* A function definition's declarator must have the form of
                   3230:      a function declarator.  */
                   3231: 
                   3232:   if (funcdef_flag && innermost_code != CALL_EXPR)
                   3233:     return 0;
                   3234: 
                   3235:   /* Anything declared one level down from the top level
                   3236:      must be one of the parameters of a function
                   3237:      (because the body is at least two levels down).  */
                   3238: 
                   3239:   /* If this looks like a function definition, make it one,
                   3240:      even if it occurs where parms are expected.
                   3241:      Then store_parm_decls will reject it and not use it as a parm.  */
                   3242:   if (decl_context == NORMAL && !funcdef_flag
                   3243:       && current_binding_level->level_chain == global_binding_level)
                   3244:     decl_context = PARM;
                   3245: 
                   3246:   /* Look through the decl specs and record which ones appear.
                   3247:      Some typespecs are defined as built-in typenames.
                   3248:      Others, the ones that are modifiers of other types,
                   3249:      are represented by bits in SPECBITS: set the bits for
                   3250:      the modifiers that appear.  Storage class keywords are also in SPECBITS.
                   3251: 
                   3252:      If there is a typedef name or a type, store the type in TYPE.
                   3253:      This includes builtin typedefs such as `int'.
                   3254: 
                   3255:      Set EXPLICIT_INT or EXPLICIT_CHAR if the type is `int' or `char'
                   3256:      and did not come from a user typedef.
                   3257: 
                   3258:      Set LONGLONG if `long' is mentioned twice.  */
                   3259: 
                   3260:   for (spec = declspecs; spec; spec = TREE_CHAIN (spec))
                   3261:     {
                   3262:       register int i;
                   3263:       register tree id = TREE_VALUE (spec);
                   3264: 
                   3265:       if (id == ridpointers[(int) RID_INT])
                   3266:        explicit_int = 1;
                   3267:       if (id == ridpointers[(int) RID_CHAR])
                   3268:        explicit_char = 1;
                   3269: 
                   3270:       if (TREE_CODE (id) == IDENTIFIER_NODE)
                   3271:        for (i = (int) RID_FIRST_MODIFIER; i < (int) RID_MAX; i++)
                   3272:          {
                   3273:            if (ridpointers[i] == id)
                   3274:              {
                   3275:                if (i == (int) RID_LONG && specbits & (1<<i))
                   3276:                  {
                   3277:                    if (pedantic)
                   3278:                      pedwarn ("duplicate `%s'", IDENTIFIER_POINTER (id));
                   3279:                    else if (longlong)
                   3280:                      warning ("`long long long' is too long for GCC");
                   3281:                    else
                   3282:                      longlong = 1;
                   3283:                  }
                   3284:                else if (specbits & (1 << i))
                   3285:                  warning ("duplicate `%s'", IDENTIFIER_POINTER (id));
                   3286:                specbits |= 1 << i;
                   3287:                goto found;
                   3288:              }
                   3289:          }
                   3290:       if (type)
                   3291:        error ("two or more data types in declaration of `%s'", name);
                   3292:       /* Actual typedefs come to us as TYPE_DECL nodes.  */
                   3293:       else if (TREE_CODE (id) == TYPE_DECL)
                   3294:        {
                   3295:          type = TREE_TYPE (id);
                   3296:          typedef_decl = id;
                   3297:        }
                   3298:       /* Built-in types come as identifiers.  */
                   3299:       else if (TREE_CODE (id) == IDENTIFIER_NODE)
                   3300:        {
                   3301:          register tree t = lookup_name (id);
                   3302:          if (TREE_TYPE (t) == error_mark_node)
                   3303:            ;
                   3304:          else if (!t || TREE_CODE (t) != TYPE_DECL)
                   3305:            error ("`%s' fails to be a typedef or built in type",
                   3306:                   IDENTIFIER_POINTER (id));
                   3307:          else
                   3308:            {
                   3309:              type = TREE_TYPE (t);
                   3310:              typedef_decl = t;
                   3311:            }
                   3312:        }
                   3313:       else if (TREE_CODE (id) != ERROR_MARK)
                   3314:        type = id;
                   3315: 
                   3316:     found: {}
                   3317:     }
                   3318: 
                   3319:   typedef_type = type;
                   3320:   if (type)
                   3321:     variable_size = C_TYPE_VARIABLE_SIZE (type);
                   3322: 
                   3323:   /* No type at all: default to `int', and set EXPLICIT_INT
                   3324:      because it was not a user-defined typedef.  */
                   3325: 
                   3326:   if (type == 0)
                   3327:     {
                   3328:       if (funcdef_flag && warn_return_type
                   3329:          && ! (specbits & ((1 << (int) RID_LONG) | (1 << (int) RID_SHORT)
                   3330:                            | (1 << (int) RID_SIGNED) | (1 << (int) RID_UNSIGNED))))
                   3331:        warn_about_return_type = 1;
                   3332:       explicit_int = 1;
                   3333:       type = integer_type_node;
                   3334:     }
                   3335: 
                   3336:   /* Now process the modifiers that were specified
                   3337:      and check for invalid combinations.  */
                   3338: 
                   3339:   /* Long double is a special combination.  */
                   3340: 
                   3341:   if ((specbits & 1 << (int) RID_LONG) && type == double_type_node)
                   3342:     {
                   3343:       specbits &= ~ (1 << (int) RID_LONG);
                   3344:       type = long_double_type_node;
                   3345:     }
                   3346: 
                   3347:   /* Check all other uses of type modifiers.  */
                   3348: 
                   3349:   if (specbits & ((1 << (int) RID_LONG) | (1 << (int) RID_SHORT)
                   3350:                  | (1 << (int) RID_UNSIGNED) | (1 << (int) RID_SIGNED)))
                   3351:     {
                   3352:       int ok = 0;
                   3353: 
                   3354:       if (TREE_CODE (type) != INTEGER_TYPE)
                   3355:        error ("long, short, signed or unsigned invalid for `%s'", name);
                   3356:       else if ((specbits & 1 << (int) RID_LONG)
                   3357:               && (specbits & 1 << (int) RID_SHORT))
                   3358:        error ("long and short specified together for `%s'", name);
                   3359:       else if (((specbits & 1 << (int) RID_LONG)
                   3360:                || (specbits & 1 << (int) RID_SHORT))
                   3361:               && explicit_char)
                   3362:        error ("long or short specified with char for `%s'", name);
                   3363:       else if (((specbits & 1 << (int) RID_LONG)
                   3364:                || (specbits & 1 << (int) RID_SHORT))
                   3365:               && TREE_CODE (type) == REAL_TYPE)
                   3366:        error ("long or short specified with floating type for `%s'", name);
                   3367:       else if ((specbits & 1 << (int) RID_SIGNED)
                   3368:               && (specbits & 1 << (int) RID_UNSIGNED))
                   3369:        error ("signed and unsigned given together for `%s'", name);
                   3370:       else
                   3371:        {
                   3372:          ok = 1;
                   3373:          if (!explicit_int && !explicit_char && pedantic)
                   3374:            {
                   3375:              pedwarn ("long, short, signed or unsigned used invalidly for `%s'",
                   3376:                       name);
                   3377:              if (flag_pedantic_errors)
                   3378:                ok = 0;
                   3379:            }
                   3380:        }
                   3381: 
                   3382:       /* Discard the type modifiers if they are invalid.  */
                   3383:       if (! ok)
                   3384:        {
                   3385:          specbits &= ~((1 << (int) RID_LONG) | (1 << (int) RID_SHORT)
                   3386:                        | (1 << (int) RID_UNSIGNED) | (1 << (int) RID_SIGNED));
                   3387:          longlong = 0;
                   3388:        }
                   3389:     }
                   3390: 
                   3391:   /* Decide whether an integer type is signed or not.
                   3392:      Optionally treat bitfields as signed by default.  */
                   3393:   if (specbits & 1 << (int) RID_UNSIGNED
                   3394:       /* Traditionally, all bitfields are unsigned.  */
                   3395:       || (bitfield && flag_traditional)
                   3396:       || (bitfield && ! flag_signed_bitfields
                   3397:          && (explicit_int || explicit_char
                   3398:              /* A typedef for plain `int' without `signed'
                   3399:                 can be controlled just like plain `int'.  */
                   3400:              || ! (typedef_decl != 0
                   3401:                    && C_TYPEDEF_EXPLICITLY_SIGNED (typedef_decl)))
                   3402:          && TREE_CODE (type) != ENUMERAL_TYPE
                   3403:          && !(specbits & 1 << (int) RID_SIGNED)))
                   3404:     {
                   3405:       if (longlong)
                   3406:        type = long_long_unsigned_type_node;
                   3407:       else if (specbits & 1 << (int) RID_LONG)
                   3408:        type = long_unsigned_type_node;
                   3409:       else if (specbits & 1 << (int) RID_SHORT)
                   3410:        type = short_unsigned_type_node;
                   3411:       else if (type == char_type_node)
                   3412:        type = unsigned_char_type_node;
                   3413:       else if (typedef_decl)
                   3414:        type = unsigned_type (type);
                   3415:       else
                   3416:        type = unsigned_type_node;
                   3417:     }
                   3418:   else if ((specbits & 1 << (int) RID_SIGNED)
                   3419:           && type == char_type_node)
                   3420:     type = signed_char_type_node;
                   3421:   else if (longlong)
                   3422:     type = long_long_integer_type_node;
                   3423:   else if (specbits & 1 << (int) RID_LONG)
                   3424:     type = long_integer_type_node;
                   3425:   else if (specbits & 1 << (int) RID_SHORT)
                   3426:     type = short_integer_type_node;
                   3427: 
                   3428:   /* Set CONSTP if this declaration is `const', whether by
                   3429:      explicit specification or via a typedef.
                   3430:      Likewise for VOLATILEP.  */
                   3431: 
                   3432:   constp = !! (specbits & 1 << (int) RID_CONST) + TYPE_READONLY (type);
                   3433:   volatilep = !! (specbits & 1 << (int) RID_VOLATILE) + TYPE_VOLATILE (type);
                   3434:   inlinep = !! (specbits & (1 << (int) RID_INLINE));
                   3435:   if (constp > 1)
                   3436:     warning ("duplicate `const'");
                   3437:   if (volatilep > 1)
                   3438:     warning ("duplicate `volatile'");
                   3439:   if (! flag_gen_aux_info && (TYPE_READONLY (type) || TYPE_VOLATILE (type)))
                   3440:     type = TYPE_MAIN_VARIANT (type);
                   3441: 
                   3442:   /* Warn if two storage classes are given. Default to `auto'.  */
                   3443: 
                   3444:   {
                   3445:     int nclasses = 0;
                   3446: 
                   3447:     if (specbits & 1 << (int) RID_AUTO) nclasses++;
                   3448:     if (specbits & 1 << (int) RID_STATIC) nclasses++;
                   3449:     if (specbits & 1 << (int) RID_EXTERN) nclasses++;
                   3450:     if (specbits & 1 << (int) RID_REGISTER) nclasses++;
                   3451:     if (specbits & 1 << (int) RID_TYPEDEF) nclasses++;
                   3452: 
                   3453:     /* Warn about storage classes that are invalid for certain
                   3454:        kinds of declarations (parameters, typenames, etc.).  */
                   3455: 
                   3456:     if (nclasses > 1)
                   3457:       error ("multiple storage classes in declaration of `%s'", name);
                   3458:     else if (funcdef_flag
                   3459:             && (specbits
                   3460:                 & ((1 << (int) RID_REGISTER)
                   3461:                    | (1 << (int) RID_AUTO)
                   3462:                    | (1 << (int) RID_TYPEDEF))))
                   3463:       {
                   3464:        if (specbits & 1 << (int) RID_AUTO
                   3465:            && (pedantic || current_binding_level == global_binding_level))
                   3466:          pedwarn ("function definition declared `auto'");
                   3467:        if (specbits & 1 << (int) RID_REGISTER)
                   3468:          error ("function definition declared `register'");
                   3469:        if (specbits & 1 << (int) RID_TYPEDEF)
                   3470:          error ("function definition declared `typedef'");
                   3471:        specbits &= ~ ((1 << (int) RID_TYPEDEF) | (1 << (int) RID_REGISTER)
                   3472:                       | (1 << (int) RID_AUTO));
                   3473:       }
                   3474:     else if (decl_context != NORMAL && nclasses > 0)
                   3475:       {
                   3476:        if (decl_context == PARM && specbits & 1 << (int) RID_REGISTER)
                   3477:          ;
                   3478:        else
                   3479:          {
                   3480:            error ((decl_context == FIELD
                   3481:                    ? "storage class specified for structure field `%s'"
                   3482:                    : (decl_context == PARM
                   3483:                       ? "storage class specified for parameter `%s'"
                   3484:                       : "storage class specified for typename")),
                   3485:                   name);
                   3486:            specbits &= ~ ((1 << (int) RID_TYPEDEF) | (1 << (int) RID_REGISTER)
                   3487:                           | (1 << (int) RID_AUTO) | (1 << (int) RID_STATIC)
                   3488:                           | (1 << (int) RID_EXTERN));
                   3489:          }
                   3490:       }
                   3491:     else if (specbits & 1 << (int) RID_EXTERN && initialized && ! funcdef_flag)
                   3492:       {
                   3493:        /* `extern' with initialization is invalid if not at top level.  */
                   3494:        if (current_binding_level == global_binding_level)
                   3495:          warning ("`%s' initialized and declared `extern'", name);
                   3496:        else
                   3497:          error ("`%s' has both `extern' and initializer", name);
                   3498:       }
                   3499:     else if (specbits & 1 << (int) RID_EXTERN && funcdef_flag
                   3500:             && current_binding_level != global_binding_level)
                   3501:       error ("nested function `%s' declared `extern'", name);
                   3502:     else if (current_binding_level == global_binding_level
                   3503:             && specbits & (1 << (int) RID_AUTO))
                   3504:       error ("top-level declaration of `%s' specifies `auto'", name);
                   3505:   }
                   3506: 
                   3507:   /* Now figure out the structure of the declarator proper.
                   3508:      Descend through it, creating more complex types, until we reach
                   3509:      the declared identifier (or NULL_TREE, in an absolute declarator).  */
                   3510: 
                   3511:   while (declarator && TREE_CODE (declarator) != IDENTIFIER_NODE)
                   3512:     {
                   3513:       if (type == error_mark_node)
                   3514:        {
                   3515:          declarator = TREE_OPERAND (declarator, 0);
                   3516:          continue;
                   3517:        }
                   3518: 
                   3519:       /* Each level of DECLARATOR is either an ARRAY_REF (for ...[..]),
                   3520:         an INDIRECT_REF (for *...),
                   3521:         a CALL_EXPR (for ...(...)),
                   3522:         an identifier (for the name being declared)
                   3523:         or a null pointer (for the place in an absolute declarator
                   3524:         where the name was omitted).
                   3525:         For the last two cases, we have just exited the loop.
                   3526: 
                   3527:         At this point, TYPE is the type of elements of an array,
                   3528:         or for a function to return, or for a pointer to point to.
                   3529:         After this sequence of ifs, TYPE is the type of the
                   3530:         array or function or pointer, and DECLARATOR has had its
                   3531:         outermost layer removed.  */
                   3532: 
                   3533:       if (TREE_CODE (declarator) == ARRAY_REF)
                   3534:        {
                   3535:          register tree itype = NULL_TREE;
                   3536:          register tree size = TREE_OPERAND (declarator, 1);
                   3537: 
                   3538:          declarator = TREE_OPERAND (declarator, 0);
                   3539: 
                   3540:          /* Check for some types that there cannot be arrays of.  */
                   3541: 
                   3542:          if (type == void_type_node)
                   3543:            {
                   3544:              error ("declaration of `%s' as array of voids", name);
                   3545:              type = error_mark_node;
                   3546:            }
                   3547: 
                   3548:          if (TREE_CODE (type) == FUNCTION_TYPE)
                   3549:            {
                   3550:              error ("declaration of `%s' as array of functions", name);
                   3551:              type = error_mark_node;
                   3552:            }
                   3553: 
                   3554:          if (size == error_mark_node)
                   3555:            type = error_mark_node;
                   3556: 
                   3557:          if (type == error_mark_node)
                   3558:            continue;
                   3559: 
                   3560:          /* If size was specified, set ITYPE to a range-type for that size.
                   3561:             Otherwise, ITYPE remains null.  finish_decl may figure it out
                   3562:             from an initial value.  */
                   3563: 
                   3564:          if (size)
                   3565:            {
                   3566:              /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue.  */
                   3567:              while (TREE_CODE (size) == NON_LVALUE_EXPR)
                   3568:                size = TREE_OPERAND (size, 0);
                   3569: 
                   3570:              if (TREE_CODE (TREE_TYPE (size)) != INTEGER_TYPE
                   3571:                  && TREE_CODE (TREE_TYPE (size)) != ENUMERAL_TYPE)
                   3572:                {
                   3573:                  error ("size of array `%s' has non-integer type", name);
                   3574:                  size = integer_one_node;
                   3575:                }
                   3576:              if (pedantic && integer_zerop (size))
                   3577:                pedwarn ("ANSI C forbids zero-size array `%s'", name);
                   3578:              if (TREE_CODE (size) == INTEGER_CST)
                   3579:                {
                   3580:                  if (INT_CST_LT (size, integer_zero_node))
                   3581:                    {
                   3582:                      error ("size of array `%s' is negative", name);
                   3583:                      size = integer_one_node;
                   3584:                    }
                   3585:                  itype = build_index_type (build_int_2 (TREE_INT_CST_LOW (size) - 1, 0));
                   3586:                }
                   3587:              else
                   3588:                {
                   3589:                  if (pedantic)
                   3590:                    pedwarn ("ANSI C forbids variable-size array `%s'", name);
                   3591:                  itype = build_binary_op (MINUS_EXPR, size, integer_one_node,
                   3592:                                           1);
                   3593:                  /* Make sure the array size remains visibly nonconstant
                   3594:                     even if it is (eg) a const variable with known value.  */
                   3595:                  variable_size = 1;
                   3596:                  itype = build_index_type (save_expr (itype));
                   3597:                }
                   3598:            }
                   3599: 
                   3600: #if 0 /* This had bad results for pointers to arrays, as in
                   3601:         union incomplete (*foo)[4];  */
                   3602:          /* Complain about arrays of incomplete types, except in typedefs.  */
                   3603: 
                   3604:          if (TYPE_SIZE (type) == 0
                   3605:              /* Avoid multiple warnings for nested array types.  */
                   3606:              && TREE_CODE (type) != ARRAY_TYPE
                   3607:              && !(specbits & (1 << (int) RID_TYPEDEF))
                   3608:              && !C_TYPE_BEING_DEFINED (type))
                   3609:            warning ("array type has incomplete element type");
                   3610: #endif
                   3611: 
                   3612:          /* Build the array type itself.
                   3613:             Merge any constancy or volatility into the target type.  */
                   3614: 
                   3615: #if 0  /* We shouldn't have a function type here at all!
                   3616:          Functions aren't allowed as array elements.  */
                   3617:          if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
                   3618:              && (constp || volatilep))
                   3619:            pedwarn ("ANSI C forbids const or volatile function types");
                   3620: #endif
                   3621:          if (constp || volatilep)
                   3622:            type = c_build_type_variant (type, constp, volatilep);
                   3623: 
                   3624: #if 0  /* don't clear these; leave them set so that the array type
                   3625:           or the variable is itself const or volatile.  */
                   3626:          constp = 0;
                   3627:          volatilep = 0;
                   3628: #endif
                   3629: 
                   3630:          type = build_array_type (type, itype);
                   3631:          if (variable_size)
                   3632:            C_TYPE_VARIABLE_SIZE (type) = 1;
                   3633:        }
                   3634:       else if (TREE_CODE (declarator) == CALL_EXPR)
                   3635:        {
                   3636:          tree arg_types;
                   3637: 
                   3638:          /* Declaring a function type.
                   3639:             Make sure we have a valid type for the function to return.  */
                   3640:          if (type == error_mark_node)
                   3641:            continue;
                   3642: 
                   3643:          variable_size = 0;
                   3644: 
                   3645:          /* Warn about some types functions can't return.  */
                   3646: 
                   3647:          if (TREE_CODE (type) == FUNCTION_TYPE)
                   3648:            {
                   3649:              error ("`%s' declared as function returning a function", name);
                   3650:              type = integer_type_node;
                   3651:            }
                   3652:          if (TREE_CODE (type) == ARRAY_TYPE)
                   3653:            {
                   3654:              error ("`%s' declared as function returning an array", name);
                   3655:              type = integer_type_node;
                   3656:            }
                   3657: 
                   3658: #ifndef TRADITIONAL_RETURN_FLOAT
                   3659:          /* Traditionally, declaring return type float means double.  */
                   3660: 
                   3661:          if (flag_traditional && type == float_type_node)
                   3662:            type = double_type_node;
                   3663: #endif /* TRADITIONAL_RETURN_FLOAT */
                   3664: 
                   3665:          /* Construct the function type and go to the next
                   3666:             inner layer of declarator.  */
                   3667: 
                   3668:          arg_types = grokparms (TREE_OPERAND (declarator, 1),
                   3669:                                 funcdef_flag
                   3670:                                 /* Say it's a definition
                   3671:                                    only for the CALL_EXPR
                   3672:                                    closest to the identifier.  */
                   3673:                                 && TREE_CODE (TREE_OPERAND (declarator, 0)) == IDENTIFIER_NODE);
                   3674: #if 0 /* This seems to be false.  We turn off temporary allocation
                   3675:         above in this function if -traditional.
                   3676:         And this code caused inconsistent results with prototypes:
                   3677:         callers would ignore them, and pass arguments wrong.  */
                   3678: 
                   3679:          /* Omit the arg types if -traditional, since the arg types
                   3680:             and the list links might not be permanent.  */
                   3681:          type = build_function_type (type, flag_traditional ? 0 : arg_types);
                   3682: #endif
                   3683:          type = build_function_type (type, arg_types);
                   3684:          declarator = TREE_OPERAND (declarator, 0);
                   3685: 
                   3686:          /* Set the TYPE_CONTEXTs for each tagged type which is local to
                   3687:             the formal parameter list of this FUNCTION_TYPE to point to
                   3688:             the FUNCTION_TYPE node itself.  */
                   3689: 
                   3690:          {
                   3691:            register tree link;
                   3692: 
                   3693:            for (link = current_function_parm_tags;
                   3694:                 link;
                   3695:                 link = TREE_CHAIN (link))
                   3696:              TYPE_CONTEXT (TREE_VALUE (link)) = type;
                   3697:          }
                   3698:        }
                   3699:       else if (TREE_CODE (declarator) == INDIRECT_REF)
                   3700:        {
                   3701:          /* Merge any constancy or volatility into the target type
                   3702:             for the pointer.  */
                   3703: 
                   3704:          if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
                   3705:              && (constp || volatilep))
                   3706:            pedwarn ("ANSI C forbids const or volatile function types");
                   3707:          if (constp || volatilep)
                   3708:            type = c_build_type_variant (type, constp, volatilep);
                   3709:          constp = 0;
                   3710:          volatilep = 0;
                   3711:          variable_size = 0;
                   3712: 
                   3713:          type = build_pointer_type (type);
                   3714: 
                   3715:          /* Process a list of type modifier keywords
                   3716:             (such as const or volatile) that were given inside the `*'.  */
                   3717: 
                   3718:          if (TREE_TYPE (declarator))
                   3719:            {
                   3720:              register tree typemodlist;
                   3721:              int erred = 0;
                   3722:              for (typemodlist = TREE_TYPE (declarator); typemodlist;
                   3723:                   typemodlist = TREE_CHAIN (typemodlist))
                   3724:                {
                   3725:                  if (TREE_VALUE (typemodlist) == ridpointers[(int) RID_CONST])
                   3726:                    constp++;
                   3727:                  else if (TREE_VALUE (typemodlist) == ridpointers[(int) RID_VOLATILE])
                   3728:                    volatilep++;
                   3729:                  else if (!erred)
                   3730:                    {
                   3731:                      erred = 1;
                   3732:                      error ("invalid type modifier within pointer declarator");
                   3733:                    }
                   3734:                }
                   3735:              if (constp > 1)
                   3736:                warning ("duplicate `const'");
                   3737:              if (volatilep > 1)
                   3738:                warning ("duplicate `volatile'");
                   3739:            }
                   3740: 
                   3741:          declarator = TREE_OPERAND (declarator, 0);
                   3742:        }
                   3743:       else
                   3744:        abort ();
                   3745: 
                   3746:     }
                   3747: 
                   3748:   /* Now TYPE has the actual type.  */
                   3749: 
                   3750:   /* If this is declaring a typedef name, return a TYPE_DECL.  */
                   3751: 
                   3752:   if (specbits & (1 << (int) RID_TYPEDEF))
                   3753:     {
                   3754:       tree decl;
                   3755:       /* Note that the grammar rejects storage classes
                   3756:         in typenames, fields or parameters */
                   3757:       if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
                   3758:          && (constp || volatilep))
                   3759:        pedwarn ("ANSI C forbids const or volatile function types");
                   3760:       if (constp || volatilep)
                   3761:        type = c_build_type_variant (type, constp, volatilep);
                   3762:       pop_obstacks ();
                   3763:       decl = build_decl (TYPE_DECL, declarator, type);
                   3764:       if ((specbits & (1 << (int) RID_SIGNED))
                   3765:          || (typedef_decl && C_TYPEDEF_EXPLICITLY_SIGNED (typedef_decl)))
                   3766:        C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1;
                   3767:       return decl;
                   3768:     }
                   3769: 
                   3770:   /* Detect the case of an array type of unspecified size
                   3771:      which came, as such, direct from a typedef name.
                   3772:      We must copy the type, so that each identifier gets
                   3773:      a distinct type, so that each identifier's size can be
                   3774:      controlled separately by its own initializer.  */
                   3775: 
                   3776:   if (type != 0 && typedef_type != 0
                   3777:       && TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (typedef_type)
                   3778:       && TREE_CODE (type) == ARRAY_TYPE && TYPE_DOMAIN (type) == 0)
                   3779:     {
                   3780:       type = build_array_type (TREE_TYPE (type), 0);
                   3781:       if (variable_size)
                   3782:        C_TYPE_VARIABLE_SIZE (type) = 1;
                   3783:     }
                   3784: 
                   3785:   /* If this is a type name (such as, in a cast or sizeof),
                   3786:      compute the type and return it now.  */
                   3787: 
                   3788:   if (decl_context == TYPENAME)
                   3789:     {
                   3790:       /* Note that the grammar rejects storage classes
                   3791:         in typenames, fields or parameters */
                   3792:       if (pedantic && TREE_CODE (type) == FUNCTION_TYPE
                   3793:          && (constp || volatilep))
                   3794:        pedwarn ("ANSI C forbids const or volatile function types");
                   3795:       if (constp || volatilep)
                   3796:        type = c_build_type_variant (type, constp, volatilep);
                   3797:       pop_obstacks ();
                   3798:       return type;
                   3799:     }
                   3800: 
                   3801:   /* `void' at top level (not within pointer)
                   3802:      is allowed only in typedefs or type names.
                   3803:      We don't complain about parms either, but that is because
                   3804:      a better error message can be made later.  */
                   3805: 
                   3806:   if (type == void_type_node && decl_context != PARM)
                   3807:     {
                   3808:       error ("variable or field `%s' declared void",
                   3809:             IDENTIFIER_POINTER (declarator));
                   3810:       type = integer_type_node;
                   3811:     }
                   3812: 
                   3813:   /* Now create the decl, which may be a VAR_DECL, a PARM_DECL
                   3814:      or a FUNCTION_DECL, depending on DECL_CONTEXT and TYPE.  */
                   3815: 
                   3816:   {
                   3817:     register tree decl;
                   3818: 
                   3819:     if (decl_context == PARM)
                   3820:       {
                   3821:        tree type_as_written = type;
                   3822: 
                   3823:        /* A parameter declared as an array of T is really a pointer to T.
                   3824:           One declared as a function is really a pointer to a function.  */
                   3825: 
                   3826:        if (TREE_CODE (type) == ARRAY_TYPE)
                   3827:          {
                   3828:            /* Transfer const-ness of array into that of type pointed to.  */
                   3829:            type = build_pointer_type
                   3830:                    (c_build_type_variant (TREE_TYPE (type), constp, volatilep));
                   3831:            volatilep = constp = 0;
                   3832:            variable_size = 0;
                   3833:          }
                   3834:        else if (TREE_CODE (type) == FUNCTION_TYPE)
                   3835:          {
                   3836:            if (pedantic && (constp || volatilep))
                   3837:              pedwarn ("ANSI C forbids const or volatile function types");
                   3838:            type = build_pointer_type (c_build_type_variant (type, constp, volatilep));
                   3839:            volatilep = constp = 0;
                   3840:          }
                   3841: 
                   3842:        if (initialized)
                   3843:          error ("parameter `%s' is initialized", name);
                   3844: 
                   3845:        decl = build_decl (PARM_DECL, declarator, type);
                   3846:        if (variable_size)
                   3847:          C_DECL_VARIABLE_SIZE (decl) = 1;
                   3848: 
                   3849:        /* Compute the type actually passed in the parmlist,
                   3850:           for the case where there is no prototype.
                   3851:           (For example, shorts and chars are passed as ints.)
                   3852:           When there is a prototype, this is overridden later.  */
                   3853: 
                   3854:        DECL_ARG_TYPE (decl) = type;
                   3855:        if (type == float_type_node)
                   3856:          DECL_ARG_TYPE (decl) = double_type_node;
                   3857:        else if (TREE_CODE (type) == INTEGER_TYPE
                   3858:                 && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
                   3859:          DECL_ARG_TYPE (decl) = integer_type_node;
                   3860: 
                   3861:        DECL_ARG_TYPE_AS_WRITTEN (decl) = type_as_written;
                   3862:       }
                   3863:     else if (decl_context == FIELD)
                   3864:       {
                   3865:        /* Structure field.  It may not be a function.  */
                   3866: 
                   3867:        if (TREE_CODE (type) == FUNCTION_TYPE)
                   3868:          {
                   3869:            error ("field `%s' declared as a function",
                   3870:                   IDENTIFIER_POINTER (declarator));
                   3871:            type = build_pointer_type (type);
                   3872:          }
                   3873:        else if (TREE_CODE (type) != ERROR_MARK && TYPE_SIZE (type) == 0)
                   3874:          {
                   3875:            error ("field `%s' has incomplete type",
                   3876:                   IDENTIFIER_POINTER (declarator));
                   3877:            type = error_mark_node;
                   3878:          }
                   3879:        /* Move type qualifiers down to element of an array.  */
                   3880:        if (TREE_CODE (type) == ARRAY_TYPE && (constp || volatilep))
                   3881:          {
                   3882:            type = build_array_type (c_build_type_variant (TREE_TYPE (type),
                   3883:                                                           constp, volatilep),
                   3884:                                     TYPE_DOMAIN (type));
                   3885: #if 0 /* Leave the field const or volatile as well.  */
                   3886:            constp = volatilep = 0;
                   3887: #endif
                   3888:          }
                   3889:        decl = build_decl (FIELD_DECL, declarator, type);
                   3890:        if (variable_size)
                   3891:          C_DECL_VARIABLE_SIZE (decl) = 1;
                   3892:       }
                   3893:     else if (TREE_CODE (type) == FUNCTION_TYPE)
                   3894:       {
                   3895:        if (specbits & (1 << (int) RID_AUTO)
                   3896:            && (pedantic || current_binding_level == global_binding_level))
                   3897:          pedwarn ("invalid storage class for function `%s'",
                   3898:                 IDENTIFIER_POINTER (declarator));
                   3899:        if (specbits & (1 << (int) RID_REGISTER))
                   3900:          error ("invalid storage class for function `%s'",
                   3901:                 IDENTIFIER_POINTER (declarator));
                   3902:        /* Function declaration not at top level.
                   3903:           Storage classes other than `extern' are not allowed
                   3904:           and `extern' makes no difference.  */
                   3905:        if (current_binding_level != global_binding_level
                   3906:            && (specbits & ((1 << (int) RID_STATIC) | (1 << (int) RID_INLINE)))
                   3907:            && pedantic)
                   3908:          pedwarn ("invalid storage class for function `%s'",
                   3909:                   IDENTIFIER_POINTER (declarator));
                   3910:        decl = build_decl (FUNCTION_DECL, declarator, type);
                   3911: 
                   3912:        if (pedantic && (constp || volatilep))
                   3913:          pedwarn ("ANSI C forbids const or volatile functions");
                   3914: 
                   3915:        /* Every function declaration is "external"
                   3916:           except for those which are inside a function body
                   3917:           in which `auto' is used.
                   3918:           That is a case not specified by ANSI C,
                   3919:           and we use it for forward declarations for nested functions.  */
                   3920:        if (!(specbits & (1 << (int) RID_AUTO))
                   3921:            || current_binding_level == global_binding_level)
                   3922:          TREE_EXTERNAL (decl) = 1;
                   3923:        /* Record absence of global scope for `static' or `auto'.  */
                   3924:        TREE_PUBLIC (decl)
                   3925:          = !(specbits & ((1 << (int) RID_STATIC) | (1 << (int) RID_AUTO)));
                   3926:        /* Record presence of `inline', if it is reasonable.  */
                   3927:        if (inlinep)
                   3928:          {
                   3929:            tree last = tree_last (TYPE_ARG_TYPES (type));
                   3930: 
                   3931:            if (! strcmp (IDENTIFIER_POINTER (declarator), "main"))
                   3932:              warning ("cannot inline function `main'");
                   3933:            else if (last && TREE_VALUE (last) != void_type_node)
                   3934:              warning ("inline declaration ignored for function with `...'");
                   3935:            else
                   3936:              /* Assume that otherwise the function can be inlined.  */
                   3937:              TREE_INLINE (decl) = 1;
                   3938: 
                   3939:            if (specbits & (1 << (int) RID_EXTERN))
                   3940:              current_extern_inline = 1;
                   3941:          }
                   3942:       }
                   3943:     else
                   3944:       {
                   3945:        /* It's a variable.  */
                   3946: 
                   3947:        /* Move type qualifiers down to element of an array.  */
                   3948:        if (TREE_CODE (type) == ARRAY_TYPE && (constp || volatilep))
                   3949:          {
                   3950:            type = build_array_type (c_build_type_variant (TREE_TYPE (type),
                   3951:                                                           constp, volatilep),
                   3952:                                     TYPE_DOMAIN (type));
                   3953: #if 0 /* Leave the variable const or volatile as well.  */
                   3954:            constp = volatilep = 0;
                   3955: #endif
                   3956:          }
                   3957: 
                   3958:        decl = build_decl (VAR_DECL, declarator, type);
                   3959:        if (variable_size)
                   3960:          C_DECL_VARIABLE_SIZE (decl) = 1;
                   3961: 
                   3962:        if (inlinep)
                   3963:          pedwarn_with_decl (decl, "variable `%s' declared `inline'");
                   3964: 
                   3965:        /* An uninitialized decl with `extern' is a reference.  */
                   3966:        TREE_EXTERNAL (decl)
                   3967:          = !initialized && (specbits & (1 << (int) RID_EXTERN));
                   3968:        /* At top level, either `static' or no s.c. makes a definition
                   3969:           (perhaps tentative), and absence of `static' makes it public.  */
                   3970:        if (current_binding_level == global_binding_level)
                   3971:          {
                   3972:            TREE_PUBLIC (decl) = !(specbits & (1 << (int) RID_STATIC));
                   3973:            TREE_STATIC (decl) = ! TREE_EXTERNAL (decl);
                   3974:          }
                   3975:        /* Not at top level, only `static' makes a static definition.  */
                   3976:        else
                   3977:          {
                   3978:            TREE_STATIC (decl) = (specbits & (1 << (int) RID_STATIC)) != 0;
                   3979:            TREE_PUBLIC (decl) = TREE_EXTERNAL (decl);
                   3980:          }
                   3981:       }
                   3982: 
                   3983:     /* Record `register' declaration for warnings on &
                   3984:        and in case doing stupid register allocation.  */
                   3985: 
                   3986:     if (specbits & (1 << (int) RID_REGISTER))
                   3987:       TREE_REGDECL (decl) = 1;
                   3988: 
                   3989:     /* Record constancy and volatility.  */
                   3990: 
                   3991:     if (constp)
                   3992:       TREE_READONLY (decl) = 1;
                   3993:     if (volatilep)
                   3994:       {
                   3995:        TREE_SIDE_EFFECTS (decl) = 1;
                   3996:        TREE_THIS_VOLATILE (decl) = 1;
                   3997:       }
                   3998:     /* If a type has volatile components, it should be stored in memory.
                   3999:        Otherwise, the fact that those components are volatile
                   4000:        will be ignored, and would even crash the compiler.  */
                   4001:     if (C_TYPE_FIELDS_VOLATILE (TREE_TYPE (decl)))
                   4002:       mark_addressable (decl);
                   4003: 
                   4004:     pop_obstacks ();
                   4005: 
                   4006:     return decl;
                   4007:   }
                   4008: }
                   4009: 
                   4010: /* Make a variant type in the proper way for C, propagating qualifiers
                   4011:    down to the element type of an array.  */
                   4012: 
                   4013: tree
                   4014: c_build_type_variant (type, constp, volatilep)
                   4015:      tree type;
                   4016:      int constp, volatilep;
                   4017: {
                   4018:   if (TREE_CODE (type) == ARRAY_TYPE)
                   4019:     type = build_array_type (c_build_type_variant (TREE_TYPE (type),
                   4020:                                                   constp, volatilep),
                   4021:                             TYPE_DOMAIN (type));
                   4022:   return build_type_variant (type, constp, volatilep);
                   4023: }
                   4024: 
                   4025: /* Decode the parameter-list info for a function type or function definition.
                   4026:    The argument is the value returned by `get_parm_info' (or made in parse.y
                   4027:    if there is an identifier list instead of a parameter decl list).
                   4028:    These two functions are separate because when a function returns
                   4029:    or receives functions then each is called multiple times but the order
                   4030:    of calls is different.  The last call to `grokparms' is always the one
                   4031:    that contains the formal parameter names of a function definition.
                   4032: 
                   4033:    Store in `last_function_parms' a chain of the decls of parms.
                   4034:    Also store in `last_function_parm_tags' a chain of the struct, union,
                   4035:    and enum tags declared among the parms.
                   4036: 
                   4037:    Return a list of arg types to use in the FUNCTION_TYPE for this function.
                   4038: 
                   4039:    FUNCDEF_FLAG is nonzero for a function definition, 0 for
                   4040:    a mere declaration.  A nonempty identifier-list gets an error message
                   4041:    when FUNCDEF_FLAG is zero.  */
                   4042: 
                   4043: static tree
                   4044: grokparms (parms_info, funcdef_flag)
                   4045:      tree parms_info;
                   4046:      int funcdef_flag;
                   4047: {
                   4048:   tree first_parm = TREE_CHAIN (parms_info);
                   4049: 
                   4050:   last_function_parms = TREE_PURPOSE (parms_info);
                   4051:   last_function_parm_tags = TREE_VALUE (parms_info);
                   4052: 
                   4053:   if (warn_strict_prototypes && first_parm == 0 && !funcdef_flag)
                   4054:     warning ("function declaration isn't a prototype");
                   4055: 
                   4056:   if (first_parm != 0
                   4057:       && TREE_CODE (TREE_VALUE (first_parm)) == IDENTIFIER_NODE)
                   4058:     {
                   4059:       if (! funcdef_flag)
                   4060:        pedwarn ("parameter names (without types) in function declaration");
                   4061: 
                   4062:       last_function_parms = first_parm;
                   4063:       return 0;
                   4064:     }
                   4065:   else
                   4066:     {
                   4067:       tree parm;
                   4068:       tree typelt;
                   4069:       /* We no longer test FUNCDEF_FLAG.
                   4070:         If the arg types are incomplete in a declaration,
                   4071:         they must include undefined tags.
                   4072:         These tags can never be defined in the scope of the declaration,
                   4073:         so the types can never be completed,
                   4074:         and no call can be compiled successfully.  */
                   4075: #if 0
                   4076:       /* In a fcn definition, arg types must be complete.  */
                   4077:       if (funcdef_flag)
                   4078: #endif
                   4079:        for (parm = last_function_parms, typelt = first_parm;
                   4080:             parm;
                   4081:             parm = TREE_CHAIN (parm))
                   4082:          /* Skip over any enumeration constants declared here.  */
                   4083:          if (TREE_CODE (parm) == PARM_DECL)
                   4084:            {
                   4085:              /* Barf if the parameter itself has an incomplete type.  */
                   4086:              tree type = TREE_VALUE (typelt);
                   4087:              if (TYPE_SIZE (type) == 0)
                   4088:                {
                   4089:                  if (funcdef_flag && DECL_NAME (parm) != 0)
                   4090:                    error ("parameter `%s' has incomplete type",
                   4091:                           IDENTIFIER_POINTER (DECL_NAME (parm)));
                   4092:                  else
                   4093:                    warning ("parameter has incomplete type");
                   4094:                  if (funcdef_flag)
                   4095:                    {
                   4096:                      TREE_VALUE (typelt) = error_mark_node;
                   4097:                      TREE_TYPE (parm) = error_mark_node;
                   4098:                    }
                   4099:                }
                   4100: #if 0  /* This has been replaced by parm_tags_warning
                   4101:          which uses a more accurate criterion for what to warn about.  */
                   4102:              else
                   4103:                {
                   4104:                  /* Now warn if is a pointer to an incomplete type.  */
                   4105:                  while (TREE_CODE (type) == POINTER_TYPE
                   4106:                         || TREE_CODE (type) == REFERENCE_TYPE)
                   4107:                    type = TREE_TYPE (type);
                   4108:                  type = TYPE_MAIN_VARIANT (type);
                   4109:                  if (TYPE_SIZE (type) == 0)
                   4110:                    {
                   4111:                      if (DECL_NAME (parm) != 0)
                   4112:                        warning ("parameter `%s' points to incomplete type",
                   4113:                                 IDENTIFIER_POINTER (DECL_NAME (parm)));
                   4114:                      else
                   4115:                        warning ("parameter points to incomplete type");
                   4116:                    }
                   4117:                }
                   4118: #endif
                   4119:              typelt = TREE_CHAIN (typelt);
                   4120:            }
                   4121: 
                   4122:       return first_parm;
                   4123:     }
                   4124: }
                   4125: 
                   4126: 
                   4127: /* Return a tree_list node with info on a parameter list just parsed.
                   4128:    The TREE_PURPOSE is a chain of decls of those parms.
                   4129:    The TREE_VALUE is a list of structure, union and enum tags defined.
                   4130:    The TREE_CHAIN is a list of argument types to go in the FUNCTION_TYPE.
                   4131:    This tree_list node is later fed to `grokparms'.
                   4132: 
                   4133:    VOID_AT_END nonzero means append `void' to the end of the type-list.
                   4134:    Zero means the parmlist ended with an ellipsis so don't append `void'.  */
                   4135: 
                   4136: tree
                   4137: get_parm_info (void_at_end)
                   4138:      int void_at_end;
                   4139: {
                   4140:   register tree decl, t;
                   4141:   register tree types = 0;
                   4142:   int erred = 0;
                   4143:   tree tags = gettags ();
                   4144:   tree parms = getdecls ();
                   4145:   tree new_parms = 0;
                   4146:   tree order = current_binding_level->parm_order;
                   4147: 
                   4148:   /* Just `void' (and no ellipsis) is special.  There are really no parms.  */
                   4149:   if (void_at_end && parms != 0
                   4150:       && TREE_CHAIN (parms) == 0
                   4151:       && TREE_TYPE (parms) == void_type_node
                   4152:       && DECL_NAME (parms) == 0)
                   4153:     {
                   4154:       parms = NULL_TREE;
                   4155:       storedecls (NULL_TREE);
                   4156:       return saveable_tree_cons (NULL_TREE, NULL_TREE,
                   4157:                                 saveable_tree_cons (NULL_TREE, void_type_node, NULL_TREE));
                   4158:     }
                   4159: 
                   4160:   /* Extract enumerator values and other non-parms declared with the parms.  */
                   4161:   for (decl = parms; decl; )
                   4162:     {
                   4163:       tree next = TREE_CHAIN (decl);
                   4164: 
                   4165:       if (TREE_CODE (decl) != PARM_DECL)
                   4166:        {
                   4167:          TREE_CHAIN (decl) = new_parms;
                   4168:          new_parms = decl;
                   4169:        }
                   4170:       decl = next;
                   4171:     }
                   4172: 
                   4173:   /* Put the parm decls back in the order they were in in the parm list.  */
                   4174:   for (t = order; t; t = TREE_CHAIN (t))
                   4175:     {
                   4176:       if (TREE_CHAIN (t))
                   4177:        TREE_CHAIN (TREE_VALUE (t)) = TREE_VALUE (TREE_CHAIN (t));
                   4178:       else
                   4179:        TREE_CHAIN (TREE_VALUE (t)) = 0;
                   4180:     }
                   4181: 
                   4182:   new_parms = chainon (order ? nreverse (TREE_VALUE (order)) : 0,
                   4183:                       new_parms);
                   4184: 
                   4185:   /* Store the parmlist in the binding level since the old one
                   4186:      is no longer a valid list.  (We have changed the chain pointers.)  */
                   4187:   storedecls (new_parms);
                   4188: 
                   4189:   for (decl = new_parms; decl; decl = TREE_CHAIN (decl))
                   4190:     /* There may also be declarations for enumerators if an enumeration
                   4191:        type is declared among the parms.  Ignore them here.  */
                   4192:     if (TREE_CODE (decl) == PARM_DECL)
                   4193:       {
                   4194:        /* Since there is a prototype,
                   4195:           args are passed in their declared types.  */
                   4196:        tree type = TREE_TYPE (decl);
                   4197:        DECL_ARG_TYPE (decl) = type;
                   4198: #ifdef PROMOTE_PROTOTYPES
                   4199:        if (TREE_CODE (type) == INTEGER_TYPE
                   4200:            && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
                   4201:          DECL_ARG_TYPE (decl) = integer_type_node;
                   4202: #endif
                   4203: 
                   4204:        types = saveable_tree_cons (NULL_TREE, TREE_TYPE (decl), types);
                   4205:        if (TREE_VALUE (types) == void_type_node && ! erred
                   4206:            && DECL_NAME (decl) == 0)
                   4207:          {
                   4208:            error ("`void' in parameter list must be the entire list");
                   4209:            erred = 1;
                   4210:          }
                   4211:       }
                   4212: 
                   4213:   if (void_at_end)
                   4214:     return saveable_tree_cons (new_parms, tags,
                   4215:                               nreverse (saveable_tree_cons (NULL_TREE, void_type_node, types)));
                   4216: 
                   4217:   return saveable_tree_cons (new_parms, tags, nreverse (types));
                   4218: }
                   4219: 
                   4220: /* At end of parameter list, warn about any struct, union or enum tags
                   4221:    defined within.  Do so because these types cannot ever become complete.  */
                   4222: 
                   4223: void
                   4224: parmlist_tags_warning ()
                   4225: {
                   4226:   tree elt;
                   4227:   static int already;
                   4228: 
                   4229:   for (elt = current_binding_level->tags; elt; elt = TREE_CHAIN (elt))
                   4230:     {
                   4231:       enum tree_code code = TREE_CODE (TREE_VALUE (elt));
                   4232:       warning ("`%s %s' declared inside parameter list",
                   4233:               (code == RECORD_TYPE ? "struct"
                   4234:                : code == UNION_TYPE ? "union"
                   4235:                : "enum"),
                   4236:               IDENTIFIER_POINTER (TREE_PURPOSE (elt)));
                   4237:       if (! already)
                   4238:        {
                   4239:          warning ("its scope is only this definition or declaration,");
                   4240:          warning ("which is probably not what you want.");
                   4241:          already = 1;
                   4242:        }
                   4243:     }
                   4244: }
                   4245: 
                   4246: /* Get the struct, enum or union (CODE says which) with tag NAME.
                   4247:    Define the tag as a forward-reference if it is not defined.  */
                   4248: 
                   4249: tree
                   4250: xref_tag (code, name)
                   4251:      enum tree_code code;
                   4252:      tree name;
                   4253: {
                   4254:   int temporary = allocation_temporary_p ();
                   4255: 
                   4256:   /* If a cross reference is requested, look up the type
                   4257:      already defined for this tag and return it.  */
                   4258: 
                   4259:   register tree ref = lookup_tag (code, name, current_binding_level, 0);
                   4260:   /* Even if this is the wrong type of tag, return what we found.
                   4261:      There will be an error message anyway, from pending_xref_error.
                   4262:      If we create an empty xref just for an invalid use of the type,
                   4263:      the main result is to create lots of superflous error messages.  */
                   4264:   if (ref)
                   4265:     return ref;
                   4266: 
                   4267:   push_obstacks_nochange ();
                   4268: 
                   4269:   if (current_binding_level == global_binding_level && temporary)
                   4270:     end_temporary_allocation ();
                   4271: 
                   4272:   /* If no such tag is yet defined, create a forward-reference node
                   4273:      and record it as the "definition".
                   4274:      When a real declaration of this type is found,
                   4275:      the forward-reference will be altered into a real type.  */
                   4276: 
                   4277:   ref = make_node (code);
                   4278:   if (code == ENUMERAL_TYPE)
                   4279:     {
                   4280:       /* (In ANSI, Enums can be referred to only if already defined.)  */
                   4281:       if (pedantic)
                   4282:        pedwarn ("ANSI C forbids forward references to `enum' types");
                   4283:       /* Give the type a default layout like unsigned int
                   4284:         to avoid crashing if it does not get defined.  */
                   4285:       TYPE_MODE (ref) = TYPE_MODE (unsigned_type_node);
                   4286:       TYPE_ALIGN (ref) = TYPE_ALIGN (unsigned_type_node);
                   4287:       TREE_UNSIGNED (ref) = 1;
                   4288:       TYPE_PRECISION (ref) = TYPE_PRECISION (unsigned_type_node);
                   4289:       TYPE_MIN_VALUE (ref) = TYPE_MIN_VALUE (unsigned_type_node);
                   4290:       TYPE_MAX_VALUE (ref) = TYPE_MAX_VALUE (unsigned_type_node);
                   4291:     }
                   4292: 
                   4293:   pushtag (name, ref);
                   4294: 
                   4295:   pop_obstacks ();
                   4296: 
                   4297:   return ref;
                   4298: }
                   4299: 
                   4300: /* Make sure that the tag NAME is defined *in the current binding level*
                   4301:    at least as a forward reference.
                   4302:    CODE says which kind of tag NAME ought to be.  */
                   4303: 
                   4304: tree
                   4305: start_struct (code, name)
                   4306:      enum tree_code code;
                   4307:      tree name;
                   4308: {
                   4309:   /* If there is already a tag defined at this binding level
                   4310:      (as a forward reference), just return it.  */
                   4311: 
                   4312:   register tree ref = 0;
                   4313: 
                   4314:   if (name != 0)
                   4315:     ref = lookup_tag (code, name, current_binding_level, 1);
                   4316:   if (ref && TREE_CODE (ref) == code)
                   4317:     {
                   4318:       C_TYPE_BEING_DEFINED (ref) = 1;
                   4319:       if (TYPE_FIELDS (ref))
                   4320:        error ((code == UNION_TYPE ? "redefinition of `union %s'"
                   4321:                : "redefinition of `struct %s'"),
                   4322:               IDENTIFIER_POINTER (name));
                   4323: 
                   4324:       return ref;
                   4325:     }
                   4326: 
                   4327:   /* Otherwise create a forward-reference just so the tag is in scope.  */
                   4328: 
                   4329:   ref = make_node (code);
                   4330:   pushtag (name, ref);
                   4331:   C_TYPE_BEING_DEFINED (ref) = 1;
                   4332:   return ref;
                   4333: }
                   4334: 
                   4335: /* Process the specs, declarator (NULL if omitted) and width (NULL if omitted)
                   4336:    of a structure component, returning a FIELD_DECL node.
                   4337:    WIDTH is non-NULL for bit fields only, and is an INTEGER_CST node.
                   4338: 
                   4339:    This is done during the parsing of the struct declaration.
                   4340:    The FIELD_DECL nodes are chained together and the lot of them
                   4341:    are ultimately passed to `build_struct' to make the RECORD_TYPE node.  */
                   4342: 
                   4343: tree
                   4344: grokfield (filename, line, declarator, declspecs, width)
                   4345:      char *filename;
                   4346:      int line;
                   4347:      tree declarator, declspecs, width;
                   4348: {
                   4349:   tree value;
                   4350: 
                   4351:   /* The corresponding pop_obstacks is in finish_decl.  */
                   4352:   push_obstacks_nochange ();
                   4353: 
                   4354:   value = grokdeclarator (declarator, declspecs, width ? BITFIELD : FIELD, 0);
                   4355: 
                   4356:   finish_decl (value, NULL, NULL);
                   4357:   DECL_INITIAL (value) = width;
                   4358: 
                   4359:   return value;
                   4360: }
                   4361: 
                   4362: /* Function to help qsort sort FIELD_DECLs by name order.  */
                   4363: 
                   4364: static int
                   4365: field_decl_cmp (x, y)
                   4366:      tree *x, *y;
                   4367: {
                   4368:   return (long)DECL_NAME (*x) - (long)DECL_NAME (*y);
                   4369: }
                   4370: 
                   4371: /* Fill in the fields of a RECORD_TYPE or UNION_TYPE node, T.
                   4372:    FIELDLIST is a chain of FIELD_DECL nodes for the fields.  */
                   4373: 
                   4374: tree
                   4375: finish_struct (t, fieldlist)
                   4376:      register tree t, fieldlist;
                   4377: {
                   4378:   register tree x;
                   4379:   int old_momentary;
                   4380:   int toplevel = global_binding_level == current_binding_level;
                   4381: 
                   4382:   /* If this type was previously laid out as a forward reference,
                   4383:      make sure we lay it out again.  */
                   4384: 
                   4385:   TYPE_SIZE (t) = 0;
                   4386: 
                   4387:   /* Nameless union parm types are useful as GCC extension.  */
                   4388:   if (! (TREE_CODE (t) == UNION_TYPE && TYPE_NAME (t) == 0) && !pedantic)
                   4389:     /* Otherwise, warn about any struct or union def. in parmlist.  */
                   4390:     if (in_parm_level_p ())
                   4391:       {
                   4392:        if (pedantic)
                   4393:          pedwarn ((TREE_CODE (t) == UNION_TYPE ? "union defined inside parms"
                   4394:                    : "structure defined inside parms"));
                   4395:        else
                   4396:          warning ((TREE_CODE (t) == UNION_TYPE ? "union defined inside parms"
                   4397:                    : "structure defined inside parms"));
                   4398:       }
                   4399: 
                   4400:   old_momentary = suspend_momentary ();
                   4401: 
                   4402:   if (fieldlist == 0 && pedantic)
                   4403:     pedwarn ((TREE_CODE (t) == UNION_TYPE ? "union has no members"
                   4404:              : "structure has no members"));
                   4405: 
                   4406:   /* Install struct as DECL_CONTEXT of each field decl.
                   4407:      Also process specified field sizes.
                   4408:      Set DECL_FRAME_SIZE to the specified size, or 0 if none specified.
                   4409:      The specified size is found in the DECL_INITIAL.
                   4410:      Store 0 there, except for ": 0" fields (so we can find them
                   4411:      and delete them, below).  */
                   4412: 
                   4413:   for (x = fieldlist; x; x = TREE_CHAIN (x))
                   4414:     {
                   4415:       DECL_CONTEXT (x) = t;
                   4416:       DECL_FRAME_SIZE (x) = 0;
                   4417: 
                   4418:       /* If any field is const, the structure type is pseudo-const.  */
                   4419:       if (TREE_READONLY (x))
                   4420:        C_TYPE_FIELDS_READONLY (t) = 1;
                   4421:       else
                   4422:        {
                   4423:          /* A field that is pseudo-const makes the structure likewise.  */
                   4424:          tree t1 = TREE_TYPE (x);
                   4425:          while (TREE_CODE (t1) == ARRAY_TYPE)
                   4426:            t1 = TREE_TYPE (t1);
                   4427:          if ((TREE_CODE (t1) == RECORD_TYPE || TREE_CODE (t1) == UNION_TYPE)
                   4428:              && C_TYPE_FIELDS_READONLY (t1))
                   4429:            C_TYPE_FIELDS_READONLY (t) = 1;
                   4430:        }
                   4431: 
                   4432:       /* Any field that is volatile means variables of this type must be
                   4433:         treated in some ways as volatile.  */
                   4434:       if (TREE_THIS_VOLATILE (x))
                   4435:        C_TYPE_FIELDS_VOLATILE (t) = 1;
                   4436: 
                   4437:       /* Any field of nominal variable size implies structure is too.  */
                   4438:       if (C_DECL_VARIABLE_SIZE (x))
                   4439:        C_TYPE_VARIABLE_SIZE (t) = 1;
                   4440: 
                   4441:       /* Detect invalid bit-field size.  */
                   4442:       while (DECL_INITIAL (x)
                   4443:             && TREE_CODE (DECL_INITIAL (x)) == NON_LVALUE_EXPR)
                   4444:        DECL_INITIAL (x) = TREE_OPERAND (DECL_INITIAL (x), 0);
                   4445:       if (DECL_INITIAL (x) && TREE_CODE (DECL_INITIAL (x)) != INTEGER_CST)
                   4446:        {
                   4447:          error_with_decl (x, "bit-field `%s' width not an integer constant");
                   4448:          DECL_INITIAL (x) = NULL;
                   4449:        }
                   4450: 
                   4451:       /* Detect invalid bit-field type.  */
                   4452:       if (DECL_INITIAL (x)
                   4453:          && TREE_CODE (TREE_TYPE (x)) != INTEGER_TYPE
                   4454:          && TREE_CODE (TREE_TYPE (x)) != ENUMERAL_TYPE)
                   4455:        {
                   4456:          error_with_decl (x, "bit-field `%s' has invalid type");
                   4457:          DECL_INITIAL (x) = NULL;
                   4458:        }
                   4459:       if (DECL_INITIAL (x) && pedantic
                   4460:          && TYPE_MAIN_VARIANT (TREE_TYPE (x)) != integer_type_node
                   4461:          && TYPE_MAIN_VARIANT (TREE_TYPE (x)) != unsigned_type_node)
                   4462:        pedwarn_with_decl (x, "bit-field `%s' type invalid in ANSI C");
                   4463: 
                   4464:       /* Detect and ignore out of range field width.  */
                   4465:       if (DECL_INITIAL (x))
                   4466:        {
                   4467:          register int width = TREE_INT_CST_LOW (DECL_INITIAL (x));
                   4468: 
                   4469:          if (width < 0)
                   4470:            {
                   4471:              DECL_INITIAL (x) = NULL;
                   4472:              error_with_decl (x, "negative width in bit-field `%s'");
                   4473:            }
                   4474:          else if (width == 0 && DECL_NAME (x) != 0)
                   4475:            {
                   4476:              error_with_decl (x, "zero width for bit-field `%s'");
                   4477:              DECL_INITIAL (x) = NULL;
                   4478:            }
                   4479:          else if (width > TYPE_PRECISION (TREE_TYPE (x)))
                   4480:            {
                   4481:              DECL_INITIAL (x) = NULL;
                   4482:              pedwarn_with_decl (x, "width of `%s' exceeds its type");
                   4483:            }
                   4484:        }
                   4485: 
                   4486:       /* Process valid field width.  */
                   4487:       if (DECL_INITIAL (x))
                   4488:        {
                   4489:          register int width = TREE_INT_CST_LOW (DECL_INITIAL (x));
                   4490: 
                   4491:          DECL_FRAME_SIZE (x) = width;
                   4492:          DECL_BIT_FIELD (x) = 1;
                   4493:          DECL_INITIAL (x) = NULL;
                   4494: 
                   4495:          if (width == 0)
                   4496:            {
                   4497:              /* field size 0 => force desired amount of alignment.  */
                   4498: #ifdef EMPTY_FIELD_BOUNDARY
                   4499:              DECL_ALIGN (x) = MAX (DECL_ALIGN (x), EMPTY_FIELD_BOUNDARY);
                   4500: #endif
                   4501: #ifdef PCC_BITFIELD_TYPE_MATTERS
                   4502:              DECL_ALIGN (x) = MAX (DECL_ALIGN (x),
                   4503:                                    TYPE_ALIGN (TREE_TYPE (x)));
                   4504: #endif
                   4505:            }
                   4506:        }
                   4507:       else
                   4508:        /* Non-bit-fields are aligned for their type.  */
                   4509:        DECL_ALIGN (x) = MAX (DECL_ALIGN (x), TYPE_ALIGN (TREE_TYPE (x)));
                   4510:     }
                   4511: 
                   4512:   /* Now DECL_INITIAL is null on all members.  */
                   4513: 
                   4514:   /* Delete all duplicate fields from the fieldlist */
                   4515:   for (x = fieldlist; x && TREE_CHAIN (x);)
                   4516:     /* Anonymous fields aren't duplicates.  */
                   4517:     if (DECL_NAME (TREE_CHAIN (x)) == 0)
                   4518:       x = TREE_CHAIN (x);
                   4519:     else
                   4520:       {
                   4521:        register tree y = fieldlist;
                   4522:          
                   4523:        while (1)
                   4524:          {
                   4525:            if (DECL_NAME (y) == DECL_NAME (TREE_CHAIN (x)))
                   4526:              break;
                   4527:            if (y == x)
                   4528:              break;
                   4529:            y = TREE_CHAIN (y);
                   4530:          }
                   4531:        if (DECL_NAME (y) == DECL_NAME (TREE_CHAIN (x)))
                   4532:          {
                   4533:            error_with_decl (TREE_CHAIN (x), "duplicate member `%s'");
                   4534:            TREE_CHAIN (x) = TREE_CHAIN (TREE_CHAIN (x));
                   4535:          }
                   4536:        else x = TREE_CHAIN (x);
                   4537:       }
                   4538: 
                   4539:   /* Now we have the nearly final fieldlist.  Record it,
                   4540:      then lay out the structure or union (including the fields).  */
                   4541: 
                   4542:   TYPE_FIELDS (t) = fieldlist;
                   4543: 
                   4544:   layout_type (t);
                   4545: 
                   4546:   /* Delete all zero-width bit-fields from the front of the fieldlist */
                   4547:   while (fieldlist
                   4548:         && DECL_INITIAL (fieldlist))
                   4549:     fieldlist = TREE_CHAIN (fieldlist);
                   4550:   /* Delete all such members from the rest of the fieldlist */
                   4551:   for (x = fieldlist; x;)
                   4552:     {
                   4553:       if (TREE_CHAIN (x) && DECL_INITIAL (TREE_CHAIN (x)))
                   4554:        TREE_CHAIN (x) = TREE_CHAIN (TREE_CHAIN (x));
                   4555:       else x = TREE_CHAIN (x);
                   4556:     }
                   4557: 
                   4558:   /*  Now we have the truly final field list.
                   4559:       Store it in this type and in the variants.  */
                   4560: 
                   4561:   TYPE_FIELDS (t) = fieldlist;
                   4562: 
                   4563:   /* If there are lots of fields, sort so we can look through them fast.
                   4564:      We arbitrarily consider 16 or more elts to be "a lot".  */
                   4565:   {
                   4566:     int len = 0;
                   4567: 
                   4568:     for (x = fieldlist; x; x = TREE_CHAIN (x))
                   4569:       {
                   4570:        if (len > 15)
                   4571:          break;
                   4572:        len += 1;
                   4573:       }
                   4574:     if (len > 15)
                   4575:       {
                   4576:        tree *field_array;
                   4577:        char *space;
                   4578: 
                   4579:        len += list_length (x);
                   4580:        /* Use the same allocation policy here that make_node uses, to
                   4581:           ensure that this lives as long as the rest of the struct decl.
                   4582:           All decls in an inline function need to be saved.  */
                   4583:        if (allocation_temporary_p ())
                   4584:          space = savealloc (sizeof (struct lang_type) + len * sizeof (tree));
                   4585:        else
                   4586:          space = oballoc (sizeof (struct lang_type) + len * sizeof (tree));
                   4587: 
                   4588:        TYPE_LANG_SPECIFIC (t) = (struct lang_type *) space;
                   4589:        TYPE_LANG_SPECIFIC (t)->len = len;
                   4590: 
                   4591:        field_array = &TYPE_LANG_SPECIFIC (t)->elts[0];
                   4592:        len = 0;
                   4593:        for (x = fieldlist; x; x = TREE_CHAIN (x))
                   4594:          field_array[len++] = x;
                   4595: 
                   4596:        qsort (field_array, len, sizeof (tree), field_decl_cmp);
                   4597:       }
                   4598:   }
                   4599: 
                   4600:   for (x = TYPE_MAIN_VARIANT (t); x; x = TYPE_NEXT_VARIANT (x))
                   4601:     {
                   4602:       TYPE_FIELDS (x) = TYPE_FIELDS (t);
                   4603:       TYPE_LANG_SPECIFIC (x) = TYPE_LANG_SPECIFIC (t);
                   4604:       TYPE_ALIGN (x) = TYPE_ALIGN (t);
                   4605:     }
                   4606: 
                   4607:   /* Promote each bit-field's type to int if it is narrower than that.  */
                   4608:   for (x = fieldlist; x; x = TREE_CHAIN (x))
                   4609:     if (DECL_BIT_FIELD (x)
                   4610:        && TREE_CODE (TREE_TYPE (x)) == INTEGER_TYPE
                   4611:        && (TREE_INT_CST_LOW (DECL_SIZE (x))
                   4612:            < TYPE_PRECISION (integer_type_node)))
                   4613:       TREE_TYPE (x) = integer_type_node;
                   4614: 
                   4615:   /* If this structure or union completes the type of any previous
                   4616:      variable declaration, lay it out and output its rtl.  */
                   4617: 
                   4618:   if (current_binding_level->n_incomplete != 0)
                   4619:     {
                   4620:       tree decl;
                   4621:       for (decl = current_binding_level->names; decl; decl = TREE_CHAIN (decl))
                   4622:        {
                   4623:          if (TREE_TYPE (decl) == t
                   4624:              && TREE_CODE (decl) != TYPE_DECL)
                   4625:            {
                   4626:              layout_decl (decl, 0);
                   4627:              /* This is a no-op in c-lang.c or something real in objc-actions.c.  */
                   4628:              maybe_objc_check_decl (decl);
                   4629:              rest_of_decl_compilation (decl, 0, toplevel, 0);
                   4630:              if (! toplevel)
                   4631:                expand_decl (decl);
                   4632:              --current_binding_level->n_incomplete;
                   4633:            }
                   4634:          else if (TYPE_SIZE (TREE_TYPE (decl)) == 0
                   4635:                   && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
                   4636:            {
                   4637:              tree element = TREE_TYPE (decl);
                   4638:              while (TREE_CODE (element) == ARRAY_TYPE)
                   4639:                element = TREE_TYPE (element);
                   4640:              if (element == t)
                   4641:                layout_array_type (TREE_TYPE (decl));
                   4642:            }
                   4643:        }
                   4644:     }
                   4645: 
                   4646:   resume_momentary (old_momentary);
                   4647: 
                   4648:   /* Finish debugging output for this type.  */
                   4649:   rest_of_type_compilation (t, toplevel);
                   4650: 
                   4651:   return t;
                   4652: }
                   4653: 
                   4654: /* Lay out the type T, and its element type, and so on.  */
                   4655: 
                   4656: static void
                   4657: layout_array_type (t)
                   4658:      tree t;
                   4659: {
                   4660:   if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
                   4661:     layout_array_type (TREE_TYPE (t));
                   4662:   layout_type (t);
                   4663: }
                   4664: 
                   4665: /* Begin compiling the definition of an enumeration type.
                   4666:    NAME is its name (or null if anonymous).
                   4667:    Returns the type object, as yet incomplete.
                   4668:    Also records info about it so that build_enumerator
                   4669:    may be used to declare the individual values as they are read.  */
                   4670: 
                   4671: tree
                   4672: start_enum (name)
                   4673:      tree name;
                   4674: {
                   4675:   register tree enumtype = 0;
                   4676: 
                   4677:   /* If this is the real definition for a previous forward reference,
                   4678:      fill in the contents in the same object that used to be the
                   4679:      forward reference.  */
                   4680: 
                   4681:   if (name != 0)
                   4682:     enumtype = lookup_tag (ENUMERAL_TYPE, name, current_binding_level, 1);
                   4683: 
                   4684:   if (enumtype == 0 || TREE_CODE (enumtype) != ENUMERAL_TYPE)
                   4685:     {
                   4686:       enumtype = make_node (ENUMERAL_TYPE);
                   4687:       pushtag (name, enumtype);
                   4688:     }
                   4689: 
                   4690:   C_TYPE_BEING_DEFINED (enumtype) = 1;
                   4691: 
                   4692:   if (TYPE_VALUES (enumtype) != 0)
                   4693:     {
                   4694:       /* This enum is a named one that has been declared already.  */
                   4695:       error ("redeclaration of `enum %s'", IDENTIFIER_POINTER (name));
                   4696: 
                   4697:       /* Completely replace its old definition.
                   4698:         The old enumerators remain defined, however.  */
                   4699:       TYPE_VALUES (enumtype) = 0;
                   4700:     }
                   4701: 
                   4702:   enum_next_value = integer_zero_node;
                   4703: 
                   4704:   return enumtype;
                   4705: }
                   4706: 
                   4707: /* After processing and defining all the values of an enumeration type,
                   4708:    install their decls in the enumeration type and finish it off.
                   4709:    ENUMTYPE is the type object and VALUES a list of decl-value pairs.
                   4710:    Returns ENUMTYPE.  */
                   4711: 
                   4712: tree
                   4713: finish_enum (enumtype, values)
                   4714:      register tree enumtype, values;
                   4715: {
                   4716:   register tree pair;
                   4717:   tree minnode = 0, maxnode = 0;
                   4718:   register long maxvalue = 0;
                   4719:   register long minvalue = 0;
                   4720:   register int i;
                   4721:   unsigned precision = 0;
                   4722:   int toplevel = global_binding_level == current_binding_level;
                   4723: 
                   4724:   if (in_parm_level_p ())
                   4725:     warning ("enum defined inside parms");
                   4726: 
                   4727:   /* Calculate the maximum value of any enumerator in this type.  */
                   4728: 
                   4729:   for (pair = values; pair; pair = TREE_CHAIN (pair))
                   4730:     {
                   4731:       tree value = TREE_VALUE (pair);
                   4732:       if (pair == values)
                   4733:        minnode = maxnode = TREE_VALUE (pair);
                   4734:       else
                   4735:        {
                   4736:          if (tree_int_cst_lt (maxnode, value))
                   4737:            maxnode = value;
                   4738:          if (tree_int_cst_lt (value, minnode))
                   4739:            minnode = value;
                   4740:        }
                   4741:     }
                   4742: 
                   4743:   TYPE_MIN_VALUE (enumtype) = minnode;
                   4744:   TYPE_MAX_VALUE (enumtype) = maxnode;
                   4745: 
                   4746:   /* Determine the precision this type needs.  */
                   4747: 
                   4748:   if (TREE_INT_CST_HIGH (minnode) >= 0
                   4749:       ? tree_int_cst_lt (TYPE_MAX_VALUE (unsigned_type_node), maxnode)
                   4750:       : (tree_int_cst_lt (minnode, TYPE_MIN_VALUE (integer_type_node))
                   4751:         || tree_int_cst_lt (TYPE_MAX_VALUE (integer_type_node), maxnode)))
                   4752:     precision = TYPE_PRECISION (long_long_integer_type_node);
                   4753:   else
                   4754:     {
                   4755:       int maxvalue = TREE_INT_CST_LOW (maxnode);
                   4756:       int minvalue = TREE_INT_CST_LOW (minnode);
                   4757: 
                   4758:       if (maxvalue > 0)
                   4759:        precision = floor_log2 (maxvalue) + 1;
                   4760:       if (minvalue < 0)
                   4761:        {
                   4762:          /* Compute number of bits to represent magnitude of a negative value.
                   4763:             Add one to MINVALUE since range of negative numbers
                   4764:             includes the power of two.  */
                   4765:          unsigned negprecision = floor_log2 (-minvalue - 1) + 1;
                   4766:          if (negprecision > precision)
                   4767:            precision = negprecision;
                   4768:          precision += 1;       /* room for sign bit */
                   4769:        }
                   4770: 
                   4771:       if (!precision)
                   4772:        precision = 1;
                   4773:     }
                   4774: 
                   4775:   if (flag_short_enums || precision > TYPE_PRECISION (integer_type_node))
                   4776:     /* Use the width of the narrowest normal C type which is wide enough.  */
                   4777:     TYPE_PRECISION (enumtype) = TYPE_PRECISION (type_for_size (precision, 1));
                   4778:   else
                   4779:     TYPE_PRECISION (enumtype) = TYPE_PRECISION (integer_type_node);
                   4780: 
                   4781:   TYPE_SIZE (enumtype) = 0;
                   4782:   layout_type (enumtype);
                   4783: 
                   4784:   /* An enum can have some negative values; then it is signed.  */
                   4785:   TREE_UNSIGNED (enumtype) = ! tree_int_cst_lt (minnode, integer_zero_node);
                   4786: 
                   4787:   /* If the enumerators might not fit in an int, change their type now.  */
                   4788:   /* It seems more useful in the debugger to leave these as int
                   4789:      unless the enumerator is wider than int.  */
                   4790:   if (TYPE_PRECISION (enumtype) <= TYPE_PRECISION (integer_type_node))
                   4791:     for (pair = values; pair; pair = TREE_CHAIN (pair))
                   4792:       {
                   4793:        TREE_TYPE (TREE_PURPOSE (pair)) = enumtype;
                   4794:        DECL_SIZE (TREE_PURPOSE (pair)) = TYPE_SIZE (enumtype);
                   4795:        DECL_ALIGN (TREE_PURPOSE (pair)) = TYPE_ALIGN (enumtype);
                   4796:       }
                   4797: 
                   4798:   /* Replace the decl nodes in VALUES with their names.  */
                   4799:   for (pair = values; pair; pair = TREE_CHAIN (pair))
                   4800:     TREE_PURPOSE (pair) = DECL_NAME (TREE_PURPOSE (pair));
                   4801: 
                   4802:   TYPE_VALUES (enumtype) = values;
                   4803: 
                   4804:   /* Finish debugging output for this type.  */
                   4805:   rest_of_type_compilation (enumtype, toplevel);
                   4806: 
                   4807:   return enumtype;
                   4808: }
                   4809: 
                   4810: /* Build and install a CONST_DECL for one value of the
                   4811:    current enumeration type (one that was begun with start_enum).
                   4812:    Return a tree-list containing the CONST_DECL and its value.
                   4813:    Assignment of sequential values by default is handled here.  */
                   4814: 
                   4815: tree
                   4816: build_enumerator (name, value)
                   4817:      tree name, value;
                   4818: {
                   4819:   register tree decl;
                   4820: 
                   4821:   /* Validate and default VALUE.  */
                   4822: 
                   4823:   /* Remove no-op casts from the value.  */
                   4824:   while (value != 0
                   4825:         && (TREE_CODE (value) == NOP_EXPR
                   4826:             || TREE_CODE (value) == NON_LVALUE_EXPR))
                   4827:     value = TREE_OPERAND (value, 0);
                   4828: 
                   4829:   if (value != 0 && TREE_CODE (value) != INTEGER_CST)
                   4830:     {
                   4831:       error ("enumerator value for `%s' not integer constant",
                   4832:             IDENTIFIER_POINTER (name));
                   4833:       value = 0;
                   4834:     }
                   4835: 
                   4836:   /* Default based on previous value.  */
                   4837:   /* It should no longer be possible to have NON_LVALUE_EXPR
                   4838:      in the default.  */
                   4839:   if (value == 0)
                   4840:     value = enum_next_value;
                   4841: 
                   4842:   if (pedantic && ! int_fits_type_p (value, integer_type_node))
                   4843:     {
                   4844:       pedwarn ("ANSI C restricts enumerator values to range of `int'");
                   4845:       value = integer_zero_node;
                   4846:     }
                   4847: 
                   4848:   /* Set basis for default for next value.  */
                   4849:   enum_next_value = build_binary_op (PLUS_EXPR, value, integer_one_node, 0);
                   4850: 
                   4851:   /* Now create a declaration for the enum value name.  */
                   4852: 
                   4853:   decl = build_decl (CONST_DECL, name, integer_type_node);
                   4854:   DECL_INITIAL (decl) = value;
                   4855:   TREE_TYPE (value) = integer_type_node;
                   4856:   pushdecl (decl);
                   4857: 
                   4858:   return saveable_tree_cons (decl, value, NULL);
                   4859: }
                   4860: 
                   4861: /* Create the FUNCTION_DECL for a function definition.
                   4862:    DECLSPECS and DECLARATOR are the parts of the declaration;
                   4863:    they describe the function's name and the type it returns,
                   4864:    but twisted together in a fashion that parallels the syntax of C.
                   4865: 
                   4866:    This function creates a binding context for the function body
                   4867:    as well as setting up the FUNCTION_DECL in current_function_decl.
                   4868: 
                   4869:    Returns 1 on success.  If the DECLARATOR is not suitable for a function
                   4870:    (it defines a datum instead), we return 0, which tells
                   4871:    yyparse to report a parse error.
                   4872: 
                   4873:    NESTED is nonzero for a function nested within another function.  */
                   4874: 
                   4875: int
                   4876: start_function (declspecs, declarator, nested)
                   4877:      tree declarator, declspecs;
                   4878:      int nested;
                   4879: {
                   4880:   tree decl1, old_decl;
                   4881:   tree restype;
                   4882: 
                   4883:   current_function_returns_value = 0;  /* Assume, until we see it does. */
                   4884:   current_function_returns_null = 0;
                   4885:   warn_about_return_type = 0;
                   4886:   current_extern_inline = 0;
                   4887:   c_function_varargs = 0;
                   4888:   named_labels = 0;
                   4889:   shadowed_labels = 0;
                   4890: 
                   4891:   decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1);
                   4892: 
                   4893:   /* If the declarator is not suitable for a function definition,
                   4894:      cause a syntax error.  */
                   4895:   if (decl1 == 0)
                   4896:     return 0;
                   4897: 
                   4898:   announce_function (decl1);
                   4899: 
                   4900:   if (TYPE_SIZE (TREE_TYPE (TREE_TYPE (decl1))) == 0)
                   4901:     {
                   4902:       error ("return-type is an incomplete type");
                   4903:       /* Make it return void instead.  */
                   4904:       TREE_TYPE (decl1)
                   4905:        = build_function_type (void_type_node,
                   4906:                               TYPE_ARG_TYPES (TREE_TYPE (decl1)));
                   4907:     }
                   4908: 
                   4909:   if (warn_about_return_type)
                   4910:     warning ("return-type defaults to `int'");
                   4911: 
                   4912:   /* Save the parm names or decls from this function's declarator
                   4913:      where store_parm_decls will find them.  */
                   4914:   current_function_parms = last_function_parms;
                   4915:   current_function_parm_tags = last_function_parm_tags;
                   4916: 
                   4917:   /* Make the init_value nonzero so pushdecl knows this is not tentative.
                   4918:      error_mark_node is replaced below (in poplevel) with the BLOCK.  */
                   4919:   DECL_INITIAL (decl1) = error_mark_node;
                   4920: 
                   4921:   /* If this definition isn't a prototype and we had a prototype declaration
                   4922:      before, copy the arg type info from that prototype.
                   4923:      But not if what we had before was a builtin function.  */
                   4924:   old_decl = lookup_name_current_level (DECL_NAME (decl1));
                   4925:   if (old_decl != 0 && TREE_CODE (TREE_TYPE (old_decl)) == FUNCTION_TYPE
                   4926:       && !DECL_BUILT_IN (old_decl)
                   4927:       && TREE_TYPE (TREE_TYPE (decl1)) == TREE_TYPE (TREE_TYPE (old_decl))
                   4928:       && TYPE_ARG_TYPES (TREE_TYPE (decl1)) == 0)
                   4929:     TREE_TYPE (decl1) = TREE_TYPE (old_decl);
                   4930: 
                   4931:   /* Optionally warn of old-fashioned def with no previous prototype.  */
                   4932:   if (warn_strict_prototypes
                   4933:       && TYPE_ARG_TYPES (TREE_TYPE (decl1)) == 0
                   4934:       && !(old_decl != 0 && TYPE_ARG_TYPES (TREE_TYPE (old_decl)) != 0))
                   4935:     warning ("function declaration isn't a prototype");
                   4936:   /* Optionally warn of any global def with no previous prototype.  */
                   4937:   else if (warn_missing_prototypes
                   4938:           && TREE_PUBLIC (decl1)
                   4939:           && !(old_decl != 0 && TYPE_ARG_TYPES (TREE_TYPE (old_decl)) != 0))
                   4940:     warning_with_decl (decl1, "no previous prototype for `%s'");
                   4941:   /* Optionally warn of any def with no previous prototype
                   4942:      if the function has already been used.  */
                   4943:   else if (warn_missing_prototypes
                   4944:           && old_decl != 0 && TREE_USED (old_decl)
                   4945:           && !(old_decl != 0 && TYPE_ARG_TYPES (TREE_TYPE (old_decl)) != 0))
                   4946:     warning_with_decl (decl1, "`%s' was used with no prototype before its definition");
                   4947: 
                   4948:   /* This is a definition, not a reference.
                   4949:      So normally clear TREE_EXTERNAL.
                   4950:      However, `extern inline' acts like a declaration
                   4951:      except for defining how to inline.  So set TREE_EXTERNAL in that case.  */
                   4952:   TREE_EXTERNAL (decl1) = current_extern_inline;
                   4953: 
                   4954:   /* This function exists in static storage.
                   4955:      (This does not mean `static' in the C sense!)  */
                   4956:   TREE_STATIC (decl1) = 1;
                   4957: 
                   4958:   /* A nested function is not global.  */
                   4959:   if (current_function_decl != 0)
                   4960:     TREE_PUBLIC (decl1) = 0;
                   4961: 
                   4962:   /* Record the decl so that the function name is defined.
                   4963:      If we already have a decl for this name, and it is a FUNCTION_DECL,
                   4964:      use the old decl.  */
                   4965: 
                   4966:   current_function_decl = pushdecl (decl1);
                   4967: 
                   4968:   pushlevel (0);
                   4969:   declare_parm_level (1);
                   4970:   current_binding_level->subblocks_tag_transparent = 1;
                   4971: 
                   4972:   make_function_rtl (current_function_decl);
                   4973: 
                   4974:   restype = TREE_TYPE (TREE_TYPE (current_function_decl));
                   4975:   /* Promote the value to int before returning it.  */
                   4976:   if (TREE_CODE (restype) == INTEGER_TYPE
                   4977:       && TYPE_PRECISION (restype) < TYPE_PRECISION (integer_type_node))
                   4978:     restype = integer_type_node;
                   4979:   DECL_RESULT (current_function_decl) = build_decl (RESULT_DECL, 0, restype);
                   4980: 
                   4981:   if (!nested)
                   4982:     /* Allocate further tree nodes temporarily during compilation
                   4983:        of this function only.  */
                   4984:     temporary_allocation ();
                   4985: 
                   4986:   /* If this fcn was already referenced via a block-scope `extern' decl
                   4987:      (or an implicit decl), propagate certain information about the usage.  */
                   4988:   if (TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (current_function_decl)))
                   4989:     TREE_ADDRESSABLE (current_function_decl) = 1;
                   4990: 
                   4991:   return 1;
                   4992: }
                   4993: 
                   4994: /* Record that this function is going to be a varargs function.
                   4995:    This is called before store_parm_decls, which is too early
                   4996:    to call mark_varargs directly.  */
                   4997: 
                   4998: void
                   4999: c_mark_varargs ()
                   5000: {
                   5001:   c_function_varargs = 1;
                   5002: }
                   5003: 
                   5004: /* Store the parameter declarations into the current function declaration.
                   5005:    This is called after parsing the parameter declarations, before
                   5006:    digesting the body of the function.
                   5007: 
                   5008:    For an old-style definition, modify the function's type
                   5009:    to specify at least the number of arguments.  */
                   5010: 
                   5011: void
                   5012: store_parm_decls ()
                   5013: {
                   5014:   register tree fndecl = current_function_decl;
                   5015:   register tree parm;
                   5016: 
                   5017:   /* This is either a chain of PARM_DECLs (if a prototype was used)
                   5018:      or a list of IDENTIFIER_NODEs (for an old-fashioned C definition).  */
                   5019:   tree specparms = current_function_parms;
                   5020: 
                   5021:   /* This is a list of types declared among parms in a prototype.  */
                   5022:   tree parmtags = current_function_parm_tags;
                   5023: 
                   5024:   /* This is a chain of PARM_DECLs from old-style parm declarations.  */
                   5025:   register tree parmdecls = getdecls ();
                   5026: 
                   5027:   /* This is a chain of any other decls that came in among the parm
                   5028:      declarations.  If a parm is declared with  enum {foo, bar} x;
                   5029:      then CONST_DECLs for foo and bar are put here.  */
                   5030:   tree nonparms = 0;
                   5031: 
                   5032:   /* Nonzero if this definition is written with a prototype.  */
                   5033:   int prototype = 0;
                   5034: 
                   5035:   if (specparms != 0 && TREE_CODE (specparms) != TREE_LIST)
                   5036:     {
                   5037:       /* This case is when the function was defined with an ANSI prototype.
                   5038:         The parms already have decls, so we need not do anything here
                   5039:         except record them as in effect
                   5040:         and complain if any redundant old-style parm decls were written.  */
                   5041: 
                   5042:       register tree next;
                   5043:       tree others = 0;
                   5044: 
                   5045:       prototype = 1;
                   5046: 
                   5047:       if (parmdecls != 0)
                   5048:        error_with_decl (fndecl,
                   5049:                         "parm types given both in parmlist and separately");
                   5050: 
                   5051:       specparms = nreverse (specparms);
                   5052:       for (parm = specparms; parm; parm = next)
                   5053:        {
                   5054:          next = TREE_CHAIN (parm);
                   5055:          if (TREE_CODE (parm) == PARM_DECL)
                   5056:            {
                   5057:              if (DECL_NAME (parm) == 0)
                   5058:                error_with_decl (parm, "parameter name omitted");
                   5059:              else if (TREE_TYPE (parm) == void_type_node)
                   5060:                error_with_decl (parm, "parameter `%s' declared void");
                   5061:              pushdecl (parm);
                   5062:            }
                   5063:          else
                   5064:            {
                   5065:              /* If we find an enum constant or a type tag,
                   5066:                 put it aside for the moment.  */
                   5067:              TREE_CHAIN (parm) = 0;
                   5068:              others = chainon (others, parm);
                   5069:            }
                   5070:        }
                   5071: 
                   5072:       /* Get the decls in their original chain order
                   5073:         and record in the function.  */
                   5074:       DECL_ARGUMENTS (fndecl) = getdecls ();
                   5075: 
                   5076: #if 0
                   5077:       /* If this function takes a variable number of arguments,
                   5078:         add a phony parameter to the end of the parm list,
                   5079:         to represent the position of the first unnamed argument.  */
                   5080:       if (TREE_VALUE (tree_last (TYPE_ARG_TYPES (TREE_TYPE (fndecl))))
                   5081:          != void_type_node)
                   5082:        {
                   5083:          tree dummy = build_decl (PARM_DECL, NULL_TREE, void_type_node);
                   5084:          /* Let's hope the address of the unnamed parm
                   5085:             won't depend on its type.  */
                   5086:          TREE_TYPE (dummy) = integer_type_node;
                   5087:          DECL_ARG_TYPE (dummy) = integer_type_node;
                   5088:          DECL_ARGUMENTS (fndecl)
                   5089:            = chainon (DECL_ARGUMENTS (fndecl), dummy);
                   5090:        }
                   5091: #endif
                   5092: 
                   5093:       /* Now pushdecl the enum constants.  */
                   5094:       for (parm = others; parm; parm = next)
                   5095:        {
                   5096:          next = TREE_CHAIN (parm);
                   5097:          if (DECL_NAME (parm) == 0)
                   5098:            ;
                   5099:          else if (TREE_TYPE (parm) == void_type_node)
                   5100:            ;
                   5101:          else if (TREE_CODE (parm) != PARM_DECL)
                   5102:            pushdecl (parm);
                   5103:        }
                   5104: 
                   5105:       storetags (chainon (parmtags, gettags ()));
                   5106:     }
                   5107:   else
                   5108:     {
                   5109:       /* SPECPARMS is an identifier list--a chain of TREE_LIST nodes
                   5110:         each with a parm name as the TREE_VALUE.
                   5111: 
                   5112:         PARMDECLS is a chain of declarations for parameters.
                   5113:         Warning! It can also contain CONST_DECLs which are not parameters
                   5114:         but are names of enumerators of any enum types
                   5115:         declared among the parameters.
                   5116: 
                   5117:         First match each formal parameter name with its declaration.
                   5118:         Associate decls with the names and store the decls
                   5119:         into the TREE_PURPOSE slots.  */
                   5120: 
                   5121:       for (parm = parmdecls; parm; parm = TREE_CHAIN (parm))
                   5122:        DECL_RESULT (parm) = 0;
                   5123: 
                   5124:       for (parm = specparms; parm; parm = TREE_CHAIN (parm))
                   5125:        {
                   5126:          register tree tail, found = NULL;
                   5127: 
                   5128:          if (TREE_VALUE (parm) == 0)
                   5129:            {
                   5130:              error_with_decl (fndecl, "parameter name missing from parameter list");
                   5131:              TREE_PURPOSE (parm) = 0;
                   5132:              continue;
                   5133:            }
                   5134: 
                   5135:          /* See if any of the parmdecls specifies this parm by name.
                   5136:             Ignore any enumerator decls.  */
                   5137:          for (tail = parmdecls; tail; tail = TREE_CHAIN (tail))
                   5138:            if (DECL_NAME (tail) == TREE_VALUE (parm)
                   5139:                && TREE_CODE (tail) == PARM_DECL)
                   5140:              {
                   5141:                found = tail;
                   5142:                break;
                   5143:              }
                   5144: 
                   5145:          /* If declaration already marked, we have a duplicate name.
                   5146:             Complain, and don't use this decl twice.   */
                   5147:          if (found && DECL_RESULT (found) != 0)
                   5148:            {
                   5149:              error_with_decl (found, "multiple parameters named `%s'");
                   5150:              found = 0;
                   5151:            }
                   5152: 
                   5153:          /* If the declaration says "void", complain and ignore it.  */
                   5154:          if (found && TREE_TYPE (found) == void_type_node)
                   5155:            {
                   5156:              error_with_decl (found, "parameter `%s' declared void");
                   5157:              TREE_TYPE (found) = integer_type_node;
                   5158:              DECL_ARG_TYPE (found) = integer_type_node;
                   5159:              layout_decl (found, 0);
                   5160:            }
                   5161: 
                   5162:          /* Traditionally, a parm declared float is actually a double.  */
                   5163:          if (found && flag_traditional
                   5164:              && TREE_TYPE (found) == float_type_node)
                   5165:            TREE_TYPE (found) = double_type_node;
                   5166: 
                   5167:          /* If no declaration found, default to int.  */
                   5168:          if (!found)
                   5169:            {
                   5170:              found = build_decl (PARM_DECL, TREE_VALUE (parm),
                   5171:                                  integer_type_node);
                   5172:              DECL_ARG_TYPE (found) = TREE_TYPE (found);
                   5173:              DECL_SOURCE_LINE (found) = DECL_SOURCE_LINE (fndecl);
                   5174:              DECL_SOURCE_FILE (found) = DECL_SOURCE_FILE (fndecl);
                   5175:              if (extra_warnings)
                   5176:                warning_with_decl (found, "type of `%s' defaults to `int'");
                   5177:              pushdecl (found);
                   5178:            }
                   5179: 
                   5180:          TREE_PURPOSE (parm) = found;
                   5181: 
                   5182:          /* Mark this decl as "already found" -- see test, above.
                   5183:             It is safe to use DECL_RESULT for this
                   5184:             since it is not used in PARM_DECLs or CONST_DECLs.  */
                   5185:          DECL_RESULT (found) = error_mark_node;
                   5186:        }
                   5187: 
                   5188:       /* Put anything which is on the parmdecls chain and which is
                   5189:         not a PARM_DECL onto the list NONPARMS.  (The types of
                   5190:         non-parm things which might appear on the list include
                   5191:         enumerators and NULL-named TYPE_DECL nodes.) Complain about
                   5192:         any actual PARM_DECLs not matched with any names.  */
                   5193: 
                   5194:       nonparms = 0;
                   5195:       for (parm = parmdecls; parm; )
                   5196:        {
                   5197:          tree next = TREE_CHAIN (parm);
                   5198:          TREE_CHAIN (parm) = 0;
                   5199: 
                   5200:          if (TREE_CODE (parm) != PARM_DECL)
                   5201:            nonparms = chainon (nonparms, parm);
                   5202:          else
                   5203:            {
                   5204:              /* Complain about args with incomplete types.  */
                   5205:              if (TYPE_SIZE (TREE_TYPE (parm)) == 0)
                   5206:                {
                   5207:                  error_with_decl (parm, "parameter `%s' has incomplete type");
                   5208:                  TREE_TYPE (parm) = error_mark_node;
                   5209:                }
                   5210: 
                   5211:              if (DECL_RESULT (parm) == 0)
                   5212:                {
                   5213:                  error_with_decl (parm,
                   5214:                                   "declaration for parameter `%s' but no such parameter");
                   5215:                  /* Pretend the parameter was not missing.
                   5216:                     This gets us to a standard state and minimizes
                   5217:                     further error messages.  */
                   5218:                  specparms
                   5219:                    = chainon (specparms,
                   5220:                               tree_cons (parm, NULL_TREE, NULL_TREE));
                   5221:                }
                   5222:            }
                   5223: 
                   5224:          parm = next;
                   5225:        }
                   5226: 
                   5227:       /* Chain the declarations together in the order of the list of names.  */
                   5228:       /* Store that chain in the function decl, replacing the list of names.  */
                   5229:       parm = specparms;
                   5230:       DECL_ARGUMENTS (fndecl) = 0;
                   5231:       {
                   5232:        register tree last;
                   5233:        for (last = 0; parm; parm = TREE_CHAIN (parm))
                   5234:          if (TREE_PURPOSE (parm))
                   5235:            {
                   5236:              if (last == 0)
                   5237:                DECL_ARGUMENTS (fndecl) = TREE_PURPOSE (parm);
                   5238:              else
                   5239:                TREE_CHAIN (last) = TREE_PURPOSE (parm);
                   5240:              last = TREE_PURPOSE (parm);
                   5241:              TREE_CHAIN (last) = 0;
                   5242:            }
                   5243:       }
                   5244: 
                   5245:       /* If there was a previous prototype,
                   5246:         set the DECL_ARG_TYPE of each argument according to
                   5247:         the type previously specified, and report any mismatches.  */
                   5248: 
                   5249:       if (TYPE_ARG_TYPES (TREE_TYPE (fndecl)))
                   5250:        {
                   5251:          register tree type;
                   5252:          for (parm = DECL_ARGUMENTS (fndecl),
                   5253:               type = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
                   5254:               parm || (type && TREE_VALUE (type) != void_type_node);
                   5255:               parm = TREE_CHAIN (parm), type = TREE_CHAIN (type))
                   5256:            {
                   5257:              if (parm == 0 || type == 0
                   5258:                  || TREE_VALUE (type) == void_type_node)
                   5259:                {
                   5260:                  error ("number of arguments doesn't match prototype");
                   5261:                  break;
                   5262:                }
                   5263:              /* Type for passing arg must be consistent
                   5264:                 with that declared for the arg.  */
                   5265:              if (! comptypes (DECL_ARG_TYPE (parm), TREE_VALUE (type))
                   5266:                  /* If -traditional, allow `unsigned int' instead of `int'
                   5267:                     in the prototype.  */
                   5268:                  && (! (flag_traditional
                   5269:                         && DECL_ARG_TYPE (parm) == integer_type_node
                   5270:                         && TREE_VALUE (type) == unsigned_type_node)))
                   5271:                {
                   5272:                  error ("argument `%s' doesn't match function prototype",
                   5273:                         IDENTIFIER_POINTER (DECL_NAME (parm)));
                   5274:                  if (DECL_ARG_TYPE (parm) == integer_type_node
                   5275:                      && TREE_VALUE (type) == TREE_TYPE (parm))
                   5276:                    {
                   5277:                      error ("a formal parameter type that promotes to `int'");
                   5278:                      error ("can match only `int' in the prototype");
                   5279:                    }
                   5280:                  if (DECL_ARG_TYPE (parm) == double_type_node
                   5281:                      && TREE_VALUE (type) == TREE_TYPE (parm))
                   5282:                    {
                   5283:                      error ("a formal parameter type that promotes to `double'");
                   5284:                      error ("can match only `double' in the prototype");
                   5285:                    }
                   5286:                }
                   5287:            }
                   5288:          TYPE_ACTUAL_ARG_TYPES (TREE_TYPE (fndecl)) = 0;
                   5289:        }
                   5290: 
                   5291:       /* Otherwise, create a prototype that would match.  */
                   5292: 
                   5293:       else
                   5294:        {
                   5295:          register tree actual, type;
                   5296:          register tree last = 0;
                   5297: 
                   5298:          for (parm = DECL_ARGUMENTS (fndecl); parm; parm = TREE_CHAIN (parm))
                   5299:            {
                   5300:              type = perm_tree_cons (NULL, DECL_ARG_TYPE (parm), NULL);
                   5301:              if (last)
                   5302:                TREE_CHAIN (last) = type;
                   5303:              else
                   5304:                actual = type;
                   5305:              last = type;
                   5306:            }
                   5307:          type = perm_tree_cons (NULL, void_type_node, NULL);
                   5308:          if (last)
                   5309:            TREE_CHAIN (last) = type;
                   5310:          else
                   5311:            actual = type;
                   5312: 
                   5313:          TYPE_ACTUAL_ARG_TYPES (TREE_TYPE (fndecl)) = actual;
                   5314:        }
                   5315: 
                   5316:       /* Now store the final chain of decls for the arguments
                   5317:         as the decl-chain of the current lexical scope.
                   5318:         Put the enumerators in as well, at the front so that
                   5319:         DECL_ARGUMENTS is not modified.  */
                   5320: 
                   5321:       storedecls (chainon (nonparms, DECL_ARGUMENTS (fndecl)));
                   5322:     }
                   5323: 
                   5324:   /* Make sure the binding level for the top of the function body
                   5325:      gets a BLOCK if there are any in the function.
                   5326:      Otherwise, the dbx output is wrong.  */
                   5327: 
                   5328:   keep_next_if_subblocks = 1;
                   5329: 
                   5330:   /* ??? This might be an improvement,
                   5331:      but needs to be thought about some more.  */
                   5332: #if 0
                   5333:   keep_next_level_flag = 1;
                   5334: #endif
                   5335: 
                   5336:   /* Write a record describing this function definition to the prototypes
                   5337:      file (if requested).  */
                   5338: 
                   5339:   gen_aux_info_record (fndecl, 1, 0, prototype);
                   5340: 
                   5341:   /* Initialize the RTL code for the function.  */
                   5342: 
                   5343:   init_function_start (fndecl, input_filename, lineno);
                   5344: 
                   5345:   /* If this is a varargs function, inform function.c.  */
                   5346: 
                   5347:   if (c_function_varargs)
                   5348:     mark_varargs ();
                   5349: 
                   5350:   /* Set up parameters and prepare for return, for the function.  */
                   5351: 
                   5352:   expand_function_start (fndecl, 0);
                   5353: 
                   5354:   /* If this function is `main', emit a call to `__main'
                   5355:      to run global initializers, etc.  */
                   5356:   if (DECL_NAME (fndecl)
                   5357:       && strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "main") == 0
                   5358:       && DECL_CONTEXT (fndecl) == NULL_TREE)
                   5359:     expand_main_function ();
                   5360: }
                   5361: 
                   5362: /* SPECPARMS is an identifier list--a chain of TREE_LIST nodes
                   5363:    each with a parm name as the TREE_VALUE.  A null pointer as TREE_VALUE
                   5364:    stands for an ellipsis in the identifier list.
                   5365: 
                   5366:    PARMLIST is the data returned by get_parm_info for the
                   5367:    parmlist that follows the semicolon.
                   5368: 
                   5369:    We return a value of the same sort that get_parm_info returns,
                   5370:    except that it describes the combination of identifiers and parmlist.  */
                   5371: 
                   5372: tree
                   5373: combine_parm_decls (specparms, parmlist, void_at_end)
                   5374:      tree specparms, parmlist;
                   5375:      int void_at_end;
                   5376: {
                   5377:   register tree fndecl = current_function_decl;
                   5378:   register tree parm;
                   5379: 
                   5380:   tree parmdecls = TREE_PURPOSE (parmlist);
                   5381: 
                   5382:   /* This is a chain of any other decls that came in among the parm
                   5383:      declarations.  They were separated already by get_parm_info,
                   5384:      so we just need to keep them separate.  */
                   5385:   tree nonparms = TREE_VALUE (parmlist);
                   5386: 
                   5387:   tree types = 0;
                   5388: 
                   5389:   for (parm = parmdecls; parm; parm = TREE_CHAIN (parm))
                   5390:     DECL_RESULT (parm) = 0;
                   5391: 
                   5392:   for (parm = specparms; parm; parm = TREE_CHAIN (parm))
                   5393:     {
                   5394:       register tree tail, found = NULL;
                   5395: 
                   5396:       /* See if any of the parmdecls specifies this parm by name.  */
                   5397:       for (tail = parmdecls; tail; tail = TREE_CHAIN (tail))
                   5398:        if (DECL_NAME (tail) == TREE_VALUE (parm))
                   5399:          {
                   5400:            found = tail;
                   5401:            break;
                   5402:          }
                   5403: 
                   5404:       /* If declaration already marked, we have a duplicate name.
                   5405:         Complain, and don't use this decl twice.   */
                   5406:       if (found && DECL_RESULT (found) != 0)
                   5407:        {
                   5408:          error_with_decl (found, "multiple parameters named `%s'");
                   5409:          found = 0;
                   5410:        }
                   5411: 
                   5412:       /* If the declaration says "void", complain and ignore it.  */
                   5413:       if (found && TREE_TYPE (found) == void_type_node)
                   5414:        {
                   5415:          error_with_decl (found, "parameter `%s' declared void");
                   5416:          TREE_TYPE (found) = integer_type_node;
                   5417:          DECL_ARG_TYPE (found) = integer_type_node;
                   5418:          layout_decl (found, 0);
                   5419:        }
                   5420: 
                   5421:       /* Traditionally, a parm declared float is actually a double.  */
                   5422:       if (found && flag_traditional
                   5423:          && TREE_TYPE (found) == float_type_node)
                   5424:        TREE_TYPE (found) = double_type_node;
                   5425: 
                   5426:       /* If no declaration found, default to int.  */
                   5427:       if (!found)
                   5428:        {
                   5429:          found = build_decl (PARM_DECL, TREE_VALUE (parm),
                   5430:                              integer_type_node);
                   5431:          DECL_ARG_TYPE (found) = TREE_TYPE (found);
                   5432:          DECL_SOURCE_LINE (found) = DECL_SOURCE_LINE (fndecl);
                   5433:          DECL_SOURCE_FILE (found) = DECL_SOURCE_FILE (fndecl);
                   5434:          error (found, "type of parameter `%s' is not declared");
                   5435:          pushdecl (found);
                   5436:        }
                   5437: 
                   5438:       TREE_PURPOSE (parm) = found;
                   5439: 
                   5440:       /* Mark this decl as "already found" -- see test, above.
                   5441:         It is safe to use DECL_RESULT for this
                   5442:         since it is not used in PARM_DECLs or CONST_DECLs.  */
                   5443:       DECL_RESULT (found) = error_mark_node;
                   5444:     }
                   5445: 
                   5446:   /* Complain about any actual PARM_DECLs not matched with any names.  */
                   5447: 
                   5448:   for (parm = parmdecls; parm; )
                   5449:     {
                   5450:       tree next = TREE_CHAIN (parm);
                   5451:       TREE_CHAIN (parm) = 0;
                   5452: 
                   5453:       /* Complain about args with incomplete types.  */
                   5454:       if (TYPE_SIZE (TREE_TYPE (parm)) == 0)
                   5455:        {
                   5456:          error_with_decl (parm, "parameter `%s' has incomplete type");
                   5457:          TREE_TYPE (parm) = error_mark_node;
                   5458:        }
                   5459: 
                   5460:       if (DECL_RESULT (parm) == 0)
                   5461:        {
                   5462:          error_with_decl (parm,
                   5463:                           "declaration for parameter `%s' but no such parameter");
                   5464:          /* Pretend the parameter was not missing.
                   5465:             This gets us to a standard state and minimizes
                   5466:             further error messages.  */
                   5467:          specparms
                   5468:            = chainon (specparms,
                   5469:                       tree_cons (parm, NULL_TREE, NULL_TREE));
                   5470:        }
                   5471: 
                   5472:       parm = next;
                   5473:     }
                   5474: 
                   5475:   /* Chain the declarations together in the order of the list of names.
                   5476:      At the same time, build up a list of their types, in reverse order.  */
                   5477: 
                   5478:   parm = specparms;
                   5479:   parmdecls = 0;
                   5480:   {
                   5481:     register tree last;
                   5482:     for (last = 0; parm; parm = TREE_CHAIN (parm))
                   5483:       if (TREE_PURPOSE (parm))
                   5484:        {
                   5485:          if (last == 0)
                   5486:            parmdecls = TREE_PURPOSE (parm);
                   5487:          else
                   5488:            TREE_CHAIN (last) = TREE_PURPOSE (parm);
                   5489:          last = TREE_PURPOSE (parm);
                   5490:          TREE_CHAIN (last) = 0;
                   5491: 
                   5492:          types = saveable_tree_cons (NULL_TREE, TREE_TYPE (parm), types);
                   5493:        }
                   5494:   }
                   5495:   
                   5496:   if (void_at_end)
                   5497:     return saveable_tree_cons (parmdecls, nonparms,
                   5498:                               nreverse (saveable_tree_cons (NULL_TREE, void_type_node, types)));
                   5499: 
                   5500:   return saveable_tree_cons (parmdecls, nonparms, nreverse (types));
                   5501: }
                   5502: 
                   5503: /* Finish up a function declaration and compile that function
                   5504:    all the way to assembler language output.  The free the storage
                   5505:    for the function definition.
                   5506: 
                   5507:    This is called after parsing the body of the function definition.
                   5508: 
                   5509:    NESTED is nonzero if the function being finished is nested in another.  */
                   5510: 
                   5511: void
                   5512: finish_function (nested)
                   5513:      int nested;
                   5514: {
                   5515:   register tree fndecl = current_function_decl;
                   5516: 
                   5517: /*  TREE_READONLY (fndecl) = 1;
                   5518:     This caused &foo to be of type ptr-to-const-function
                   5519:     which then got a warning when stored in a ptr-to-function variable.  */
                   5520: 
                   5521:   poplevel (1, 0, 1);
                   5522: 
                   5523:   /* Must mark the RESULT_DECL as being in this function.  */
                   5524: 
                   5525:   DECL_CONTEXT (DECL_RESULT (fndecl)) = fndecl;
                   5526: 
                   5527:   /* Obey `register' declarations if `setjmp' is called in this fn.  */
                   5528:   if (flag_traditional && current_function_calls_setjmp)
                   5529:     {
                   5530:       setjmp_protect (DECL_INITIAL (fndecl));
                   5531:       setjmp_protect_args ();
                   5532:     }
                   5533: 
                   5534: #ifdef DEFAULT_MAIN_RETURN
                   5535:   if (! strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "main"))
                   5536:     {
                   5537:       /* Make it so that `main' always returns success by default.  */
                   5538:       DEFAULT_MAIN_RETURN;
                   5539:     }
                   5540: #endif
                   5541: 
                   5542:   /* Generate rtl for function exit.  */
                   5543:   expand_function_end (input_filename, lineno);
                   5544: 
                   5545:   /* So we can tell if jump_optimize sets it to 1.  */
                   5546:   can_reach_end = 0;
                   5547: 
                   5548:   /* Run the optimizers and output the assembler code for this function.  */
                   5549:   rest_of_compilation (fndecl);
                   5550: 
                   5551:   current_function_returns_null |= can_reach_end;
                   5552: 
                   5553:   if (TREE_THIS_VOLATILE (fndecl) && current_function_returns_null)
                   5554:     warning ("`volatile' function does return");
                   5555:   else if (warn_return_type && current_function_returns_null
                   5556:           && TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl))) != void_type_node)
                   5557:     /* If this function returns non-void and control can drop through,
                   5558:        complain.  */
                   5559:     warning ("control reaches end of non-void function");
                   5560:   /* With just -W, complain only if function returns both with
                   5561:      and without a value.  */
                   5562:   else if (extra_warnings
                   5563:           && current_function_returns_value && current_function_returns_null)
                   5564:     warning ("this function may return with or without a value");
                   5565: 
                   5566:   /* Free all the tree nodes making up this function.  */
                   5567:   /* Switch back to allocating nodes permanently
                   5568:      until we start another function.  */
                   5569:   if (! nested)
                   5570:     permanent_allocation ();
                   5571: 
                   5572:   if (DECL_SAVED_INSNS (fndecl) == 0 && ! nested)
                   5573:     {
                   5574:       /* Stop pointing to the local nodes about to be freed.  */
                   5575:       /* But DECL_INITIAL must remain nonzero so we know this
                   5576:         was an actual function definition.  */
                   5577:       /* For a nested function, this is done in pop_c_function_context.  */
                   5578:       DECL_INITIAL (fndecl) = error_mark_node;
                   5579:       DECL_ARGUMENTS (fndecl) = 0;
                   5580:     }
                   5581: 
                   5582:   if (! nested)
                   5583:     {
                   5584:       /* Let the error reporting routines know that we're outside a
                   5585:         function.  For a nested function, this value is used in
                   5586:         pop_c_function_context and then reset via pop_function_context.  */
                   5587:       current_function_decl = NULL;
                   5588:     }
                   5589: }
                   5590: 
                   5591: /* Save and restore the variables in this file and elsewhere
                   5592:    that keep track of the progress of compilation of the current function.
                   5593:    Used for nested functions.  */
                   5594: 
                   5595: struct c_function
                   5596: {
                   5597:   struct c_function *next;
                   5598:   tree enum_next_value;
                   5599:   tree named_labels;
                   5600:   tree shadowed_labels;
                   5601:   int returns_value;
                   5602:   int returns_null;
                   5603:   int warn_about_return_type;
                   5604:   int extern_inline;
                   5605:   struct binding_level *binding_level;
                   5606: };
                   5607: 
                   5608: struct c_function *c_function_chain;
                   5609: 
                   5610: /* Save and reinitialize the variables
                   5611:    used during compilation of a C function.  */
                   5612: 
                   5613: void
                   5614: push_c_function_context ()
                   5615: {
                   5616:   struct c_function *p
                   5617:     = (struct c_function *) xmalloc (sizeof (struct c_function));
                   5618: 
                   5619:   push_function_context ();
                   5620: 
                   5621:   p->next = c_function_chain;
                   5622:   c_function_chain = p;
                   5623: 
                   5624:   p->enum_next_value = enum_next_value;
                   5625:   p->named_labels = named_labels;
                   5626:   p->shadowed_labels = shadowed_labels;
                   5627:   p->returns_value = current_function_returns_value;
                   5628:   p->returns_null = current_function_returns_null;
                   5629:   p->warn_about_return_type = warn_about_return_type;
                   5630:   p->extern_inline = current_extern_inline;
                   5631:   p->binding_level = current_binding_level;
                   5632: }
                   5633: 
                   5634: /* Restore the variables used during compilation of a C function.  */
                   5635: 
                   5636: void
                   5637: pop_c_function_context ()
                   5638: {
                   5639:   struct c_function *p = c_function_chain;
                   5640:   tree link;
                   5641: 
                   5642:   /* Bring back all the labels that were shadowed.  */
                   5643:   for (link = shadowed_labels; link; link = TREE_CHAIN (link))
                   5644:     if (DECL_NAME (TREE_VALUE (link)) != 0)
                   5645:       IDENTIFIER_LABEL_VALUE (DECL_NAME (TREE_VALUE (link)))
                   5646:        = TREE_VALUE (link);
                   5647: 
                   5648:   if (DECL_SAVED_INSNS (current_function_decl) == 0)
                   5649:     {
                   5650:       /* Stop pointing to the local nodes about to be freed.  */
                   5651:       /* But DECL_INITIAL must remain nonzero so we know this
                   5652:         was an actual function definition.  */
                   5653:       DECL_INITIAL (current_function_decl) = error_mark_node;
                   5654:       DECL_ARGUMENTS (current_function_decl) = 0;
                   5655:     }
                   5656: 
                   5657:   pop_function_context ();
                   5658: 
                   5659:   c_function_chain = p->next;
                   5660: 
                   5661:   enum_next_value = p->enum_next_value;
                   5662:   named_labels = p->named_labels;
                   5663:   shadowed_labels = p->shadowed_labels;
                   5664:   current_function_returns_value = p->returns_value;
                   5665:   current_function_returns_null = p->returns_null;
                   5666:   warn_about_return_type = p->warn_about_return_type;
                   5667:   current_extern_inline = p->extern_inline;
                   5668:   current_binding_level = p->binding_level;
                   5669: 
                   5670:   free (p);
                   5671: }

unix.superglobalmegacorp.com

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