Annotation of GNUtools/cc/cp-decl.c, revision 1.1.1.1

1.1       root        1: /* Process declarations and variables for C compiler.
                      2:    Copyright (C) 1988, 1992, 1993 Free Software Foundation, Inc.
                      3:    Hacked by Michael Tiemann ([email protected])
                      4: 
                      5: This file is part of GNU CC.
                      6: 
                      7: GNU CC is free software; you can redistribute it and/or modify
                      8: it under the terms of the GNU General Public License as published by
                      9: the Free Software Foundation; either version 2, or (at your option)
                     10: any later version.
                     11: 
                     12: GNU CC is distributed in the hope that it will be useful,
                     13: but WITHOUT ANY WARRANTY; without even the implied warranty of
                     14: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
                     15: GNU General Public License for more details.
                     16: 
                     17: You should have received a copy of the GNU General Public License
                     18: along with GNU CC; see the file COPYING.  If not, write to
                     19: the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
                     20: 
                     21: 
                     22: /* Process declarations and symbol lookup for C front end.
                     23:    Also constructs types; the standard scalar types at initialization,
                     24:    and structure, union, array and enum types when they are declared.  */
                     25: 
                     26: /* ??? not all decl nodes are given the most useful possible
                     27:    line numbers.  For example, the CONST_DECLs for enum values.  */
                     28: 
                     29: #include <stdio.h>
                     30: #include "config.h"
                     31: #include "tree.h"
                     32: #include "rtl.h"
                     33: #include "flags.h"
                     34: #include "cp-tree.h"
                     35: #include "cp-decl.h"
                     36: #include "cp-lex.h"
                     37: #include <sys/types.h>
                     38: #include <signal.h>
                     39: #include "obstack.h"
                     40: 
                     41: #define obstack_chunk_alloc xmalloc
                     42: #define obstack_chunk_free free
                     43: 
                     44: #ifndef OBJCPLUS
                     45: /* Define this if C structs should have gratuitous typedefing
                     46:    done just like C++ structs do.  */
                     47: #define BREAK_C_TAGS
                     48: #endif /* not OBJCPLUS */
                     49: extern struct obstack permanent_obstack;
                     50: 
                     51: #ifdef OBJCPLUS
                     52: #define DECL_HAS_C_LINKAGE(DECL) \
                     53:   (DECL_LANGUAGE (DECL)==lang_c || DECL_LANGUAGE (DECL)==lang_objc)
                     54: #else
                     55: #define DECL_HAS_C_LINKAGE(DECL)        (DECL_LANGUAGE (DECL)==lang_c)
                     56: #endif
                     57: #define DECL_LINKAGE(DECL) \
                     58:    (DECL_HAS_C_LINKAGE(DECL) ? lang_c : \
                     59:     DECL_HAS_CPLUSPLUS_LINKAGE(DECL) ? lang_cplusplus : 0)
                     60: 
                     61: #define DECL_HAS_CPLUSPLUS_LINKAGE(DECL) (DECL_LANGUAGE (DECL)==lang_cplusplus)
                     62: 
                     63: #define DECLS_SAME_LINKAGE(DECL1, DECL2)                                       \
                     64:   (DECL_LINKAGE(DECL1) == DECL_LINKAGE(DECL2))
                     65: 
                     66: extern int current_class_depth;
                     67: 
                     68: /* Stack of places to restore the search obstack back to.  */
                     69:    
                     70: /* Obstack used for remembering local class declarations (like
                     71:    enums and static (const) members.  */
                     72: #include "stack.h"
                     73: static struct obstack decl_obstack;
                     74: static struct stack_level *decl_stack;
                     75: 
                     76: #ifndef CHAR_TYPE_SIZE
                     77: #define CHAR_TYPE_SIZE BITS_PER_UNIT
                     78: #endif
                     79: 
                     80: #ifndef SHORT_TYPE_SIZE
                     81: #define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2))
                     82: #endif
                     83: 
                     84: #ifndef INT_TYPE_SIZE
                     85: #define INT_TYPE_SIZE BITS_PER_WORD
                     86: #endif
                     87: 
                     88: #ifndef LONG_TYPE_SIZE
                     89: #define LONG_TYPE_SIZE BITS_PER_WORD
                     90: #endif
                     91: 
                     92: #ifndef LONG_LONG_TYPE_SIZE
                     93: #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
                     94: #endif
                     95: 
                     96: #ifndef WCHAR_UNSIGNED
                     97: #define WCHAR_UNSIGNED 0
                     98: #endif
                     99: 
                    100: #ifndef FLOAT_TYPE_SIZE
                    101: #define FLOAT_TYPE_SIZE BITS_PER_WORD
                    102: #endif
                    103: 
                    104: #ifndef DOUBLE_TYPE_SIZE
                    105: #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
                    106: #endif
                    107: 
                    108: #ifndef LONG_DOUBLE_TYPE_SIZE
                    109: #define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
                    110: #endif
                    111: 
                    112: /* We let tm.h override the types used here, to handle trivial differences
                    113:    such as the choice of unsigned int or long unsigned int for size_t.
                    114:    When machines start needing nontrivial differences in the size type,
                    115:    it would be best to do something here to figure out automatically
                    116:    from other information what type to use.  */
                    117: 
                    118: #ifndef SIZE_TYPE
                    119: #define SIZE_TYPE "long unsigned int"
                    120: #endif
                    121: 
                    122: #ifndef PTRDIFF_TYPE
                    123: #define PTRDIFF_TYPE "long int"
                    124: #endif
                    125: 
                    126: #ifndef WCHAR_TYPE
                    127: #define WCHAR_TYPE "int"
                    128: #endif
                    129: 
                    130: #define builtin_function(NAME, TYPE, CODE, LIBNAME) \
                    131:   define_function (NAME, TYPE, CODE, (void (*)())pushdecl, LIBNAME)
                    132: #define auto_function(NAME, TYPE, CODE) \
                    133:   do {                                 \
                    134:     tree __name = NAME;                \
                    135:     tree __type = TYPE;                        \
                    136:     define_function (IDENTIFIER_POINTER (__name), __type, CODE,        \
                    137:                     (void (*)())push_overloaded_decl_1,        \
                    138:                     IDENTIFIER_POINTER (build_decl_overload (__name, TYPE_ARG_TYPES (__type), 0)));\
                    139:   } while (0)
                    140: 
                    141:        tree grokparms                          PROTO((tree, int));
                    142: static tree lookup_nested_type                 PROTO((tree, tree));
                    143: static char *redeclaration_error_message       PROTO((tree, tree));
                    144: static int parmlist_is_random                  PROTO((tree));
                    145: static void grok_op_properties                 PROTO((tree, int));
                    146: static void expand_static_init                 PROTO((tree, tree));
                    147: static void deactivate_exception_cleanups      PROTO((void));
                    148: 
                    149: tree define_function                           PROTO((char *, tree, enum built_in_function, void (*)(), char *));
                    150: 
                    151: /* a node which has tree code ERROR_MARK, and whose type is itself.
                    152:    All erroneous expressions are replaced with this node.  All functions
                    153:    that accept nodes as arguments should avoid generating error messages
                    154:    if this node is one of the arguments, since it is undesirable to get
                    155:    multiple error messages from one error in the input.  */
                    156: 
                    157: tree error_mark_node;
                    158: 
                    159: /* Erroneous argument lists can use this *IFF* they do not modify it.  */
                    160: tree error_mark_list;
                    161: 
                    162: /* INTEGER_TYPE and REAL_TYPE nodes for the standard data types */
                    163: 
                    164: tree short_integer_type_node;
                    165: tree integer_type_node;
                    166: tree long_integer_type_node;
                    167: tree long_long_integer_type_node;
                    168: 
                    169: tree short_unsigned_type_node;
                    170: tree unsigned_type_node;
                    171: tree long_unsigned_type_node;
                    172: tree long_long_unsigned_type_node;
                    173: 
                    174: tree ptrdiff_type_node;
                    175: 
                    176: tree unsigned_char_type_node;
                    177: tree signed_char_type_node;
                    178: tree char_type_node;
                    179: tree wchar_type_node;
                    180: tree signed_wchar_type_node;
                    181: tree unsigned_wchar_type_node;
                    182: 
                    183: tree float_type_node;
                    184: tree double_type_node;
                    185: tree long_double_type_node;
                    186: 
                    187: tree intQI_type_node;
                    188: tree intHI_type_node;
                    189: tree intSI_type_node;
                    190: tree intDI_type_node;
                    191: 
                    192: tree unsigned_intQI_type_node;
                    193: tree unsigned_intHI_type_node;
                    194: tree unsigned_intSI_type_node;
                    195: tree unsigned_intDI_type_node;
                    196: 
                    197: /* a VOID_TYPE node, and the same, packaged in a TREE_LIST.  */
                    198: 
                    199: tree void_type_node, void_list_node;
                    200: tree void_zero_node;
                    201: 
                    202: /* Nodes for types `void *' and `const void *'.  */
                    203: 
                    204: tree ptr_type_node, const_ptr_type_node;
                    205: 
                    206: /* Nodes for types `char *' and `const char *'.  */
                    207: 
                    208: tree string_type_node, const_string_type_node;
                    209: 
                    210: /* Type `char[256]' or something like it.
                    211:    Used when an array of char is needed and the size is irrelevant.  */
                    212: 
                    213: tree char_array_type_node;
                    214: 
                    215: /* Type `int[256]' or something like it.
                    216:    Used when an array of int needed and the size is irrelevant.  */
                    217: 
                    218: tree int_array_type_node;
                    219: 
                    220: /* Type `wchar_t[256]' or something like it.
                    221:    Used when a wide string literal is created.  */
                    222: 
                    223: tree wchar_array_type_node;
                    224: 
                    225: /* type `int ()' -- used for implicit declaration of functions.  */
                    226: 
                    227: tree default_function_type;
                    228: 
                    229: /* function types `double (double)' and `double (double, double)', etc.  */
                    230: 
                    231: tree double_ftype_double, double_ftype_double_double;
                    232: tree int_ftype_int, long_ftype_long;
                    233: 
                    234: /* Function type `void (void *, void *, int)' and similar ones.  */
                    235: 
                    236: tree void_ftype_ptr_ptr_int, int_ftype_ptr_ptr_int, void_ftype_ptr_int_int;
                    237: 
                    238: /* Function type `char *(char *, char *)' and similar ones */
                    239: tree string_ftype_ptr_ptr, int_ftype_string_string;
                    240: 
                    241: /* Function type `size_t (const char *)' */
                    242: tree sizet_ftype_string;
                    243: 
                    244: /* Function type `int (const void *, const void *, size_t)' */
                    245: tree int_ftype_cptr_cptr_sizet;
                    246: 
                    247: /* C++ extensions */
                    248: tree vtable_entry_type;
                    249: tree __t_desc_type_node, __i_desc_type_node, __m_desc_type_node;
                    250: tree __t_desc_array_type, __i_desc_array_type, __m_desc_array_type;
                    251: tree class_star_type_node;
                    252: tree class_type_node, record_type_node, union_type_node, enum_type_node;
                    253: tree exception_type_node, unknown_type_node;
                    254: tree maybe_gc_cleanup;
                    255: 
                    256: /* Used for virtual function tables.  */
                    257: tree vtbl_mask;
                    258: 
                    259: /* Array type `(void *)[]' */
                    260: tree vtbl_type_node;
                    261: 
                    262: /* Static decls which do not have static initializers have no
                    263:    initializers as far as GNU C is concerned.  EMPTY_INIT_NODE
                    264:    is a static initializer which makes varasm code place the decl
                    265:    in data rather than in bss space.  Such gymnastics are necessary
                    266:    to avoid the problem that the linker will not include a library
                    267:    file if all the library appears to contribute are bss variables.  */
                    268: 
                    269: tree empty_init_node;
                    270: 
                    271: /* In a destructor, the point at which all derived class destroying
                    272:    has been done, just before any base class destroying will be done.  */
                    273: 
                    274: tree dtor_label;
                    275: 
                    276: /* In a constructor, the point at which we are ready to return
                    277:    the pointer to the initialized object.  */
                    278: 
                    279: tree ctor_label;
                    280: 
                    281: /* A FUNCTION_DECL which can call `unhandled_exception'.
                    282:    Not necessarily the one that the user will declare,
                    283:    but sufficient to be called by routines that want to abort the program.  */
                    284: 
                    285: tree unhandled_exception_fndecl;
                    286: 
                    287: /* A FUNCTION_DECL which can call `abort'.  Not necessarily the
                    288:    one that the user will declare, but sufficient to be called
                    289:    by routines that want to abort the program.  */
                    290: 
                    291: tree abort_fndecl;
                    292: 
                    293: extern rtx cleanup_label, return_label;
                    294: 
                    295: /* If original DECL_RESULT of current function was a register,
                    296:    but due to being an addressable named return value, would up
                    297:    on the stack, this variable holds the named return value's
                    298:    original location.  */
                    299: rtx original_result_rtx;
                    300: 
                    301: /* Sequence of insns which represents base initialization.  */
                    302: rtx base_init_insns;
                    303: 
                    304: /* C++: Keep these around to reduce calls to `get_identifier'.
                    305:    Identifiers for `this' in member functions and the auto-delete
                    306:    parameter for destructors.  */
                    307: tree this_identifier, in_charge_identifier;
                    308: /* Used in pointer to member functions, and in vtables. */
                    309: tree pfn_identifier, index_identifier, delta_identifier, delta2_identifier;
                    310: tree pfn_or_delta2_identifier;
                    311: 
                    312: /* A list (chain of TREE_LIST nodes) of named label uses.
                    313:    The TREE_PURPOSE field is the list of variables defined
                    314:    the the label's scope defined at the point of use.
                    315:    The TREE_VALUE field is the LABEL_DECL used.
                    316:    The TREE_TYPE field holds `current_binding_level' at the
                    317:    point of the label's use.
                    318: 
                    319:    Used only for jumps to as-yet undefined labels, since
                    320:    jumps to defined labels can have their validity checked
                    321:    by stmt.c.  */
                    322: 
                    323: static tree named_label_uses;
                    324: 
                    325: /* A list of objects which have constructors or destructors
                    326:    which reside in the global scope.  The decl is stored in
                    327:    the TREE_VALUE slot and the initializer is stored
                    328:    in the TREE_PURPOSE slot.  */
                    329: tree static_aggregates;
                    330: 
                    331: /* A list of functions which were declared inline, but later had their
                    332:    address taken.  Used only for non-virtual member functions, since we can
                    333:    find other functions easily enough.  */
                    334: tree pending_addressable_inlines;
                    335: 
                    336: /* A list of overloaded functions which we should forget ever
                    337:    existed, such as functions declared in a function's scope,
                    338:    once we leave that function's scope.  */
                    339: static tree overloads_to_forget;
                    340: 
                    341: /* -- end of C++ */
                    342: 
                    343: /* Two expressions that are constants with value zero.
                    344:    The first is of type `int', the second of type `void *'.  */
                    345: 
                    346: tree integer_zero_node;
                    347: tree null_pointer_node;
                    348: 
                    349: /* A node for the integer constants 1, 2, and 3.  */
                    350: 
                    351: tree integer_one_node, integer_two_node, integer_three_node;
                    352: 
                    353: /* Nonzero if we have seen an invalid cross reference
                    354:    to a struct, union, or enum, but not yet printed the message.  */
                    355: 
                    356: tree pending_invalid_xref;
                    357: /* File and line to appear in the eventual error message.  */
                    358: char *pending_invalid_xref_file;
                    359: int pending_invalid_xref_line;
                    360: 
                    361: /* While defining an enum type, this is 1 plus the last enumerator
                    362:    constant value.  */
                    363: 
                    364: static tree enum_next_value;
                    365: 
                    366: /* Parsing a function declarator leaves a list of parameter names
                    367:    or a chain or parameter decls here.  */
                    368: 
                    369: tree last_function_parms;
                    370: 
                    371: /* Parsing a function declarator leaves here a chain of structure
                    372:    and enum types declared in the parmlist.  */
                    373: 
                    374: static tree last_function_parm_tags;
                    375: 
                    376: /* After parsing the declarator that starts a function definition,
                    377:    `start_function' puts here the list of parameter names or chain of decls.
                    378:    `store_parm_decls' finds it here.  */
                    379: 
                    380: static tree current_function_parms;
                    381: 
                    382: /* Similar, for last_function_parm_tags.  */
                    383: static tree current_function_parm_tags;
                    384: 
                    385: /* A list (chain of TREE_LIST nodes) of all LABEL_DECLs in the function
                    386:    that have names.  Here so we can clear out their names' definitions
                    387:    at the end of the function.  */
                    388: 
                    389: static tree named_labels;
                    390: 
                    391: /* A list of LABEL_DECLs from outer contexts that are currently shadowed.  */
                    392: 
                    393: static tree shadowed_labels;
                    394: 
                    395: #if 0 /* Not needed by C++ */
                    396: /* Nonzero when store_parm_decls is called indicates a varargs function.
                    397:    Value not meaningful after store_parm_decls.  */
                    398: 
                    399: static int c_function_varargs;
                    400: #endif
                    401: 
                    402: /* The FUNCTION_DECL for the function currently being compiled,
                    403:    or 0 if between functions.  */
                    404: tree current_function_decl;
                    405: 
                    406: /* Set to 0 at beginning of a function definition, set to 1 if
                    407:    a return statement that specifies a return value is seen.  */
                    408: 
                    409: int current_function_returns_value;
                    410: 
                    411: /* Set to 0 at beginning of a function definition, set to 1 if
                    412:    a return statement with no argument is seen.  */
                    413: 
                    414: int current_function_returns_null;
                    415: 
                    416: /* Set to 0 at beginning of a function definition, and whenever
                    417:    a label (case or named) is defined.  Set to value of expression
                    418:    returned from function when that value can be transformed into
                    419:    a named return value.  */
                    420: 
                    421: tree current_function_return_value;
                    422: 
                    423: /* Set to nonzero by `grokdeclarator' for a function
                    424:    whose return type is defaulted, if warnings for this are desired.  */
                    425: 
                    426: static int warn_about_return_type;
                    427: 
                    428: /* Nonzero when starting a function declared `extern inline'.  */
                    429: 
                    430: static int current_extern_inline;
                    431: 
                    432: /* Nonzero means give `double' the same size as `float'.  */
                    433: 
                    434: extern int flag_short_double;
                    435: 
                    436: /* Nonzero means don't recognize any builtin functions.  */
                    437: 
                    438: extern int flag_no_builtin;
                    439: 
                    440: /* Nonzero means do emit exported implementations of functions even if
                    441:    they can be inlined.  */
                    442: 
                    443: extern int flag_implement_inlines;
                    444: 
                    445: /* Nonzero means handle things in ANSI, instead of GNU fashion.  This
                    446:    flag should be tested for language behavior that's different between
                    447:    ANSI and GNU, but not so horrible as to merit a PEDANTIC label.  */
                    448: 
                    449: extern int flag_ansi;
                    450: 
                    451: /* Pointers to the base and current top of the language name stack.  */
                    452: 
                    453: extern tree *current_lang_base, *current_lang_stack;
                    454: 
                    455: /* C and C++ flags are in cp-decl2.c.  */
                    456: 
                    457: /* Set to 0 at beginning of a constructor, set to 1
                    458:    if that function does an allocation before referencing its
                    459:    instance variable.  */
                    460: int current_function_assigns_this;
                    461: int current_function_just_assigned_this;
                    462: 
                    463: /* Set to 0 at beginning of a function.  Set non-zero when
                    464:    store_parm_decls is called.  Don't call store_parm_decls
                    465:    if this flag is non-zero!  */
                    466: int current_function_parms_stored;
                    467: 
                    468: /* Current end of entries in the gc obstack for stack pointer variables.  */
                    469: 
                    470: int current_function_obstack_index;
                    471: 
                    472: /* Flag saying whether we have used the obstack in this function or not.  */
                    473: 
                    474: int current_function_obstack_usage;
                    475: 
                    476: /* Flag used when debugging cp-spew.c */
                    477: 
                    478: extern int spew_debug;
                    479: 
                    480: /* This is a copy of the class_shadowed list of the previous class binding
                    481:    contour when at global scope.  It's used to reset IDENTIFIER_CLASS_VALUEs
                    482:    when entering another class scope (i.e. a cache miss).  */
                    483: extern tree previous_class_values;
                    484: 
                    485: 
                    486: 
                    487: #ifdef NeXT
                    488: #ifdef HPPA
                    489: extern void add_vararg_func(char *, char);
                    490: #endif
                    491: #endif
                    492: 
                    493: /* Allocate a level of searching.  */
                    494: struct stack_level *
                    495: push_decl_level (stack, obstack)
                    496:      struct stack_level *stack;
                    497:      struct obstack *obstack;
                    498: {
                    499:   struct stack_level tem;
                    500:   tem.prev = stack;
                    501: 
                    502:   return push_stack_level (obstack, (char *)&tem, sizeof (tem));
                    503: }
                    504: 
                    505: /* Discard a level of decl allocation.  */
                    506: 
                    507: static struct stack_level *
                    508: pop_decl_level (stack)
                    509:      struct stack_level *stack;
                    510: {
                    511: #if !NEW_CLASS_SCOPING
                    512:   tree *bp, *tp;
                    513:   struct obstack *obstack = stack->obstack;
                    514:   bp = stack->first;
                    515:   tp = (tree *)obstack_next_free (obstack);
                    516:   while (tp != bp)
                    517:     {
                    518:       --tp;
                    519:       if (*tp != NULL_TREE)
                    520:        IDENTIFIER_CLASS_VALUE (DECL_NAME (*tp)) = NULL_TREE;
                    521:     }
                    522: #endif
                    523:   return pop_stack_level (stack);
                    524: }
                    525: 
                    526: /* For each binding contour we allocate a binding_level structure
                    527:  * which records the names defined in that contour.
                    528:  * Contours include:
                    529:  *  0) the global one
                    530:  *  1) one for each function definition,
                    531:  *     where internal declarations of the parameters appear.
                    532:  *  2) one for each compound statement,
                    533:  *     to record its declarations.
                    534:  *
                    535:  * The current meaning of a name can be found by searching the levels from
                    536:  * the current one out to the global one.
                    537:  *
                    538:  * Off to the side, may be the class_binding_level.  This exists
                    539:  * only to catch class-local declarations.  It is otherwise
                    540:  * nonexistent.
                    541:  * 
                    542:  * Also there may be binding levels that catch cleanups that
                    543:  * must be run when exceptions occur.
                    544:  */
                    545: 
                    546: /* Note that the information in the `names' component of the global contour
                    547:    is duplicated in the IDENTIFIER_GLOBAL_VALUEs of all identifiers.  */
                    548: 
                    549: struct binding_level
                    550:   {
                    551:     /* A chain of _DECL nodes for all variables, constants, functions,
                    552:      * and typedef types.  These are in the reverse of the order supplied.
                    553:      */
                    554:     tree names;
                    555: 
                    556:     /* A list of structure, union and enum definitions,
                    557:      * for looking up tag names.
                    558:      * It is a chain of TREE_LIST nodes, each of whose TREE_PURPOSE is a name,
                    559:      * or NULL_TREE; and whose TREE_VALUE is a RECORD_TYPE, UNION_TYPE,
                    560:      * or ENUMERAL_TYPE node.
                    561:      *
                    562:      * C++: the TREE_VALUE nodes can be simple types for component_bindings.
                    563:      *
                    564:      */
                    565:     tree tags;
                    566: 
                    567:     /* For each level, a list of shadowed outer-level local definitions
                    568:        to be restored when this level is popped.
                    569:        Each link is a TREE_LIST whose TREE_PURPOSE is an identifier and
                    570:        whose TREE_VALUE is its old definition (a kind of ..._DECL node).  */
                    571:     tree shadowed;
                    572: 
                    573:     /* Same, for IDENTIFIER_CLASS_VALUE.  */
                    574:     tree class_shadowed;
                    575: 
                    576:     /* Same, for IDENTIFIER_TYPE_VALUE.  */
                    577:     tree type_shadowed;
                    578: 
                    579:     /* For each level (except not the global one),
                    580:        a chain of BLOCK nodes for all the levels
                    581:        that were entered and exited one level down.  */
                    582:     tree blocks;
                    583: 
                    584:     /* The BLOCK node for this level, if one has been preallocated.
                    585:        If 0, the BLOCK is allocated (if needed) when the level is popped.  */
                    586:     tree this_block;
                    587: 
                    588:     /* The binding level which this one is contained in (inherits from).  */
                    589:     struct binding_level *level_chain;
                    590: 
                    591:     /* Number of decls in `names' that have incomplete 
                    592:        structure or union types.  */
                    593:     unsigned short n_incomplete;
                    594: 
                    595:     /* 1 for the level that holds the parameters of a function.
                    596:        2 for the level that holds a class declaration.
                    597:        3 for levels that hold parameter declarations.  */
                    598:     unsigned parm_flag : 4;
                    599: 
                    600:     /* 1 means make a BLOCK for this level regardless of all else.
                    601:        2 for temporary binding contours created by the compiler.  */
                    602:     unsigned keep : 3;
                    603: 
                    604:     /* Nonzero if this level "doesn't exist" for tags.  */
                    605:     unsigned tag_transparent : 1;
                    606: 
                    607:     /* Nonzero if this level can safely have additional
                    608:        cleanup-needing variables added to it.  */
                    609:     unsigned more_cleanups_ok : 1;
                    610:     unsigned have_cleanups : 1;
                    611: 
                    612:     /* Nonzero if this level can safely have additional
                    613:        exception-raising statements added to it.  */
                    614:     unsigned more_exceptions_ok : 1;
                    615:     unsigned have_exceptions : 1;
                    616: 
                    617:     /* Nonzero if we should accept any name as an identifier in
                    618:        this scope.  This happens in some template definitions.  */
                    619:     unsigned accept_any : 1;
                    620: 
                    621:     /* Nonzero if this level is for completing a template class definition
                    622:        inside a binding level that temporarily binds the parameters.  This
                    623:        means that definitions here should not be popped off when unwinding
                    624:        this binding level.  (Not actually implemented this way,
                    625:        unfortunately.)  */
                    626:     unsigned pseudo_global : 1;
                    627: 
                    628:     /* Two bits left for this word.  */
                    629: 
                    630: #if defined(DEBUG_CP_BINDING_LEVELS)
                    631:     /* Binding depth at which this level began.  */
                    632:     unsigned binding_depth;
                    633: #endif /* defined(DEBUG_CP_BINDING_LEVELS) */
                    634:   };
                    635: 
                    636: #define NULL_BINDING_LEVEL ((struct binding_level *) NULL)
                    637:   
                    638: /* The binding level currently in effect.  */
                    639: 
                    640: static struct binding_level *current_binding_level;
                    641: 
                    642: /* The binding level of the current class, if any.  */
                    643: 
                    644: static struct binding_level *class_binding_level;
                    645: 
                    646: /* A chain of binding_level structures awaiting reuse.  */
                    647: 
                    648: static struct binding_level *free_binding_level;
                    649: 
                    650: /* The outermost binding level, for names of file scope.
                    651:    This is created when the compiler is started and exists
                    652:    through the entire run.  */
                    653: 
                    654: static struct binding_level *global_binding_level;
                    655: 
                    656: /* Binding level structures are initialized by copying this one.  */
                    657: 
                    658: static struct binding_level clear_binding_level;
                    659: 
                    660: /* Nonzero means unconditionally make a BLOCK for the next level pushed.  */
                    661: 
                    662: static int keep_next_level_flag;
                    663: 
                    664: #if defined(DEBUG_CP_BINDING_LEVELS)
                    665: static int binding_depth = 0;
                    666: static int is_class_level = 0;
                    667: 
                    668: static void
                    669: indent ()
                    670: {
                    671:   register unsigned i;
                    672: 
                    673:   for (i = 0; i < binding_depth*2; i++)
                    674:     putc (' ', stderr);
                    675: }
                    676: #endif /* defined(DEBUG_CP_BINDING_LEVELS) */
                    677: 
                    678: static void
                    679: push_binding_level (newlevel, tag_transparent, keep)
                    680:      struct binding_level *newlevel;
                    681:      int tag_transparent, keep;
                    682: {
                    683:   /* Add this level to the front of the chain (stack) of levels that
                    684:      are active.  */
                    685:   *newlevel = clear_binding_level;
                    686:   if (class_binding_level)
                    687:     {
                    688:       newlevel->level_chain = class_binding_level;
                    689:       class_binding_level = (struct binding_level *)0;
                    690:     }
                    691:   else
                    692:     {
                    693:       newlevel->level_chain = current_binding_level;
                    694:     }
                    695:   current_binding_level = newlevel;
                    696:   newlevel->tag_transparent = tag_transparent;
                    697:   newlevel->more_cleanups_ok = 1;
                    698:   newlevel->more_exceptions_ok = 1;
                    699:   newlevel->keep = keep;
                    700: #if defined(DEBUG_CP_BINDING_LEVELS)
                    701:   newlevel->binding_depth = binding_depth;
                    702:   indent ();
                    703:   fprintf (stderr, "push %s level 0x%08x line %d\n",
                    704:           (is_class_level) ? "class" : "block", newlevel, lineno);
                    705:   is_class_level = 0;
                    706:   binding_depth++;
                    707: #endif /* defined(DEBUG_CP_BINDING_LEVELS) */
                    708: }
                    709: 
                    710: static void
                    711: pop_binding_level ()
                    712: {
                    713:   if (class_binding_level)
                    714:     current_binding_level = class_binding_level;
                    715: 
                    716:   if (global_binding_level)
                    717:     {
                    718:       /* cannot pop a level, if there are none left to pop. */
                    719:       if (current_binding_level == global_binding_level)
                    720:        my_friendly_abort (123);
                    721:     }
                    722:   /* Pop the current level, and free the structure for reuse.  */
                    723: #if defined(DEBUG_CP_BINDING_LEVELS)
                    724:   binding_depth--;
                    725:   indent ();
                    726:   fprintf (stderr, "pop  %s level 0x%08x line %d\n",
                    727:          (is_class_level) ? "class" : "block",
                    728:          current_binding_level, lineno);
                    729:   if (is_class_level != (current_binding_level == class_binding_level))
                    730: #if 0 /* XXX Don't abort when we're watching how things are being managed.  */
                    731:     abort ();
                    732: #else
                    733:   {
                    734:     indent ();
                    735:     fprintf (stderr, "XXX is_class_level != (current_binding_level == class_binding_level)\n");
                    736:   }
                    737: #endif
                    738:   is_class_level = 0;
                    739: #endif /* defined(DEBUG_CP_BINDING_LEVELS) */
                    740:   {
                    741:     register struct binding_level *level = current_binding_level;
                    742:     current_binding_level = current_binding_level->level_chain;
                    743:     level->level_chain = free_binding_level;
                    744: #if 0 /* defined(DEBUG_CP_BINDING_LEVELS) */
                    745:     if (level->binding_depth != binding_depth)
                    746:       abort ();
                    747: #endif /* defined(DEBUG_CP_BINDING_LEVELS) */
                    748:       free_binding_level = level;
                    749: 
                    750:     class_binding_level = current_binding_level;
                    751:     if (class_binding_level->parm_flag != 2)
                    752:       class_binding_level = 0;
                    753:     while (current_binding_level->parm_flag == 2)
                    754:       current_binding_level = current_binding_level->level_chain;
                    755:   }
                    756: }
                    757: 
                    758: /* Nonzero if we are currently in the global binding level.  */
                    759: 
                    760: int
                    761: global_bindings_p ()
                    762: {
                    763:   return current_binding_level == global_binding_level;
                    764: }
                    765: 
                    766: void
                    767: keep_next_level ()
                    768: {
                    769:   keep_next_level_flag = 1;
                    770: }
                    771: 
                    772: /* Nonzero if the current level needs to have a BLOCK made.  */
                    773: 
                    774: int
                    775: kept_level_p ()
                    776: {
                    777:   return (current_binding_level->blocks != NULL_TREE
                    778:          || current_binding_level->keep
                    779:          || current_binding_level->names != NULL_TREE
                    780:          || (current_binding_level->tags != NULL_TREE
                    781:              && !current_binding_level->tag_transparent));
                    782: }
                    783: 
                    784: /* Identify this binding level as a level of parameters.  */
                    785: 
                    786: void
                    787: declare_parm_level ()
                    788: {
                    789:   current_binding_level->parm_flag = 1;
                    790: }
                    791: 
                    792: /* Identify this binding level as a level of a default exception handler.  */
                    793: 
                    794: void
                    795: declare_implicit_exception ()
                    796: {
                    797:   current_binding_level->parm_flag = 3;
                    798: }
                    799: 
                    800: /* Nonzero if current binding contour contains expressions
                    801:    that might raise exceptions.  */
                    802: 
                    803: int
                    804: have_exceptions_p ()
                    805: {
                    806:   return current_binding_level->have_exceptions;
                    807: }
                    808: 
                    809: void
                    810: declare_uninstantiated_type_level ()
                    811: {
                    812:   current_binding_level->accept_any = 1;
                    813: }
                    814: 
                    815: int
                    816: uninstantiated_type_level_p ()
                    817: {
                    818:   return current_binding_level->accept_any;
                    819: }
                    820: 
                    821: void
                    822: declare_pseudo_global_level ()
                    823: {
                    824:   current_binding_level->pseudo_global = 1;
                    825: }
                    826: 
                    827: int
                    828: pseudo_global_level_p ()
                    829: {
                    830:   return current_binding_level->pseudo_global;
                    831: }
                    832: 
                    833: void
                    834: set_class_shadows (shadows)
                    835:      tree shadows;
                    836: {
                    837:   class_binding_level->class_shadowed = shadows;
                    838: }
                    839: 
                    840: /* Enter a new binding level.
                    841:    If TAG_TRANSPARENT is nonzero, do so only for the name space of variables,
                    842:    not for that of tags.  */
                    843: 
                    844: void
                    845: pushlevel (tag_transparent)
                    846:      int tag_transparent;
                    847: {
                    848:   register struct binding_level *newlevel = NULL_BINDING_LEVEL;
                    849: 
                    850:   /* If this is the top level of a function,
                    851:      just make sure that NAMED_LABELS is 0.
                    852:      They should have been set to 0 at the end of the previous function.  */
                    853: 
                    854:   if (current_binding_level == global_binding_level)
                    855:     my_friendly_assert (named_labels == NULL_TREE, 134);
                    856: 
                    857:   /* Reuse or create a struct for this binding level.  */
                    858: 
                    859: #if defined(DEBUG_CP_BINDING_LEVELS)
                    860:   if (0)
                    861: #else /* !defined(DEBUG_CP_BINDING_LEVELS) */
                    862:   if (free_binding_level)
                    863: #endif /* !defined(DEBUG_CP_BINDING_LEVELS) */
                    864:     {
                    865:       newlevel = free_binding_level;
                    866:       free_binding_level = free_binding_level->level_chain;
                    867:     }
                    868:   else
                    869:     {
                    870:       /* Create a new `struct binding_level'.  */
                    871:       newlevel = (struct binding_level *) xmalloc (sizeof (struct binding_level));
                    872:     }
                    873:   push_binding_level (newlevel, tag_transparent, keep_next_level_flag);
                    874:   GNU_xref_start_scope ((HOST_WIDE_INT) newlevel);
                    875:   keep_next_level_flag = 0;
                    876: }
                    877: 
                    878: void
                    879: pushlevel_temporary (tag_transparent)
                    880:      int tag_transparent;
                    881: {
                    882:   pushlevel (tag_transparent);
                    883:   current_binding_level->keep = 2;
                    884:   clear_last_expr ();
                    885: 
                    886:   /* Note we don't call push_momentary() here.  Otherwise, it would cause
                    887:      cleanups to be allocated on the momentary obstack, and they will be
                    888:      overwritten by the next statement.  */
                    889: 
                    890:   expand_start_bindings (0);
                    891: }
                    892: 
                    893: /* Exit a binding level.
                    894:    Pop the level off, and restore the state of the identifier-decl mappings
                    895:    that were in effect when this level was entered.
                    896: 
                    897:    If KEEP == 1, this level had explicit declarations, so
                    898:    and create a "block" (a BLOCK node) for the level
                    899:    to record its declarations and subblocks for symbol table output.
                    900: 
                    901:    If KEEP == 2, this level's subblocks go to the front,
                    902:    not the back of the current binding level.  This happens,
                    903:    for instance, when code for constructors and destructors
                    904:    need to generate code at the end of a function which must
                    905:    be moved up to the front of the function.
                    906: 
                    907:    If FUNCTIONBODY is nonzero, this level is the body of a function,
                    908:    so create a block as if KEEP were set and also clear out all
                    909:    label names.
                    910: 
                    911:    If REVERSE is nonzero, reverse the order of decls before putting
                    912:    them into the BLOCK.  */
                    913: 
                    914: tree
                    915: poplevel (keep, reverse, functionbody)
                    916:      int keep;
                    917:      int reverse;
                    918:      int functionbody;
                    919: {
                    920:   register tree link;
                    921:   /* The chain of decls was accumulated in reverse order.
                    922:      Put it into forward order, just for cleanliness.  */
                    923:   tree decls;
                    924:   int tmp = functionbody;
                    925:   int implicit_try_block = current_binding_level->parm_flag == 3;
                    926:   int real_functionbody = current_binding_level->keep == 2
                    927:     ? ((functionbody = 0), tmp) : functionbody;
                    928:   tree tags = functionbody >= 0 ? current_binding_level->tags : 0;
                    929:   tree subblocks = functionbody >= 0 ? current_binding_level->blocks : 0;
                    930:   tree block = NULL_TREE;
                    931:   tree decl;
                    932:   int block_previously_created;
                    933: 
                    934:   GNU_xref_end_scope ((HOST_WIDE_INT) current_binding_level,
                    935:                      (HOST_WIDE_INT) current_binding_level->level_chain,
                    936:                      current_binding_level->parm_flag,
                    937:                      current_binding_level->keep,
                    938:                      current_binding_level->tag_transparent);
                    939: 
                    940:   if (current_binding_level->keep == 1)
                    941:     keep = 1;
                    942: 
                    943:   /* This warning is turned off because it causes warnings for
                    944:      declarations like `extern struct foo *x'.  */
                    945: #if 0
                    946:   /* Warn about incomplete structure types in this level.  */
                    947:   for (link = tags; link; link = TREE_CHAIN (link))
                    948:     if (TYPE_SIZE (TREE_VALUE (link)) == NULL_TREE)
                    949:       {
                    950:        tree type = TREE_VALUE (link);
                    951:        char *errmsg;
                    952:        switch (TREE_CODE (type))
                    953:          {
                    954:          case RECORD_TYPE:
                    955:            errmsg = "`struct %s' incomplete in scope ending here";
                    956:            break;
                    957:          case UNION_TYPE:
                    958:            errmsg = "`union %s' incomplete in scope ending here";
                    959:            break;
                    960:          case ENUMERAL_TYPE:
                    961:            errmsg = "`enum %s' incomplete in scope ending here";
                    962:            break;
                    963:          }
                    964:        if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
                    965:          error (errmsg, IDENTIFIER_POINTER (TYPE_NAME (type)));
                    966:        else
                    967:          /* If this type has a typedef-name, the TYPE_NAME is a TYPE_DECL.  */
                    968:          error (errmsg, TYPE_NAME_STRING (type));
                    969:       }
                    970: #endif /* 0 */
                    971: 
                    972:   /* Get the decls in the order they were written.
                    973:      Usually current_binding_level->names is in reverse order.
                    974:      But parameter decls were previously put in forward order.  */
                    975: 
                    976:   if (reverse)
                    977:     current_binding_level->names
                    978:       = decls = nreverse (current_binding_level->names);
                    979:   else
                    980:     decls = current_binding_level->names;
                    981: 
                    982:   /* Output any nested inline functions within this block
                    983:      if they weren't already output.  */
                    984: 
                    985:   for (decl = decls; decl; decl = TREE_CHAIN (decl))
                    986:     if (TREE_CODE (decl) == FUNCTION_DECL
                    987:        && ! TREE_ASM_WRITTEN (decl)
                    988:        && DECL_INITIAL (decl) != NULL_TREE
                    989:        && TREE_ADDRESSABLE (decl))
                    990:       {
                    991:        /* If this decl was copied from a file-scope decl
                    992:           on account of a block-scope extern decl,
                    993:           propagate TREE_ADDRESSABLE to the file-scope decl.  */
                    994:        if (DECL_ABSTRACT_ORIGIN (decl) != NULL_TREE)
                    995:          TREE_ADDRESSABLE (DECL_ABSTRACT_ORIGIN (decl)) = 1;
                    996:        else
                    997:          {
                    998:            push_function_context ();
                    999:            output_inline_function (decl);
                   1000:            pop_function_context ();
                   1001:          }
                   1002:       }
                   1003: 
                   1004:   /* If there were any declarations or structure tags in that level,
                   1005:      or if this level is a function body,
                   1006:      create a BLOCK to record them for the life of this function.  */
                   1007: 
                   1008:   block = NULL_TREE;
                   1009:   block_previously_created = (current_binding_level->this_block != NULL_TREE);
                   1010:   if (block_previously_created)
                   1011:     block = current_binding_level->this_block;
                   1012:   else if (keep == 1 || functionbody)
                   1013:     block = make_node (BLOCK);
                   1014:   if (block != NULL_TREE)
                   1015:     {
                   1016:       BLOCK_VARS (block) = decls;
                   1017:       BLOCK_TYPE_TAGS (block) = tags;
                   1018:       BLOCK_SUBBLOCKS (block) = subblocks;
                   1019:       /* If we created the block earlier on, and we are just diddling it now,
                   1020:         then it already should have a proper BLOCK_END_NOTE value associated
                   1021:         with it, so avoid trashing that.  Otherwise, for a new block, install
                   1022:         a new BLOCK_END_NOTE value.  */
                   1023:       if (! block_previously_created)
                   1024:        remember_end_note (block);
                   1025:     }
                   1026: 
                   1027:   /* In each subblock, record that this is its superior.  */
                   1028: 
                   1029:   if (keep >= 0)
                   1030:     for (link = subblocks; link; link = TREE_CHAIN (link))
                   1031:       BLOCK_SUPERCONTEXT (link) = block;
                   1032: 
                   1033:   /* Clear out the meanings of the local variables of this level.  */
                   1034: 
                   1035:   for (link = decls; link; link = TREE_CHAIN (link))
                   1036:     {
                   1037:       if (DECL_NAME (link) != NULL_TREE)
                   1038:        {
                   1039:          /* If the ident. was used or addressed via a local extern decl,
                   1040:             don't forget that fact.  */
                   1041:          if (DECL_EXTERNAL (link))
                   1042:            {
                   1043:              if (TREE_USED (link))
                   1044:                TREE_USED (DECL_ASSEMBLER_NAME (link)) = 1;
                   1045:              if (TREE_ADDRESSABLE (link))
                   1046:                TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (link)) = 1;
                   1047:            }
                   1048:          IDENTIFIER_LOCAL_VALUE (DECL_NAME (link)) = NULL_TREE;
                   1049:        }
                   1050:     }
                   1051: 
                   1052:   /* Restore all name-meanings of the outer levels
                   1053:      that were shadowed by this level.  */
                   1054: 
                   1055:   for (link = current_binding_level->shadowed; link; link = TREE_CHAIN (link))
                   1056:     IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
                   1057:   for (link = current_binding_level->class_shadowed;
                   1058:        link; link = TREE_CHAIN (link))
                   1059:     IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
                   1060:   for (link = current_binding_level->type_shadowed;
                   1061:        link; link = TREE_CHAIN (link))
                   1062:     IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
                   1063: 
                   1064:   /* If the level being exited is the top level of a function,
                   1065:      check over all the labels.  */
                   1066: 
                   1067:   if (functionbody)
                   1068:     {
                   1069:       /* If this is the top level block of a function,
                   1070:          the vars are the function's parameters.
                   1071:          Don't leave them in the BLOCK because they are
                   1072:          found in the FUNCTION_DECL instead.  */
                   1073: 
                   1074:       BLOCK_VARS (block) = 0;
                   1075: 
                   1076:       /* Clear out the definitions of all label names,
                   1077:         since their scopes end here.  */
                   1078: 
                   1079:       for (link = named_labels; link; link = TREE_CHAIN (link))
                   1080:        {
                   1081:          register tree label = TREE_VALUE (link);
                   1082: 
                   1083:          if (DECL_INITIAL (label) == NULL_TREE)
                   1084:            {
                   1085:              cp_error_at ("label `%D' used but not defined", label);
                   1086:              /* Avoid crashing later.  */
                   1087:              define_label (input_filename, 1, DECL_NAME (label));
                   1088:            }
                   1089:          else if (warn_unused && !TREE_USED (label))
                   1090:            cp_warning_at ("label `%D' defined but not used", label);
                   1091:          SET_IDENTIFIER_LABEL_VALUE (DECL_NAME (label), NULL_TREE);
                   1092: 
                   1093:           /* Put the labels into the "variables" of the
                   1094:              top-level block, so debugger can see them.  */
                   1095:           TREE_CHAIN (label) = BLOCK_VARS (block);
                   1096:           BLOCK_VARS (block) = label;
                   1097:        }
                   1098: 
                   1099:       named_labels = NULL_TREE;
                   1100:     }
                   1101: 
                   1102:   /* Any uses of undefined labels now operate under constraints
                   1103:      of next binding contour.  */
                   1104:   {
                   1105:     struct binding_level *level_chain;
                   1106:     level_chain = current_binding_level->level_chain;
                   1107:     if (level_chain)
                   1108:       {
                   1109:        tree labels;
                   1110:        for (labels = named_label_uses; labels; labels = TREE_CHAIN (labels))
                   1111:          if (TREE_TYPE (labels) == (tree)current_binding_level)
                   1112:            {
                   1113:              TREE_TYPE (labels) = (tree)level_chain;
                   1114:              TREE_PURPOSE (labels) = level_chain->names;
                   1115:            }
                   1116:       }
                   1117:   }
                   1118: 
                   1119:   tmp = current_binding_level->keep;
                   1120: 
                   1121:   pop_binding_level ();
                   1122:   if (functionbody)
                   1123:     DECL_INITIAL (current_function_decl) = block;
                   1124:   else if (block)
                   1125:     {
                   1126:       if (!block_previously_created)
                   1127:         current_binding_level->blocks
                   1128:           = chainon (current_binding_level->blocks, block);
                   1129:     }
                   1130:   /* If we did not make a block for the level just exited,
                   1131:      any blocks made for inner levels
                   1132:      (since they cannot be recorded as subblocks in that level)
                   1133:      must be carried forward so they will later become subblocks
                   1134:      of something else.  */
                   1135:   else if (subblocks)
                   1136:     {
                   1137:       if (keep == 2)
                   1138:        current_binding_level->blocks
                   1139:          = chainon (subblocks, current_binding_level->blocks);
                   1140:       else
                   1141:        current_binding_level->blocks
                   1142:          = chainon (current_binding_level->blocks, subblocks);
                   1143:     }
                   1144: 
                   1145:   /* Take care of compiler's internal binding structures.  */
                   1146:   if (tmp == 2 && !implicit_try_block)
                   1147:     {
                   1148: #if 0
                   1149:       /* We did not call push_momentary for this
                   1150:         binding contour, so there is nothing to pop.  */
                   1151:       pop_momentary ();
                   1152: #endif
                   1153:       expand_end_bindings (getdecls (), keep, 1);
                   1154:       /* Each and every BLOCK node created here in `poplevel' is important
                   1155:         (e.g. for proper debugging information) so if we created one
                   1156:         earlier, mark it as "used".  */
                   1157:       if (block)
                   1158:        TREE_USED (block) = 1;
                   1159:       block = poplevel (keep, reverse, real_functionbody);
                   1160:     }
                   1161: 
                   1162:   /* Each and every BLOCK node created here in `poplevel' is important
                   1163:      (e.g. for proper debugging information) so if we created one
                   1164:      earlier, mark it as "used".  */
                   1165:   if (block)
                   1166:     TREE_USED (block) = 1;
                   1167:   return block;
                   1168: }
                   1169: 
                   1170: /* Delete the node BLOCK from the current binding level.
                   1171:    This is used for the block inside a stmt expr ({...})
                   1172:    so that the block can be reinserted where appropriate.  */
                   1173: 
                   1174: void
                   1175: delete_block (block)
                   1176:      tree block;
                   1177: {
                   1178:   tree t;
                   1179:   if (current_binding_level->blocks == block)
                   1180:     current_binding_level->blocks = TREE_CHAIN (block);
                   1181:   for (t = current_binding_level->blocks; t;)
                   1182:     {
                   1183:       if (TREE_CHAIN (t) == block)
                   1184:        TREE_CHAIN (t) = TREE_CHAIN (block);
                   1185:       else
                   1186:        t = TREE_CHAIN (t);
                   1187:     }
                   1188:   TREE_CHAIN (block) = NULL_TREE;
                   1189:   /* Clear TREE_USED which is always set by poplevel.
                   1190:      The flag is set again if insert_block is called.  */
                   1191:   TREE_USED (block) = 0;
                   1192: }
                   1193: 
                   1194: /* Insert BLOCK at the end of the list of subblocks of the
                   1195:    current binding level.  This is used when a BIND_EXPR is expanded,
                   1196:    to handle the BLOCK node inside the BIND_EXPR.  */
                   1197: 
                   1198: void
                   1199: insert_block (block)
                   1200:      tree block;
                   1201: {
                   1202:   TREE_USED (block) = 1;
                   1203:   current_binding_level->blocks
                   1204:     = chainon (current_binding_level->blocks, block);
                   1205: }
                   1206: 
                   1207: /* Add BLOCK to the current list of blocks for this binding contour.  */
                   1208: void
                   1209: add_block_current_level (block)
                   1210:      tree block;
                   1211: {
                   1212:   current_binding_level->blocks
                   1213:     = chainon (current_binding_level->blocks, block);
                   1214: }
                   1215: 
                   1216: /* Set the BLOCK node for the innermost scope
                   1217:    (the one we are currently in).  */
                   1218: 
                   1219: void
                   1220: set_block (block)
                   1221:     register tree block;
                   1222: {
                   1223:   current_binding_level->this_block = block;
                   1224: }
                   1225: 
                   1226: /* Do a pushlevel for class declarations.  */
                   1227: void
                   1228: pushlevel_class ()
                   1229: {
                   1230:   register struct binding_level *newlevel;
                   1231: 
                   1232:   /* Reuse or create a struct for this binding level.  */
                   1233: #if defined(DEBUG_CP_BINDING_LEVELS)
                   1234:   if (0)
                   1235: #else /* !defined(DEBUG_CP_BINDING_LEVELS) */
                   1236:   if (free_binding_level)
                   1237: #endif /* !defined(DEBUG_CP_BINDING_LEVELS) */
                   1238:     {
                   1239:       newlevel = free_binding_level;
                   1240:       free_binding_level = free_binding_level->level_chain;
                   1241:     }
                   1242:   else
                   1243:     {
                   1244:       /* Create a new `struct binding_level'.  */
                   1245:       newlevel = (struct binding_level *) xmalloc (sizeof (struct binding_level));
                   1246:     }
                   1247: 
                   1248: #if defined(DEBUG_CP_BINDING_LEVELS)
                   1249:   is_class_level = 1;
                   1250: #endif /* defined(DEBUG_CP_BINDING_LEVELS) */
                   1251: 
                   1252:   push_binding_level (newlevel, 0, 0);
                   1253: 
                   1254:   decl_stack = push_decl_level (decl_stack, &decl_obstack);
                   1255:   class_binding_level = current_binding_level;
                   1256:   class_binding_level->parm_flag = 2;
                   1257:   /* We have just pushed into a new binding level.  Now, fake out the rest
                   1258:      of the compiler.  Set the `current_binding_level' back to point to
                   1259:      the most closely containing non-class binding level.  */
                   1260:   do
                   1261:     {
                   1262:       current_binding_level = current_binding_level->level_chain;
                   1263:     }
                   1264:   while (current_binding_level->parm_flag == 2);
                   1265: }
                   1266: 
                   1267: /* ...and a poplevel for class declarations.  */
                   1268: tree
                   1269: poplevel_class ()
                   1270: {
                   1271:   register struct binding_level *level = class_binding_level;
                   1272:   tree block = NULL_TREE;
                   1273:   tree shadowed;
                   1274: 
                   1275:   my_friendly_assert (level != 0, 354);
                   1276:   
                   1277:   decl_stack = pop_decl_level (decl_stack);
                   1278: #if !NEW_CLASS_SCOPING
                   1279:   for (shadowed = level->shadowed; shadowed; shadowed = TREE_CHAIN (shadowed))
                   1280:     IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (shadowed)) = TREE_VALUE (shadowed);
                   1281:   for (shadowed = level->class_shadowed; shadowed; shadowed = TREE_CHAIN (shadowed))
                   1282:     IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (shadowed)) = TREE_VALUE (shadowed);
                   1283:   for (shadowed = level->type_shadowed; shadowed; shadowed = TREE_CHAIN (shadowed))
                   1284:     IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (shadowed)) = TREE_VALUE (shadowed);
                   1285: #else
                   1286:   for (shadowed = level->shadowed; shadowed; shadowed = TREE_CHAIN (shadowed))
                   1287:     IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (shadowed)) = TREE_VALUE (shadowed);
                   1288:   /* If we're leaving a toplevel class, don't bother to do the setting
                   1289:      of IDENTIFER_CLASS_VALUE to NULL_TREE, since first of all this slot
                   1290:      shouldn't even be used when current_class_type isn't set, and second,
                   1291:      if we don't touch it here, we're able to use the caching effect if the
                   1292:      next time we're entering a class scope, it is the same class.  */
                   1293:   if (current_class_depth != 1)
                   1294:     for (shadowed = level->class_shadowed;
                   1295:         shadowed;
                   1296:         shadowed = TREE_CHAIN (shadowed))
                   1297:       IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (shadowed)) = TREE_VALUE (shadowed);
                   1298:   else
                   1299:     /* Remember to save what IDENTIFIER's were bound in this scope so we
                   1300:        can recover from cache misses.  */
                   1301:     previous_class_values = class_binding_level->class_shadowed;
                   1302:   for (shadowed = level->type_shadowed;
                   1303:        shadowed;
                   1304:        shadowed = TREE_CHAIN (shadowed))
                   1305:     IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (shadowed)) = TREE_VALUE (shadowed);
                   1306: #endif
                   1307: 
                   1308:   GNU_xref_end_scope ((HOST_WIDE_INT) class_binding_level,
                   1309:                      (HOST_WIDE_INT) class_binding_level->level_chain,
                   1310:                      class_binding_level->parm_flag,
                   1311:                      class_binding_level->keep,
                   1312:                      class_binding_level->tag_transparent);
                   1313: 
                   1314:   if (class_binding_level->parm_flag != 2)
                   1315:     class_binding_level = (struct binding_level *)0;
                   1316: 
                   1317:   /* Now, pop out of the the binding level which we created up in the
                   1318:      `pushlevel_class' routine.  */
                   1319: #if defined(DEBUG_CP_BINDING_LEVELS)
                   1320:   is_class_level = 1;
                   1321: #endif /* defined(DEBUG_CP_BINDING_LEVELS) */
                   1322: 
                   1323:   pop_binding_level ();
                   1324: 
                   1325:   return block;
                   1326: }
                   1327: 
                   1328: /* For debugging.  */
                   1329: int no_print_functions = 0;
                   1330: int no_print_builtins = 0;
                   1331: 
                   1332: void
                   1333: print_binding_level (lvl)
                   1334:      struct binding_level *lvl;
                   1335: {
                   1336:   tree t;
                   1337:   int i = 0, len;
                   1338:   fprintf (stderr, " blocks=");
                   1339:   fprintf (stderr, HOST_PTR_PRINTF, lvl->blocks);
                   1340:   fprintf (stderr, " n_incomplete=%d parm_flag=%d keep=%d",
                   1341:           lvl->n_incomplete, lvl->parm_flag, lvl->keep);
                   1342:   if (lvl->tag_transparent)
                   1343:     fprintf (stderr, " tag-transparent");
                   1344:   if (lvl->more_cleanups_ok)
                   1345:     fprintf (stderr, " more-cleanups-ok");
                   1346:   if (lvl->have_cleanups)
                   1347:     fprintf (stderr, " have-cleanups");
                   1348:   if (lvl->more_exceptions_ok)
                   1349:     fprintf (stderr, " more-exceptions-ok");
                   1350:   if (lvl->have_exceptions)
                   1351:     fprintf (stderr, " have-exceptions");
                   1352:   fprintf (stderr, "\n");
                   1353:   if (lvl->names)
                   1354:     {
                   1355:       fprintf (stderr, " names:\t");
                   1356:       /* We can probably fit 3 names to a line?  */
                   1357:       for (t = lvl->names; t; t = TREE_CHAIN (t))
                   1358:        {
                   1359:          if (no_print_functions && (TREE_CODE(t) == FUNCTION_DECL)) 
                   1360:            continue;
                   1361:          if (no_print_builtins
                   1362:              && (TREE_CODE(t) == TYPE_DECL)
                   1363:              && (!strcmp(DECL_SOURCE_FILE(t),"<built-in>")))
                   1364:            continue;
                   1365: 
                   1366:          /* Function decls tend to have longer names.  */
                   1367:          if (TREE_CODE (t) == FUNCTION_DECL)
                   1368:            len = 3;
                   1369:          else
                   1370:            len = 2;
                   1371:          i += len;
                   1372:          if (i > 6)
                   1373:            {
                   1374:              fprintf (stderr, "\n\t");
                   1375:              i = len;
                   1376:            }
                   1377:          print_node_brief (stderr, "", t, 0);
                   1378:          if (TREE_CODE (t) == ERROR_MARK)
                   1379:            break;
                   1380:        }
                   1381:       if (i)
                   1382:         fprintf (stderr, "\n");
                   1383:     }
                   1384:   if (lvl->tags)
                   1385:     {
                   1386:       fprintf (stderr, " tags:\t");
                   1387:       i = 0;
                   1388:       for (t = lvl->tags; t; t = TREE_CHAIN (t))
                   1389:        {
                   1390:          if (TREE_PURPOSE (t) == NULL_TREE)
                   1391:            len = 3;
                   1392:          else if (TREE_PURPOSE (t) == TYPE_IDENTIFIER (TREE_VALUE (t)))
                   1393:            len = 2;
                   1394:          else
                   1395:            len = 4;
                   1396:          i += len;
                   1397:          if (i > 5)
                   1398:            {
                   1399:              fprintf (stderr, "\n\t");
                   1400:              i = len;
                   1401:            }
                   1402:          if (TREE_PURPOSE (t) == NULL_TREE)
                   1403:            {
                   1404:              print_node_brief (stderr, "<unnamed-typedef", TREE_VALUE (t), 0);
                   1405:              fprintf (stderr, ">");
                   1406:            }
                   1407:          else if (TREE_PURPOSE (t) == TYPE_IDENTIFIER (TREE_VALUE (t)))
                   1408:            print_node_brief (stderr, "", TREE_VALUE (t), 0);
                   1409:          else
                   1410:            {
                   1411:              print_node_brief (stderr, "<typedef", TREE_PURPOSE (t), 0);
                   1412:              print_node_brief (stderr, "", TREE_VALUE (t), 0);
                   1413:              fprintf (stderr, ">");
                   1414:            }
                   1415:        }
                   1416:       if (i)
                   1417:        fprintf (stderr, "\n");
                   1418:     }
                   1419:   if (lvl->shadowed)
                   1420:     {
                   1421:       fprintf (stderr, " shadowed:");
                   1422:       for (t = lvl->shadowed; t; t = TREE_CHAIN (t))
                   1423:        {
                   1424:          fprintf (stderr, " %s ", IDENTIFIER_POINTER (TREE_PURPOSE (t)));
                   1425:        }
                   1426:       fprintf (stderr, "\n");
                   1427:     }
                   1428:   if (lvl->class_shadowed)
                   1429:     {
                   1430:       fprintf (stderr, " class-shadowed:");
                   1431:       for (t = lvl->class_shadowed; t; t = TREE_CHAIN (t))
                   1432:        {
                   1433:          fprintf (stderr, " %s ", IDENTIFIER_POINTER (TREE_PURPOSE (t)));
                   1434:        }
                   1435:       fprintf (stderr, "\n");
                   1436:     }
                   1437:   if (lvl->type_shadowed)
                   1438:     {
                   1439:       fprintf (stderr, " type-shadowed:");
                   1440:       for (t = lvl->type_shadowed; t; t = TREE_CHAIN (t))
                   1441:         {
                   1442: #if 0
                   1443:           fprintf (stderr, "\n\t");
                   1444:           print_node_brief (stderr, "<", TREE_PURPOSE (t), 0);
                   1445:           if (TREE_VALUE (t))
                   1446:             print_node_brief (stderr, " ", TREE_VALUE (t), 0);
                   1447:           else
                   1448:             fprintf (stderr, " (none)");
                   1449:           fprintf (stderr, ">");
                   1450: #else
                   1451:          fprintf (stderr, " %s ", IDENTIFIER_POINTER (TREE_PURPOSE (t)));
                   1452: #endif
                   1453:         }
                   1454:       fprintf (stderr, "\n");
                   1455:     }
                   1456: }
                   1457: 
                   1458: void
                   1459: print_other_binding_stack (stack)
                   1460:      struct binding_level *stack;
                   1461: {
                   1462:   struct binding_level *level;
                   1463:   for (level = stack; level != global_binding_level; level = level->level_chain)
                   1464:     {
                   1465:       fprintf (stderr, "binding level ");
                   1466:       fprintf (stderr, HOST_PTR_PRINTF, level);
                   1467:       fprintf (stderr, "\n");
                   1468:       print_binding_level (level);
                   1469:     }
                   1470: }
                   1471: 
                   1472: void
                   1473: print_binding_stack ()
                   1474: {
                   1475:   struct binding_level *b;
                   1476:   fprintf (stderr, "current_binding_level=");
                   1477:   fprintf (stderr, HOST_PTR_PRINTF, current_binding_level);
                   1478:   fprintf (stderr, "\nclass_binding_level=");
                   1479:   fprintf (stderr, HOST_PTR_PRINTF, class_binding_level);
                   1480:   fprintf (stderr, "\nglobal_binding_level=");
                   1481:   fprintf (stderr, HOST_PTR_PRINTF, global_binding_level);
                   1482:   fprintf (stderr, "\n");
                   1483:   if (class_binding_level)
                   1484:     {
                   1485:       for (b = class_binding_level; b; b = b->level_chain)
                   1486:        if (b == current_binding_level)
                   1487:          break;
                   1488:       if (b)
                   1489:        b = class_binding_level;
                   1490:       else
                   1491:        b = current_binding_level;
                   1492:     }
                   1493:   else
                   1494:     b = current_binding_level;
                   1495:   print_other_binding_stack (b);
                   1496:   fprintf (stderr, "global:\n");
                   1497:   print_binding_level (global_binding_level);
                   1498: }
                   1499: 
                   1500: /* Subroutines for reverting temporarily to top-level for instantiation
                   1501:    of templates and such.  We actually need to clear out the class- and
                   1502:    local-value slots of all identifiers, so that only the global values
                   1503:    are at all visible.  Simply setting current_binding_level to the global
                   1504:    scope isn't enough, because more binding levels may be pushed.  */
                   1505: struct saved_scope {
                   1506:   struct binding_level *old_binding_level;
                   1507:   tree old_bindings;
                   1508:   struct saved_scope *prev;
                   1509:   tree class_name, class_type, class_decl, function_decl;
                   1510:   struct binding_level *class_bindings;
                   1511:   tree previous_class_type;
                   1512: };
                   1513: static struct saved_scope *current_saved_scope;
                   1514: extern tree prev_class_type;
                   1515: 
                   1516: void
                   1517: push_to_top_level ()
                   1518: {
                   1519:   struct saved_scope *s =
                   1520:     (struct saved_scope *) xmalloc (sizeof (struct saved_scope));
                   1521:   struct binding_level *b = current_binding_level;
                   1522:   tree old_bindings = NULL_TREE;
                   1523: 
                   1524:   /* Have to include global_binding_level, because class-level decls
                   1525:      aren't listed anywhere useful.  */
                   1526:   for (; b; b = b->level_chain)
                   1527:     {
                   1528:       tree t;
                   1529:       for (t = b->names; t; t = TREE_CHAIN (t))
                   1530:        if (b != global_binding_level)
                   1531:          {
                   1532:            tree binding, t1, t2 = t;
                   1533:            tree id = DECL_ASSEMBLER_NAME (t2);
                   1534: 
                   1535:            if (!id
                   1536:                || (!IDENTIFIER_LOCAL_VALUE (id)
                   1537:                    && !IDENTIFIER_CLASS_VALUE (id)))
                   1538:              continue;
                   1539: 
                   1540:            for (t1 = old_bindings; t1; t1 = TREE_CHAIN (t1))
                   1541:              if (TREE_VEC_ELT (t1, 0) == id)
                   1542:                goto skip_it;
                   1543:            
                   1544:            binding = make_tree_vec (4);
                   1545:            if (id)
                   1546:              {
                   1547:                my_friendly_assert (TREE_CODE (id) == IDENTIFIER_NODE, 135);
                   1548:                TREE_VEC_ELT (binding, 0) = id;
                   1549:                TREE_VEC_ELT (binding, 1) = IDENTIFIER_TYPE_VALUE (id);
                   1550:                TREE_VEC_ELT (binding, 2) = IDENTIFIER_LOCAL_VALUE (id);
                   1551:                TREE_VEC_ELT (binding, 3) = IDENTIFIER_CLASS_VALUE (id);
                   1552:                IDENTIFIER_LOCAL_VALUE (id) = NULL_TREE;
                   1553:                IDENTIFIER_CLASS_VALUE (id) = NULL_TREE;
                   1554: #if !NEW_CLASS_SCOPING
                   1555:                /* The type unwinding below should take care of this.  */
                   1556:                adjust_type_value (id);
                   1557: #endif
                   1558:              }
                   1559:            TREE_CHAIN (binding) = old_bindings;
                   1560:            old_bindings = binding;
                   1561:            skip_it:
                   1562:            ;
                   1563:          }
                   1564:       /* Unwind type-value slots back to top level.  */
                   1565:       if (b != global_binding_level)
                   1566:         for (t = b->type_shadowed; t; t = TREE_CHAIN (t))
                   1567:           SET_IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (t), TREE_VALUE (t));
                   1568:     }
                   1569: 
                   1570:   s->old_binding_level = current_binding_level;
                   1571:   current_binding_level = global_binding_level;
                   1572: 
                   1573:   s->class_name = current_class_name;
                   1574:   s->class_type = current_class_type;
                   1575:   s->class_decl = current_class_decl;
                   1576:   s->function_decl = current_function_decl;
                   1577:   s->class_bindings = class_binding_level;
                   1578:   s->previous_class_type = previous_class_type;
                   1579:   current_class_name = current_class_type = current_class_decl = NULL_TREE;
                   1580:   current_function_decl = NULL_TREE;
                   1581:   class_binding_level = (struct binding_level *)0;
                   1582:   previous_class_type = NULL_TREE;
                   1583: 
                   1584:   s->prev = current_saved_scope;
                   1585:   s->old_bindings = old_bindings;
                   1586:   current_saved_scope = s;
                   1587: }
                   1588: 
                   1589: void
                   1590: pop_from_top_level ()
                   1591: {
                   1592:   struct saved_scope *s = current_saved_scope;
                   1593:   tree t;
                   1594: 
                   1595:   if (previous_class_type)
                   1596:     previous_class_type = NULL_TREE;
                   1597: 
                   1598:   current_binding_level = s->old_binding_level;
                   1599:   current_saved_scope = s->prev;
                   1600:   for (t = s->old_bindings; t; t = TREE_CHAIN (t))
                   1601:     {
                   1602:       tree id = TREE_VEC_ELT (t, 0);
                   1603:       if (id)
                   1604:        {
                   1605:          IDENTIFIER_TYPE_VALUE (id) = TREE_VEC_ELT (t, 1);
                   1606:          IDENTIFIER_LOCAL_VALUE (id) = TREE_VEC_ELT (t, 2);
                   1607:          IDENTIFIER_CLASS_VALUE (id) = TREE_VEC_ELT (t, 3);
                   1608:        }
                   1609:     }
                   1610:   current_class_name = s->class_name;
                   1611:   current_class_type = s->class_type;
                   1612:   current_class_decl = s->class_decl;
                   1613:   if (current_class_type)
                   1614:     C_C_D = CLASSTYPE_INST_VAR (current_class_type);
                   1615:   else
                   1616:     C_C_D = NULL_TREE;
                   1617:   current_function_decl = s->function_decl;
                   1618:   class_binding_level = s->class_bindings;
                   1619:   previous_class_type = s->previous_class_type;
                   1620:   free (s);
                   1621: }
                   1622: 
                   1623: /* Push a definition of struct, union or enum tag "name".
                   1624:    "type" should be the type node.
                   1625:    We assume that the tag "name" is not already defined.
                   1626: 
                   1627:    Note that the definition may really be just a forward reference.
                   1628:    In that case, the TYPE_SIZE will be a NULL_TREE.
                   1629: 
                   1630:    C++ gratuitously puts all these tags in the name space. */
                   1631: 
                   1632: /* When setting the IDENTIFIER_TYPE_VALUE field of an identifier ID,
                   1633:    record the shadowed value for this binding contour.  TYPE is
                   1634:    the type that ID maps to.  */
                   1635: void
                   1636: set_identifier_type_value (id, type)
                   1637:      tree id;
                   1638:      tree type;
                   1639: {
                   1640: #if NEW_CLASS_SCOPING
                   1641:   if (class_binding_level)
                   1642:     {
                   1643:       tree old_type_value = IDENTIFIER_TYPE_VALUE (id);
                   1644:       class_binding_level->type_shadowed
                   1645:        = tree_cons (id, old_type_value, class_binding_level->type_shadowed);
                   1646:     }      
                   1647:   else if (current_binding_level != global_binding_level)
                   1648:     {
                   1649:       tree old_type_value = IDENTIFIER_TYPE_VALUE (id);
                   1650:       current_binding_level->type_shadowed
                   1651:        = tree_cons (id, old_type_value, current_binding_level->type_shadowed);
                   1652:     }
                   1653: #else
                   1654:   if (current_binding_level != global_binding_level)
                   1655:     {
                   1656:       tree old_type_value = IDENTIFIER_TYPE_VALUE (id);
                   1657:       current_binding_level->type_shadowed
                   1658:        = tree_cons (id, old_type_value, current_binding_level->type_shadowed);
                   1659:     }
                   1660:   else if (class_binding_level)
                   1661:     {
                   1662:       tree old_type_value = IDENTIFIER_TYPE_VALUE (id);
                   1663:       class_binding_level->type_shadowed
                   1664:        = tree_cons (id, old_type_value, class_binding_level->type_shadowed);
                   1665:     }      
                   1666: #endif
                   1667:   SET_IDENTIFIER_TYPE_VALUE (id, type);
                   1668: }
                   1669: 
                   1670: /*
                   1671:  * local values can need to be shadowed too, but it only happens
                   1672:  * explicitly from pushdecl, in support of nested enums.
                   1673:  */
                   1674: void
                   1675: set_identifier_local_value (id, type)
                   1676:      tree id;
                   1677:      tree type;
                   1678: {
                   1679:   if (current_binding_level != global_binding_level)
                   1680:     {
                   1681:       tree old_local_value = IDENTIFIER_LOCAL_VALUE (id);
                   1682:       current_binding_level->shadowed
                   1683:        = tree_cons (id, old_local_value, current_binding_level->shadowed);
                   1684:     }
                   1685:   else if (class_binding_level)
                   1686:     {
                   1687:       tree old_local_value = IDENTIFIER_LOCAL_VALUE (id);
                   1688:       class_binding_level->shadowed
                   1689:        = tree_cons (id, old_local_value, class_binding_level->shadowed);
                   1690:     }      
                   1691:   IDENTIFIER_LOCAL_VALUE (id) = type;
                   1692: 
                   1693: #if NEW_CLASS_SCOPING
                   1694:   /* If this is a TYPE_DECL, push it into the type value slot.  */
                   1695:   if (TREE_CODE (type) == TYPE_DECL)
                   1696:     set_identifier_type_value (id, TREE_TYPE (type));
                   1697: #endif
                   1698: }
                   1699: 
                   1700: /* Subroutine "set_nested_typename" builds the nested-typename of
                   1701:    the type decl in question.  (Argument CLASSNAME can actually be
                   1702:    a function as well, if that's the smallest containing scope.)  */
                   1703: 
                   1704: static void
                   1705: set_nested_typename (decl, classname, name, type)
                   1706:      tree decl, classname, name, type;
                   1707: {
                   1708:   my_friendly_assert (TREE_CODE (decl) == TYPE_DECL, 136);
                   1709:   if (classname != NULL_TREE)
                   1710:     {
                   1711:       char *buf;
                   1712:       my_friendly_assert (TREE_CODE (classname) == IDENTIFIER_NODE, 137);
                   1713:       my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE, 138);
                   1714:       buf = (char *) alloca (4 + IDENTIFIER_LENGTH (classname)
                   1715:                             + IDENTIFIER_LENGTH (name));
                   1716:       sprintf (buf, "%s::%s", IDENTIFIER_POINTER (classname),
                   1717:               IDENTIFIER_POINTER (name));
                   1718:       DECL_NESTED_TYPENAME (decl) = get_identifier (buf);
                   1719: 
                   1720:       /* When NEW_CLASS_SCOPING is set to 1:
                   1721: 
                   1722:         This is a special usage of IDENTIFIER_TYPE_VALUE which have no
                   1723:         correspondence in any binding_level.  This is ok since the
                   1724:         DECL_NESTED_TYPENAME is just a convenience identifier whose
                   1725:         IDENTIFIER_TYPE_VALUE will remain constant from now on.  */
                   1726:       SET_IDENTIFIER_TYPE_VALUE (DECL_NESTED_TYPENAME (decl), type);
                   1727:     }
                   1728:   else
                   1729:     DECL_NESTED_TYPENAME (decl) = name;
                   1730: }
                   1731: 
                   1732: #if 0 /* not yet, should get fixed properly later */
                   1733: /* Create a TYPE_DECL node with the correct DECL_ASSEMBLER_NAME.
                   1734:    Other routines shouldn't use build_decl directly; they'll produce
                   1735:    incorrect results with `-g' unless they duplicate this code.
                   1736: 
                   1737:    This is currently needed mainly for dbxout.c, but we can make
                   1738:    use of it in cp-method.c later as well.  */
                   1739: tree
                   1740: make_type_decl (name, type)
                   1741:      tree name, type;
                   1742: {
                   1743:   tree decl, id;
                   1744:   decl = build_decl (TYPE_DECL, name, type);
                   1745:   if (TYPE_NAME (type) == name)
                   1746:     /* Class/union/enum definition, or a redundant typedef for same.  */
                   1747:     {
                   1748:       id = get_identifier (build_overload_name (type, 1, 1));
                   1749:       DECL_ASSEMBLER_NAME (decl) = id;
                   1750:     }
                   1751:   else if (TYPE_NAME (type) != NULL_TREE)
                   1752:     /* Explicit typedef, or implicit typedef for template expansion.  */
                   1753:     DECL_ASSEMBLER_NAME (decl) = DECL_ASSEMBLER_NAME (TYPE_NAME (type));
                   1754:   else
                   1755:     {
                   1756:       /* XXX: Typedef for unnamed struct; some other situations.
                   1757:         TYPE_NAME is null; what's right here?  */
                   1758:     }
                   1759:   return decl;
                   1760: }
                   1761: #endif
                   1762: 
                   1763: void
                   1764: pushtag (name, type)
                   1765:      tree name, type;
                   1766: {
                   1767:   register struct binding_level *b;
                   1768: 
                   1769:   if (class_binding_level)
                   1770:     b = class_binding_level;
                   1771:   else
                   1772:     {
                   1773:       b = current_binding_level;
                   1774:       while (b->tag_transparent) b = b->level_chain;
                   1775:     }
                   1776: 
                   1777:   if (b == global_binding_level)
                   1778:     b->tags = perm_tree_cons (name, type, b->tags);
                   1779:   else
                   1780:     b->tags = saveable_tree_cons (name, type, b->tags);
                   1781: 
                   1782:   if (name)
                   1783:     {
                   1784:       /* Record the identifier as the type's name if it has none.  */
                   1785: 
                   1786:       if (TYPE_NAME (type) == NULL_TREE)
                   1787:         TYPE_NAME (type) = name;
                   1788:       
                   1789:       /* Do C++ gratuitous typedefing.  */
                   1790:       if (IDENTIFIER_TYPE_VALUE (name) != type
                   1791:          && (TREE_CODE (type) != RECORD_TYPE
                   1792:              || class_binding_level == (struct binding_level *)0
                   1793:              || !CLASSTYPE_DECLARED_EXCEPTION (type)))
                   1794:         {
                   1795:           register tree d;
                   1796:          if (current_class_type == NULL_TREE
                   1797:              || TYPE_SIZE (current_class_type) != NULL_TREE)
                   1798:            {
                   1799:              if (current_lang_name == lang_name_cplusplus)
                   1800:                d = lookup_nested_type (type, current_class_type ? TYPE_NAME (current_class_type) : NULL_TREE);
                   1801:              else
                   1802:                d = NULL_TREE;
                   1803: 
                   1804:              if (d == NULL_TREE)
                   1805:                {
                   1806: #if 0 /* not yet, should get fixed properly later */
                   1807:                  d = make_type_decl (name, type);
                   1808:                  DECL_ASSEMBLER_NAME (d) = get_identifier (build_overload_name (type, 1, 1));
                   1809: #else
                   1810:                  d = build_decl (TYPE_DECL, name, type);
                   1811:                  DECL_ASSEMBLER_NAME (d) = get_identifier (build_overload_name (type, 1, 1));
                   1812: #endif
                   1813: #ifdef DWARF_DEBUGGING_INFO
                   1814:                  if (write_symbols == DWARF_DEBUG)
                   1815:                    {
                   1816:                      /* Mark the TYPE_DECL node we created just above as an
                   1817:                         gratuitous one.  We need to do this so that dwarfout.c
                   1818:                         will understand that it is not supposed to output a
                   1819:                         TAG_typedef DIE  for it. */
                   1820:                      DECL_IGNORED_P (d) = 1;
                   1821:                    }
                   1822: #endif /* DWARF_DEBUGGING_INFO */
                   1823:                  set_identifier_type_value (name, type);
                   1824:                }
                   1825:              else
                   1826:                d = TYPE_NAME (d);
                   1827: 
                   1828:              /* If it is anonymous, then we are called from pushdecl,
                   1829:                 and we don't want to infinitely recurse.  Also, if the
                   1830:                 name is already in scope, we don't want to push it
                   1831:                 again--pushdecl is only for pushing new decls.  */
                   1832:              if (! ANON_AGGRNAME_P (name)
                   1833: #ifdef OBJCPLUS
                   1834:                  /* we only want this behavior when doing c++ */
                   1835:                  && current_lang_name == lang_name_cplusplus
                   1836: #endif
                   1837:                  && TYPE_NAME (type)
                   1838:                  && (TREE_CODE (TYPE_NAME (type)) != TYPE_DECL
                   1839:                      || lookup_name (name, 1) != TYPE_NAME (type)))
                   1840:                {
                   1841:                  if (class_binding_level)
                   1842:                    d = pushdecl_class_level (d);
                   1843:                  else
                   1844:                    d = pushdecl (d);
                   1845:                }
                   1846:            }
                   1847:          else
                   1848:            {
                   1849:              /* Make nested declarations go into class-level scope.  */
                   1850:              d = build_lang_field_decl (TYPE_DECL, name, type);
                   1851: #ifdef DWARF_DEBUGGING_INFO
                   1852:              if (write_symbols == DWARF_DEBUG)
                   1853:                {
                   1854:                  /* Mark the TYPE_DECL node we created just above as an
                   1855:                     gratuitous one.  We need to do this so that dwarfout.c
                   1856:                     will understand that it is not supposed to output a
                   1857:                     TAG_typedef DIE  for it. */
                   1858:                  DECL_IGNORED_P (d) = 1;
                   1859:                }
                   1860: #endif /* DWARF_DEBUGGING_INFO */
                   1861: #if !NEW_CLASS_SCOPING
                   1862:              set_identifier_type_value (name, type);
                   1863: #else
                   1864:              /* Make sure we're in this type's scope when we push the
                   1865:                 decl for a template, otherwise class_binding_level will
                   1866:                 be NULL and we'll end up dying inside of
                   1867:                 push_class_level_binding.  */
                   1868:              if (TREE_CODE (type) == UNINSTANTIATED_P_TYPE)
                   1869:                pushclass (type, 0);
                   1870:              d = pushdecl_class_level (d);
                   1871:              if (TREE_CODE (type) == UNINSTANTIATED_P_TYPE)
                   1872:                popclass (0);
                   1873: #endif
                   1874:            }
                   1875:          if (write_symbols != DWARF_DEBUG)
                   1876:            {
                   1877:              if (ANON_AGGRNAME_P (name))
                   1878:                DECL_IGNORED_P (d) = 1;
                   1879:            }
                   1880:          TYPE_NAME (type) = d;
                   1881: 
                   1882:          if ((current_class_type == NULL_TREE
                   1883:               && current_function_decl == NULL_TREE)
                   1884:              || current_lang_name != lang_name_cplusplus)
                   1885:            /* Non-nested class.  */
                   1886:            DECL_NESTED_TYPENAME (d) = name;
                   1887:          else if (current_function_decl != NULL_TREE)
                   1888:            {
                   1889:              /* Function-nested class.  */
                   1890:              set_nested_typename (d, DECL_ASSEMBLER_NAME (current_function_decl),
                   1891:                                   name, type);
                   1892:              /* This builds the links for classes nested in fn scope.  */
                   1893:              DECL_CONTEXT (d) = current_function_decl;
                   1894:            }
                   1895:          else if (TYPE_SIZE (current_class_type) == NULL_TREE)
                   1896:            {
                   1897:              /* Class-nested class.  */
                   1898:              set_nested_typename (d, DECL_NESTED_TYPENAME (TYPE_NAME (current_class_type)),
                   1899:                                   name, type);
                   1900:              /* This builds the links for classes nested in type scope.  */
                   1901:              DECL_CONTEXT (d) = current_class_type;
                   1902:              DECL_CLASS_CONTEXT (d) = current_class_type;
                   1903:            }
                   1904:          TYPE_CONTEXT (type) = DECL_CONTEXT (d);
                   1905:         }
                   1906:       if (b->parm_flag == 2)
                   1907:        {
                   1908:          TREE_NONLOCAL_FLAG (type) = 1;
                   1909: #if !NEW_CLASS_SCOPING
                   1910:          IDENTIFIER_CLASS_VALUE (name) = TYPE_NAME (type);
                   1911: #endif
                   1912:          if (TYPE_SIZE (current_class_type) == NULL_TREE)
                   1913:            CLASSTYPE_TAGS (current_class_type) = b->tags;
                   1914:        }
                   1915:     }
                   1916: 
                   1917:   if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
                   1918:     /* Use the canonical TYPE_DECL for this node.  */
                   1919:     TYPE_STUB_DECL (type) = TYPE_NAME (type);
                   1920:   else
                   1921:     {
                   1922:       /* Create a fake NULL-named TYPE_DECL node whose TREE_TYPE
                   1923:         will be the tagged type we just added to the current
                   1924:         binding level.  This fake NULL-named TYPE_DECL node helps
                   1925:         dwarfout.c to know when it needs to output a
                   1926:         representation of a tagged type, and it also gives us a
                   1927:         convenient place to record the "scope start" address for
                   1928:         the tagged type.  */
                   1929: 
                   1930: #if 0 /* not yet, should get fixed properly later */
                   1931:       TYPE_STUB_DECL (type) = pushdecl (make_type_decl (NULL_TREE, type));
                   1932: #else
                   1933:       TYPE_STUB_DECL (type) = pushdecl (build_decl (TYPE_DECL, NULL_TREE, type));
                   1934: #endif
                   1935:     }
                   1936: }
                   1937: 
                   1938: /* Counter used to create anonymous type names.  */
                   1939: static int anon_cnt = 0;
                   1940: 
                   1941: /* Return an IDENTIFIER which can be used as a name for
                   1942:    anonymous structs and unions.  */
                   1943: tree
                   1944: make_anon_name ()
                   1945: {
                   1946:   char buf[32];
                   1947: 
                   1948:   sprintf (buf, ANON_AGGRNAME_FORMAT, anon_cnt++);
                   1949:   return get_identifier (buf);
                   1950: }
                   1951: 
                   1952: /* Clear the TREE_PURPOSE slot of tags which have anonymous typenames.
                   1953:    This keeps dbxout from getting confused.  */
                   1954: void
                   1955: clear_anon_tags ()
                   1956: {
                   1957:   register struct binding_level *b;
                   1958:   register tree tags;
                   1959:   static int last_cnt = 0;
                   1960: 
                   1961:   /* Fast out if no new anon names were declared.  */
                   1962:   if (last_cnt == anon_cnt)
                   1963:     return;
                   1964: 
                   1965:   b = current_binding_level;
                   1966:   while (b->tag_transparent)
                   1967:     b = b->level_chain;
                   1968:   tags = b->tags;
                   1969:   while (tags)
                   1970:     {
                   1971:       /* A NULL purpose means we have already processed all tags
                   1972:         from here to the end of the list.  */
                   1973:       if (TREE_PURPOSE (tags) == NULL_TREE)
                   1974:        break;
                   1975:       if (ANON_AGGRNAME_P (TREE_PURPOSE (tags)))
                   1976:        TREE_PURPOSE (tags) = NULL_TREE;
                   1977:       tags = TREE_CHAIN (tags);
                   1978:     }
                   1979:   last_cnt = anon_cnt;
                   1980: }
                   1981: 
                   1982: /* Subroutine of duplicate_decls: return truthvalue of whether
                   1983:    or not types of these decls match.
                   1984: 
                   1985:    For C++, we must compare the parameter list so that `int' can match
                   1986:    `int&' in a parameter position, but `int&' is not confused with
                   1987:    `const int&'.  */
                   1988: int
                   1989: decls_match (newdecl, olddecl)
                   1990:      tree newdecl, olddecl;
                   1991: {
                   1992:   int types_match;
                   1993: 
                   1994:   if (TREE_CODE (newdecl) == FUNCTION_DECL && TREE_CODE (olddecl) == FUNCTION_DECL)
                   1995:     {
                   1996:       tree f1 = TREE_TYPE (newdecl);
                   1997:       tree f2 = TREE_TYPE (olddecl);
                   1998:       tree p1 = TYPE_ARG_TYPES (f1);
                   1999:       tree p2 = TYPE_ARG_TYPES (f2);
                   2000: 
                   2001:       /* When we parse a static member function definition,
                   2002:         we put together a FUNCTION_DECL which thinks its type
                   2003:         is METHOD_TYPE.  Change that to FUNCTION_TYPE, and
                   2004:         proceed.  */
                   2005:       if (TREE_CODE (f1) == METHOD_TYPE && DECL_STATIC_FUNCTION_P (olddecl))
                   2006:        revert_static_member_fn (&f1, &newdecl, &p1);
                   2007:       else if (TREE_CODE (f2) == METHOD_TYPE
                   2008:               && DECL_STATIC_FUNCTION_P (newdecl))
                   2009:        revert_static_member_fn (&f2, &olddecl, &p2);
                   2010: 
                   2011:       /* Here we must take care of the case where new default
                   2012:         parameters are specified.  Also, warn if an old
                   2013:         declaration becomes ambiguous because default
                   2014:         parameters may cause the two to be ambiguous.  */
                   2015:       if (TREE_CODE (f1) != TREE_CODE (f2))
                   2016:        {
                   2017:          if (TREE_CODE (f1) == OFFSET_TYPE)
                   2018:            cp_compiler_error ("`%D' redeclared as member function", newdecl);
                   2019:          else
                   2020:            cp_compiler_error ("`%D' redeclared as non-member function", newdecl);
                   2021:          return 0;
                   2022:        }
                   2023: 
                   2024:       if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (f1)),
                   2025:                     TYPE_MAIN_VARIANT (TREE_TYPE (f2)), 2))
                   2026:        types_match = compparms (p1, p2, 2);
                   2027:       else
                   2028:        types_match = 0;
                   2029:     }
                   2030:   else
                   2031:     {
                   2032:       if (TREE_TYPE (newdecl) == error_mark_node)
                   2033:        types_match = TREE_TYPE (olddecl) == error_mark_node;
                   2034:       else if (TREE_TYPE (olddecl) == NULL_TREE)
                   2035:        types_match = TREE_TYPE (newdecl) == NULL_TREE;
                   2036:       else
                   2037:        types_match = comptypes (TREE_TYPE (newdecl), TREE_TYPE (olddecl), 1);
                   2038:     }
                   2039: 
                   2040:   return types_match;
                   2041: }
                   2042: 
                   2043: /* Handle when a new declaration NEWDECL has the same name as an old
                   2044:    one OLDDECL in the same binding contour.  Prints an error message
                   2045:    if appropriate.
                   2046: 
                   2047:    If safely possible, alter OLDDECL to look like NEWDECL, and return 1.
                   2048:    Otherwise, return 0.  */
                   2049: 
                   2050: int
                   2051: duplicate_decls (newdecl, olddecl)
                   2052:      register tree newdecl, olddecl;
                   2053: {
                   2054:   extern struct obstack permanent_obstack;
                   2055:   unsigned olddecl_uid = DECL_UID (olddecl);
                   2056:   int olddecl_friend = 0, types_match = 0;
                   2057:   int new_defines_function;
                   2058: 
                   2059:   if (TREE_CODE (olddecl) == TREE_LIST
                   2060:       && TREE_CODE (newdecl) == FUNCTION_DECL)
                   2061:     {
                   2062:       /* If a new decl finds a list of old decls, then
                   2063:         we assume that the new decl has C linkage, and
                   2064:         that the old decls have C++ linkage.  In this case,
                   2065:         we must look through the list to see whether
                   2066:         there is an ambiguity or not.  */
                   2067:       tree olddecls = olddecl;
                   2068:       tree previous_c_decl = NULL_TREE; 
                   2069: 
                   2070:       /* If the overload list is empty, just install the decl.  */
                   2071:       if (TREE_VALUE (olddecls) == NULL_TREE)
                   2072:        {
                   2073:          TREE_VALUE (olddecls) = newdecl;
                   2074:          return 1;
                   2075:        }
                   2076: 
                   2077:       while (olddecls)
                   2078:        {
                   2079:          if (DECL_HAS_C_LINKAGE (TREE_VALUE (olddecls)))
                   2080:            previous_c_decl = TREE_VALUE (olddecls);
                   2081: 
                   2082:          if (decls_match (newdecl, TREE_VALUE (olddecls)))
                   2083:            {
                   2084:              if (TREE_CODE (newdecl) == VAR_DECL)
                   2085:                ;
                   2086:              else if (! DECLS_SAME_LINKAGE (newdecl, TREE_VALUE (olddecls)))
                   2087:                {
                   2088:                  cp_error
                   2089:                    ("declaration of `%#D' with different language linkage",
                   2090:                     newdecl);
                   2091:                  cp_error_at ("previous declaration here", TREE_VALUE (olddecls));
                   2092:                }
                   2093:              types_match = 1;
                   2094:              break;
                   2095:            }
                   2096:          olddecls = TREE_CHAIN (olddecls);
                   2097:        }
                   2098:       if (olddecls)
                   2099:        olddecl = TREE_VALUE (olddecls);
                   2100:       else
                   2101:        {
                   2102:          if (previous_c_decl != NULL_TREE
                   2103:              && DECL_HAS_C_LINKAGE (newdecl))
                   2104:            {
                   2105:              cp_error ("declaration of C function `%#D' conflicts with previous declaration", newdecl);
                   2106:              cp_error_at ("`%#D' declared previously at this point in file", previous_c_decl);
                   2107:            }
                   2108:          else
                   2109:            {
                   2110:              /* If we found no match, make this join the other
                   2111:                 overloaded decls.  */
                   2112:              DECL_OVERLOADED (newdecl) = 1;
                   2113:            }
                   2114:          return 1;
                   2115:        }
                   2116:     }
                   2117:   else
                   2118:     {
                   2119:       if (TREE_CODE (olddecl) != TREE_LIST)
                   2120:        olddecl_friend = DECL_LANG_SPECIFIC (olddecl) && DECL_FRIEND_P (olddecl);
                   2121:       types_match = decls_match (newdecl, olddecl);
                   2122:     }
                   2123: 
                   2124:   /* If either the type of the new decl or the type of the old decl is an
                   2125:      error_mark_node, then that implies that we have already issued an
                   2126:      error (earlier) for some bogus type specification, and in that case,
                   2127:      it is rather pointless to harass the user with yet more error message
                   2128:      about the same declaration, so well just pretent the types match here.  */
                   2129:   if ((TREE_TYPE (newdecl)
                   2130:        && TREE_CODE (TREE_TYPE (newdecl)) == ERROR_MARK)
                   2131:       || (TREE_TYPE (olddecl)
                   2132:          && TREE_CODE (TREE_TYPE (olddecl)) == ERROR_MARK))
                   2133:     types_match = 1;
                   2134: 
                   2135:   /* If this decl has linkage, and the old one does too, maybe no error.  */
                   2136:   if (TREE_CODE (olddecl) != TREE_CODE (newdecl))
                   2137:     {
                   2138:       cp_error ("`%#D' redeclared as different kind of symbol", newdecl);
                   2139:       if (TREE_CODE (olddecl) == TREE_LIST)
                   2140:        olddecl = TREE_VALUE (olddecl);
                   2141:       cp_error_at ("previous declaration of `%#D'", olddecl);
                   2142: 
                   2143:       /* New decl is completely inconsistent with the old one =>
                   2144:         tell caller to replace the old one.  */
                   2145: 
                   2146:       return 0;
                   2147:     }
                   2148: 
                   2149:   if (flag_traditional && TREE_CODE (newdecl) == FUNCTION_DECL
                   2150:       && IDENTIFIER_IMPLICIT_DECL (DECL_ASSEMBLER_NAME (newdecl)) == olddecl)
                   2151:     /* If -traditional, avoid error for redeclaring fcn
                   2152:        after implicit decl.  */
                   2153:     ;
                   2154:   else if (TREE_CODE (olddecl) == FUNCTION_DECL && DECL_BUILT_IN (olddecl))
                   2155:     {
                   2156:       /* A function declaration for a built-in function.  */
                   2157:       if (!TREE_PUBLIC (newdecl))
                   2158:        {
                   2159:          /* If you declare a built-in function name as static, the
                   2160:             built-in definition is overridden,
                   2161:             but optionally warn this was a bad choice of name.  */
                   2162:          if (warn_shadow)
                   2163:            cp_warning ("shadowing built-in function `%#D'", newdecl);
                   2164:          /* Discard the old built-in function.  */
                   2165:          return 0;
                   2166:        }
                   2167:       if (!types_match)
                   2168:        {
                   2169:          cp_warning ("declaration of `%#D'", newdecl);
                   2170:          cp_warning ("conflicts with built-in declaration `%#D'",
                   2171:                      olddecl);
                   2172:          return 0;
                   2173:        }
                   2174:     }
                   2175:   else if (!types_match)
                   2176:     {
                   2177:       tree oldtype = TREE_TYPE (olddecl);
                   2178:       tree newtype = TREE_TYPE (newdecl);
                   2179:       int give_error = 0;
                   2180: 
                   2181:       /* Already complained about this, so don't do so again.  */
                   2182:       if (current_class_type == NULL_TREE
                   2183:          || IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (newdecl)) != current_class_type)
                   2184:        {
                   2185:          give_error = 1;
                   2186: 
                   2187:          /* Since we're doing this before finish_struct can set the
                   2188:             line number on NEWDECL, we just do a regular error here.  */
                   2189:          if (DECL_SOURCE_LINE (newdecl) == 0)
                   2190:            cp_error ("conflicting types for `%#D'", newdecl);
                   2191:          else
                   2192:            cp_error_at ("conflicting types for `%#D'", newdecl);
                   2193:        }
                   2194: 
                   2195:       /* Check for function type mismatch
                   2196:         involving an empty arglist vs a nonempty one.  */
                   2197:       if (TREE_CODE (olddecl) == FUNCTION_DECL
                   2198:          && comptypes (TREE_TYPE (oldtype),
                   2199:                        TREE_TYPE (newtype), 1)
                   2200:          && ((TYPE_ARG_TYPES (oldtype) == NULL_TREE
                   2201:               && DECL_INITIAL (olddecl) == NULL_TREE)
                   2202:              || (TYPE_ARG_TYPES (newtype) == NULL_TREE
                   2203:                  && DECL_INITIAL (newdecl) == NULL_TREE)))
                   2204:        {
                   2205:          /* Classify the problem further.  */
                   2206:          register tree t = TYPE_ARG_TYPES (oldtype);
                   2207: 
                   2208:          if (t == NULL_TREE)
                   2209:            t = TYPE_ARG_TYPES (newtype);
                   2210:          for (; t; t = TREE_CHAIN (t))
                   2211:            {
                   2212:              register tree type = TREE_VALUE (t);
                   2213: 
                   2214:              if (TREE_CHAIN (t) == NULL_TREE && type != void_type_node)
                   2215:                {
                   2216:                  give_error = 1;
                   2217:                  error ("A parameter list with an ellipsis can't match");
                   2218:                  error ("an empty parameter name list declaration.");
                   2219:                  break;
                   2220:                }
                   2221: 
                   2222:              if (TYPE_MAIN_VARIANT (type) == float_type_node
                   2223:                  || C_PROMOTING_INTEGER_TYPE_P (type))
                   2224:                {
                   2225:                  give_error = 1;
                   2226:                  error ("An argument type that has a default promotion");
                   2227:                  error ("can't match an empty parameter name list declaration.");
                   2228:                  break;
                   2229:                }
                   2230:            }
                   2231:        }
                   2232:       if (give_error)
                   2233:        cp_error_at ("previous declaration as `%#D'", olddecl);
                   2234: 
                   2235:       /* There is one thing GNU C++ cannot tolerate: a constructor
                   2236:         which takes the type of object being constructed.
                   2237:         Farm that case out here.  */
                   2238:       if (TREE_CODE (newdecl) == FUNCTION_DECL
                   2239:          && DECL_CONSTRUCTOR_P (newdecl))
                   2240:        {
                   2241:          tree tmp = TREE_CHAIN (TYPE_ARG_TYPES (newtype));
                   2242: 
                   2243:          if (tmp != NULL_TREE
                   2244:              && (TYPE_MAIN_VARIANT (TREE_VALUE (tmp))
                   2245:                  == TYPE_METHOD_BASETYPE (newtype)))
                   2246:            {
                   2247:              tree parm = TREE_CHAIN (DECL_ARGUMENTS (newdecl));
                   2248:              tree argtypes
                   2249:                = hash_tree_chain (build_reference_type (TREE_VALUE (tmp)),
                   2250:                                   TREE_CHAIN (tmp));
                   2251: 
                   2252:              DECL_ARG_TYPE (parm)
                   2253:                = TREE_TYPE (parm)
                   2254:                  = TYPE_REFERENCE_TO (TREE_VALUE (tmp));
                   2255: 
                   2256:              TREE_TYPE (newdecl) = newtype
                   2257:                = build_cplus_method_type (TYPE_METHOD_BASETYPE (newtype),
                   2258:                                           TREE_TYPE (newtype), argtypes);
                   2259:              error ("constructor cannot take as argument the type being constructed");
                   2260:              SET_IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (newdecl), current_class_type);
                   2261:            }
                   2262:        }
                   2263:     }
                   2264:   else
                   2265:     {
                   2266:       char *errmsg = redeclaration_error_message (newdecl, olddecl);
                   2267:       if (errmsg)
                   2268:        {
                   2269:          error_with_decl (newdecl, errmsg);
                   2270:          if (DECL_NAME (olddecl) != NULL_TREE)
                   2271:            cp_error_at ((DECL_INITIAL (olddecl)
                   2272:                          && current_binding_level == global_binding_level)
                   2273:                         ? "`%#D' previously defined here"
                   2274:                         : "`%#D' previously declared here", olddecl);
                   2275:        }
                   2276:       else if (TREE_CODE (olddecl) == FUNCTION_DECL
                   2277:               && DECL_INITIAL (olddecl) != NULL_TREE
                   2278:               && TYPE_ARG_TYPES (TREE_TYPE (olddecl)) == NULL_TREE
                   2279:               && TYPE_ARG_TYPES (TREE_TYPE (newdecl)) != NULL_TREE)
                   2280:        {
                   2281:          /* Prototype decl follows defn w/o prototype.  */
                   2282:          cp_warning_at ("prototype for `%#D'", newdecl);
                   2283:          cp_warning_at ("follows non-prototype definition here", olddecl);
                   2284:        }
                   2285:       else if (TREE_CODE (olddecl) == FUNCTION_DECL
                   2286:               && ! DECLS_SAME_LINKAGE (newdecl, olddecl))
                   2287:        /* extern "C" int foo ();
                   2288:           int foo () { bar (); }
                   2289:           is OK.  */
                   2290:        if (current_lang_stack == current_lang_base)
                   2291:          DECL_LANGUAGE (newdecl) = DECL_LANGUAGE (olddecl);
                   2292:        else
                   2293:          {
                   2294:            cp_error_at ("previous declaration of `%#D' with %L linkage",
                   2295:                         olddecl, DECL_LANGUAGE (olddecl));
                   2296:            cp_error ("conflicts with new declaration with %L linkage",
                   2297:                      DECL_LANGUAGE (newdecl));
                   2298:          }
                   2299: 
                   2300:       /* These bits are logically part of the type.  */
                   2301:       if (pedantic
                   2302:          && (TREE_READONLY (newdecl) != TREE_READONLY (olddecl)
                   2303:              || TREE_THIS_VOLATILE (newdecl) != TREE_THIS_VOLATILE (olddecl)))
                   2304:        cp_error_at ("type qualifiers for `%D' conflict with previous decl", newdecl);
                   2305:     }
                   2306: 
                   2307:   /* We have committed to returning 1 at this point. */
                   2308:   if (TREE_CODE (newdecl) == FUNCTION_DECL)
                   2309:     {
                   2310:       /* Now that functions must hold information normally held
                   2311:         by field decls, there is extra work to do so that
                   2312:         declaration information does not get destroyed during
                   2313:         definition.  */
                   2314:       if (DECL_VINDEX (olddecl))
                   2315:        DECL_VINDEX (newdecl) = DECL_VINDEX (olddecl);
                   2316:       if (DECL_CONTEXT (olddecl))
                   2317:        DECL_CONTEXT (newdecl) = DECL_CONTEXT (olddecl);
                   2318:       if (DECL_CLASS_CONTEXT (olddecl))
                   2319:        DECL_CLASS_CONTEXT (newdecl) = DECL_CLASS_CONTEXT (olddecl);
                   2320:       if (DECL_CHAIN (newdecl) == NULL_TREE)
                   2321:        DECL_CHAIN (newdecl) = DECL_CHAIN (olddecl);
                   2322:       if (DECL_PENDING_INLINE_INFO (newdecl) == (struct pending_inline *)0)
                   2323:        DECL_PENDING_INLINE_INFO (newdecl) = DECL_PENDING_INLINE_INFO (olddecl);
                   2324:     }
                   2325: 
                   2326:   /* Deal with C++: must preserve virtual function table size.  */
                   2327:   if (TREE_CODE (olddecl) == TYPE_DECL)
                   2328:     {
                   2329:       register tree newtype = TREE_TYPE (newdecl);
                   2330:       register tree oldtype = TREE_TYPE (olddecl);
                   2331: 
                   2332:       if (newtype != error_mark_node && oldtype != error_mark_node
                   2333:          && TYPE_LANG_SPECIFIC (newtype) && TYPE_LANG_SPECIFIC (oldtype))
                   2334:        {
                   2335:          CLASSTYPE_VSIZE (newtype) = CLASSTYPE_VSIZE (oldtype);
                   2336:          CLASSTYPE_FRIEND_CLASSES (newtype)
                   2337:            = CLASSTYPE_FRIEND_CLASSES (oldtype);
                   2338:        }
                   2339:       /* why assert here?  Just because debugging information is
                   2340:         messed up? (mrs) */
                   2341:       /* it happens on something like:
                   2342:                typedef struct Thing {
                   2343:                        Thing();
                   2344:                        int     x;
                   2345:                } Thing;
                   2346:       */
                   2347: #if 0
                   2348:       my_friendly_assert (DECL_IGNORED_P (olddecl) == DECL_IGNORED_P (newdecl), 139);
                   2349: #endif
                   2350:     }
                   2351: 
                   2352:   /* Special handling ensues if new decl is a function definition.  */
                   2353:   new_defines_function = (TREE_CODE (newdecl) == FUNCTION_DECL
                   2354:                          && DECL_INITIAL (newdecl) != NULL_TREE);
                   2355: 
                   2356:   /* Optionally warn about more than one declaration for the same name,
                   2357:      but don't warn about a function declaration followed by a definition.  */
                   2358:   if (warn_redundant_decls
                   2359:       && DECL_SOURCE_LINE (olddecl) != 0
                   2360:       && !(new_defines_function && DECL_INITIAL (olddecl) == NULL_TREE))
                   2361:     {
                   2362:       cp_warning ("redundant redeclaration of `%D' in same scope", newdecl);
                   2363:       cp_warning ("previous declaration of `%D'", olddecl);
                   2364:     }
                   2365: 
                   2366:   /* Copy all the DECL_... slots specified in the new decl
                   2367:      except for any that we copy here from the old type.  */
                   2368: 
                   2369:   if (types_match)
                   2370:     {
                   2371:       /* Automatically handles default parameters.  */
                   2372:       tree oldtype = TREE_TYPE (olddecl);
                   2373:       /* Merge the data types specified in the two decls.  */
                   2374:       tree newtype = common_type (TREE_TYPE (newdecl), TREE_TYPE (olddecl));
                   2375: 
                   2376:       if (TREE_CODE (newdecl) == VAR_DECL)
                   2377:        DECL_THIS_EXTERN (newdecl) |= DECL_THIS_EXTERN (olddecl);
                   2378:       /* Do this after calling `common_type' so that default
                   2379:         parameters don't confuse us.  */
                   2380:       else if (TREE_CODE (newdecl) == FUNCTION_DECL
                   2381:          && (TYPE_RAISES_EXCEPTIONS (TREE_TYPE (newdecl))
                   2382:              != TYPE_RAISES_EXCEPTIONS (TREE_TYPE (olddecl))))
                   2383:        {
                   2384:          tree ctype = NULL_TREE;
                   2385:          ctype = DECL_CLASS_CONTEXT (newdecl);
                   2386:          TREE_TYPE (newdecl) = build_exception_variant (ctype, newtype,
                   2387:                                                         TYPE_RAISES_EXCEPTIONS (TREE_TYPE (newdecl)));
                   2388:          TREE_TYPE (olddecl) = build_exception_variant (ctype, newtype,
                   2389:                                                         TYPE_RAISES_EXCEPTIONS (oldtype));
                   2390: 
                   2391:          if (! compexcepttypes (TREE_TYPE (newdecl), TREE_TYPE(olddecl), 0))
                   2392:            {
                   2393:              cp_error ("declaration of `%D' raises different exceptions...", newdecl);
                   2394:              cp_error_at ("...from previous declaration here", olddecl);
                   2395:            }
                   2396:        }
                   2397:       TREE_TYPE (newdecl) = TREE_TYPE (olddecl) = newtype;
                   2398: 
                   2399:       /* Lay the type out, unless already done.  */
                   2400:       if (oldtype != TREE_TYPE (newdecl))
                   2401:        {
                   2402:          if (TREE_TYPE (newdecl) != error_mark_node)
                   2403:            layout_type (TREE_TYPE (newdecl));
                   2404:          if (TREE_CODE (newdecl) != FUNCTION_DECL
                   2405:              && TREE_CODE (newdecl) != TYPE_DECL
                   2406:              && TREE_CODE (newdecl) != CONST_DECL)
                   2407:            layout_decl (newdecl, 0);
                   2408:        }
                   2409:       else
                   2410:        {
                   2411:          /* Since the type is OLDDECL's, make OLDDECL's size go with.  */
                   2412:          DECL_SIZE (newdecl) = DECL_SIZE (olddecl);
                   2413:        }
                   2414: 
                   2415:       /* Merge the type qualifiers.  */
                   2416:       if (TREE_READONLY (newdecl))
                   2417:        TREE_READONLY (olddecl) = 1;
                   2418:       if (TREE_THIS_VOLATILE (newdecl))
                   2419:        TREE_THIS_VOLATILE (olddecl) = 1;
                   2420: 
                   2421:       /* Merge the initialization information.  */
                   2422:       if (DECL_INITIAL (newdecl) == NULL_TREE)
                   2423:        DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
                   2424:       /* Keep the old rtl since we can safely use it, unless it's the
                   2425:         call to abort() used for abstract virtuals.  */
                   2426:       if ((DECL_LANG_SPECIFIC (olddecl)
                   2427:           && !DECL_ABSTRACT_VIRTUAL_P (olddecl))
                   2428:          || DECL_RTL (olddecl) != DECL_RTL (abort_fndecl))
                   2429:        DECL_RTL (newdecl) = DECL_RTL (olddecl);
                   2430:     }
                   2431:   /* If cannot merge, then use the new type and qualifiers,
                   2432:      and don't preserve the old rtl.  */
                   2433:   else
                   2434:     {
                   2435:       /* Clean out any memory we had of the old declaration.  */
                   2436:       tree oldstatic = value_member (olddecl, static_aggregates);
                   2437:       if (oldstatic)
                   2438:        TREE_VALUE (oldstatic) = error_mark_node;
                   2439: 
                   2440:       TREE_TYPE (olddecl) = TREE_TYPE (newdecl);
                   2441:       TREE_READONLY (olddecl) = TREE_READONLY (newdecl);
                   2442:       TREE_THIS_VOLATILE (olddecl) = TREE_THIS_VOLATILE (newdecl);
                   2443:       TREE_SIDE_EFFECTS (olddecl) = TREE_SIDE_EFFECTS (newdecl);
                   2444:     }
                   2445: 
                   2446:   /* Merge the storage class information.  */
                   2447:   if (DECL_EXTERNAL (newdecl))
                   2448:     {
                   2449:       TREE_STATIC (newdecl) = TREE_STATIC (olddecl);
                   2450:       DECL_EXTERNAL (newdecl) = DECL_EXTERNAL (olddecl);
                   2451: 
                   2452:       /* For functions, static overrides non-static.  */
                   2453:       if (TREE_CODE (newdecl) == FUNCTION_DECL)
                   2454:        {
                   2455:          TREE_PUBLIC (newdecl) &= TREE_PUBLIC (olddecl);
                   2456:          /* This is since we don't automatically
                   2457:             copy the attributes of NEWDECL into OLDDECL.  */
                   2458:          TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
                   2459:          /* If this clears `static', clear it in the identifier too.  */
                   2460:          if (! TREE_PUBLIC (olddecl))
                   2461:            TREE_PUBLIC (DECL_ASSEMBLER_NAME (olddecl)) = 0;
                   2462:        }
                   2463:       else
                   2464:        TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
                   2465:     }
                   2466:   else
                   2467:     {
                   2468:       TREE_STATIC (olddecl) = TREE_STATIC (newdecl);
                   2469:       /* A `const' which was not declared `extern' and is
                   2470:         in static storage is invisible.  */
                   2471:       if (TREE_CODE (newdecl) == VAR_DECL
                   2472:          && TREE_READONLY (newdecl) && TREE_STATIC (newdecl)
                   2473:          && ! DECL_THIS_EXTERN (newdecl))
                   2474:        TREE_PUBLIC (newdecl) = 0;
                   2475:       TREE_PUBLIC (olddecl) = TREE_PUBLIC (newdecl);
                   2476:     }
                   2477: 
                   2478:   /* If either decl says `inline', this fn is inline,
                   2479:      unless its definition was passed already.  */
                   2480:   if (DECL_INLINE (newdecl) && DECL_INITIAL (olddecl) == NULL_TREE)
                   2481:     DECL_INLINE (olddecl) = 1;
                   2482:   DECL_INLINE (newdecl) = DECL_INLINE (olddecl);
                   2483: 
                   2484:   if (TREE_CODE (newdecl) == FUNCTION_DECL)
                   2485:     {
                   2486:       if (new_defines_function)
                   2487:        /* If defining a function declared with other language
                   2488:           linkage, use the previously declared language linkage.  */
                   2489:        DECL_LANGUAGE (newdecl) = DECL_LANGUAGE (olddecl);
                   2490:       else
                   2491:        {
                   2492:          /* If redeclaring a builtin function, and not a definition,
                   2493:             it stays built in.  */
                   2494:          if (DECL_BUILT_IN (olddecl))
                   2495:            {
                   2496:              DECL_BUILT_IN (newdecl) = 1;
                   2497:              DECL_SET_FUNCTION_CODE (newdecl, DECL_FUNCTION_CODE (olddecl));
                   2498:              /* If we're keeping the built-in definition, keep the rtl,
                   2499:                 regardless of declaration matches.  */
                   2500:              DECL_RTL (newdecl) = DECL_RTL (olddecl);
                   2501:            }
                   2502:          else
                   2503:            DECL_FRAME_SIZE (newdecl) = DECL_FRAME_SIZE (olddecl);
                   2504: 
                   2505:          DECL_RESULT (newdecl) = DECL_RESULT (olddecl);
                   2506:          if (DECL_SAVED_INSNS (newdecl) = DECL_SAVED_INSNS (olddecl))
                   2507:            /* Previously saved insns go together with
                   2508:               the function's previous definition.  */
                   2509:            DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
                   2510:          /* Don't clear out the arguments if we're redefining a function.  */
                   2511:          if (DECL_ARGUMENTS (olddecl))
                   2512:            DECL_ARGUMENTS (newdecl) = DECL_ARGUMENTS (olddecl);
                   2513:        }
                   2514:     }
                   2515: 
                   2516:   /* Now preserve various other info from the definition.  */
                   2517:   TREE_ADDRESSABLE (newdecl) = TREE_ADDRESSABLE (olddecl);
                   2518:   TREE_ASM_WRITTEN (newdecl) = TREE_ASM_WRITTEN (olddecl);
                   2519: 
                   2520:   /* Don't really know how much of the language-specific
                   2521:      values we should copy from old to new.  */
                   2522: #if 1
                   2523:   if (DECL_LANG_SPECIFIC (olddecl))
                   2524:     DECL_IN_AGGR_P (newdecl) = DECL_IN_AGGR_P (olddecl);
                   2525: #endif
                   2526: 
                   2527:   if (TREE_CODE (newdecl) == FUNCTION_DECL)
                   2528:     {
                   2529:       int function_size;
                   2530:       struct lang_decl *ol = DECL_LANG_SPECIFIC (olddecl);
                   2531:       struct lang_decl *nl = DECL_LANG_SPECIFIC (newdecl);
                   2532: 
                   2533:       function_size = sizeof (struct tree_decl);
                   2534: 
                   2535:       bcopy ((char *) newdecl + sizeof (struct tree_common),
                   2536:             (char *) olddecl + sizeof (struct tree_common),
                   2537:             function_size - sizeof (struct tree_common));
                   2538: 
                   2539:       if ((char *)newdecl + ((function_size + sizeof (struct lang_decl)
                   2540:                             + obstack_alignment_mask (&permanent_obstack))
                   2541:                             & ~ obstack_alignment_mask (&permanent_obstack))
                   2542:          == obstack_next_free (&permanent_obstack))
                   2543:        {
                   2544:          DECL_MAIN_VARIANT (newdecl) = olddecl;
                   2545:          DECL_LANG_SPECIFIC (olddecl) = ol;
                   2546:          bcopy ((char *)nl, (char *)ol, sizeof (struct lang_decl));
                   2547: 
                   2548:          obstack_free (&permanent_obstack, newdecl);
                   2549:        }
                   2550:       else if (LANG_DECL_PERMANENT (ol))
                   2551:        {
                   2552:          if (DECL_MAIN_VARIANT (olddecl) == olddecl)
                   2553:            {
                   2554:              /* Save these lang_decls that would otherwise be lost.  */
                   2555:              extern tree free_lang_decl_chain;
                   2556:              tree free_lang_decl = (tree) ol;
                   2557:              TREE_CHAIN (free_lang_decl) = free_lang_decl_chain;
                   2558:              free_lang_decl_chain = free_lang_decl;
                   2559:            }
                   2560:          else
                   2561:            {
                   2562:              /* Storage leak.  */
                   2563:            }
                   2564:        }
                   2565:     }
                   2566:   else
                   2567:     {
                   2568:       bcopy ((char *) newdecl + sizeof (struct tree_common),
                   2569:             (char *) olddecl + sizeof (struct tree_common),
                   2570:             sizeof (struct tree_decl) - sizeof (struct tree_common)
                   2571:             + tree_code_length [(int)TREE_CODE (newdecl)] * sizeof (char *));
                   2572:     }
                   2573: 
                   2574:   DECL_UID (olddecl) = olddecl_uid;
                   2575:   if (olddecl_friend)
                   2576:     DECL_FRIEND_P (olddecl) = 1;
                   2577: 
                   2578:   return 1;
                   2579: }
                   2580: 
                   2581: #if !NEW_CLASS_SCOPING
                   2582: /* This was always a hack, that never should've been necessary.  */
                   2583: void
                   2584: adjust_type_value (id)
                   2585:      tree id;
                   2586: {
                   2587:   tree t;
                   2588: 
                   2589:   if (current_binding_level != global_binding_level)
                   2590:     {
                   2591:       if (current_binding_level != class_binding_level)
                   2592:        {
                   2593:          t = IDENTIFIER_LOCAL_VALUE (id);
                   2594:          if (t && TREE_CODE (t) == TYPE_DECL)
                   2595:            {
                   2596:            set_it:
                   2597:              SET_IDENTIFIER_TYPE_VALUE (id, TREE_TYPE (t));
                   2598:              return;
                   2599:            }
                   2600:        }
                   2601:       else
                   2602:        my_friendly_abort (7);
                   2603: 
                   2604:       if (current_class_type)
                   2605:        {
                   2606:          t = IDENTIFIER_CLASS_VALUE (id);
                   2607:          if (t && TREE_CODE (t) == TYPE_DECL)
                   2608:            goto set_it;
                   2609:        }
                   2610:     }
                   2611: 
                   2612:   t = IDENTIFIER_GLOBAL_VALUE (id);
                   2613:   if (t && TREE_CODE (t) == TYPE_DECL)
                   2614:     goto set_it;
                   2615:   if (t && TREE_CODE (t) == TEMPLATE_DECL)
                   2616:     SET_IDENTIFIER_TYPE_VALUE (id, NULL_TREE);
                   2617: }
                   2618: #endif
                   2619: 
                   2620: /* Record a decl-node X as belonging to the current lexical scope.
                   2621:    Check for errors (such as an incompatible declaration for the same
                   2622:    name already seen in the same scope).
                   2623: 
                   2624:    Returns either X or an old decl for the same name.
                   2625:    If an old decl is returned, it may have been smashed
                   2626:    to agree with what X says.  */
                   2627: 
                   2628: tree
                   2629: pushdecl (x)
                   2630:      tree x;
                   2631: {
                   2632:   register tree t;
                   2633: #if 0 /* not yet, should get fixed properly later */
                   2634:   register tree name;
                   2635: #else
                   2636:   register tree name = DECL_ASSEMBLER_NAME (x);
                   2637: #endif
                   2638:   register struct binding_level *b = current_binding_level;
                   2639: 
                   2640: #if 0
                   2641:   static int nglobals; int len;
                   2642: 
                   2643:   len = list_length (global_binding_level->names);
                   2644:   if (len < nglobals)
                   2645:     my_friendly_abort (8);
                   2646:   else if (len > nglobals)
                   2647:     nglobals = len;
                   2648: #endif
                   2649: 
                   2650:   /* Don't change DECL_CONTEXT of virtual methods.  */
                   2651:   if (x != current_function_decl
                   2652:       && (TREE_CODE (x) != FUNCTION_DECL
                   2653:          || !DECL_VIRTUAL_P (x)))
                   2654:     DECL_CONTEXT (x) = current_function_decl;
                   2655:   /* A local declaration for a function doesn't constitute nesting.  */
                   2656:   if (TREE_CODE (x) == FUNCTION_DECL && DECL_INITIAL (x) == 0)
                   2657:     DECL_CONTEXT (x) = 0;
                   2658: 
                   2659: #if 0 /* not yet, should get fixed properly later */
                   2660:   /* For functions and class static data, we currently look up the encoded
                   2661:      form of the name.  For types, we want the real name.  The former will
                   2662:      probably be changed soon, according to MDT.  */
                   2663:   if (TREE_CODE (x) == FUNCTION_DECL || TREE_CODE (x) == VAR_DECL)
                   2664:     name = DECL_ASSEMBLER_NAME (x);
                   2665:   else
                   2666:     name = DECL_NAME (x);
                   2667: #else
                   2668:   /* Type are looked up using the DECL_NAME, as that is what the rest of the
                   2669:      compiler wants to use. */
                   2670:   if (TREE_CODE (x) == TYPE_DECL)
                   2671:     name = DECL_NAME (x);
                   2672: #endif
                   2673: 
                   2674:   if (name)
                   2675:     {
                   2676:       char *file;
                   2677:       int line;
                   2678: 
                   2679:       t = lookup_name_current_level (name);
                   2680:       if (t == error_mark_node)
                   2681:        {
                   2682:          /* error_mark_node is 0 for a while during initialization!  */
                   2683:          t = NULL_TREE;
                   2684:          cp_error_at ("`%#D' used prior to declaration", x);
                   2685:        }
                   2686: 
                   2687:       if (t != NULL_TREE)
                   2688:        {
                   2689:          if (TREE_CODE (t) == PARM_DECL)
                   2690:            {
                   2691:              if (DECL_CONTEXT (t) == NULL_TREE)
                   2692:                fatal ("parse errors have confused me too much");
                   2693:            }
                   2694:          file = DECL_SOURCE_FILE (t);
                   2695:          line = DECL_SOURCE_LINE (t);
                   2696:        }
                   2697: 
                   2698:       if (t != NULL_TREE && TREE_CODE (t) != TREE_CODE (x))
                   2699:        {
                   2700:          if (TREE_CODE (t) == TYPE_DECL || TREE_CODE (x) == TYPE_DECL)
                   2701:            {
                   2702:              /* We do nothing special here, because C++ does such nasty
                   2703:                 things with TYPE_DECLs.  Instead, just let the TYPE_DECL
                   2704:                 get shadowed, and know that if we need to find a TYPE_DECL
                   2705:                 for a given name, we can look in the IDENTIFIER_TYPE_VALUE
                   2706:                 slot of the identifier.  */
                   2707:              ;
                   2708:            }
                   2709:          else if (duplicate_decls (x, t))
                   2710:            return t;
                   2711:        }
                   2712:       else if (t != NULL_TREE && duplicate_decls (x, t))
                   2713:        {
                   2714:          /* If this decl is `static' and an `extern' was seen previously,
                   2715:             that is erroneous.  But don't complain if -traditional,
                   2716:             since traditional compilers don't complain.
                   2717: 
                   2718:             Note that this does not apply to the C++ case of declaring
                   2719:             a variable `extern const' and then later `const'.  */
                   2720:          if (!flag_traditional && TREE_PUBLIC (name)
                   2721:              && ! TREE_PUBLIC (x) && ! DECL_EXTERNAL (x) && ! DECL_INLINE (x))
                   2722:            {
                   2723:              /* Due to interference in memory reclamation (X may be
                   2724:                 obstack-deallocated at this point), we must guard against
                   2725:                 one really special case.  */
                   2726:              if (current_function_decl == x)
                   2727:                current_function_decl = t;
                   2728:              if (IDENTIFIER_IMPLICIT_DECL (name))
                   2729:                cp_warning ("`%D' was declared implicitly `extern' and later `static'", t);
                   2730:              else
                   2731:                cp_warning ("`%D' was declared `extern' and later `static'",
                   2732:                            x);
                   2733:              cp_warning_at ("previous declaration of `%D'", t);
                   2734:            }
                   2735: #if 0
                   2736:          /* This is turned off until I have time to do it right (bpk).  */
                   2737: 
                   2738:          /* Also warn if they did a prototype with `static' on it, but
                   2739:             then later left the `static' off.  */
                   2740:          else if (! TREE_PUBLIC (name) && TREE_PUBLIC (x))
                   2741:            {
                   2742:              if (DECL_LANG_SPECIFIC (t) && DECL_FRIEND_P (t))
                   2743:                return t;
                   2744: 
                   2745:              if (current_function_decl == x)
                   2746:                current_function_decl = t;
                   2747: 
                   2748:              if (extra_warnings)
                   2749:                {
                   2750:                  cp_warning ("`static' missing from declaration of `%D'", t);
                   2751:                  warning_with_file_and_line (file, line,
                   2752:                                              "previous declaration of `%s'",
                   2753:                                              decl_as_string (t, 0));
                   2754:                }
                   2755: 
                   2756:              /* Now fix things so it'll do what they expect.  */
                   2757:              if (current_function_decl)
                   2758:                TREE_PUBLIC (current_function_decl) = 0;
                   2759:            }
                   2760: #endif
                   2761:          return t;
                   2762:        }
                   2763: 
                   2764:       /* If declaring a type as a typedef, and the type has no known
                   2765:         typedef name, install this TYPE_DECL as its typedef name.  */
                   2766:       if (TREE_CODE (x) == TYPE_DECL)
                   2767:        {
                   2768:          tree type = TREE_TYPE (x);
                   2769:          tree name = (type != error_mark_node) ? TYPE_NAME (type) : x;
                   2770: 
                   2771:          if (name == NULL_TREE || TREE_CODE (name) != TYPE_DECL)
                   2772:            {
                   2773:              /* If these are different names, and we're at the global
                   2774:                 binding level, make two equivalent definitions.  */
                   2775:               name = x;
                   2776:               if (global_bindings_p ())
                   2777:                 TYPE_NAME (type) = x;
                   2778:            }
                   2779:          else
                   2780:            {
                   2781:              tree tname = DECL_NAME (name);
                   2782: 
                   2783:              if (global_bindings_p () && ANON_AGGRNAME_P (tname))
                   2784:                {
                   2785:                  /* do gratuitous C++ typedefing, and make sure that
                   2786:                     we access this type either through TREE_TYPE field
                   2787:                     or via the tags list.  */
                   2788:                  TYPE_NAME (TREE_TYPE (x)) = x;
                   2789:                  pushtag (tname, TREE_TYPE (x));
                   2790:                }
                   2791:            }
                   2792:          my_friendly_assert (TREE_CODE (name) == TYPE_DECL, 140);
                   2793: 
                   2794:          if (DECL_NAME (name) && !DECL_NESTED_TYPENAME (name))
                   2795:            set_nested_typename (x, current_class_name,
                   2796:                                 DECL_NAME (name), type);
                   2797: 
                   2798:          if (type != error_mark_node
                   2799:              && TYPE_NAME (type)
                   2800:              && TYPE_IDENTIFIER (type))
                   2801:             set_identifier_type_value (DECL_NAME (x), type);
                   2802:        }
                   2803: 
                   2804:       /* Multiple external decls of the same identifier ought to match.
                   2805: 
                   2806:         We get warnings about inline functions where they are defined.
                   2807:         Avoid duplicate warnings where they are used.  */
                   2808:       if (TREE_PUBLIC (x) && !DECL_INLINE (x))
                   2809:        {
                   2810:          tree decl;
                   2811: 
                   2812:          if (IDENTIFIER_GLOBAL_VALUE (name) != NULL_TREE
                   2813:              && (DECL_EXTERNAL (IDENTIFIER_GLOBAL_VALUE (name))
                   2814:                  || TREE_PUBLIC (IDENTIFIER_GLOBAL_VALUE (name))))
                   2815:            decl = IDENTIFIER_GLOBAL_VALUE (name);
                   2816:          else
                   2817:            decl = NULL_TREE;
                   2818: 
                   2819:          if (decl && ! comptypes (TREE_TYPE (x), TREE_TYPE (decl), 1)
                   2820:              /* If old decl is built-in, we already warned if we should.  */
                   2821:              && !DECL_BUILT_IN (decl))
                   2822:            {
                   2823:              cp_pedwarn_at ("type mismatch with previous external decl", x);
                   2824:              cp_pedwarn_at ("previous external decl of `%D'", decl);
                   2825:            }
                   2826:        }
                   2827: 
                   2828:       /* In PCC-compatibility mode, extern decls of vars with no current decl
                   2829:         take effect at top level no matter where they are.  */
                   2830:       if (flag_traditional && DECL_EXTERNAL (x)
                   2831:          && lookup_name (name, 0) == NULL_TREE)
                   2832:        b = global_binding_level;
                   2833: 
                   2834:       /* This name is new in its binding level.
                   2835:         Install the new declaration and return it.  */
                   2836:       if (b == global_binding_level)
                   2837:        {
                   2838:          /* Install a global value.  */
                   2839: 
                   2840:          /* Rule for VAR_DECLs, but not for other kinds of _DECLs:
                   2841:             A `const' which was not declared `extern' is invisible.  */
                   2842:          if (TREE_CODE (x) == VAR_DECL
                   2843:              && TREE_READONLY (x) && ! DECL_THIS_EXTERN (x))
                   2844:            TREE_PUBLIC (x) = 0;
                   2845: 
                   2846:          /* If the first global decl has external linkage,
                   2847:             warn if we later see static one.  */
                   2848:          if (IDENTIFIER_GLOBAL_VALUE (name) == NULL_TREE && TREE_PUBLIC (x))
                   2849:            TREE_PUBLIC (name) = 1;
                   2850: 
                   2851:          /* Don't install a TYPE_DECL if we already have another
                   2852:             sort of _DECL with that name.  */
                   2853:          if (TREE_CODE (x) != TYPE_DECL
                   2854:              || t == NULL_TREE
                   2855:              || TREE_CODE (t) == TYPE_DECL)
                   2856:            IDENTIFIER_GLOBAL_VALUE (name) = x;
                   2857: 
                   2858:          /* Don't forget if the function was used via an implicit decl.  */
                   2859:          if (IDENTIFIER_IMPLICIT_DECL (name)
                   2860:              && TREE_USED (IDENTIFIER_IMPLICIT_DECL (name)))
                   2861:            TREE_USED (x) = 1;
                   2862: 
                   2863:          /* Don't forget if its address was taken in that way.  */
                   2864:          if (IDENTIFIER_IMPLICIT_DECL (name)
                   2865:              && TREE_ADDRESSABLE (IDENTIFIER_IMPLICIT_DECL (name)))
                   2866:            TREE_ADDRESSABLE (x) = 1;
                   2867: 
                   2868:          /* Warn about mismatches against previous implicit decl.  */
                   2869:          if (IDENTIFIER_IMPLICIT_DECL (name) != NULL_TREE
                   2870:              /* If this real decl matches the implicit, don't complain.  */
                   2871:              && ! (TREE_CODE (x) == FUNCTION_DECL
                   2872:                    && TREE_TYPE (TREE_TYPE (x)) == integer_type_node))
                   2873:            cp_warning
                   2874:              ("`%D' was previously implicitly declared to return `int'", x);
                   2875: 
                   2876:          /* If this decl is `static' and an `extern' was seen previously,
                   2877:             that is erroneous.  Don't do this for TYPE_DECLs.  */
                   2878:          if (TREE_PUBLIC (name)
                   2879:              && TREE_CODE (x) != TYPE_DECL
                   2880:              && ! TREE_PUBLIC (x) && ! DECL_EXTERNAL (x))
                   2881:            {
                   2882:              if (IDENTIFIER_IMPLICIT_DECL (name))
                   2883:                cp_warning
                   2884:                  ("`%D' was declared implicitly `extern' and later `static'",
                   2885:                   x);
                   2886:              else
                   2887:                cp_warning
                   2888:                  ("`%D' was declared `extern' and later `static'", x);
                   2889:            }
                   2890:        }
                   2891:       else
                   2892:        {
                   2893:          /* Here to install a non-global value.  */
                   2894:          tree oldlocal = IDENTIFIER_LOCAL_VALUE (name);
                   2895:          tree oldglobal = IDENTIFIER_GLOBAL_VALUE (name);
                   2896:          set_identifier_local_value (name, x);
                   2897: 
                   2898:          /* If this is an extern function declaration, see if we
                   2899:             have a global definition or declaration for the function.  */
                   2900:          if (oldlocal == NULL_TREE
                   2901:              && DECL_EXTERNAL (x) && !DECL_INLINE (x)
                   2902:              && oldglobal != NULL_TREE
                   2903:              && TREE_CODE (x) == FUNCTION_DECL
                   2904:              && TREE_CODE (oldglobal) == FUNCTION_DECL)
                   2905:            {
                   2906:              /* We have one.  Their types must agree.  */
                   2907:              if (! comptypes (TREE_TYPE (x), TREE_TYPE (oldglobal), 1))
                   2908:                {
                   2909:                  cp_warning ("extern declaration of `%#D' doesn't match", x);
                   2910:                  cp_warning_at ("global declaration `%#D'", oldglobal);
                   2911:                }
                   2912:              else
                   2913:                {
                   2914:                  /* Inner extern decl is inline if global one is.
                   2915:                     Copy enough to really inline it.  */
                   2916:                  if (DECL_INLINE (oldglobal))
                   2917:                    {
                   2918:                      DECL_INLINE (x) = DECL_INLINE (oldglobal);
                   2919:                      DECL_INITIAL (x) = (current_function_decl == oldglobal
                   2920:                                          ? NULL_TREE : DECL_INITIAL (oldglobal));
                   2921:                      DECL_SAVED_INSNS (x) = DECL_SAVED_INSNS (oldglobal);
                   2922:                      DECL_FRAME_SIZE (x) = DECL_FRAME_SIZE (oldglobal);
                   2923:                      DECL_ARGUMENTS (x) = DECL_ARGUMENTS (oldglobal);
                   2924:                      DECL_RESULT (x) = DECL_RESULT (oldglobal);
                   2925:                      TREE_ASM_WRITTEN (x) = TREE_ASM_WRITTEN (oldglobal);
                   2926:                      DECL_ABSTRACT_ORIGIN (x) = oldglobal;
                   2927:                    }
                   2928:                  /* Inner extern decl is built-in if global one is.  */
                   2929:                  if (DECL_BUILT_IN (oldglobal))
                   2930:                    {
                   2931:                      DECL_BUILT_IN (x) = DECL_BUILT_IN (oldglobal);
                   2932:                      DECL_SET_FUNCTION_CODE (x, DECL_FUNCTION_CODE (oldglobal));
                   2933:                    }
                   2934:                  /* Keep the arg types from a file-scope fcn defn.  */
                   2935:                  if (TYPE_ARG_TYPES (TREE_TYPE (oldglobal)) != NULL_TREE
                   2936:                      && DECL_INITIAL (oldglobal)
                   2937:                      && TYPE_ARG_TYPES (TREE_TYPE (x)) == NULL_TREE)
                   2938:                    TREE_TYPE (x) = TREE_TYPE (oldglobal);
                   2939:                }
                   2940:            }
                   2941:          /* If we have a local external declaration,
                   2942:             and no file-scope declaration has yet been seen,
                   2943:             then if we later have a file-scope decl it must not be static.  */
                   2944:          if (oldlocal == NULL_TREE
                   2945:              && oldglobal == NULL_TREE
                   2946:              && DECL_EXTERNAL (x)
                   2947:              && TREE_PUBLIC (x))
                   2948:            {
                   2949:              TREE_PUBLIC (name) = 1;
                   2950:            }
                   2951: 
                   2952:          if (DECL_FROM_INLINE (x))
                   2953:            /* Inline decls shadow nothing.  */;
                   2954: 
                   2955:          /* Warn if shadowing an argument at the top level of the body.  */
                   2956:          else if (oldlocal != NULL_TREE && !DECL_EXTERNAL (x)
                   2957:              && TREE_CODE (oldlocal) == PARM_DECL
                   2958:              && TREE_CODE (x) != PARM_DECL)
                   2959:            {
                   2960:              /* Go to where the parms should be and see if we
                   2961:                 find them there.  */
                   2962:              struct binding_level *b = current_binding_level->level_chain;
                   2963: 
                   2964:              if (cleanup_label)
                   2965:                b = b->level_chain;
                   2966: 
                   2967:              /* ARM $8.3 */
                   2968:              if (b->parm_flag == 1)
                   2969:                cp_error ("declaration of `%#D' shadows a parameter", name);
                   2970:            }
                   2971:          /* Maybe warn if shadowing something else.  */
                   2972:          else if (warn_shadow && !DECL_EXTERNAL (x)
                   2973:                   /* No shadow warnings for internally generated vars.  */
                   2974:                   && DECL_SOURCE_LINE (x) != 0
                   2975:                   /* No shadow warnings for vars made for inlining.  */
                   2976:                   && ! DECL_FROM_INLINE (x))
                   2977:            {
                   2978:              char *warnstring = NULL;
                   2979: 
                   2980:              if (oldlocal != NULL_TREE && TREE_CODE (oldlocal) == PARM_DECL)
                   2981:                warnstring = "declaration of `%s' shadows a parameter";
                   2982:              else if (IDENTIFIER_CLASS_VALUE (name) != NULL_TREE
                   2983:                       && !TREE_STATIC (name))
                   2984:                warnstring = "declaration of `%s' shadows a member of `this'";
                   2985:              else if (oldlocal != NULL_TREE)
                   2986:                warnstring = "declaration of `%s' shadows previous local";
                   2987:              else if (oldglobal != NULL_TREE)
                   2988:                warnstring = "declaration of `%s' shadows global declaration";
                   2989: 
                   2990:              if (warnstring)
                   2991:                warning (warnstring, IDENTIFIER_POINTER (name));
                   2992:            }
                   2993: 
                   2994:          /* If storing a local value, there may already be one (inherited).
                   2995:             If so, record it for restoration when this binding level ends.  */
                   2996:          if (oldlocal != NULL_TREE)
                   2997:            b->shadowed = tree_cons (name, oldlocal, b->shadowed);
                   2998:        }
                   2999: 
                   3000:       /* Keep count of variables in this level with incomplete type.  */
                   3001:       if (TREE_CODE (x) != TEMPLATE_DECL
                   3002:          && TREE_CODE (x) != CPLUS_CATCH_DECL
                   3003:          && TYPE_SIZE (TREE_TYPE (x)) == NULL_TREE
                   3004:          && PROMOTES_TO_AGGR_TYPE (TREE_TYPE (x), ARRAY_TYPE))
                   3005:        {
                   3006:          if (++b->n_incomplete == 0)
                   3007:            error ("too many incomplete variables at this point");
                   3008:        }
                   3009:     }
                   3010: 
                   3011:   if (TREE_CODE (x) == TYPE_DECL && name != NULL_TREE)
                   3012:     {
                   3013: #if !NEW_CLASS_SCOPING
                   3014:       adjust_type_value (name);
                   3015: #endif
                   3016:       if (current_class_name)
                   3017:        {
                   3018:          if (!DECL_NESTED_TYPENAME (x))
                   3019:            set_nested_typename (x, current_class_name, DECL_NAME (x),
                   3020:                                 TREE_TYPE (x));
                   3021: #if !NEW_CLASS_SCOPING
                   3022:          adjust_type_value (DECL_NESTED_TYPENAME (x));
                   3023: #endif
                   3024:        }
                   3025:     }
                   3026: 
                   3027:   /* Put decls on list in reverse order.
                   3028:      We will reverse them later if necessary.  */
                   3029:   TREE_CHAIN (x) = b->names;
                   3030:   b->names = x;
                   3031:   if (! (b != global_binding_level || TREE_PERMANENT (x)))
                   3032:     my_friendly_abort (124);
                   3033: 
                   3034:   return x;
                   3035: }
                   3036: 
                   3037: /* Like pushdecl, only it places X in GLOBAL_BINDING_LEVEL,
                   3038:    if appropriate.  */
                   3039: tree
                   3040: pushdecl_top_level (x)
                   3041:      tree x;
                   3042: {
                   3043:   register tree t;
                   3044:   register struct binding_level *b = current_binding_level;
                   3045: 
                   3046:   current_binding_level = global_binding_level;
                   3047:   t = pushdecl (x);
                   3048:   current_binding_level = b;
                   3049:   if (class_binding_level)
                   3050:     b = class_binding_level;
                   3051:   /* Now, the type_shadowed stack may screw us.  Munge it so it does
                   3052:      what we want.  */
                   3053:   if (TREE_CODE (x) == TYPE_DECL)
                   3054:     {
                   3055:       tree name = DECL_NAME (x);
                   3056:       tree newval;
                   3057:       tree *ptr = (tree *)0;
                   3058:       for (; b != global_binding_level; b = b->level_chain)
                   3059:         {
                   3060:           tree shadowed = b->type_shadowed;
                   3061:           for (; shadowed; shadowed = TREE_CHAIN (shadowed))
                   3062:             if (TREE_PURPOSE (shadowed) == name)
                   3063:               {
                   3064:                ptr = &TREE_VALUE (shadowed);
                   3065:                /* Can't break out of the loop here because sometimes
                   3066:                   a binding level will have duplicate bindings for
                   3067:                   PT names.  It's gross, but I haven't time to fix it.  */
                   3068:               }
                   3069:         }
                   3070:       newval = TREE_TYPE (x);
                   3071:       if (ptr == (tree *)0)
                   3072:         {
                   3073:           /* @@ This shouldn't be needed.  My test case "zstring.cc" trips
                   3074:              up here if this is changed to an assertion.  --KR  */
                   3075:          SET_IDENTIFIER_TYPE_VALUE (name, newval);
                   3076:        }
                   3077:       else
                   3078:         {
                   3079: #if 0
                   3080:          /* Disabled this 11/10/92, since there are many cases which
                   3081:             behave just fine when *ptr doesn't satisfy either of these.
                   3082:             For example, nested classes declared as friends of their enclosing
                   3083:             class will not meet this criteria.  (bpk) */
                   3084:          my_friendly_assert (*ptr == NULL_TREE || *ptr == newval, 141);
                   3085: #endif
                   3086:          *ptr = newval;
                   3087:         }
                   3088:     }
                   3089:   return t;
                   3090: }
                   3091: 
                   3092: /* Like push_overloaded_decl, only it places X in GLOBAL_BINDING_LEVEL,
                   3093:    if appropriate.  */
                   3094: void
                   3095: push_overloaded_decl_top_level (x, forget)
                   3096:      tree x;
                   3097:      int forget;
                   3098: {
                   3099:   struct binding_level *b = current_binding_level;
                   3100: 
                   3101:   current_binding_level = global_binding_level;
                   3102:   push_overloaded_decl (x, forget);
                   3103:   current_binding_level = b;
                   3104: }
                   3105: 
                   3106: /* Make the declaration of X appear in CLASS scope.  */
                   3107: tree
                   3108: pushdecl_class_level (x)
                   3109:      tree x;
                   3110: {
                   3111:   /* Don't use DECL_ASSEMBLER_NAME here!  Everything that looks in class
                   3112:      scope looks for the pre-mangled name.  */
                   3113:   register tree name = DECL_NAME (x);
                   3114: 
                   3115:   if (name)
                   3116:     {
                   3117: #if NEW_CLASS_SCOPING
                   3118:       push_class_level_binding (name, x);
                   3119:       if (TREE_CODE (x) == TYPE_DECL)
                   3120:        {
                   3121:          set_identifier_type_value (name, TREE_TYPE (x));
                   3122:          if (!DECL_NESTED_TYPENAME (x))
                   3123:            set_nested_typename (x, current_class_name, name, TREE_TYPE (x));
                   3124:        }
                   3125: #else
                   3126:       tree oldclass = IDENTIFIER_CLASS_VALUE (name);
                   3127:       if (oldclass)
                   3128:        class_binding_level->class_shadowed
                   3129:          = tree_cons (name, oldclass, class_binding_level->class_shadowed);
                   3130:       IDENTIFIER_CLASS_VALUE (name) = x;
                   3131:       obstack_ptr_grow (&decl_obstack, x);
                   3132:       if (TREE_CODE (x) == TYPE_DECL && !DECL_NESTED_TYPENAME (x))
                   3133:        set_nested_typename (x, current_class_name, name, TREE_TYPE (x));
                   3134: #endif
                   3135:     }
                   3136:   return x;
                   3137: }
                   3138: 
                   3139: #if NEW_CLASS_SCOPING
                   3140: /* Make the declaration(s) of X appear in CLASS scope
                   3141:    under the name NAME.  */
                   3142: void
                   3143: push_class_level_binding (name, x)
                   3144:      tree name;
                   3145:      tree x;
                   3146: {
                   3147:   maybe_push_cache_obstack ();
                   3148:   class_binding_level->class_shadowed
                   3149:       = tree_cons (name, IDENTIFIER_CLASS_VALUE (name),
                   3150:                   class_binding_level->class_shadowed);
                   3151:   pop_obstacks ();
                   3152:   IDENTIFIER_CLASS_VALUE (name) = x;
                   3153:   obstack_ptr_grow (&decl_obstack, x);
                   3154: }
                   3155: #endif
                   3156: 
                   3157: /* Tell caller how to interpret a TREE_LIST which contains
                   3158:    chains of FUNCTION_DECLS.  */
                   3159: int
                   3160: overloaded_globals_p (list)
                   3161:      tree list;
                   3162: {
                   3163:   my_friendly_assert (TREE_CODE (list) == TREE_LIST, 142);
                   3164: 
                   3165:   /* Don't commit caller to seeing them as globals.  */
                   3166:   if (TREE_NONLOCAL_FLAG (list))
                   3167:     return -1;
                   3168:   /* Do commit caller to seeing them as globals.  */
                   3169:   if (TREE_CODE (TREE_PURPOSE (list)) == IDENTIFIER_NODE)
                   3170:     return 1;
                   3171:   /* Do commit caller to not seeing them as globals.  */
                   3172:   return 0;
                   3173: }
                   3174: 
                   3175: /* DECL is a FUNCTION_DECL which may have other definitions already in place.
                   3176:    We get around this by making IDENTIFIER_GLOBAL_VALUE (DECL_NAME (DECL))
                   3177:    point to a list of all the things that want to be referenced by that name.
                   3178:    It is then up to the users of that name to decide what to do with that
                   3179:    list.
                   3180: 
                   3181:    DECL may also be a TEMPLATE_DECL, with a FUNCTION_DECL in its DECL_RESULT
                   3182:    slot.  It is dealt with the same way.
                   3183: 
                   3184:    The value returned may be a previous declaration if we guessed wrong
                   3185:    about what language DECL should belong to (C or C++).  Otherwise,
                   3186:    it's always DECL (and never something that's not a _DECL).  */
                   3187: tree
                   3188: push_overloaded_decl (decl, forgettable)
                   3189:      tree decl;
                   3190:      int forgettable;
                   3191: {
                   3192:   tree orig_name = DECL_NAME (decl);
                   3193:   tree glob = IDENTIFIER_GLOBAL_VALUE (orig_name);
                   3194: 
                   3195:   DECL_OVERLOADED (decl) = 1;
                   3196:   if (glob)
                   3197:     {
                   3198:       if (TREE_CODE (glob) != TREE_LIST)
                   3199:        {
                   3200:          if (DECL_HAS_C_LINKAGE (decl))
                   3201:            {
                   3202:              if (TREE_CODE (glob) == FUNCTION_DECL)
                   3203:                {
                   3204:                  if (DECL_HAS_C_LINKAGE (glob))
                   3205:                    {
                   3206:                      cp_error ("C-language function `%D' overloaded here", decl);
                   3207:                      cp_error_at ("Previous C-language version of this function was `%D'", glob);
                   3208:                    }
                   3209:                }
                   3210:              else
                   3211:                my_friendly_abort (9);
                   3212:            }
                   3213:          if (forgettable
                   3214:              && ! flag_traditional
                   3215:              && TREE_PERMANENT (glob) == 1
                   3216:              && !global_bindings_p ())
                   3217:            overloads_to_forget = tree_cons (orig_name, glob, overloads_to_forget);
                   3218:          /* We cache the value of builtin functions as ADDR_EXPRs
                   3219:             in the name space.  Convert it to some kind of _DECL after
                   3220:             remembering what to forget.  */
                   3221:          if (TREE_CODE (glob) == ADDR_EXPR)
                   3222:            glob = TREE_OPERAND (glob, 0);
                   3223: 
                   3224:          if (TREE_CODE (glob) == FUNCTION_DECL
                   3225:              && ! DECLS_SAME_LINKAGE (glob, decl)
                   3226:              && comptypes (TREE_TYPE (glob), TREE_TYPE (decl), 2))
                   3227:            {
                   3228:              if (current_lang_stack == current_lang_base)
                   3229:                {
                   3230:                  DECL_LANGUAGE (decl) = DECL_LANGUAGE (glob);
                   3231:                  return glob;
                   3232:                }
                   3233:              else
                   3234:                {
                   3235:                  cp_error ("conflicting language contexts for declaration of `%D';", decl);
                   3236:                  cp_error_at ("conflicts with previous declaration here", glob);
                   3237:                }
                   3238:            }
                   3239:          if (pedantic && TREE_CODE (glob) == VAR_DECL)
                   3240:            {
                   3241:              my_friendly_assert (TREE_CODE_CLASS (TREE_CODE (glob)) == 'd', 143);
                   3242:              cp_error ("non-function declaration `%D'", glob);
                   3243:              cp_error_at ("conflicts with function declaration `%D'", decl);
                   3244:            }
                   3245:          glob = tree_cons (orig_name, glob, NULL_TREE);
                   3246:          glob = tree_cons (TREE_PURPOSE (glob), decl, glob);
                   3247:          IDENTIFIER_GLOBAL_VALUE (orig_name) = glob;
                   3248:          TREE_TYPE (glob) = unknown_type_node;
                   3249:          return decl;
                   3250:        }
                   3251: 
                   3252:       if (TREE_VALUE (glob) == NULL_TREE)
                   3253:        {
                   3254:          TREE_VALUE (glob) = decl;
                   3255:          return decl;
                   3256:        }
                   3257:       if (TREE_CODE (decl) != TEMPLATE_DECL)
                   3258:         {
                   3259:           tree name = DECL_ASSEMBLER_NAME (decl);
                   3260:           tree tmp;
                   3261:          
                   3262:          for (tmp = glob; tmp; tmp = TREE_CHAIN (tmp))
                   3263:            {
                   3264:              if (TREE_CODE (TREE_VALUE (tmp)) == FUNCTION_DECL
                   3265:                  && comptypes (TREE_TYPE (TREE_VALUE (tmp)), TREE_TYPE (decl),
                   3266:                                2))
                   3267:                {
                   3268:                  if (! DECLS_SAME_LINKAGE (TREE_VALUE (tmp), decl))
                   3269:                    {
                   3270:                      cp_error_at ("conflicting language contexts for declaration of `%D';", decl);
                   3271:                      cp_error_at ("conflicts with previous declaration here", TREE_VALUE (tmp));
                   3272:                    }
                   3273:                  else if (TREE_CODE (TREE_VALUE (tmp)) != TEMPLATE_DECL
                   3274:                           && DECL_ASSEMBLER_NAME (TREE_VALUE (tmp)) != name)
                   3275:                    {
                   3276:                      cp_error ("new declaration `%#D'", decl);
                   3277:                      cp_error_at ("ambiguates old declaration `%#D'",
                   3278:                                     TREE_VALUE (tmp));
                   3279:                    }
                   3280:                }
                   3281:              /* If we really have seen this before, then if it ambiguates
                   3282:                 something, we've already given an error before.  */
                   3283:              if (TREE_CODE (TREE_VALUE (tmp)) != TEMPLATE_DECL
                   3284:                  && DECL_ASSEMBLER_NAME (TREE_VALUE (tmp)) == name)
                   3285:                return decl;
                   3286:            }
                   3287:        }
                   3288:     }
                   3289:   if (DECL_HAS_C_LINKAGE (decl))
                   3290:     {
                   3291:       tree decls = glob;
                   3292:       while (decls && DECL_HAS_CPLUSPLUS_LINKAGE (TREE_VALUE (decls)))
                   3293:        decls = TREE_CHAIN (decls);
                   3294:       if (decls)
                   3295:        {
                   3296:          cp_error ("C-language function `%D' overloaded here", decl);
                   3297:          cp_error_at
                   3298:            ("Previous C-language version of this function was `%D'",
                   3299:             TREE_VALUE (decls));
                   3300:        }
                   3301:     }
                   3302: 
                   3303:   if (forgettable
                   3304:       && ! flag_traditional
                   3305:       && (glob == NULL_TREE || TREE_PERMANENT (glob) == 1)
                   3306:       && !global_bindings_p ()
                   3307:       && !pseudo_global_level_p ())
                   3308:     overloads_to_forget = tree_cons (orig_name, glob, overloads_to_forget);
                   3309:   glob = tree_cons (orig_name, decl, glob);
                   3310:   IDENTIFIER_GLOBAL_VALUE (orig_name) = glob;
                   3311:   TREE_TYPE (glob) = unknown_type_node;
                   3312:   return decl;
                   3313: }
                   3314: 
                   3315: /* Generate an implicit declaration for identifier FUNCTIONID
                   3316:    as a function of type int ().  Print a warning if appropriate.  */
                   3317: 
                   3318: tree
                   3319: implicitly_declare (functionid)
                   3320:      tree functionid;
                   3321: {
                   3322:   register tree decl;
                   3323:   int temp = allocation_temporary_p ();
                   3324: 
                   3325:   push_obstacks_nochange ();
                   3326: 
                   3327:   /* Save the decl permanently so we can warn if definition follows.
                   3328:      In ANSI C, warn_implicit is usually false, so the saves little space.
                   3329:      But in C++, it's usually true, hence the extra code.  */
                   3330:   if (temp && (flag_traditional || !warn_implicit
                   3331:               || current_binding_level == global_binding_level))
                   3332:     end_temporary_allocation ();
                   3333: 
                   3334:   /* We used to reuse an old implicit decl here,
                   3335:      but this loses with inline functions because it can clobber
                   3336:      the saved decl chains.  */
                   3337:   decl = build_lang_decl (FUNCTION_DECL, functionid, default_function_type);
                   3338: 
                   3339:   DECL_EXTERNAL (decl) = 1;
                   3340:   TREE_PUBLIC (decl) = 1;
                   3341: 
                   3342:   /* ANSI standard says implicit declarations are in the innermost block.
                   3343:      So we record the decl in the standard fashion.
                   3344:      If flag_traditional is set, pushdecl does it top-level.  */
                   3345:   pushdecl (decl);
                   3346:   rest_of_decl_compilation (decl, NULL_PTR, 0, 0);
                   3347: 
                   3348:   if (warn_implicit
                   3349:       /* Only one warning per identifier.  */
                   3350:       && IDENTIFIER_IMPLICIT_DECL (functionid) == NULL_TREE)
                   3351:     {
                   3352:       cp_pedwarn ("implicit declaration of function `%#D'", decl);
                   3353:     }
                   3354: 
                   3355:   SET_IDENTIFIER_IMPLICIT_DECL (functionid, decl);
                   3356: 
                   3357:   pop_obstacks ();
                   3358: 
                   3359:   return decl;
                   3360: }
                   3361: 
                   3362: /* Return zero if the declaration NEWDECL is valid
                   3363:    when the declaration OLDDECL (assumed to be for the same name)
                   3364:    has already been seen.
                   3365:    Otherwise return an error message format string with a %s
                   3366:    where the identifier should go.  */
                   3367: 
                   3368: static char *
                   3369: redeclaration_error_message (newdecl, olddecl)
                   3370:      tree newdecl, olddecl;
                   3371: {
                   3372:   if (TREE_CODE (newdecl) == TYPE_DECL)
                   3373:     {
                   3374:       /* Because C++ can put things into name space for free,
                   3375:         constructs like "typedef struct foo { ... } foo"
                   3376:         would look like an erroneous redeclaration.  */
                   3377:       if (comptypes (newdecl, olddecl, 0))
                   3378:        return 0;
                   3379:       else
                   3380:        return "redefinition of `%s'";
                   3381:     }
                   3382:   else if (TREE_CODE (newdecl) == FUNCTION_DECL)
                   3383:     {
                   3384:       /* If this is a pure function, its olddecl will actually be
                   3385:         the original initialization to `0' (which we force to call
                   3386:         abort()).  Don't complain about redefinition in this case.  */
                   3387:       if (DECL_LANG_SPECIFIC (olddecl) && DECL_ABSTRACT_VIRTUAL_P (olddecl))
                   3388:        return 0;
                   3389: 
                   3390:       /* Declarations of functions can insist on internal linkage
                   3391:         but they can't be inconsistent with internal linkage,
                   3392:         so there can be no error on that account.
                   3393:         However defining the same name twice is no good.  */
                   3394:       if (DECL_INITIAL (olddecl) != NULL_TREE
                   3395:          && DECL_INITIAL (newdecl) != NULL_TREE
                   3396:          /* However, defining once as extern inline and a second
                   3397:             time in another way is ok.  */
                   3398:          && !(DECL_INLINE (olddecl) && DECL_EXTERNAL (olddecl)
                   3399:               && !(DECL_INLINE (newdecl) && DECL_EXTERNAL (newdecl))))
                   3400:        {
                   3401:          if (DECL_NAME (olddecl) == NULL_TREE)
                   3402:            return "`%s' not declared in class";
                   3403:          else
                   3404:            return "redefinition of `%s'";
                   3405:        }
                   3406:       return 0;
                   3407:     }
                   3408:   else if (current_binding_level == global_binding_level)
                   3409:     {
                   3410:       /* Objects declared at top level:  */
                   3411:       /* If at least one is a reference, it's ok.  */
                   3412:       if (DECL_EXTERNAL (newdecl) || DECL_EXTERNAL (olddecl))
                   3413:        return 0;
                   3414:       /* Reject two definitions.  */
                   3415:       if (DECL_INITIAL (olddecl) != NULL_TREE
                   3416:          && DECL_INITIAL (newdecl) != NULL_TREE)
                   3417:        return "redefinition of `%s'";
                   3418:       /* Now we have two tentative defs, or one tentative and one real def.  */
                   3419:       /* Insist that the linkage match.  */
                   3420:       if (TREE_PUBLIC (olddecl) != TREE_PUBLIC (newdecl))
                   3421:        return "conflicting declarations of `%s'";
                   3422:       return 0;
                   3423:     }
                   3424:   else
                   3425:     {
                   3426:       /* Objects declared with block scope:  */
                   3427:       /* Reject two definitions, and reject a definition
                   3428:         together with an external reference.  */
                   3429:       if (!(DECL_EXTERNAL (newdecl) && DECL_EXTERNAL (olddecl)))
                   3430:        return "redeclaration of `%s'";
                   3431:       return 0;
                   3432:     }
                   3433: }
                   3434: 
                   3435: /* Get the LABEL_DECL corresponding to identifier ID as a label.
                   3436:    Create one if none exists so far for the current function.
                   3437:    This function is called for both label definitions and label references.  */
                   3438: 
                   3439: tree
                   3440: lookup_label (id)
                   3441:      tree id;
                   3442: {
                   3443:   register tree decl = IDENTIFIER_LABEL_VALUE (id);
                   3444: 
                   3445:   if (current_function_decl == NULL_TREE)
                   3446:     {
                   3447:       error ("label `%s' referenced outside of any function",
                   3448:             IDENTIFIER_POINTER (id));
                   3449:       return NULL_TREE;
                   3450:     }
                   3451: 
                   3452:   if ((decl == NULL_TREE
                   3453:       || DECL_SOURCE_LINE (decl) == 0)
                   3454:       && (named_label_uses == NULL_TREE
                   3455:          || TREE_PURPOSE (named_label_uses) != current_binding_level->names
                   3456:          || TREE_VALUE (named_label_uses) != decl))
                   3457:     {
                   3458:       named_label_uses
                   3459:        = tree_cons (current_binding_level->names, decl, named_label_uses);
                   3460:       TREE_TYPE (named_label_uses) = (tree)current_binding_level;
                   3461:     }
                   3462: 
                   3463:   /* Use a label already defined or ref'd with this name.  */
                   3464:   if (decl != NULL_TREE)
                   3465:     {
                   3466:       /* But not if it is inherited and wasn't declared to be inheritable.  */
                   3467:       if (DECL_CONTEXT (decl) != current_function_decl
                   3468:          && ! C_DECLARED_LABEL_FLAG (decl))
                   3469:        return shadow_label (id);
                   3470:       return decl;
                   3471:     }
                   3472: 
                   3473:   decl = build_decl (LABEL_DECL, id, void_type_node);
                   3474: 
                   3475:   /* A label not explicitly declared must be local to where it's ref'd.  */
                   3476:   DECL_CONTEXT (decl) = current_function_decl;
                   3477: 
                   3478:   DECL_MODE (decl) = VOIDmode;
                   3479: 
                   3480:   /* Say where one reference is to the label,
                   3481:      for the sake of the error if it is not defined.  */
                   3482:   DECL_SOURCE_LINE (decl) = lineno;
                   3483:   DECL_SOURCE_FILE (decl) = input_filename;
                   3484: 
                   3485:   SET_IDENTIFIER_LABEL_VALUE (id, decl);
                   3486: 
                   3487:   named_labels = tree_cons (NULL_TREE, decl, named_labels);
                   3488:   TREE_VALUE (named_label_uses) = decl;
                   3489: 
                   3490:   return decl;
                   3491: }
                   3492: 
                   3493: /* Make a label named NAME in the current function,
                   3494:    shadowing silently any that may be inherited from containing functions
                   3495:    or containing scopes.
                   3496: 
                   3497:    Note that valid use, if the label being shadowed
                   3498:    comes from another scope in the same function,
                   3499:    requires calling declare_nonlocal_label right away.  */
                   3500: 
                   3501: tree
                   3502: shadow_label (name)
                   3503:      tree name;
                   3504: {
                   3505:   register tree decl = IDENTIFIER_LABEL_VALUE (name);
                   3506: 
                   3507:   if (decl != NULL_TREE)
                   3508:     {
                   3509:       shadowed_labels = tree_cons (NULL_TREE, decl, shadowed_labels);
                   3510:       SET_IDENTIFIER_LABEL_VALUE (name, NULL_TREE);
                   3511:       SET_IDENTIFIER_LABEL_VALUE (decl, NULL_TREE);
                   3512:     }
                   3513: 
                   3514:   return lookup_label (name);
                   3515: }
                   3516: 
                   3517: /* Define a label, specifying the location in the source file.
                   3518:    Return the LABEL_DECL node for the label, if the definition is valid.
                   3519:    Otherwise return 0.  */
                   3520: 
                   3521: tree
                   3522: define_label (filename, line, name)
                   3523:      char *filename;
                   3524:      int line;
                   3525:      tree name;
                   3526: {
                   3527:   tree decl = lookup_label (name);
                   3528: 
                   3529:   /* After labels, make any new cleanups go into their
                   3530:      own new (temporary) binding contour.  */
                   3531:   current_binding_level->more_cleanups_ok = 0;
                   3532: 
                   3533:   /* If label with this name is known from an outer context, shadow it.  */
                   3534:   if (decl != NULL_TREE && DECL_CONTEXT (decl) != current_function_decl)
                   3535:     {
                   3536:       shadowed_labels = tree_cons (NULL_TREE, decl, shadowed_labels);
                   3537:       SET_IDENTIFIER_LABEL_VALUE (name, NULL_TREE);
                   3538:       decl = lookup_label (name);
                   3539:     }
                   3540: 
                   3541:   if (DECL_INITIAL (decl) != NULL_TREE)
                   3542:     {
                   3543:       cp_error ("duplicate label `%D'", decl);
                   3544:       return 0;
                   3545:     }
                   3546:   else
                   3547:     {
                   3548:       tree uses, prev;
                   3549: 
                   3550:       /* Mark label as having been defined.  */
                   3551:       DECL_INITIAL (decl) = error_mark_node;
                   3552:       /* Say where in the source.  */
                   3553:       DECL_SOURCE_FILE (decl) = filename;
                   3554:       DECL_SOURCE_LINE (decl) = line;
                   3555: 
                   3556:       for (prev = NULL_TREE, uses = named_label_uses;
                   3557:           uses;
                   3558:           prev = uses, uses = TREE_CHAIN (uses))
                   3559:        if (TREE_VALUE (uses) == decl)
                   3560:          {
                   3561:            struct binding_level *b = current_binding_level;
                   3562:            while (b)
                   3563:              {
                   3564:                tree new_decls = b->names;
                   3565:                tree old_decls = ((tree)b == TREE_TYPE (uses)
                   3566:                                  ? TREE_PURPOSE (uses) : NULL_TREE);
                   3567:                while (new_decls != old_decls)
                   3568:                  {
                   3569:                    if (TREE_CODE (new_decls) == VAR_DECL
                   3570:                        /* Don't complain about crossing initialization
                   3571:                           of internal entities.  They can't be accessed,
                   3572:                           and they should be cleaned up
                   3573:                           by the time we get to the label.  */
                   3574:                        && DECL_SOURCE_LINE (new_decls) != 0
                   3575:                        && ((DECL_INITIAL (new_decls) != NULL_TREE
                   3576:                             && DECL_INITIAL (new_decls) != error_mark_node)
                   3577:                            || TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (new_decls))))
                   3578:                      {
                   3579:                        if (IDENTIFIER_ERROR_LOCUS (decl) == NULL_TREE)
                   3580:                          cp_error ("invalid jump to label `%D'", decl);
                   3581:                        SET_IDENTIFIER_ERROR_LOCUS (decl, current_function_decl);
                   3582:                        cp_error ("crosses initialization of `%D'", new_decls);
                   3583:                      }
                   3584:                    new_decls = TREE_CHAIN (new_decls);
                   3585:                  }
                   3586:                if ((tree)b == TREE_TYPE (uses))
                   3587:                  break;
                   3588:                b = b->level_chain;
                   3589:              }
                   3590: 
                   3591:            if (prev)
                   3592:              TREE_CHAIN (prev) = TREE_CHAIN (uses);
                   3593:            else
                   3594:              named_label_uses = TREE_CHAIN (uses);
                   3595:          }
                   3596:       current_function_return_value = NULL_TREE;
                   3597:       return decl;
                   3598:     }
                   3599: }
                   3600: 
                   3601: /* Same, but for CASE labels.  If DECL is NULL_TREE, it's the default.  */
                   3602: /* XXX Note decl is never actually used. (bpk) */
                   3603: void
                   3604: define_case_label (decl)
                   3605:      tree decl;
                   3606: {
                   3607:   tree cleanup = last_cleanup_this_contour ();
                   3608:   if (cleanup)
                   3609:     {
                   3610:       static int explained = 0;
                   3611:       cp_error_at ("destructor needed for `%#D'", TREE_PURPOSE (cleanup));
                   3612:       error ("where case label appears here");
                   3613:       if (!explained)
                   3614:        {
                   3615:          error ("(enclose actions of previous case statements requiring");
                   3616:          error ("destructors in their own binding contours.)");
                   3617:          explained = 1;
                   3618:        }
                   3619:     }
                   3620: 
                   3621:   /* After labels, make any new cleanups go into their
                   3622:      own new (temporary) binding contour.  */
                   3623: 
                   3624:   current_binding_level->more_cleanups_ok = 0;
                   3625:   current_function_return_value = NULL_TREE;
                   3626: }
                   3627: 
                   3628: /* Return the list of declarations of the current level.
                   3629:    Note that this list is in reverse order unless/until
                   3630:    you nreverse it; and when you do nreverse it, you must
                   3631:    store the result back using `storedecls' or you will lose.  */
                   3632: 
                   3633: tree
                   3634: getdecls ()
                   3635: {
                   3636:   return current_binding_level->names;
                   3637: }
                   3638: 
                   3639: /* Return the list of type-tags (for structs, etc) of the current level.  */
                   3640: 
                   3641: tree
                   3642: gettags ()
                   3643: {
                   3644:   return current_binding_level->tags;
                   3645: }
                   3646: 
                   3647: /* Store the list of declarations of the current level.
                   3648:    This is done for the parameter declarations of a function being defined,
                   3649:    after they are modified in the light of any missing parameters.  */
                   3650: 
                   3651: static void
                   3652: storedecls (decls)
                   3653:      tree decls;
                   3654: {
                   3655:   current_binding_level->names = decls;
                   3656: }
                   3657: 
                   3658: /* Similarly, store the list of tags of the current level.  */
                   3659: 
                   3660: static void
                   3661: storetags (tags)
                   3662:      tree tags;
                   3663: {
                   3664:   current_binding_level->tags = tags;
                   3665: }
                   3666: 
                   3667: /* Given NAME, an IDENTIFIER_NODE,
                   3668:    return the structure (or union or enum) definition for that name.
                   3669:    Searches binding levels from BINDING_LEVEL up to the global level.
                   3670:    If THISLEVEL_ONLY is nonzero, searches only the specified context
                   3671:    (but skips any tag-transparent contexts to find one that is
                   3672:    meaningful for tags).
                   3673:    FORM says which kind of type the caller wants;
                   3674:    it is RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE.
                   3675:    If the wrong kind of type is found, and it's not a template, an error is
                   3676:    reported.  */
                   3677: 
                   3678: static tree
                   3679: lookup_tag (form, name, binding_level, thislevel_only)
                   3680:      enum tree_code form;
                   3681:      struct binding_level *binding_level;
                   3682:      tree name;
                   3683:      int thislevel_only;
                   3684: {
                   3685:   register struct binding_level *level;
                   3686: 
                   3687:   for (level = binding_level; level; level = level->level_chain)
                   3688:     {
                   3689:       register tree tail;
                   3690:       if (ANON_AGGRNAME_P (name))
                   3691:        for (tail = level->tags; tail; tail = TREE_CHAIN (tail))
                   3692:          {
                   3693:            /* There's no need for error checking here, because
                   3694:               anon names are unique throughout the compilation.  */
                   3695:            if (TYPE_IDENTIFIER (TREE_VALUE (tail)) == name)
                   3696:              return TREE_VALUE (tail);
                   3697:          }
                   3698:       else
                   3699:        for (tail = level->tags; tail; tail = TREE_CHAIN (tail))
                   3700:          {
                   3701:            if (TREE_PURPOSE (tail) == name)
                   3702:              {
                   3703:                enum tree_code code = TREE_CODE (TREE_VALUE (tail));
                   3704:                /* Should tighten this up; it'll probably permit
                   3705:                   UNION_TYPE and a struct template, for example.  */
                   3706:                if (code != form
                   3707:                    && !(form != ENUMERAL_TYPE
                   3708:                         && (code == TEMPLATE_DECL
                   3709:                             || code == UNINSTANTIATED_P_TYPE)))
                   3710:                           
                   3711:                  {
                   3712:                    /* Definition isn't the kind we were looking for.  */
                   3713:                    cp_error ("`%#D' redeclared as %C", TREE_VALUE (tail),
                   3714:                              form);
                   3715:                  }
                   3716:                return TREE_VALUE (tail);
                   3717:              }
                   3718:          }
                   3719:       if (thislevel_only && ! level->tag_transparent)
                   3720:        return NULL_TREE;
                   3721:       if (current_class_type && level->level_chain == global_binding_level)
                   3722:        {
                   3723:          /* Try looking in this class's tags before heading into
                   3724:             global binding level.  */
                   3725:          tree context = current_class_type;
                   3726:          while (context)
                   3727:            {
                   3728:              switch (TREE_CODE_CLASS (TREE_CODE (context)))
                   3729:                {
                   3730:                case 't':
                   3731:                  {
                   3732:                    tree these_tags = CLASSTYPE_TAGS (context);
                   3733:                    if (ANON_AGGRNAME_P (name))
                   3734:                      while (these_tags)
                   3735:                        {
                   3736:                          if (TYPE_IDENTIFIER (TREE_VALUE (these_tags))
                   3737:                              == name)
                   3738:                            return TREE_VALUE (tail);
                   3739:                          these_tags = TREE_CHAIN (these_tags);
                   3740:                        }
                   3741:                    else
                   3742:                      while (these_tags)
                   3743:                        {
                   3744:                          if (TREE_PURPOSE (these_tags) == name)
                   3745:                            {
                   3746:                              if (TREE_CODE (TREE_VALUE (these_tags)) != form)
                   3747:                                {
                   3748:                                  cp_error ("`%#D' redeclared as %C in class scope",
                   3749:                                            TREE_VALUE (tail), form);
                   3750:                                }
                   3751:                              return TREE_VALUE (tail);
                   3752:                            }
                   3753:                          these_tags = TREE_CHAIN (these_tags);
                   3754:                        }
                   3755:                    /* If this type is not yet complete, then don't
                   3756:                       look at its context.  */
                   3757:                    if (TYPE_SIZE (context) == NULL_TREE)
                   3758:                      goto no_context;
                   3759:                    /* Go to next enclosing type, if any.  */
                   3760:                    context = DECL_CONTEXT (TYPE_NAME (context));
                   3761:                    break;
                   3762:                  case 'd':
                   3763:                    context = DECL_CONTEXT (context);
                   3764:                    break;
                   3765:                  default:
                   3766:                    my_friendly_abort (10);
                   3767:                  }
                   3768:                  continue;
                   3769:                }
                   3770:            no_context:
                   3771:              break;
                   3772:            }
                   3773:        }
                   3774:     }
                   3775:   return NULL_TREE;
                   3776: }
                   3777: 
                   3778: void
                   3779: set_current_level_tags_transparency (tags_transparent)
                   3780:      int tags_transparent;
                   3781: {
                   3782:   current_binding_level->tag_transparent = tags_transparent;
                   3783: }
                   3784: 
                   3785: /* Given a type, find the tag that was defined for it and return the tag name.
                   3786:    Otherwise return 0.  However, the value can never be 0
                   3787:    in the cases in which this is used.
                   3788: 
                   3789:    C++: If NAME is non-zero, this is the new name to install.  This is
                   3790:    done when replacing anonymous tags with real tag names.  */
                   3791: 
                   3792: static tree
                   3793: lookup_tag_reverse (type, name)
                   3794:      tree type;
                   3795:      tree name;
                   3796: {
                   3797:   register struct binding_level *level;
                   3798: 
                   3799:   for (level = current_binding_level; level; level = level->level_chain)
                   3800:     {
                   3801:       register tree tail;
                   3802:       for (tail = level->tags; tail; tail = TREE_CHAIN (tail))
                   3803:        {
                   3804:          if (TREE_VALUE (tail) == type)
                   3805:            {
                   3806:              if (name)
                   3807:                TREE_PURPOSE (tail) = name;
                   3808:              return TREE_PURPOSE (tail);
                   3809:            }
                   3810:        }
                   3811:     }
                   3812:   return NULL_TREE;
                   3813: }
                   3814: 
                   3815: /* Given type TYPE which was not declared in C++ language context,
                   3816:    attempt to find a name by which it is referred.  */
                   3817: tree
                   3818: typedecl_for_tag (tag)
                   3819:      tree tag;
                   3820: {
                   3821:   struct binding_level *b = current_binding_level;
                   3822: 
                   3823:   if (TREE_CODE (TYPE_NAME (tag)) == TYPE_DECL)
                   3824:     return TYPE_NAME (tag);
                   3825: 
                   3826:   while (b)
                   3827:     {
                   3828:       tree decls = b->names;
                   3829:       while (decls)
                   3830:        {
                   3831:          if (TREE_CODE (decls) == TYPE_DECL && TREE_TYPE (decls) == tag)
                   3832:            break;
                   3833:          decls = TREE_CHAIN (decls);
                   3834:        }
                   3835:       if (decls)
                   3836:        return decls;
                   3837:       b = b->level_chain;
                   3838:     }
                   3839:   return NULL_TREE;
                   3840: }
                   3841: 
                   3842: /* Called when we must retroactively globalize a type we previously
                   3843:    thought needed to be nested.  This happens, for example, when
                   3844:    a `friend class' declaration is seen for an undefined type.  */
                   3845: 
                   3846: static void
                   3847: globalize_nested_type (type)
                   3848:      tree type;
                   3849: {
                   3850:   tree t, prev = NULL_TREE, d = TYPE_NAME (type);
                   3851:   struct binding_level *b;
                   3852:   tree name = DECL_NAME (d);
                   3853: #if NEW_CLASS_SCOPING
                   3854:   tree class_shadower = NULL_TREE, type_shadower = NULL_TREE, shadow;
                   3855: #endif
                   3856: 
                   3857:   my_friendly_assert (TREE_CODE (d) == TYPE_DECL, 144);
                   3858:   /* If the type value has already been globalized, then we're set.  */
                   3859:   if (IDENTIFIER_GLOBAL_VALUE (name) == d)
                   3860:     return;
                   3861:   if (IDENTIFIER_HAS_TYPE_VALUE (name))
                   3862:     {
                   3863:       /* If this type already made it into the global tags,
                   3864:         silently return.  */
                   3865:       if (value_member (type, global_binding_level->tags))
                   3866:        return;
                   3867:     }
                   3868: 
                   3869: #if NEW_CLASS_SCOPING
                   3870:   if (DECL_LANG_SPECIFIC (d))
                   3871:     DECL_CLASS_CONTEXT (d) = NULL_TREE;
                   3872: #else
                   3873:   set_identifier_type_value (DECL_NESTED_TYPENAME (d), NULL_TREE);
                   3874: #endif
                   3875:   DECL_CONTEXT (d) = NULL_TREE;
                   3876:   TYPE_CONTEXT (d) = NULL_TREE;
                   3877:   DECL_NESTED_TYPENAME (d) = name;
                   3878:   if (class_binding_level)
                   3879:     b = class_binding_level;
                   3880:   else
                   3881:     b = current_binding_level;
                   3882:   while (b != global_binding_level)
                   3883:     {
                   3884:       prev = NULL_TREE;
                   3885:       if (b->parm_flag == 2)
                   3886:        for (t = b->tags; t != NULL_TREE; prev = t, t = TREE_CHAIN (t))
                   3887:          if (TREE_VALUE (t) == type)
                   3888:            goto found;
                   3889: #if NEW_CLASS_SCOPING
                   3890:       /* Find (im?)possible objects shadowing the type we're globalizing.  */
                   3891:       class_shadower = purpose_member (name, b->class_shadowed);
                   3892:       type_shadower = purpose_member (name, b->type_shadowed);
                   3893: #endif      
                   3894:       b = b->level_chain;
                   3895:     }
                   3896:   /* We failed to find this tag anywhere up the binding chains.
                   3897:      B is now the global binding level... check there.  */
                   3898:   prev = NULL_TREE;
                   3899:   if (b->parm_flag == 2)
                   3900:     for (t = b->tags; t != NULL_TREE; prev = t, t = TREE_CHAIN (t))
                   3901:       if (TREE_VALUE (t) == type)
                   3902:        goto foundglobal;
                   3903:   /* It wasn't in global scope either, so this is an anonymous forward ref
                   3904:      of some kind; let it happen.  */
                   3905:   return;
                   3906: 
                   3907: foundglobal:
                   3908:   print_node_brief (stderr, "Tried to globalize already-global type ",
                   3909:                    type, 0);
                   3910:   my_friendly_abort (11);
                   3911: 
                   3912: found:
                   3913:   /* Pull the tag out of the nested binding contour.  */
                   3914:   if (prev)
                   3915:     TREE_CHAIN (prev) = TREE_CHAIN (t);
                   3916:   else
                   3917:     b->tags = TREE_CHAIN (t);
                   3918:   
                   3919: #if NEW_CLASS_SCOPING
                   3920:   /* Find and remove the corresponding entry from the class_shadowed list,
                   3921:      and move the shadowed value to a possibly later shadow.  If there were
                   3922:      no such beast (could there ever be?), install the previously shadowed
                   3923:      value as the IDENTIFIER_CLASS_VALUE.  */
                   3924:   prev = NULL_TREE;
                   3925:   for (shadow = b->class_shadowed;
                   3926:        shadow != NULL_TREE;
                   3927:        prev = shadow, shadow = TREE_CHAIN (shadow))
                   3928:     if (TREE_PURPOSE (shadow) == name)
                   3929:       break;
                   3930: 
                   3931:   if (shadow)
                   3932:     {
                   3933:       /* An example where shadow is NULL is when you have something
                   3934:         like `class foo { public: struct bar; bar *x(); };', since
                   3935:         bar isn't added to the class_shadowed list until it's been
                   3936:         defined.  */
                   3937: 
                   3938:       if (prev)
                   3939:        TREE_CHAIN (prev) = TREE_CHAIN (shadow);
                   3940:       else
                   3941:        b->class_shadowed = TREE_CHAIN (shadow);
                   3942: 
                   3943:       if (class_shadower)
                   3944:        TREE_VALUE (class_shadower) = TREE_VALUE (shadow);
                   3945:       else
                   3946:        IDENTIFIER_CLASS_VALUE (name) = TREE_VALUE (shadow);
                   3947:     }
                   3948: 
                   3949:   /* Find and remove the corresponding entry from the type_shadowed list,
                   3950:      and move the shadowed value to a possibly later shadow.  If there were
                   3951:      no such beast (could there ever be?), install the previously shadowed
                   3952:      value as the IDENTIFIER_TYPE_VALUE.  */
                   3953:   prev = NULL_TREE;
                   3954:   for (shadow = b->type_shadowed;
                   3955:        shadow != NULL_TREE;
                   3956:        prev = shadow, shadow = TREE_CHAIN (shadow))
                   3957:     if (TREE_PURPOSE (shadow) == name)
                   3958:       break;
                   3959: 
                   3960:   if (shadow)
                   3961:     {
                   3962:       if (prev)
                   3963:        TREE_CHAIN (prev) = TREE_CHAIN (shadow);
                   3964:       else
                   3965:        b->type_shadowed = TREE_CHAIN (shadow);
                   3966: 
                   3967:       if (type_shadower)
                   3968:        TREE_VALUE (type_shadower) = TREE_VALUE (shadow);
                   3969:       else
                   3970:        SET_IDENTIFIER_TYPE_VALUE (name, TREE_VALUE (shadow));
                   3971:     }
                   3972: #else
                   3973:   set_identifier_type_value (TREE_PURPOSE (t), TREE_VALUE (t));
                   3974: #endif
                   3975:   global_binding_level->tags
                   3976:     = perm_tree_cons (TREE_PURPOSE (t), TREE_VALUE (t),
                   3977:                      global_binding_level->tags);
                   3978: 
                   3979:   /* Pull the tag out of the class's tags (if there).
                   3980:      It won't show up if it appears e.g. in a parameter declaration
                   3981:      or definition of a member function of this type.  */
                   3982:   if (current_class_type != NULL_TREE)
                   3983:     {
                   3984:       for (t = CLASSTYPE_TAGS (current_class_type), prev = NULL_TREE;
                   3985:           t != NULL_TREE;
                   3986:           prev = t, t = TREE_CHAIN (t))
                   3987:        if (TREE_VALUE (t) == type)
                   3988:          break;
                   3989: 
                   3990:       if (t != NULL_TREE)
                   3991:        {
                   3992:          if (prev)
                   3993:            TREE_CHAIN (prev) = TREE_CHAIN (t);
                   3994:          else
                   3995:            CLASSTYPE_TAGS (current_class_type) = TREE_CHAIN (t);
                   3996:        }
                   3997:     }
                   3998: 
                   3999:   pushdecl_top_level (d);
                   4000: }
                   4001: 
                   4002: static void
                   4003: maybe_globalize_type (type)
                   4004:      tree type;
                   4005: {
                   4006:   if ((((TREE_CODE (type) == RECORD_TYPE
                   4007:         || TREE_CODE (type) == UNION_TYPE)
                   4008:        && ! TYPE_BEING_DEFINED (type))
                   4009:        || TREE_CODE (type) == ENUMERAL_TYPE)
                   4010:       && TYPE_SIZE (type) == NULL_TREE
                   4011:       /* This part is gross.  We keep calling here with types that
                   4012:         are instantiations of templates, when that type should is
                   4013:         global, or doesn't have the type decl established yet,
                   4014:         so globalizing will fail (because it won't find the type in any
                   4015:         non-global scope).  So we short-circuit that path.  */
                   4016:       && !(TYPE_NAME (type) != NULL_TREE
                   4017:           && TYPE_IDENTIFIER (type) != NULL_TREE
                   4018:           && ! IDENTIFIER_HAS_TYPE_VALUE (TYPE_IDENTIFIER (type)))
                   4019:       )
                   4020:     globalize_nested_type (type);
                   4021: }
                   4022: 
                   4023: /* Lookup TYPE in CONTEXT (a chain of nested types or a FUNCTION_DECL).
                   4024:    Return the type value, or NULL_TREE if not found.  */
                   4025: static tree
                   4026: lookup_nested_type (type, context)
                   4027:      tree type;
                   4028:      tree context;
                   4029: {
                   4030:   if (context == NULL_TREE)
                   4031:     return NULL_TREE;
                   4032:   while (context)
                   4033:     {
                   4034:       switch (TREE_CODE (context))
                   4035:        {
                   4036:        case TYPE_DECL:
                   4037:          {
                   4038:            tree ctype = TREE_TYPE (context);
                   4039:            tree match = value_member (type, CLASSTYPE_TAGS (ctype));
                   4040:            if (match)
                   4041:              return TREE_VALUE (match);
                   4042:            context = DECL_CONTEXT (context);
                   4043: 
                   4044:            /* When we have a nested class whose member functions have
                   4045:               local types (e.g., a set of enums), we'll arrive here
                   4046:               with the DECL_CONTEXT as the actual RECORD_TYPE node for
                   4047:               the enclosing class.  Instead, we want to make sure we
                   4048:               come back in here with the TYPE_DECL, not the RECORD_TYPE.  */
                   4049:            if (context && TREE_CODE (context) == RECORD_TYPE)
                   4050:              context = TREE_CHAIN (context);
                   4051:          }
                   4052:          break;
                   4053:        case FUNCTION_DECL:
                   4054:          return TYPE_IDENTIFIER (type) ? lookup_name (TYPE_IDENTIFIER (type), 1) : NULL_TREE;
                   4055:          break;
                   4056:        default:
                   4057:          my_friendly_abort (12);
                   4058:        }
                   4059:     }
                   4060:   return NULL_TREE;
                   4061: }
                   4062: 
                   4063: /* Look up NAME in the current binding level and its superiors in the
                   4064:    namespace of variables, functions and typedefs.  Return a ..._DECL
                   4065:    node of some kind representing its definition if there is only one
                   4066:    such declaration, or return a TREE_LIST with all the overloaded
                   4067:    definitions if there are many, or return 0 if it is undefined.
                   4068: 
                   4069:    If PREFER_TYPE is > 0, we prefer TYPE_DECLs.
                   4070:    If PREFER_TYPE is = 0, we prefer non-TYPE_DECLs.
                   4071:    If PREFER_TYPE is < 0, we arbitrate according to lexical context.  */
                   4072: 
                   4073: tree
                   4074: lookup_name (name, prefer_type)
                   4075:      tree name;
                   4076:      int prefer_type;
                   4077: {
                   4078:   register tree val;
                   4079: 
                   4080:   if (current_binding_level != global_binding_level
                   4081:       && IDENTIFIER_LOCAL_VALUE (name))
                   4082:     val = IDENTIFIER_LOCAL_VALUE (name);
                   4083:   /* In C++ class fields are between local and global scope,
                   4084:      just before the global scope.  */
                   4085:   else if (current_class_type)
                   4086:     {
                   4087:       val = IDENTIFIER_CLASS_VALUE (name);
                   4088:       if (val == NULL_TREE
                   4089:          && TYPE_SIZE (current_class_type) == NULL_TREE
                   4090:          && CLASSTYPE_LOCAL_TYPEDECLS (current_class_type))
                   4091:        {
                   4092:          /* Try to find values from base classes
                   4093:             if we are presently defining a type.
                   4094:             We are presently only interested in TYPE_DECLs.  */
                   4095:          val = lookup_field (current_class_type, name, 0, prefer_type < 0);
                   4096:          if (val == error_mark_node)
                   4097:            return val;
                   4098:          if (val && TREE_CODE (val) != TYPE_DECL)
                   4099:            val = NULL_TREE;
                   4100:        }
                   4101: 
                   4102:       /* yylex() calls this with -2, since we should never start digging for
                   4103:         the nested name at the point where we haven't even, for example,
                   4104:         created the COMPONENT_REF or anything like that.  */
                   4105:       if (val == NULL_TREE)
                   4106:        val = lookup_nested_field (name, prefer_type != -2);
                   4107: 
                   4108:       if (val == NULL_TREE)
                   4109:        val = IDENTIFIER_GLOBAL_VALUE (name);
                   4110:     }
                   4111:   else
                   4112:     val = IDENTIFIER_GLOBAL_VALUE (name);
                   4113: 
                   4114:   if (val)
                   4115:     {
                   4116:       extern int looking_for_typename;
                   4117: 
                   4118:       /* Arbitrate between finding a TYPE_DECL and finding
                   4119:         other kinds of _DECLs.  */
                   4120:       if (TREE_CODE (val) == TYPE_DECL || looking_for_typename < 0)
                   4121:        return val;
                   4122: 
                   4123:       if (IDENTIFIER_HAS_TYPE_VALUE (name))
                   4124:        {
                   4125:          register tree val_as_type = TYPE_NAME (IDENTIFIER_TYPE_VALUE (name));
                   4126: 
                   4127:          if (val == val_as_type || prefer_type > 0
                   4128:              || looking_for_typename > 0)
                   4129:            return val_as_type;
                   4130:          if (prefer_type == 0)
                   4131:            return val;
                   4132:          return arbitrate_lookup (name, val, val_as_type);
                   4133:        }
                   4134:       if (TREE_TYPE (val) == error_mark_node)
                   4135:        return error_mark_node;
                   4136:     }
                   4137: 
                   4138:   return val;
                   4139: }
                   4140: 
                   4141: /* Similar to `lookup_name' but look only at current binding level.  */
                   4142: 
                   4143: tree
                   4144: lookup_name_current_level (name)
                   4145:      tree name;
                   4146: {
                   4147:   register tree t;
                   4148: 
                   4149:   if (current_binding_level == global_binding_level)
                   4150:     return IDENTIFIER_GLOBAL_VALUE (name);
                   4151: 
                   4152:   if (IDENTIFIER_LOCAL_VALUE (name) == NULL_TREE)
                   4153:     return 0;
                   4154: 
                   4155:   for (t = current_binding_level->names; t; t = TREE_CHAIN (t))
                   4156:     if (DECL_NAME (t) == name)
                   4157:       break;
                   4158: 
                   4159:   return t;
                   4160: }
                   4161: 
                   4162: /* Arrange for the user to get a source line number, even when the
                   4163:    compiler is going down in flames, so that she at least has a
                   4164:    chance of working around problems in the compiler.  We used to
                   4165:    call error(), but that let the segmentation fault continue
                   4166:    through; now, it's much more passive by asking them to send the
                   4167:    maintainers mail about the problem.  */
                   4168: 
                   4169: static void
                   4170: signal_catch (sig)
                   4171:      int sig;
                   4172: {
                   4173:   signal (SIGSEGV, SIG_DFL);
                   4174: #ifdef SIGIOT
                   4175:   signal (SIGIOT, SIG_DFL);
                   4176: #endif
                   4177: #ifdef SIGILL
                   4178:   signal (SIGILL, SIG_DFL);
                   4179: #endif
                   4180: #ifdef SIGABRT
                   4181:   signal (SIGABRT, SIG_DFL);
                   4182: #endif
                   4183: #ifdef SIGBUS
                   4184:   signal (SIGBUS, SIG_DFL);
                   4185: #endif
                   4186:   printf ("signal_catch=%d\n", sig);
                   4187:   my_friendly_abort (0);
                   4188: }
                   4189: 
                   4190: /* Array for holding types considered "built-in".  These types
                   4191:    are output in the module in which `main' is defined.  */
                   4192: static tree *builtin_type_tdescs_arr;
                   4193: static int builtin_type_tdescs_len, builtin_type_tdescs_max;
                   4194: 
                   4195: /* Push the declarations of builtin types into the namespace.
                   4196:    RID_INDEX, if < RID_MAX is the index of the builtin type
                   4197:    in the array RID_POINTERS.  NAME is the name used when looking
                   4198:    up the builtin type.  TYPE is the _TYPE node for the builtin type.  */
                   4199: 
                   4200: static void
                   4201: record_builtin_type (rid_index, name, type)
                   4202:      enum rid rid_index;
                   4203:      char *name;
                   4204:      tree type;
                   4205: {
                   4206:   tree rname = NULL_TREE, tname = NULL_TREE;
                   4207:   tree tdecl;
                   4208: 
                   4209:   if ((int) rid_index < (int) RID_MAX)
                   4210:     rname = ridpointers[(int) rid_index];
                   4211:   if (name)
                   4212:     tname = get_identifier (name);
                   4213: 
                   4214:   TYPE_BUILT_IN (type) = 1;
                   4215:   
                   4216:   if (tname)
                   4217:     {
                   4218: #if 0 /* not yet, should get fixed properly later */
                   4219:       tdecl = pushdecl (make_type_decl (tname, type));
                   4220: #else
                   4221:       tdecl = pushdecl (build_decl (TYPE_DECL, tname, type));
                   4222: #endif
                   4223:       set_identifier_type_value (tname, NULL_TREE);
                   4224:       if ((int) rid_index < (int) RID_MAX)
                   4225:        IDENTIFIER_GLOBAL_VALUE (tname) = tdecl;
                   4226:     }
                   4227:   if (rname != NULL_TREE)
                   4228:     {
                   4229:       if (tname != NULL_TREE)
                   4230:        {
                   4231:          set_identifier_type_value (rname, NULL_TREE);
                   4232:          IDENTIFIER_GLOBAL_VALUE (rname) = tdecl;
                   4233:        }
                   4234:       else
                   4235:        {
                   4236: #if 0 /* not yet, should get fixed properly later */
                   4237:          tdecl = pushdecl (make_type_decl (rname, type));
                   4238: #else
                   4239:          tdecl = pushdecl (build_decl (TYPE_DECL, rname, type));
                   4240: #endif
                   4241:          set_identifier_type_value (rname, NULL_TREE);
                   4242:        }
                   4243:     }
                   4244: 
                   4245:   if (flag_dossier)
                   4246:     {
                   4247:       if (builtin_type_tdescs_len+5 >= builtin_type_tdescs_max)
                   4248:        {
                   4249:          builtin_type_tdescs_max *= 2;
                   4250:          builtin_type_tdescs_arr
                   4251:            = (tree *)xrealloc (builtin_type_tdescs_arr,
                   4252:                                builtin_type_tdescs_max * sizeof (tree));
                   4253:        }
                   4254:       builtin_type_tdescs_arr[builtin_type_tdescs_len++] = type;
                   4255:       if (TREE_CODE (type) != POINTER_TYPE)
                   4256:        {
                   4257:          builtin_type_tdescs_arr[builtin_type_tdescs_len++]
                   4258:            = build_pointer_type (type);
                   4259:          builtin_type_tdescs_arr[builtin_type_tdescs_len++]
                   4260:            = build_type_variant (TYPE_POINTER_TO (type), 1, 0);
                   4261:        }
                   4262:       if (TREE_CODE (type) != VOID_TYPE)
                   4263:        {
                   4264:          builtin_type_tdescs_arr[builtin_type_tdescs_len++]
                   4265:            = build_reference_type (type);
                   4266:          builtin_type_tdescs_arr[builtin_type_tdescs_len++]
                   4267:            = build_type_variant (TYPE_REFERENCE_TO (type), 1, 0);
                   4268:        }
                   4269:     }
                   4270: }
                   4271: 
                   4272: static void
                   4273: output_builtin_tdesc_entries ()
                   4274: {
                   4275:   extern struct obstack permanent_obstack;
                   4276: 
                   4277:   /* If there's more than one main in this file, don't crash.  */
                   4278:   if (builtin_type_tdescs_arr == 0)
                   4279:     return;
                   4280: 
                   4281:   push_obstacks (&permanent_obstack, &permanent_obstack);
                   4282:   while (builtin_type_tdescs_len > 0)
                   4283:     {
                   4284:       tree type = builtin_type_tdescs_arr[--builtin_type_tdescs_len];
                   4285:       tree tdesc = build_t_desc (type, 0);
                   4286:       TREE_ASM_WRITTEN (tdesc) = 0;
                   4287:       build_t_desc (type, 2);
                   4288:     }
                   4289:   free (builtin_type_tdescs_arr);
                   4290:   builtin_type_tdescs_arr = 0;
                   4291:   pop_obstacks ();
                   4292: }
                   4293: 
                   4294: /* Push overloaded decl, in global scope, with one argument so it
                   4295:    can be used as a callback from define_function.  */
                   4296: static void
                   4297: push_overloaded_decl_1 (x)
                   4298:      tree x;
                   4299: {
                   4300:   push_overloaded_decl (x, 0);
                   4301: }
                   4302: 
                   4303: /* Create the predefined scalar types of C,
                   4304:    and some nodes representing standard constants (0, 1, (void *)0).
                   4305:    Initialize the global binding level.
                   4306:    Make definitions for built-in primitive functions.  */
                   4307: 
                   4308: void
                   4309: init_decl_processing ()
                   4310: {
                   4311:   tree decl;
                   4312:   register tree endlink, int_endlink, double_endlink, ptr_endlink;
                   4313:   tree fields[20];
                   4314:   /* Either char* or void*.  */
                   4315:   tree traditional_ptr_type_node;
                   4316:   /* Data type of memcpy.  */
                   4317:   tree memcpy_ftype;
                   4318:   /* Data type of strncpy.  */
                   4319:   tree strncpy_ftype;
                   4320:   int wchar_type_size;
                   4321:   tree temp;
                   4322:   tree array_domain_type;
                   4323: 
                   4324:   /* Have to make these distinct before we try using them.  */
                   4325:   lang_name_cplusplus = get_identifier ("C++");
                   4326:   lang_name_c = get_identifier ("C");
                   4327: #ifdef OBJCPLUS
                   4328:   lang_name_objc = get_identifier ("Objective-C");
                   4329: #endif
                   4330: 
                   4331:   /* Initially, C.  */
                   4332:   current_lang_name = lang_name_c;
                   4333: 
                   4334:   current_function_decl = NULL_TREE;
                   4335:   named_labels = NULL_TREE;
                   4336:   named_label_uses = NULL_TREE;
                   4337:   current_binding_level = NULL_BINDING_LEVEL;
                   4338:   free_binding_level = NULL_BINDING_LEVEL;
                   4339: 
                   4340:   /* Because most segmentation signals can be traced back into user
                   4341:      code, catch them and at least give the user a chance of working
                   4342:      around compiler bugs. */
                   4343:   signal (SIGSEGV, signal_catch);
                   4344: 
                   4345:   /* We will also catch aborts in the back-end through signal_catch and
                   4346:      give the user a chance to see where the error might be, and to defeat
                   4347:      aborts in the back-end when there have been errors previously in their
                   4348:      code. */
                   4349: #ifdef SIGIOT
                   4350:   signal (SIGIOT, signal_catch);
                   4351: #endif
                   4352: #ifdef SIGILL
                   4353:   signal (SIGILL, signal_catch);
                   4354: #endif
                   4355: #ifdef SIGABRT
                   4356:   signal (SIGABRT, signal_catch);
                   4357: #endif
                   4358: #ifdef SIGBUS
                   4359:   signal (SIGBUS, signal_catch);
                   4360: #endif
                   4361: 
                   4362:   gcc_obstack_init (&decl_obstack);
                   4363:   if (flag_dossier)
                   4364:     {
                   4365:       builtin_type_tdescs_max = 100;
                   4366:       builtin_type_tdescs_arr = (tree *)xmalloc (100 * sizeof (tree));
                   4367:     }
                   4368: 
                   4369:   /* Must lay these out before anything else gets laid out.  */
                   4370:   error_mark_node = make_node (ERROR_MARK);
                   4371:   TREE_PERMANENT (error_mark_node) = 1;
                   4372:   TREE_TYPE (error_mark_node) = error_mark_node;
                   4373:   error_mark_list = build_tree_list (error_mark_node, error_mark_node);
                   4374:   TREE_TYPE (error_mark_list) = error_mark_node;
                   4375: 
                   4376:   pushlevel (0);       /* make the binding_level structure for global names.  */
                   4377:   global_binding_level = current_binding_level;
                   4378: 
                   4379:   this_identifier = get_identifier (THIS_NAME);
                   4380:   in_charge_identifier = get_identifier (IN_CHARGE_NAME);
                   4381:   pfn_identifier = get_identifier (VTABLE_PFN_NAME);
                   4382:   index_identifier = get_identifier (VTABLE_INDEX_NAME);
                   4383:   delta_identifier = get_identifier (VTABLE_DELTA_NAME);
                   4384:   delta2_identifier = get_identifier (VTABLE_DELTA2_NAME);
                   4385:   pfn_or_delta2_identifier = get_identifier ("__pfn_or_delta2");
                   4386: 
                   4387:   /* Define `int' and `char' first so that dbx will output them first.  */
                   4388: 
                   4389:   integer_type_node = make_signed_type (INT_TYPE_SIZE);
                   4390:   record_builtin_type (RID_INT, NULL_PTR, integer_type_node);
                   4391: 
                   4392:   /* Define `char', which is like either `signed char' or `unsigned char'
                   4393:      but not the same as either.  */
                   4394: 
                   4395:   char_type_node =
                   4396:     (flag_signed_char
                   4397:      ? make_signed_type (CHAR_TYPE_SIZE)
                   4398:      : make_unsigned_type (CHAR_TYPE_SIZE));
                   4399:   record_builtin_type (RID_CHAR, "char", char_type_node);
                   4400: 
                   4401:   long_integer_type_node = make_signed_type (LONG_TYPE_SIZE);
                   4402:   record_builtin_type (RID_LONG, "long int", long_integer_type_node);
                   4403: 
                   4404:   unsigned_type_node = make_unsigned_type (INT_TYPE_SIZE);
                   4405:   record_builtin_type (RID_UNSIGNED, "unsigned int", unsigned_type_node);
                   4406: 
                   4407:   long_unsigned_type_node = make_unsigned_type (LONG_TYPE_SIZE);
                   4408:   record_builtin_type (RID_MAX, "long unsigned int", long_unsigned_type_node);
                   4409:   record_builtin_type (RID_MAX, "unsigned long", long_unsigned_type_node);
                   4410: 
                   4411:   /* `unsigned long' is the standard type for sizeof.
                   4412:      Traditionally, use a signed type.
                   4413:      Note that stddef.h uses `unsigned long',
                   4414:      and this must agree, even of long and int are the same size.  */
                   4415:   sizetype
                   4416:     = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (SIZE_TYPE)));
                   4417:   if (flag_traditional && TREE_UNSIGNED (sizetype))
                   4418:     sizetype = signed_type (sizetype);
                   4419: 
                   4420:   ptrdiff_type_node
                   4421:     = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (PTRDIFF_TYPE)));
                   4422: 
                   4423:   TREE_TYPE (TYPE_SIZE (integer_type_node)) = sizetype;
                   4424:   TREE_TYPE (TYPE_SIZE (char_type_node)) = sizetype;
                   4425:   TREE_TYPE (TYPE_SIZE (unsigned_type_node)) = sizetype;
                   4426:   TREE_TYPE (TYPE_SIZE (long_unsigned_type_node)) = sizetype;
                   4427:   TREE_TYPE (TYPE_SIZE (long_integer_type_node)) = sizetype;
                   4428: 
                   4429:   short_integer_type_node = make_signed_type (SHORT_TYPE_SIZE);
                   4430:   record_builtin_type (RID_SHORT, "short int", short_integer_type_node);
                   4431:   long_long_integer_type_node = make_signed_type (LONG_LONG_TYPE_SIZE);
                   4432:   record_builtin_type (RID_MAX, "long long int", long_long_integer_type_node);
                   4433:   short_unsigned_type_node = make_unsigned_type (SHORT_TYPE_SIZE);
                   4434:   record_builtin_type (RID_MAX, "short unsigned int", short_unsigned_type_node);
                   4435:   record_builtin_type (RID_MAX, "unsigned short", short_unsigned_type_node);
                   4436:   long_long_unsigned_type_node = make_unsigned_type (LONG_LONG_TYPE_SIZE);
                   4437:   record_builtin_type (RID_MAX, "long long unsigned int", long_long_unsigned_type_node);
                   4438:   record_builtin_type (RID_MAX, "long long unsigned", long_long_unsigned_type_node);
                   4439: 
                   4440:   /* Define both `signed char' and `unsigned char'.  */
                   4441:   signed_char_type_node = make_signed_type (CHAR_TYPE_SIZE);
                   4442:   record_builtin_type (RID_MAX, "signed char", signed_char_type_node);
                   4443:   unsigned_char_type_node = make_unsigned_type (CHAR_TYPE_SIZE);
                   4444:   record_builtin_type (RID_MAX, "unsigned char", unsigned_char_type_node);
                   4445: 
                   4446:   /* These are types that type_for_size and type_for_mode use.  */
                   4447:   intQI_type_node = make_signed_type (GET_MODE_BITSIZE (QImode));
                   4448:   pushdecl (build_decl (TYPE_DECL, NULL_TREE, intQI_type_node));
                   4449:   intHI_type_node = make_signed_type (GET_MODE_BITSIZE (HImode));
                   4450:   pushdecl (build_decl (TYPE_DECL, NULL_TREE, intHI_type_node));
                   4451:   intSI_type_node = make_signed_type (GET_MODE_BITSIZE (SImode));
                   4452:   pushdecl (build_decl (TYPE_DECL, NULL_TREE, intSI_type_node));
                   4453:   intDI_type_node = make_signed_type (GET_MODE_BITSIZE (DImode));
                   4454:   pushdecl (build_decl (TYPE_DECL, NULL_TREE, intDI_type_node));
                   4455:   unsigned_intQI_type_node = make_unsigned_type (GET_MODE_BITSIZE (QImode));
                   4456:   pushdecl (build_decl (TYPE_DECL, NULL_TREE, unsigned_intQI_type_node));
                   4457:   unsigned_intHI_type_node = make_unsigned_type (GET_MODE_BITSIZE (HImode));
                   4458:   pushdecl (build_decl (TYPE_DECL, NULL_TREE, unsigned_intHI_type_node));
                   4459:   unsigned_intSI_type_node = make_unsigned_type (GET_MODE_BITSIZE (SImode));
                   4460:   pushdecl (build_decl (TYPE_DECL, NULL_TREE, unsigned_intSI_type_node));
                   4461:   unsigned_intDI_type_node = make_unsigned_type (GET_MODE_BITSIZE (DImode));
                   4462:   pushdecl (build_decl (TYPE_DECL, NULL_TREE, unsigned_intDI_type_node));
                   4463: 
                   4464:   float_type_node = make_node (REAL_TYPE);
                   4465:   TYPE_PRECISION (float_type_node) = FLOAT_TYPE_SIZE;
                   4466:   record_builtin_type (RID_FLOAT, NULL_PTR, float_type_node);
                   4467:   layout_type (float_type_node);
                   4468: 
                   4469:   double_type_node = make_node (REAL_TYPE);
                   4470:   if (flag_short_double)
                   4471:     TYPE_PRECISION (double_type_node) = FLOAT_TYPE_SIZE;
                   4472:   else
                   4473:     TYPE_PRECISION (double_type_node) = DOUBLE_TYPE_SIZE;
                   4474:   record_builtin_type (RID_DOUBLE, NULL_PTR, double_type_node);
                   4475:   layout_type (double_type_node);
                   4476: 
                   4477:   long_double_type_node = make_node (REAL_TYPE);
                   4478:   TYPE_PRECISION (long_double_type_node) = LONG_DOUBLE_TYPE_SIZE;
                   4479:   record_builtin_type (RID_MAX, "long double", long_double_type_node);
                   4480:   layout_type (long_double_type_node);
                   4481: 
                   4482:   integer_zero_node = build_int_2 (0, 0);
                   4483:   TREE_TYPE (integer_zero_node) = integer_type_node;
                   4484:   integer_one_node = build_int_2 (1, 0);
                   4485:   TREE_TYPE (integer_one_node) = integer_type_node;
                   4486:   integer_two_node = build_int_2 (2, 0);
                   4487:   TREE_TYPE (integer_two_node) = integer_type_node;
                   4488:   integer_three_node = build_int_2 (3, 0);
                   4489:   TREE_TYPE (integer_three_node) = integer_type_node;
                   4490:   empty_init_node = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
                   4491: 
                   4492:   /* These are needed by stor-layout.c.  */
                   4493:   size_zero_node = size_int (0);
                   4494:   size_one_node = size_int (1);
                   4495: 
                   4496:   void_type_node = make_node (VOID_TYPE);
                   4497:   record_builtin_type (RID_VOID, NULL_PTR, void_type_node);
                   4498:   layout_type (void_type_node); /* Uses integer_zero_node.  */
                   4499:   void_list_node = build_tree_list (NULL_TREE, void_type_node);
                   4500:   TREE_PARMLIST (void_list_node) = 1;
                   4501: 
                   4502:   null_pointer_node = build_int_2 (0, 0);
                   4503:   TREE_TYPE (null_pointer_node) = build_pointer_type (void_type_node);
                   4504:   layout_type (TREE_TYPE (null_pointer_node));
                   4505: 
                   4506:   /* Used for expressions that do nothing, but are not errors.  */
                   4507:   void_zero_node = build_int_2 (0, 0);
                   4508:   TREE_TYPE (void_zero_node) = void_type_node;
                   4509: 
                   4510:   string_type_node = build_pointer_type (char_type_node);
                   4511:   const_string_type_node = build_pointer_type (build_type_variant (char_type_node, 1, 0));
                   4512:   record_builtin_type (RID_MAX, NULL_PTR, string_type_node);
                   4513: 
                   4514:   /* Make a type to be the domain of a few array types
                   4515:      whose domains don't really matter.
                   4516:      200 is small enough that it always fits in size_t
                   4517:      and large enough that it can hold most function names for the
                   4518:      initializations of __FUNCTION__ and __PRETTY_FUNCTION__.  */
                   4519:   array_domain_type = build_index_type (build_int_2 (200, 0));
                   4520: 
                   4521:   /* make a type for arrays of characters.
                   4522:      With luck nothing will ever really depend on the length of this
                   4523:      array type.  */
                   4524:   char_array_type_node
                   4525:     = build_array_type (char_type_node, array_domain_type);
                   4526:   /* Likewise for arrays of ints.  */
                   4527:   int_array_type_node
                   4528:     = build_array_type (integer_type_node, array_domain_type);
                   4529: 
                   4530:   /* This is just some anonymous class type.  Nobody should ever
                   4531:      need to look inside this envelope.  */
                   4532:   class_star_type_node = build_pointer_type (make_lang_type (RECORD_TYPE));
                   4533: 
                   4534:   default_function_type
                   4535:     = build_function_type (integer_type_node, NULL_TREE);
                   4536:   build_pointer_type (default_function_type);
                   4537: 
                   4538:   ptr_type_node = build_pointer_type (void_type_node);
                   4539:   const_ptr_type_node = build_pointer_type (build_type_variant (void_type_node, 1, 0));
                   4540:   record_builtin_type (RID_MAX, NULL_PTR, ptr_type_node);
                   4541:   endlink = void_list_node;
                   4542:   int_endlink = tree_cons (NULL_TREE, integer_type_node, endlink);
                   4543:   double_endlink = tree_cons (NULL_TREE, double_type_node, endlink);
                   4544:   ptr_endlink = tree_cons (NULL_TREE, ptr_type_node, endlink);
                   4545: 
                   4546:   double_ftype_double
                   4547:     = build_function_type (double_type_node, double_endlink);
                   4548: 
                   4549:   double_ftype_double_double
                   4550:     = build_function_type (double_type_node,
                   4551:                           tree_cons (NULL_TREE, double_type_node, double_endlink));
                   4552: 
                   4553:   int_ftype_int
                   4554:     = build_function_type (integer_type_node, int_endlink);
                   4555: 
                   4556:   long_ftype_long
                   4557:     = build_function_type (long_integer_type_node,
                   4558:                           tree_cons (NULL_TREE, long_integer_type_node, endlink));
                   4559: 
                   4560:   void_ftype_ptr_ptr_int
                   4561:     = build_function_type (void_type_node,
                   4562:                           tree_cons (NULL_TREE, ptr_type_node,
                   4563:                                      tree_cons (NULL_TREE, ptr_type_node,
                   4564:                                                 int_endlink)));
                   4565: 
                   4566:   int_ftype_cptr_cptr_sizet
                   4567:     = build_function_type (integer_type_node,
                   4568:                           tree_cons (NULL_TREE, const_ptr_type_node,
                   4569:                                      tree_cons (NULL_TREE, const_ptr_type_node,
                   4570:                                                 tree_cons (NULL_TREE,
                   4571:                                                            sizetype,
                   4572:                                                            endlink))));
                   4573: 
                   4574:   void_ftype_ptr_int_int
                   4575:     = build_function_type (void_type_node,
                   4576:                           tree_cons (NULL_TREE, ptr_type_node,
                   4577:                                      tree_cons (NULL_TREE, integer_type_node,
                   4578:                                                 int_endlink)));
                   4579: 
                   4580:   string_ftype_ptr_ptr         /* strcpy prototype */
                   4581:     = build_function_type (string_type_node,
                   4582:                           tree_cons (NULL_TREE, string_type_node,
                   4583:                                      tree_cons (NULL_TREE,
                   4584:                                                 const_string_type_node,
                   4585:                                                 endlink)));
                   4586: 
                   4587: #if 0
                   4588:   /* Not yet.  */
                   4589:   strncpy_ftype                        /* strncpy prototype */
                   4590:     = build_function_type (string_type_node,
                   4591:                           tree_cons (NULL_TREE, string_type_node,
                   4592:                                      tree_cons (NULL_TREE, const_string_type_node,
                   4593:                                                 tree_cons (NULL_TREE,
                   4594:                                                            sizetype,
                   4595:                                                            endlink))));
                   4596: #endif
                   4597: 
                   4598:   int_ftype_string_string      /* strcmp prototype */
                   4599:     = build_function_type (integer_type_node,
                   4600:                           tree_cons (NULL_TREE, const_string_type_node,
                   4601:                                      tree_cons (NULL_TREE,
                   4602:                                                 const_string_type_node,
                   4603:                                                 endlink)));
                   4604: 
                   4605:   sizet_ftype_string           /* strlen prototype */
                   4606:     = build_function_type (sizetype,
                   4607:                           tree_cons (NULL_TREE, const_string_type_node,
                   4608:                                      endlink));
                   4609: 
                   4610:   traditional_ptr_type_node
                   4611:     = (flag_traditional ? string_type_node : ptr_type_node);
                   4612: 
                   4613:   memcpy_ftype /* memcpy prototype */
                   4614:     = build_function_type (traditional_ptr_type_node,
                   4615:                           tree_cons (NULL_TREE, ptr_type_node,
                   4616:                                      tree_cons (NULL_TREE, const_ptr_type_node,
                   4617:                                                 tree_cons (NULL_TREE,
                   4618:                                                            sizetype,
                   4619:                                                            endlink))));
                   4620: 
                   4621: #ifdef VTABLE_USES_MASK
                   4622:   /* This is primarily for virtual function definition.  We
                   4623:      declare an array of `void *', which can later be
                   4624:      converted to the appropriate function pointer type.
                   4625:      To do pointers to members, we need a mask which can
                   4626:      distinguish an index value into a virtual function table
                   4627:      from an address.  */
                   4628:   vtbl_mask = build_int_2 (~((HOST_WIDE_INT) VINDEX_MAX - 1), -1);
                   4629: #endif
                   4630: 
                   4631:   vtbl_type_node
                   4632:     = build_array_type (ptr_type_node, NULL_TREE);
                   4633:   layout_type (vtbl_type_node);
                   4634:   vtbl_type_node = build_type_variant (vtbl_type_node, 1, 0);
                   4635:   record_builtin_type (RID_MAX, NULL_PTR, vtbl_type_node);
                   4636: 
                   4637:   builtin_function ("__builtin_constant_p", int_ftype_int,
                   4638:                    BUILT_IN_CONSTANT_P, NULL_PTR);
                   4639: 
                   4640:   builtin_function ("__builtin_alloca",
                   4641:                    build_function_type (ptr_type_node,
                   4642:                                         tree_cons (NULL_TREE,
                   4643:                                                    sizetype,
                   4644:                                                    endlink)),
                   4645:                    BUILT_IN_ALLOCA, "alloca");
                   4646: #if 0
                   4647:   builtin_function ("alloca",
                   4648:                    build_function_type (ptr_type_node,
                   4649:                                         tree_cons (NULL_TREE,
                   4650:                                                    sizetype,
                   4651:                                                    endlink)),
                   4652:                    BUILT_IN_ALLOCA, NULL_PTR);
                   4653: #endif
                   4654: 
                   4655:   builtin_function ("__builtin_abs", int_ftype_int,
                   4656:                    BUILT_IN_ABS, NULL_PTR);
                   4657:   builtin_function ("__builtin_fabs", double_ftype_double,
                   4658:                    BUILT_IN_FABS, NULL_PTR);
                   4659:   builtin_function ("__builtin_labs", long_ftype_long,
                   4660:                    BUILT_IN_LABS, NULL_PTR);
                   4661:   builtin_function ("__builtin_ffs", int_ftype_int,
                   4662:                    BUILT_IN_FFS, NULL_PTR);
                   4663:   builtin_function ("__builtin_fsqrt", double_ftype_double,
                   4664:                    BUILT_IN_FSQRT, NULL_PTR);
                   4665:   builtin_function ("__builtin_sin", double_ftype_double, 
                   4666:                    BUILT_IN_SIN, "sin");
                   4667:   builtin_function ("__builtin_cos", double_ftype_double, 
                   4668:                    BUILT_IN_COS, "cos");
                   4669:   builtin_function ("__builtin_saveregs",
                   4670:                    build_function_type (ptr_type_node, NULL_TREE),
                   4671:                    BUILT_IN_SAVEREGS, NULL_PTR);
                   4672: /* EXPAND_BUILTIN_VARARGS is obsolete.  */
                   4673: #if 0
                   4674:   builtin_function ("__builtin_varargs",
                   4675:                    build_function_type (ptr_type_node,
                   4676:                                         tree_cons (NULL_TREE,
                   4677:                                                    integer_type_node,
                   4678:                                                    endlink)),
                   4679:                    BUILT_IN_VARARGS, NULL_PTR);
                   4680: #endif
                   4681:   builtin_function ("__builtin_classify_type", default_function_type,
                   4682:                    BUILT_IN_CLASSIFY_TYPE, NULL_PTR);
                   4683:   builtin_function ("__builtin_next_arg",
                   4684:                    build_function_type (ptr_type_node, endlink),
                   4685:                    BUILT_IN_NEXT_ARG, NULL_PTR);
                   4686:   builtin_function ("__builtin_args_info",
                   4687:                    build_function_type (integer_type_node,
                   4688:                                         tree_cons (NULL_TREE,
                   4689:                                                    integer_type_node,
                   4690:                                                    endlink)),
                   4691:                    BUILT_IN_ARGS_INFO, NULL_PTR);
                   4692: 
                   4693:   /* Untyped call and return.  */
                   4694:   builtin_function ("__builtin_apply_args",
                   4695:                    build_function_type (ptr_type_node, NULL_TREE),
                   4696:                    BUILT_IN_APPLY_ARGS, NULL_PTR);
                   4697: 
                   4698:   temp = tree_cons (NULL_TREE,
                   4699:                    build_pointer_type (build_function_type (void_type_node,
                   4700:                                                             NULL_TREE)),
                   4701:                    tree_cons (NULL_TREE,
                   4702:                               ptr_type_node,
                   4703:                               tree_cons (NULL_TREE,
                   4704:                                          sizetype,
                   4705:                                          endlink)));
                   4706:   builtin_function ("__builtin_apply",
                   4707:                    build_function_type (ptr_type_node, temp),
                   4708:                    BUILT_IN_APPLY, NULL_PTR);
                   4709:   builtin_function ("__builtin_return",
                   4710:                    build_function_type (void_type_node,
                   4711:                                         tree_cons (NULL_TREE,
                   4712:                                                    ptr_type_node,
                   4713:                                                    endlink)),
                   4714:                    BUILT_IN_RETURN, NULL_PTR);
                   4715: 
                   4716:   /* Currently under experimentation.  */
                   4717:   builtin_function ("__builtin_memcpy", memcpy_ftype,
                   4718:                    BUILT_IN_MEMCPY, "memcpy");
                   4719:   builtin_function ("__builtin_memcmp", int_ftype_cptr_cptr_sizet,
                   4720:                    BUILT_IN_MEMCMP, "memcmp");
                   4721:   builtin_function ("__builtin_strcmp", int_ftype_string_string,
                   4722:                    BUILT_IN_STRCMP, "strcmp");
                   4723:   builtin_function ("__builtin_strcpy", string_ftype_ptr_ptr,
                   4724:                    BUILT_IN_STRCPY, "strcpy");
                   4725: #if 0
                   4726:   /* Not yet.  */
                   4727:   builtin_function ("__builtin_strncpy", strncpy_ftype,
                   4728:                    BUILT_IN_STRNCPY, "strncpy");
                   4729: #endif
                   4730:   builtin_function ("__builtin_strlen", sizet_ftype_string,
                   4731:                    BUILT_IN_STRLEN, "strlen");
                   4732: 
                   4733:   if (!flag_no_builtin)
                   4734:     {
                   4735: #if 0 /* These do not work well with libg++.  */
                   4736:       builtin_function ("abs", int_ftype_int, BUILT_IN_ABS, NULL_PTR);
                   4737:       builtin_function ("fabs", double_ftype_double, BUILT_IN_FABS, NULL_PTR);
                   4738:       builtin_function ("labs", long_ftype_long, BUILT_IN_LABS, NULL_PTR);
                   4739: #endif
                   4740:       builtin_function ("memcpy", memcpy_ftype, BUILT_IN_MEMCPY, NULL_PTR);
                   4741:       builtin_function ("memcmp", int_ftype_cptr_cptr_sizet, BUILT_IN_MEMCMP,
                   4742:                        NULL_PTR);
                   4743:       builtin_function ("strcmp", int_ftype_string_string, BUILT_IN_STRCMP, NULL_PTR);
                   4744:       builtin_function ("strcpy", string_ftype_ptr_ptr, BUILT_IN_STRCPY, NULL_PTR);
                   4745: #if 0
                   4746:       /* Not yet.  */
                   4747:       builtin_function ("strncpy", strncpy_ftype, BUILT_IN_STRNCPY, NULL_PTR);
                   4748: #endif
                   4749:       builtin_function ("strlen", sizet_ftype_string, BUILT_IN_STRLEN, NULL_PTR);
                   4750:       builtin_function ("sin", double_ftype_double, BUILT_IN_SIN, NULL_PTR);
                   4751:       builtin_function ("cos", double_ftype_double, BUILT_IN_COS, NULL_PTR);
                   4752:     }
                   4753: 
                   4754: #if 0
                   4755:   /* Support for these has not been written in either expand_builtin
                   4756:      or build_function_call.  */
                   4757:   builtin_function ("__builtin_div", default_ftype, BUILT_IN_DIV, 0);
                   4758:   builtin_function ("__builtin_ldiv", default_ftype, BUILT_IN_LDIV, 0);
                   4759:   builtin_function ("__builtin_ffloor", double_ftype_double, BUILT_IN_FFLOOR, 0);
                   4760:   builtin_function ("__builtin_fceil", double_ftype_double, BUILT_IN_FCEIL, 0);
                   4761:   builtin_function ("__builtin_fmod", double_ftype_double_double, BUILT_IN_FMOD, 0);
                   4762:   builtin_function ("__builtin_frem", double_ftype_double_double, BUILT_IN_FREM, 0);
                   4763:   builtin_function ("__builtin_memset", ptr_ftype_ptr_int_int, BUILT_IN_MEMSET, 0);
                   4764:   builtin_function ("__builtin_getexp", double_ftype_double, BUILT_IN_GETEXP, 0);
                   4765:   builtin_function ("__builtin_getman", double_ftype_double, BUILT_IN_GETMAN, 0);
                   4766: #endif
                   4767: 
                   4768:   /* C++ extensions */
                   4769: 
                   4770:   unknown_type_node = make_node (UNKNOWN_TYPE);
                   4771: #if 0 /* not yet, should get fixed properly later */
                   4772:   pushdecl (make_type_decl (get_identifier ("unknown type"),
                   4773:                       unknown_type_node));
                   4774: #else
                   4775:   decl = pushdecl (build_decl (TYPE_DECL, get_identifier ("unknown type"),
                   4776:                        unknown_type_node));
                   4777:   /* Make sure the "unknown type" typedecl gets ignored for debug info.  */
                   4778:   DECL_IGNORED_P (decl) = 1;
                   4779: #endif
                   4780:   TYPE_SIZE (unknown_type_node) = TYPE_SIZE (void_type_node);
                   4781:   TYPE_ALIGN (unknown_type_node) = 1;
                   4782:   TYPE_MODE (unknown_type_node) = TYPE_MODE (void_type_node);
                   4783:   /* Indirecting an UNKNOWN_TYPE node yields an UNKNOWN_TYPE node.  */
                   4784:   TREE_TYPE (unknown_type_node) = unknown_type_node;
                   4785:   /* Looking up TYPE_POINTER_TO and TYPE_REFERENCE_TO yield the same result.  */
                   4786:   TYPE_POINTER_TO (unknown_type_node) = unknown_type_node;
                   4787:   TYPE_REFERENCE_TO (unknown_type_node) = unknown_type_node;
                   4788: 
                   4789:   /* This is special for C++ so functions can be overloaded. */
                   4790:   wchar_type_node
                   4791:     = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (WCHAR_TYPE)));
                   4792:   wchar_type_size = TYPE_PRECISION (wchar_type_node);
                   4793:   signed_wchar_type_node = make_signed_type (wchar_type_size);
                   4794:   unsigned_wchar_type_node = make_unsigned_type (wchar_type_size);
                   4795:   wchar_type_node
                   4796:     = TREE_UNSIGNED (wchar_type_node)
                   4797:       ? unsigned_wchar_type_node
                   4798:       : signed_wchar_type_node;
                   4799:   record_builtin_type (RID_WCHAR, "__wchar_t", wchar_type_node);
                   4800: 
                   4801:   /* This is for wide string constants.  */
                   4802:   wchar_array_type_node
                   4803:     = build_array_type (wchar_type_node, array_domain_type);
                   4804: 
                   4805:   /* This is a hack that should go away when we deliver the
                   4806:      real gc code.  */
                   4807:   if (flag_gc)
                   4808:     {
                   4809:       builtin_function ("__gc_main", default_function_type, NOT_BUILT_IN, 0);
                   4810:       pushdecl (lookup_name (get_identifier ("__gc_main"), 0));
                   4811:     }
                   4812: 
                   4813:   /* Simplify life by making a "vtable_entry_type".  Give its
                   4814:      fields names so that the debugger can use them.  */
                   4815: 
                   4816:   vtable_entry_type = make_lang_type (RECORD_TYPE);
                   4817:   fields[0] = build_lang_field_decl (FIELD_DECL, delta_identifier, short_integer_type_node);
                   4818:   fields[1] = build_lang_field_decl (FIELD_DECL, index_identifier, short_integer_type_node);
                   4819:   fields[2] = build_lang_field_decl (FIELD_DECL, pfn_identifier, ptr_type_node);
                   4820:   finish_builtin_type (vtable_entry_type, VTBL_PTR_TYPE, fields, 2,
                   4821:                       double_type_node);
                   4822: 
                   4823:   /* Make this part of an invisible union.  */
                   4824:   fields[3] = copy_node (fields[2]);
                   4825:   TREE_TYPE (fields[3]) = short_integer_type_node;
                   4826:   DECL_NAME (fields[3]) = delta2_identifier;
                   4827:   DECL_MODE (fields[3]) = TYPE_MODE (short_integer_type_node);
                   4828:   DECL_SIZE (fields[3]) = TYPE_SIZE (short_integer_type_node);
                   4829:   TREE_UNSIGNED (fields[3]) = 0;
                   4830:   TREE_CHAIN (fields[2]) = fields[3];
                   4831:   vtable_entry_type = build_type_variant (vtable_entry_type, 1, 0);
                   4832:   record_builtin_type (RID_MAX, VTBL_PTR_TYPE, vtable_entry_type);
                   4833: 
                   4834:   if (flag_dossier)
                   4835:     {
                   4836:       /* Must build __t_desc type.  Currently, type descriptors look like this:
                   4837: 
                   4838:         struct __t_desc
                   4839:         {
                   4840:            const char *name;
                   4841:           int size;
                   4842:           int bits;
                   4843:           struct __t_desc *points_to;
                   4844:           int ivars_count, meths_count;
                   4845:           struct __i_desc *ivars[];
                   4846:           struct __m_desc *meths[];
                   4847:           struct __t_desc *parents[];
                   4848:           struct __t_desc *vbases[];
                   4849:           int offsets[];
                   4850:         };
                   4851: 
                   4852:         ...as per Linton's paper.  */
                   4853: 
                   4854:       __t_desc_type_node = make_lang_type (RECORD_TYPE);
                   4855:       __i_desc_type_node = make_lang_type (RECORD_TYPE);
                   4856:       __m_desc_type_node = make_lang_type (RECORD_TYPE);
                   4857:       __t_desc_array_type = build_array_type (TYPE_POINTER_TO (__t_desc_type_node), NULL_TREE);
                   4858:       __i_desc_array_type = build_array_type (TYPE_POINTER_TO (__i_desc_type_node), NULL_TREE);
                   4859:       __m_desc_array_type = build_array_type (TYPE_POINTER_TO (__m_desc_type_node), NULL_TREE);
                   4860: 
                   4861:       fields[0] = build_lang_field_decl (FIELD_DECL, get_identifier ("name"),
                   4862:                                         string_type_node);
                   4863:       fields[1] = build_lang_field_decl (FIELD_DECL, get_identifier ("size"),
                   4864:                                         unsigned_type_node);
                   4865:       fields[2] = build_lang_field_decl (FIELD_DECL, get_identifier ("bits"),
                   4866:                                         unsigned_type_node);
                   4867:       fields[3] = build_lang_field_decl (FIELD_DECL, get_identifier ("points_to"),
                   4868:                                         TYPE_POINTER_TO (__t_desc_type_node));
                   4869:       fields[4] = build_lang_field_decl (FIELD_DECL,
                   4870:                                         get_identifier ("ivars_count"),
                   4871:                                         integer_type_node);
                   4872:       fields[5] = build_lang_field_decl (FIELD_DECL,
                   4873:                                         get_identifier ("meths_count"),
                   4874:                                         integer_type_node);
                   4875:       fields[6] = build_lang_field_decl (FIELD_DECL, get_identifier ("ivars"),
                   4876:                                         build_pointer_type (__i_desc_array_type));
                   4877:       fields[7] = build_lang_field_decl (FIELD_DECL, get_identifier ("meths"),
                   4878:                                         build_pointer_type (__m_desc_array_type));
                   4879:       fields[8] = build_lang_field_decl (FIELD_DECL, get_identifier ("parents"),
                   4880:                                         build_pointer_type (__t_desc_array_type));
                   4881:       fields[9] = build_lang_field_decl (FIELD_DECL, get_identifier ("vbases"),
                   4882:                                         build_pointer_type (__t_desc_array_type));
                   4883:       fields[10] = build_lang_field_decl (FIELD_DECL, get_identifier ("offsets"),
                   4884:                                         build_pointer_type (integer_type_node));
                   4885:       finish_builtin_type (__t_desc_type_node, "__t_desc", fields, 10, integer_type_node);
                   4886: 
                   4887:       /* ivar descriptors look like this:
                   4888: 
                   4889:         struct __i_desc
                   4890:         {
                   4891:           const char *name;
                   4892:           int offset;
                   4893:           struct __t_desc *type;
                   4894:         };
                   4895:       */
                   4896: 
                   4897:       fields[0] = build_lang_field_decl (FIELD_DECL, get_identifier ("name"),
                   4898:                                         string_type_node);
                   4899:       fields[1] = build_lang_field_decl (FIELD_DECL, get_identifier ("offset"),
                   4900:                                         integer_type_node);
                   4901:       fields[2] = build_lang_field_decl (FIELD_DECL, get_identifier ("type"),
                   4902:                                         TYPE_POINTER_TO (__t_desc_type_node));
                   4903:       finish_builtin_type (__i_desc_type_node, "__i_desc", fields, 2, integer_type_node);
                   4904: 
                   4905:       /* method descriptors look like this:
                   4906: 
                   4907:         struct __m_desc
                   4908:         {
                   4909:           const char *name;
                   4910:           int vindex;
                   4911:           struct __t_desc *vcontext;
                   4912:           struct __t_desc *return_type;
                   4913:           void (*address)();
                   4914:           short parm_count;
                   4915:           short required_parms;
                   4916:           struct __t_desc *parm_types[];
                   4917:         };
                   4918:       */
                   4919: 
                   4920:       fields[0] = build_lang_field_decl (FIELD_DECL, get_identifier ("name"),
                   4921:                                         string_type_node);
                   4922:       fields[1] = build_lang_field_decl (FIELD_DECL, get_identifier ("vindex"),
                   4923:                                         integer_type_node);
                   4924:       fields[2] = build_lang_field_decl (FIELD_DECL, get_identifier ("vcontext"),
                   4925:                                         TYPE_POINTER_TO (__t_desc_type_node));
                   4926:       fields[3] = build_lang_field_decl (FIELD_DECL, get_identifier ("return_type"),
                   4927:                                         TYPE_POINTER_TO (__t_desc_type_node));
                   4928:       fields[4] = build_lang_field_decl (FIELD_DECL, get_identifier ("address"),
                   4929:                                         build_pointer_type (default_function_type));
                   4930:       fields[5] = build_lang_field_decl (FIELD_DECL, get_identifier ("parm_count"),
                   4931:                                         short_integer_type_node);
                   4932:       fields[6] = build_lang_field_decl (FIELD_DECL, get_identifier ("required_parms"),
                   4933:                                         short_integer_type_node);
                   4934:       fields[7] = build_lang_field_decl (FIELD_DECL, get_identifier ("parm_types"),
                   4935:                                         build_pointer_type (build_array_type (TYPE_POINTER_TO (__t_desc_type_node), NULL_TREE)));
                   4936:       finish_builtin_type (__m_desc_type_node, "__m_desc", fields, 7, integer_type_node);
                   4937:     }
                   4938: 
                   4939:   /* Now, C++.  */
                   4940:   current_lang_name = lang_name_cplusplus;
                   4941:   if (flag_dossier)
                   4942:     {
                   4943:       int i = builtin_type_tdescs_len;
                   4944:       while (i > 0)
                   4945:        {
                   4946:          tree tdesc = build_t_desc (builtin_type_tdescs_arr[--i], 0);
                   4947:          TREE_ASM_WRITTEN (tdesc) = 1;
                   4948:          TREE_PUBLIC (TREE_OPERAND (tdesc, 0)) = 1;
                   4949:        }
                   4950:     }
                   4951: 
                   4952:   auto_function (ansi_opname[(int) NEW_EXPR],
                   4953:                 build_function_type (ptr_type_node,
                   4954:                                      tree_cons (NULL_TREE, sizetype,
                   4955:                                                 void_list_node)),
                   4956:                 NOT_BUILT_IN);
                   4957:   auto_function (ansi_opname[(int) DELETE_EXPR],
                   4958:                 build_function_type (void_type_node,
                   4959:                                      tree_cons (NULL_TREE, ptr_type_node,
                   4960:                                                 void_list_node)),
                   4961:                 NOT_BUILT_IN);
                   4962: 
                   4963:   abort_fndecl
                   4964:     = define_function ("abort",
                   4965:                       build_function_type (void_type_node, void_list_node),
                   4966:                       NOT_BUILT_IN, 0, 0);
                   4967: 
                   4968:   unhandled_exception_fndecl
                   4969:     = define_function ("__unhandled_exception",
                   4970:                       build_function_type (void_type_node, NULL_TREE),
                   4971:                       NOT_BUILT_IN, 0, 0);
                   4972: 
                   4973:   /* Perform other language dependent initializations.  */
                   4974:   init_class_processing ();
                   4975:   init_init_processing ();
                   4976:   init_search_processing ();
                   4977: 
                   4978:   if (flag_handle_exceptions)
                   4979:     {
                   4980:       if (flag_handle_exceptions == 2)
                   4981:        /* Too much trouble to inline all the trys needed for this.  */
                   4982:        flag_this_is_variable = 2;
                   4983:       init_exception_processing ();
                   4984:     }
                   4985:   if (flag_gc)
                   4986:     init_gc_processing ();
                   4987:   if (flag_no_inline)
                   4988:     flag_inline_functions = 0, flag_default_inline = 0;
                   4989:   if (flag_cadillac)
                   4990:     init_cadillac ();
                   4991: 
                   4992:   /* Create the global bindings for __FUNCTION__ and __PRETTY_FUNCTION__.  */
                   4993:   declare_function_name ();
                   4994: }
                   4995: 
                   4996: /* Make a definition for a builtin function named NAME and whose data type
                   4997:    is TYPE.  TYPE should be a function type with argument types.
                   4998:    FUNCTION_CODE tells later passes how to compile calls to this function.
                   4999:    See tree.h for its possible values.
                   5000: 
                   5001:    If LIBRARY_NAME is nonzero, use that for DECL_ASSEMBLER_NAME,
                   5002:    the name to be called if we can't opencode the function.  */
                   5003: 
                   5004: tree
                   5005: define_function (name, type, function_code, pfn, library_name)
                   5006:      char *name;
                   5007:      tree type;
                   5008:      enum built_in_function function_code;
                   5009:      void (*pfn)();
                   5010:      char *library_name;
                   5011: {
                   5012:   tree decl = build_lang_decl (FUNCTION_DECL, get_identifier (name), type);
                   5013:   DECL_EXTERNAL (decl) = 1;
                   5014:   TREE_PUBLIC (decl) = 1;
                   5015: 
                   5016:   /* Since `pushdecl' relies on DECL_ASSEMBLER_NAME instead of DECL_NAME,
                   5017:      we cannot change DECL_ASSEMBLER_NAME until we have installed this
                   5018:      function in the namespace.  */
                   5019:   if (pfn) (*pfn) (decl);
                   5020:   if (library_name)
                   5021:     DECL_ASSEMBLER_NAME (decl) = get_identifier (library_name);
                   5022:   make_function_rtl (decl);
                   5023:   if (function_code != NOT_BUILT_IN)
                   5024:     {
                   5025:       DECL_BUILT_IN (decl) = 1;
                   5026:       DECL_SET_FUNCTION_CODE (decl, function_code);
                   5027:     }
                   5028:   return decl;
                   5029: }
                   5030: 
                   5031: /* Called when a declaration is seen that contains no names to declare.
                   5032:    If its type is a reference to a structure, union or enum inherited
                   5033:    from a containing scope, shadow that tag name for the current scope
                   5034:    with a forward reference.
                   5035:    If its type defines a new named structure or union
                   5036:    or defines an enum, it is valid but we need not do anything here.
                   5037:    Otherwise, it is an error.
                   5038: 
                   5039:    C++: may have to grok the declspecs to learn about static,
                   5040:    complain for anonymous unions.  */
                   5041: 
                   5042: void
                   5043: shadow_tag (declspecs)
                   5044:      tree declspecs;
                   5045: {
                   5046:   int found_tag = 0;
                   5047:   int warned = 0;
                   5048:   int static_or_extern = 0;
                   5049:   register tree link;
                   5050:   register enum tree_code code, ok_code = ERROR_MARK;
                   5051:   register tree t = NULL_TREE;
                   5052: 
                   5053:   for (link = declspecs; link; link = TREE_CHAIN (link))
                   5054:     {
                   5055:       register tree value = TREE_VALUE (link);
                   5056: 
                   5057:       code = TREE_CODE (value);
                   5058:       if (IS_AGGR_TYPE_CODE (code) || code == ENUMERAL_TYPE)
                   5059:        /* Used to test also that TYPE_SIZE (value) != 0.
                   5060:           That caused warning for `struct foo;' at top level in the file.  */
                   5061:        {
                   5062:          register tree name = TYPE_NAME (value);
                   5063: 
                   5064:          if (name == NULL_TREE)
                   5065:            name = lookup_tag_reverse (value, NULL_TREE);
                   5066: 
                   5067:          if (name && TREE_CODE (name) == TYPE_DECL)
                   5068:            name = DECL_NAME (name);
                   5069: 
                   5070:          if (class_binding_level)
                   5071:            t = lookup_tag (code, name, class_binding_level, 1);
                   5072:          else
                   5073:            t = lookup_tag (code, name, current_binding_level, 1);
                   5074: 
                   5075:          if (t == NULL_TREE)
                   5076:            {
                   5077:              push_obstacks (&permanent_obstack, &permanent_obstack);
                   5078:              if (IS_AGGR_TYPE_CODE (code))
                   5079:                t = make_lang_type (code);
                   5080:              else
                   5081:                t = make_node (code);
                   5082:              pushtag (name, t);
                   5083:              pop_obstacks ();
                   5084:              ok_code = code;
                   5085:              break;
                   5086:            }
                   5087:          else if (name != NULL_TREE || code == ENUMERAL_TYPE)
                   5088:            ok_code = code;
                   5089: 
                   5090:          if (ok_code != ERROR_MARK)
                   5091:            found_tag++;
                   5092:          else
                   5093:            {
                   5094:              if (!warned)
                   5095:                pedwarn ("useless keyword or type name in declaration");
                   5096:              warned = 1;
                   5097:            }
                   5098:        }
                   5099:       else if (value == ridpointers[(int) RID_STATIC]
                   5100:               || value == ridpointers[(int) RID_EXTERN])
                   5101:        static_or_extern = 1;
                   5102:     }
                   5103: 
                   5104:   /* This is where the variables in an anonymous union are
                   5105:      declared.  An anonymous union declaration looks like:
                   5106:      union { ... } ;
                   5107:      because there is no declarator after the union, the parser
                   5108:      sends that declaration here.  */
                   5109:   if (ok_code == UNION_TYPE
                   5110:       && t != NULL_TREE
                   5111:       && ((TREE_CODE (TYPE_NAME (t)) == IDENTIFIER_NODE
                   5112:           && ANON_AGGRNAME_P (TYPE_NAME (t)))
                   5113:          || (TREE_CODE (TYPE_NAME (t)) == TYPE_DECL
                   5114:              && ANON_AGGRNAME_P (TYPE_IDENTIFIER (t)))))
                   5115:     {
                   5116:       /* ANSI C++ June 5 1992 WP 9.5.3.  Anonymous unions may not have
                   5117:         function members.  */
                   5118:       if (TYPE_FIELDS (t))
                   5119:        {
                   5120:          tree decl = grokdeclarator (NULL_TREE, declspecs, NORMAL, 0, NULL_TREE);
                   5121:          finish_anon_union (decl);
                   5122:        }
                   5123:       else
                   5124:        error ("anonymous union cannot have a function member");
                   5125:     }
                   5126:   else
                   5127:     {
                   5128:       /* Anonymous unions are objects, that's why we only check for
                   5129:         static/extern specifiers in this branch.  */
                   5130:       if (static_or_extern)
                   5131:        error ("static/extern can only be specified for objects and functions");
                   5132: 
                   5133:       if (ok_code == RECORD_TYPE
                   5134:          && found_tag == 1
                   5135:          && TYPE_LANG_SPECIFIC (t)
                   5136:          && CLASSTYPE_DECLARED_EXCEPTION (t))
                   5137:        {
                   5138:          if (TYPE_SIZE (t))
                   5139:            cp_error ("redeclaration of exception `%T'", t);
                   5140:          else
                   5141:            {
                   5142:              tree ename, decl;
                   5143: 
                   5144:              push_obstacks (&permanent_obstack, &permanent_obstack);
                   5145: 
                   5146:              pushclass (t, 0);
                   5147:              finish_exception (t, NULL_TREE);
                   5148: 
                   5149:              ename = TYPE_NAME (t);
                   5150:              if (TREE_CODE (ename) == TYPE_DECL)
                   5151:                ename = DECL_NAME (ename);
                   5152:              decl = build_lang_field_decl (VAR_DECL, ename, t);
                   5153:              finish_exception_decl (current_class_name, decl);
                   5154:              end_exception_decls ();
                   5155: 
                   5156:              pop_obstacks ();
                   5157:            }
                   5158:        }
                   5159:       else if (!warned && found_tag > 1)
                   5160:        warning ("multiple types in one declaration");
                   5161:     }
                   5162: }
                   5163: 
                   5164: /* Decode a "typename", such as "int **", returning a ..._TYPE node.  */
                   5165: 
                   5166: tree
                   5167: groktypename (typename)
                   5168:      tree typename;
                   5169: {
                   5170:   if (TREE_CODE (typename) != TREE_LIST)
                   5171:     return typename;
                   5172:   return grokdeclarator (TREE_VALUE (typename),
                   5173:                         TREE_PURPOSE (typename),
                   5174:                         TYPENAME, 0, NULL_TREE);
                   5175: }
                   5176: 
                   5177: #ifdef OBJCPLUS
                   5178: /* Return a PARM_DECL node for a given pair of specs and declarator.  */
                   5179: 
                   5180: tree
                   5181: groktypename_in_parm_context (typename)
                   5182:      tree typename;
                   5183: {
                   5184:   if (TREE_CODE (typename) != TREE_LIST)
                   5185:     return typename;
                   5186:   return grokdeclarator (TREE_VALUE (typename),
                   5187:                          TREE_PURPOSE (typename),
                   5188:                          PARM, 0, NULL_TREE);
                   5189: }
                   5190: #endif /* OBJCPLUS */
                   5191: 
                   5192: 
                   5193: /* Decode a declarator in an ordinary declaration or data definition.
                   5194:    This is called as soon as the type information and variable name
                   5195:    have been parsed, before parsing the initializer if any.
                   5196:    Here we create the ..._DECL node, fill in its type,
                   5197:    and put it on the list of decls for the current context.
                   5198:    The ..._DECL node is returned as the value.
                   5199: 
                   5200:    Exception: for arrays where the length is not specified,
                   5201:    the type is left null, to be filled in by `finish_decl'.
                   5202: 
                   5203:    Function definitions do not come here; they go to start_function
                   5204:    instead.  However, external and forward declarations of functions
                   5205:    do go through here.  Structure field declarations are done by
                   5206:    grokfield and not through here.  */
                   5207: 
                   5208: /* Set this to zero to debug not using the temporary obstack
                   5209:    to parse initializers.  */
                   5210: int debug_temp_inits = 1;
                   5211: 
                   5212: tree
                   5213: start_decl (declarator, declspecs, initialized, raises)
                   5214:      tree declarator, declspecs;
                   5215:      int initialized;
                   5216:      tree raises;
                   5217: {
                   5218:   register tree decl;
                   5219:   register tree type, tem;
                   5220:   tree context;
                   5221:   extern int have_extern_spec;
                   5222:   extern int used_extern_spec;
                   5223: 
                   5224:   int init_written = initialized;
                   5225: 
                   5226:   /* This should only be done once on the top most decl. */
                   5227:   if (have_extern_spec && !used_extern_spec)
                   5228:     {
                   5229:       declspecs = decl_tree_cons (NULL_TREE, get_identifier ("extern"), declspecs);
                   5230:       used_extern_spec = 1;
                   5231:     }
                   5232: 
                   5233:   decl = grokdeclarator (declarator, declspecs, NORMAL, initialized, raises);
                   5234:   if (decl == NULL_TREE || decl == void_type_node)
                   5235:     return NULL_TREE;
                   5236: 
                   5237:   type = TREE_TYPE (decl);
                   5238: 
                   5239:   /* Don't lose if destructors must be executed at file-level.  */
                   5240:   if (TREE_STATIC (decl)
                   5241:       && TYPE_NEEDS_DESTRUCTOR (type)
                   5242:       && !TREE_PERMANENT (decl))
                   5243:     {
                   5244:       push_obstacks (&permanent_obstack, &permanent_obstack);
                   5245:       decl = copy_node (decl);
                   5246:       if (TREE_CODE (type) == ARRAY_TYPE)
                   5247:        {
                   5248:          tree itype = TYPE_DOMAIN (type);
                   5249:          if (itype && ! TREE_PERMANENT (itype))
                   5250:            {
                   5251:              itype = build_index_type (copy_to_permanent (TYPE_MAX_VALUE (itype)));
                   5252:              type = build_cplus_array_type (TREE_TYPE (type), itype);
                   5253:              TREE_TYPE (decl) = type;
                   5254:            }
                   5255:        }
                   5256:       pop_obstacks ();
                   5257:     }
                   5258: 
                   5259:   /* Interesting work for this is done in `finish_exception_decl'.  */
                   5260:   if (TREE_CODE (type) == RECORD_TYPE
                   5261:       && CLASSTYPE_DECLARED_EXCEPTION (type))
                   5262:     return decl;
                   5263: 
                   5264:   /* Corresponding pop_obstacks is done in `finish_decl'.  */
                   5265:   push_obstacks_nochange ();
                   5266: 
                   5267:   context
                   5268:     = (TREE_CODE (decl) == FUNCTION_DECL && DECL_VIRTUAL_P (decl))
                   5269:       ? DECL_CLASS_CONTEXT (decl)
                   5270:       : DECL_CONTEXT (decl);
                   5271: 
                   5272:   if (processing_template_decl)
                   5273:     {
                   5274:       tree d;
                   5275:       if (TREE_CODE (decl) == FUNCTION_DECL)
                   5276:         {
                   5277:           /* Declarator is a call_expr; extract arguments from it, since
                   5278:              grokdeclarator didn't do it.  */
                   5279:           tree args;
                   5280:           args = copy_to_permanent (last_function_parms);
                   5281:           if (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)
                   5282:             {
                   5283:              tree t = TREE_TYPE (decl);
                   5284:               tree decl;
                   5285:              
                   5286:               t = TYPE_METHOD_BASETYPE (t); /* type method belongs to */
                   5287:              if (TREE_CODE (t) != UNINSTANTIATED_P_TYPE)
                   5288:                {
                   5289:                  t = build_pointer_type (t); /* base type of `this' */
                   5290: #if 1
                   5291:                  /* I suspect this is wrong. */
                   5292:                  t = build_type_variant (t, flag_this_is_variable <= 0,
                   5293:                                          0); /* type of `this' */
                   5294: #else
                   5295:                  t = build_type_variant (t, 0, 0); /* type of `this' */
                   5296: #endif
                   5297:                  t = build (PARM_DECL, t, this_identifier);
                   5298:                  TREE_CHAIN (t) = args;
                   5299:                  args = t;
                   5300:                }
                   5301:            }
                   5302:           DECL_ARGUMENTS (decl) = args;
                   5303:         }
                   5304:       d = build_lang_decl (TEMPLATE_DECL, DECL_NAME (decl), TREE_TYPE (decl));
                   5305:       if (interface_unknown && flag_external_templates)
                   5306:        warn_if_unknown_interface ();
                   5307:       TREE_PUBLIC (d) = TREE_PUBLIC (decl) = flag_external_templates && !interface_unknown;
                   5308:       TREE_STATIC (d) = TREE_STATIC (decl);
                   5309:       DECL_EXTERNAL (d) = (DECL_EXTERNAL (decl)
                   5310:                           && !(context && !DECL_THIS_EXTERN (decl)));
                   5311:       DECL_TEMPLATE_RESULT (d) = decl;
                   5312:       DECL_OVERLOADED (d) = 1;
                   5313:       decl = d;
                   5314:     }
                   5315: 
                   5316:   if (context && TYPE_SIZE (context) != NULL_TREE)
                   5317:     {
                   5318:       /* If it was not explicitly declared `extern',
                   5319:         revoke any previous claims of DECL_EXTERNAL.  */
                   5320:       if (DECL_THIS_EXTERN (decl) == 0)
                   5321:        DECL_EXTERNAL (decl) = 0;
                   5322:       if (DECL_LANG_SPECIFIC (decl))
                   5323:        DECL_IN_AGGR_P (decl) = 0;
                   5324:       pushclass (context, 2);
                   5325:     }
                   5326: 
                   5327:   /* If this type of object needs a cleanup, and control may
                   5328:      jump past it, make a new binding level so that it is cleaned
                   5329:      up only when it is initialized first.  */
                   5330:   if (TYPE_NEEDS_DESTRUCTOR (type)
                   5331:       && current_binding_level->more_cleanups_ok == 0)
                   5332:     pushlevel_temporary (1);
                   5333: 
                   5334:   if (initialized)
                   5335:     /* Is it valid for this decl to have an initializer at all?
                   5336:        If not, set INITIALIZED to zero, which will indirectly
                   5337:        tell `finish_decl' to ignore the initializer once it is parsed.  */
                   5338:     switch (TREE_CODE (decl))
                   5339:       {
                   5340:       case TYPE_DECL:
                   5341:        /* typedef foo = bar  means give foo the same type as bar.
                   5342:           We haven't parsed bar yet, so `finish_decl' will fix that up.
                   5343:           Any other case of an initialization in a TYPE_DECL is an error.  */
                   5344:        if (pedantic || list_length (declspecs) > 1)
                   5345:          {
                   5346:            cp_error ("typedef `%D' is initialized", decl);
                   5347:            initialized = 0;
                   5348:          }
                   5349:        break;
                   5350: 
                   5351:       case FUNCTION_DECL:
                   5352:        cp_error ("function `%#D' is initialized like a variable", decl);
                   5353:        initialized = 0;
                   5354:        break;
                   5355: 
                   5356:       default:
                   5357:        /* Don't allow initializations for incomplete types except for
                   5358:           arrays which might be completed by the initialization.  */
                   5359:        if (TYPE_SIZE (type) != NULL_TREE)
                   5360:          ;                     /* A complete type is ok.  */
                   5361:        else if (TREE_CODE (type) != ARRAY_TYPE)
                   5362:          {
                   5363:            cp_error ("variable `%#D' has initializer but incomplete type",
                   5364:                      decl);
                   5365:            initialized = 0;
                   5366:          }
                   5367:        else if (TYPE_SIZE (TREE_TYPE (type)) == NULL_TREE)
                   5368:          {
                   5369:            cp_error ("elements of array `%#D' have incomplete type", decl);
                   5370:            initialized = 0;
                   5371:          }
                   5372:       }
                   5373: 
                   5374:   if (!initialized
                   5375:       && TREE_CODE (decl) != TYPE_DECL
                   5376:       && TREE_CODE (decl) != TEMPLATE_DECL
                   5377:       && IS_AGGR_TYPE (type) && ! DECL_EXTERNAL (decl))
                   5378:     {
                   5379:       if (TYPE_SIZE (type) == NULL_TREE)
                   5380:        {
                   5381:          cp_error ("aggregate `%#D' has incomplete type and cannot be initialized",
                   5382:                 decl);
                   5383:          /* Change the type so that assemble_variable will give
                   5384:             DECL an rtl we can live with: (mem (const_int 0)).  */
                   5385:          TREE_TYPE (decl) = error_mark_node;
                   5386:          type = error_mark_node;
                   5387:        }
                   5388:       else
                   5389:        {
                   5390:          /* If any base type in the hierarchy of TYPE needs a constructor,
                   5391:             then we set initialized to 1.  This way any nodes which are
                   5392:             created for the purposes of initializing this aggregate
                   5393:             will live as long as it does.  This is necessary for global
                   5394:             aggregates which do not have their initializers processed until
                   5395:             the end of the file.  */
                   5396:          initialized = TYPE_NEEDS_CONSTRUCTING (type);
                   5397:        }
                   5398:     }
                   5399: 
                   5400:   if (initialized)
                   5401:     {
                   5402:       if (current_binding_level != global_binding_level
                   5403:          && DECL_EXTERNAL (decl))
                   5404:        cp_warning ("declaration of `%#D' has `extern' and is initialized",
                   5405:                    decl);
                   5406:       DECL_EXTERNAL (decl) = 0;
                   5407:       if (current_binding_level == global_binding_level)
                   5408:        TREE_STATIC (decl) = 1;
                   5409: 
                   5410:       /* Tell `pushdecl' this is an initialized decl
                   5411:         even though we don't yet have the initializer expression.
                   5412:         Also tell `finish_decl' it may store the real initializer.  */
                   5413:       DECL_INITIAL (decl) = error_mark_node;
                   5414:     }
                   5415: 
                   5416:   /* Add this decl to the current binding level, but not if it
                   5417:      comes from another scope, e.g. a static member variable.
                   5418:      TEM may equal DECL or it may be a previous decl of the same name.  */
                   5419:   if ((TREE_CODE (decl) != PARM_DECL && DECL_CONTEXT (decl) != NULL_TREE)
                   5420:       || (TREE_CODE (decl) == TEMPLATE_DECL && !global_bindings_p ())
                   5421:       || TREE_CODE (type) == LANG_TYPE)
                   5422:     tem = decl;
                   5423:   else
                   5424:     {
                   5425:       tem = pushdecl (decl);
                   5426:       if (TREE_CODE (tem) == TREE_LIST)
                   5427:        {
                   5428:          tree tem2 = value_member (decl, tem);
                   5429:          if (tem2 != NULL_TREE)
                   5430:            tem = TREE_VALUE (tem2);
                   5431:          else
                   5432:            {
                   5433:              while (tem && ! decls_match (decl, TREE_VALUE (tem)))
                   5434:                tem = TREE_CHAIN (tem);
                   5435:              if (tem == NULL_TREE)
                   5436:                tem = decl;
                   5437:              else
                   5438:                tem = TREE_VALUE (tem);
                   5439:            }
                   5440:        }
                   5441:     }
                   5442: 
                   5443: #if 0
                   5444:   /* We don't do this yet for GNU C++.  */
                   5445:   /* For a local variable, define the RTL now.  */
                   5446:   if (current_binding_level != global_binding_level
                   5447:       /* But not if this is a duplicate decl
                   5448:         and we preserved the rtl from the previous one
                   5449:         (which may or may not happen).  */
                   5450:       && DECL_RTL (tem) == NULL_RTX)
                   5451:     {
                   5452:       if (TYPE_SIZE (TREE_TYPE (tem)) != NULL_TREE)
                   5453:        expand_decl (tem);
                   5454:       else if (TREE_CODE (TREE_TYPE (tem)) == ARRAY_TYPE
                   5455:               && DECL_INITIAL (tem) != NULL_TREE)
                   5456:        expand_decl (tem);
                   5457:     }
                   5458: #endif
                   5459: 
                   5460:   if (TREE_CODE (decl) == FUNCTION_DECL && DECL_OVERLOADED (decl))
                   5461:     /* @@ Also done in start_function.  */
                   5462:     tem = push_overloaded_decl (tem, 1);
                   5463:   else if (TREE_CODE (decl) == TEMPLATE_DECL)
                   5464:     {
                   5465:       tree result = DECL_TEMPLATE_RESULT (decl);
                   5466:       if (DECL_CONTEXT (result) != NULL_TREE)
                   5467:        {
                   5468:           tree type;
                   5469:           type = DECL_CONTEXT (result);
                   5470: 
                   5471:          if (TREE_CODE (type) != UNINSTANTIATED_P_TYPE)
                   5472:            {
                   5473:              cp_error ("declaration of `%D' in non-template type `%T'",
                   5474:                        decl, type);
                   5475:              return NULL_TREE;
                   5476:            }
                   5477: 
                   5478:           if (/* TREE_CODE (result) == VAR_DECL */ 1)
                   5479:             {
                   5480: #if 0
                   5481:               tree tmpl = UPT_TEMPLATE (type);
                   5482:              
                   5483:              fprintf (stderr, "%s:%d: adding ", __FILE__, __LINE__);
                   5484:              print_node_brief (stderr, "", DECL_NAME (tem), 0);
                   5485:              fprintf (stderr, " to class %s\n",
                   5486:                       IDENTIFIER_POINTER (DECL_NAME (tmpl)));
                   5487:               DECL_TEMPLATE_MEMBERS (tmpl)
                   5488:                 = perm_tree_cons (DECL_NAME (tem), tem,
                   5489:                                  DECL_TEMPLATE_MEMBERS (tmpl));
                   5490: #endif
                   5491:              return tem;
                   5492:            }
                   5493:           my_friendly_abort (13);
                   5494:         }
                   5495:       else if (TREE_CODE (result) == FUNCTION_DECL)
                   5496:         tem = push_overloaded_decl (tem, 0);
                   5497:       else if (TREE_CODE (result) == VAR_DECL
                   5498:               || TREE_CODE (result) == TYPE_DECL)
                   5499:        {
                   5500:          cp_error ("invalid template `%#D'", result);
                   5501:          return NULL_TREE;
                   5502:        }
                   5503:       else
                   5504:        my_friendly_abort (14);
                   5505:     }
                   5506: 
                   5507:   if (init_written
                   5508:       && ! (TREE_CODE (tem) == PARM_DECL
                   5509:            || (TREE_READONLY (tem)
                   5510:                && (TREE_CODE (tem) == VAR_DECL
                   5511:                    || TREE_CODE (tem) == FIELD_DECL))))
                   5512:     {
                   5513:       /* When parsing and digesting the initializer,
                   5514:         use temporary storage.  Do this even if we will ignore the value.  */
                   5515:       if (current_binding_level == global_binding_level && debug_temp_inits)
                   5516:        {
                   5517:          if (TYPE_NEEDS_CONSTRUCTING (type) || TREE_CODE (type) == REFERENCE_TYPE)
                   5518:            /* In this case, the initializer must lay down in permanent
                   5519:               storage, since it will be saved until `finish_file' is run.   */
                   5520:            ;
                   5521:          else
                   5522:            temporary_allocation ();
                   5523:        }
                   5524:     }
                   5525: 
                   5526:   if (flag_cadillac)
                   5527:     cadillac_start_decl (tem);
                   5528: 
                   5529:   return tem;
                   5530: }
                   5531: 
                   5532: static void
                   5533: make_temporary_for_reference (decl, ctor_call, init, cleanupp)
                   5534:      tree decl, ctor_call, init;
                   5535:      tree *cleanupp;
                   5536: {
                   5537:   tree type = TREE_TYPE (decl);
                   5538:   tree target_type = TREE_TYPE (type);
                   5539:   tree tmp, tmp_addr;
                   5540: 
                   5541:   if (ctor_call)
                   5542:     {
                   5543:       tmp_addr = TREE_VALUE (TREE_OPERAND (ctor_call, 1));
                   5544:       if (TREE_CODE (tmp_addr) == NOP_EXPR)
                   5545:        tmp_addr = TREE_OPERAND (tmp_addr, 0);
                   5546:       my_friendly_assert (TREE_CODE (tmp_addr) == ADDR_EXPR, 146);
                   5547:       tmp = TREE_OPERAND (tmp_addr, 0);
                   5548:     }
                   5549:   else
                   5550:     {
                   5551:       tmp = get_temp_name (target_type,
                   5552:                           current_binding_level == global_binding_level);
                   5553:       tmp_addr = build_unary_op (ADDR_EXPR, tmp, 0);
                   5554:     }
                   5555: 
                   5556:   TREE_TYPE (tmp_addr) = build_pointer_type (target_type);
                   5557:   DECL_INITIAL (decl) = convert (TYPE_POINTER_TO (target_type), tmp_addr);
                   5558:   TREE_TYPE (DECL_INITIAL (decl)) = type;
                   5559:   if (TYPE_NEEDS_CONSTRUCTING (target_type))
                   5560:     {
                   5561:       if (current_binding_level == global_binding_level)
                   5562:        {
                   5563:          /* lay this variable out now.  Otherwise `output_addressed_constants'
                   5564:             gets confused by its initializer.  */
                   5565:          make_decl_rtl (tmp, NULL_PTR, 1);
                   5566:          static_aggregates = perm_tree_cons (init, tmp, static_aggregates);
                   5567:        }
                   5568:       else
                   5569:        {
                   5570:          if (ctor_call != NULL_TREE)
                   5571:            init = ctor_call;
                   5572:          else
                   5573:            init = build_method_call (tmp, constructor_name_full (target_type),
                   5574:                                      build_tree_list (NULL_TREE, init),
                   5575:                                      NULL_TREE, LOOKUP_NORMAL);
                   5576:          DECL_INITIAL (decl) = build (COMPOUND_EXPR, type, init,
                   5577:                                       DECL_INITIAL (decl));
                   5578:          *cleanupp = maybe_build_cleanup (tmp);
                   5579:        }
                   5580:     }
                   5581:   else
                   5582:     {
                   5583:       DECL_INITIAL (tmp) = init;
                   5584:       TREE_STATIC (tmp) = current_binding_level == global_binding_level;
                   5585:       finish_decl (tmp, init, 0, 0);
                   5586:     }
                   5587:   if (TREE_STATIC (tmp))
                   5588:     preserve_initializer ();
                   5589: }
                   5590: 
                   5591: /* Handle initialization of references.
                   5592:    These three arguments from from `finish_decl', and have the
                   5593:    same meaning here that they do there.  */
                   5594: /* quotes on semantics can be found in ARM 8.4.3. */
                   5595: static void
                   5596: grok_reference_init (decl, type, init, cleanupp)
                   5597:      tree decl, type, init;
                   5598:      tree *cleanupp;
                   5599: {
                   5600:   char *errstr = NULL;
                   5601:   int is_reference;
                   5602:   tree tmp;
                   5603:   tree this_ptr_type, actual_init;
                   5604: 
                   5605:   if (init == NULL_TREE)
                   5606:     {
                   5607:       if (DECL_LANG_SPECIFIC (decl) == 0
                   5608:          || DECL_IN_AGGR_P (decl) == 0)
                   5609:        {
                   5610:          error ("variable declared as reference not initialized");
                   5611:          if (TREE_CODE (decl) == VAR_DECL)
                   5612:            SET_DECL_REFERENCE_SLOT (decl, error_mark_node);
                   5613:        }
                   5614:       return;
                   5615:     }
                   5616: 
                   5617:   if (TREE_CODE (type) == REFERENCE_TYPE
                   5618:       && TREE_CODE (init) == CONSTRUCTOR)
                   5619:     {
                   5620:       error ("ANSI C++ forbids use of initializer list for a reference initializer");
                   5621:       return;
                   5622:     }
                   5623: 
                   5624:   if (TREE_CODE (init) == TREE_LIST)
                   5625:     init = build_compound_expr (init);
                   5626:   is_reference = TREE_CODE (TREE_TYPE (init)) == REFERENCE_TYPE;
                   5627:   tmp = is_reference ? convert_from_reference (init) : init;
                   5628: 
                   5629:   if (is_reference)
                   5630:     {
                   5631:       if (! comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (type)),
                   5632:                       TYPE_MAIN_VARIANT (TREE_TYPE (tmp)), 0))
                   5633:        errstr = "initialization of `%s' from dissimilar reference type";
                   5634:       else if (TYPE_READONLY (TREE_TYPE (type))
                   5635:               >= TYPE_READONLY (TREE_TYPE (TREE_TYPE (init))))
                   5636:        {
                   5637:          is_reference = 0;
                   5638:          init = tmp;
                   5639:        }
                   5640:     }
                   5641:   else
                   5642:     {
                   5643:       if (TREE_CODE (TREE_TYPE (type)) != ARRAY_TYPE
                   5644:          && TREE_CODE (TREE_TYPE (init)) == ARRAY_TYPE)
                   5645:        {
                   5646:          /* Note: default conversion is only called in very
                   5647:             special cases.  */
                   5648:          init = default_conversion (init);
                   5649:        }
                   5650:       if (TREE_CODE (TREE_TYPE (type)) == TREE_CODE (TREE_TYPE (init)))
                   5651:        {
                   5652:          if (comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (type)),
                   5653:                         TYPE_MAIN_VARIANT (TREE_TYPE (init)), 0))
                   5654:            {
                   5655:              /* This section implements ANSI C++ June 5 1992 WP 8.4.3.5. */
                   5656: 
                   5657:              /* A reference to a volatile T cannot be initialized with
                   5658:                 a const T, and vice-versa.  */
                   5659:              if (TYPE_VOLATILE (TREE_TYPE (type)) && TREE_READONLY (init))
                   5660:                errstr = "cannot initialize a reference to a volatile T with a const T";
                   5661:              else if (TYPE_READONLY (TREE_TYPE (type)) && TREE_THIS_VOLATILE (init))
                   5662:                errstr = "cannot initialize a reference to a const T with a volatile T";
                   5663:              /* A reference to a plain T can be initialized only with
                   5664:                 a plain T.  */
                   5665:              else if (!TYPE_VOLATILE (TREE_TYPE (type))
                   5666:                       && !TYPE_READONLY (TREE_TYPE (type)))
                   5667:                {
                   5668:                  if (TREE_READONLY (init))
                   5669:                    errstr = "cannot initialize a reference to T with a const T";
                   5670:                  else if (TREE_THIS_VOLATILE (init))
                   5671:                    errstr = "cannot initialize a reference to T with a volatile T";
                   5672:                }
                   5673:            }
                   5674:          else
                   5675:            init = convert (TREE_TYPE (type), init);
                   5676:        }
                   5677:       else if (init != error_mark_node
                   5678:               && ! comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (type)),
                   5679:                               TYPE_MAIN_VARIANT (TREE_TYPE (init)), 0))
                   5680:        errstr = "invalid type conversion for reference";
                   5681:     }
                   5682: 
                   5683:   if (errstr)
                   5684:     {
                   5685:       /* Things did not go smoothly; look for operator& type conversion.  */
                   5686:       if (IS_AGGR_TYPE (TREE_TYPE (tmp)))
                   5687:        {
                   5688:          tmp = build_type_conversion (CONVERT_EXPR, type, init, 0);
                   5689:          if (tmp != NULL_TREE)
                   5690:            {
                   5691:              init = tmp;
                   5692:              if (tmp == error_mark_node)
                   5693:                errstr = "ambiguous pointer conversion";
                   5694:              else
                   5695:                errstr = NULL;
                   5696:              is_reference = 1;
                   5697:            }
                   5698:          else
                   5699:            {
                   5700:              tmp = build_type_conversion (CONVERT_EXPR, TREE_TYPE (type), init, 0);
                   5701:              if (tmp != NULL_TREE)
                   5702:                {
                   5703:                  init = tmp;
                   5704:                  if (tmp == error_mark_node)
                   5705:                    errstr = "ambiguous pointer conversion";
                   5706:                  else
                   5707:                    errstr = NULL;
                   5708:                  is_reference = 0;
                   5709:                }
                   5710:            }
                   5711:        }
                   5712:       /* Look for constructor.  */
                   5713:       else if (IS_AGGR_TYPE (TREE_TYPE (type))
                   5714:               && TYPE_HAS_CONSTRUCTOR (TREE_TYPE (type)))
                   5715:        {
                   5716:          tmp = get_temp_name (TREE_TYPE (type),
                   5717:                               current_binding_level == global_binding_level);
                   5718:          tmp = build_method_call (tmp, constructor_name_full (TREE_TYPE (type)),
                   5719:                                   build_tree_list (NULL_TREE, init),
                   5720:                                   NULL_TREE, LOOKUP_NORMAL);
                   5721:          if (tmp == NULL_TREE || tmp == error_mark_node)
                   5722:            {
                   5723:              if (TREE_CODE (decl) == VAR_DECL)
                   5724:                SET_DECL_REFERENCE_SLOT (decl, error_mark_node);
                   5725:              cp_error_at ("constructor failed to build reference initializer", decl);
                   5726:              return;
                   5727:            }
                   5728:          make_temporary_for_reference (decl, tmp, init, cleanupp);
                   5729:          goto done;
                   5730:        }
                   5731:     }
                   5732: 
                   5733:   if (errstr)
                   5734:     {
                   5735:       error_with_decl (decl, errstr);
                   5736:       if (TREE_CODE (decl) == VAR_DECL)
                   5737:        SET_DECL_REFERENCE_SLOT (decl, error_mark_node);
                   5738:       return;
                   5739:     }
                   5740: 
                   5741:   /* In the case of initialization, it is permissible
                   5742:      to assign one reference to another.  */
                   5743:   this_ptr_type = build_pointer_type (TREE_TYPE (type));
                   5744: 
                   5745:   if (is_reference)
                   5746:     {
                   5747:       if (TREE_SIDE_EFFECTS (init))
                   5748:        DECL_INITIAL (decl) = save_expr (init);
                   5749:       else
                   5750:        DECL_INITIAL (decl) = init;
                   5751:     }
                   5752:   else if (lvalue_p (init))
                   5753:     {
                   5754:       tmp = build_unary_op (ADDR_EXPR, init, 0);
                   5755:       if (TREE_CODE (tmp) == ADDR_EXPR
                   5756:          && TREE_CODE (TREE_OPERAND (tmp, 0)) == WITH_CLEANUP_EXPR)
                   5757:        {
                   5758:          /* Associate the cleanup with the reference so that we
                   5759:             don't get burned by "aggressive" cleanup policy.  */
                   5760:          *cleanupp = TREE_OPERAND (TREE_OPERAND (tmp, 0), 2);
                   5761:          TREE_OPERAND (TREE_OPERAND (tmp, 0), 2) = error_mark_node;
                   5762:        }
                   5763:       if (IS_AGGR_TYPE (TREE_TYPE (this_ptr_type)))
                   5764:        DECL_INITIAL (decl) = convert_pointer_to (TREE_TYPE (this_ptr_type), tmp);
                   5765:       else
                   5766:        DECL_INITIAL (decl) = convert (this_ptr_type, tmp);
                   5767: 
                   5768:       DECL_INITIAL (decl) = save_expr (DECL_INITIAL (decl));
                   5769:       if (DECL_INITIAL (decl) == current_class_decl)
                   5770:        DECL_INITIAL (decl) = copy_node (current_class_decl);
                   5771:       TREE_TYPE (DECL_INITIAL (decl)) = type;
                   5772:     }
                   5773:   else if ((actual_init = unary_complex_lvalue (ADDR_EXPR, init)))
                   5774:     {
                   5775:       /* The initializer for this decl goes into its
                   5776:         DECL_REFERENCE_SLOT.  Make sure that we can handle
                   5777:         multiple evaluations without ill effect.  */
                   5778:       if (TREE_CODE (actual_init) == ADDR_EXPR
                   5779:          && TREE_CODE (TREE_OPERAND (actual_init, 0)) == TARGET_EXPR)
                   5780:        actual_init = save_expr (actual_init);
                   5781:       DECL_INITIAL (decl) = convert_pointer_to (TREE_TYPE (this_ptr_type), actual_init);
                   5782:       DECL_INITIAL (decl) = save_expr (DECL_INITIAL (decl));
                   5783:       TREE_TYPE (DECL_INITIAL (decl)) = type;
                   5784:     }
                   5785:   else if (TYPE_READONLY (TREE_TYPE (type)))
                   5786:     /* Section 8.4.3 allows us to make a temporary for
                   5787:        the initialization of const&.  */
                   5788:     make_temporary_for_reference (decl, NULL_TREE, init, cleanupp);
                   5789:   else
                   5790:     {
                   5791:       cp_error ("type mismatch in initialization of `%D' (use `const')", decl);
                   5792:       DECL_INITIAL (decl) = error_mark_node;
                   5793:     }
                   5794: 
                   5795:  done:
                   5796:   /* ?? Can this be optimized in some cases to
                   5797:      hand back the DECL_INITIAL slot??  */
                   5798:   if (TYPE_SIZE (TREE_TYPE (type)))
                   5799:     {
                   5800:       init = convert_from_reference (decl);
                   5801:       if (TREE_PERMANENT (decl))
                   5802:        init = copy_to_permanent (init);
                   5803:       SET_DECL_REFERENCE_SLOT (decl, init);
                   5804:     }
                   5805: 
                   5806:   if (TREE_STATIC (decl) && ! TREE_CONSTANT (DECL_INITIAL (decl)))
                   5807:     {
                   5808:       expand_static_init (decl, DECL_INITIAL (decl));
                   5809:       DECL_INITIAL (decl) = NULL_TREE;
                   5810:     }
                   5811: }
                   5812: 
                   5813: /* Finish processing of a declaration;
                   5814:    install its line number and initial value.
                   5815:    If the length of an array type is not known before,
                   5816:    it must be determined now, from the initial value, or it is an error.
                   5817: 
                   5818:    Call `pop_obstacks' iff NEED_POP is nonzero.
                   5819: 
                   5820:    For C++, `finish_decl' must be fairly evasive:  it must keep initializers
                   5821:    for aggregates that have constructors alive on the permanent obstack,
                   5822:    so that the global initializing functions can be written at the end.
                   5823: 
                   5824:    INIT0 holds the value of an initializer that should be allowed to escape
                   5825:    the normal rules.
                   5826: 
                   5827:    For functions that take default parameters, DECL points to its
                   5828:    "maximal" instantiation.  `finish_decl' must then also declared its
                   5829:    subsequently lower and lower forms of instantiation, checking for
                   5830:    ambiguity as it goes.  This can be sped up later.  */
                   5831: 
                   5832: void
                   5833: finish_decl (decl, init, asmspec_tree, need_pop)
                   5834:      tree decl, init;
                   5835:      tree asmspec_tree;
                   5836:      int need_pop;
                   5837: {
                   5838:   register tree type;
                   5839:   tree cleanup = NULL_TREE, ttype;
                   5840:   int was_incomplete;
                   5841:   int temporary = allocation_temporary_p ();
                   5842:   char *asmspec = NULL;
                   5843:   int was_readonly = 0;
                   5844: 
                   5845:   /* If this is 0, then we did not change obstacks.  */
                   5846:   if (! decl)
                   5847:     {
                   5848:       if (init)
                   5849:        error ("assignment (not initialization) in declaration");
                   5850:       return;
                   5851:     }
                   5852: 
                   5853:   if (asmspec_tree)
                   5854:     {
                   5855:       asmspec = TREE_STRING_POINTER (asmspec_tree);
                   5856:       /* Zero out old RTL, since we will rewrite it.  */
                   5857:       DECL_RTL (decl) = NULL_RTX;
                   5858:     }
                   5859: 
                   5860:   /* If the type of the thing we are declaring either has
                   5861:      a constructor, or has a virtual function table pointer,
                   5862:      AND its initialization was accepted by `start_decl',
                   5863:      then we stayed on the permanent obstack through the
                   5864:      declaration, otherwise, changed obstacks as GCC would.  */
                   5865: 
                   5866:   type = TREE_TYPE (decl);
                   5867: 
                   5868:   was_incomplete = (DECL_SIZE (decl) == NULL_TREE);
                   5869: 
                   5870:   /* Take care of TYPE_DECLs up front.  */
                   5871:   if (TREE_CODE (decl) == TYPE_DECL)
                   5872:     {
                   5873:       if (init && DECL_INITIAL (decl))
                   5874:        {
                   5875:          /* typedef foo = bar; store the type of bar as the type of foo.  */
                   5876:          TREE_TYPE (decl) = type = TREE_TYPE (init);
                   5877:          DECL_INITIAL (decl) = init = NULL_TREE;
                   5878:        }
                   5879:       if (IS_AGGR_TYPE (type) && DECL_NAME (decl))
                   5880:        {
                   5881:          if (TREE_TYPE (DECL_NAME (decl)) && TREE_TYPE (decl) != type)
                   5882:            cp_warning ("shadowing previous type declaration of `%#D'", decl);
                   5883:          set_identifier_type_value (DECL_NAME (decl), type);
                   5884:          CLASSTYPE_GOT_SEMICOLON (type) = 1;
                   5885:        }
                   5886:       GNU_xref_decl (current_function_decl, decl);
                   5887:       rest_of_decl_compilation (decl, NULL_PTR,
                   5888:                                DECL_CONTEXT (decl) == NULL_TREE, 0);
                   5889:       goto finish_end;
                   5890:     }
                   5891:   if (type != error_mark_node && IS_AGGR_TYPE (type)
                   5892:       && CLASSTYPE_DECLARED_EXCEPTION (type))
                   5893:     {
                   5894:       finish_exception_decl (NULL_TREE, decl);
                   5895:       CLASSTYPE_GOT_SEMICOLON (type) = 1;
                   5896:       goto finish_end;
                   5897:     }
                   5898:   if (TREE_CODE (decl) != FUNCTION_DECL)
                   5899:     {
                   5900:       ttype = target_type (type);
                   5901: #if 0 /* WTF?  -KR
                   5902:         Leave this out until we can figure out why it was
                   5903:         needed/desirable in the first place.  Then put a comment
                   5904:         here explaining why.  Or just delete the code if no ill
                   5905:         effects arise.  */
                   5906:       if (TYPE_NAME (ttype)
                   5907:          && TREE_CODE (TYPE_NAME (ttype)) == TYPE_DECL
                   5908:          && ANON_AGGRNAME_P (TYPE_IDENTIFIER (ttype)))
                   5909:        {
                   5910:          tree old_id = TYPE_IDENTIFIER (ttype);
                   5911:          char *newname = (char *)alloca (IDENTIFIER_LENGTH (old_id) + 2);
                   5912:          /* Need to preserve template data for UPT nodes.  */
                   5913:          tree old_template = IDENTIFIER_TEMPLATE (old_id);
                   5914:          newname[0] = '_';
                   5915:          bcopy (IDENTIFIER_POINTER (old_id), newname + 1,
                   5916:                 IDENTIFIER_LENGTH (old_id) + 1);
                   5917:          old_id = get_identifier (newname);
                   5918:          lookup_tag_reverse (ttype, old_id);
                   5919:          TYPE_IDENTIFIER (ttype) = old_id;
                   5920:          IDENTIFIER_TEMPLATE (old_id) = old_template;
                   5921:        }
                   5922: #endif
                   5923:     }
                   5924: 
                   5925:   if (! DECL_EXTERNAL (decl) && TREE_READONLY (decl)
                   5926:       && TYPE_NEEDS_CONSTRUCTING (type))
                   5927:     {
                   5928: 
                   5929:       /* Currently, GNU C++ puts constants in text space, making them
                   5930:         impossible to initialize.  In the future, one would hope for
                   5931:         an operating system which understood the difference between
                   5932:         initialization and the running of a program.  */
                   5933:       was_readonly = 1;
                   5934:       TREE_READONLY (decl) = 0;
                   5935:     }
                   5936: 
                   5937:   if (TREE_CODE (decl) == FIELD_DECL)
                   5938:     {
                   5939:       if (init && init != error_mark_node)
                   5940:        my_friendly_assert (TREE_PERMANENT (init), 147);
                   5941: 
                   5942:       if (asmspec)
                   5943:        {
                   5944:          /* This must override the asm specifier which was placed
                   5945:             by grokclassfn.  Lay this out fresh.
                   5946:             
                   5947:             @@ Should emit an error if this redefines an asm-specified
                   5948:             @@ name, or if we have already used the function's name.  */
                   5949:          DECL_RTL (TREE_TYPE (decl)) = NULL_RTX;
                   5950:          DECL_ASSEMBLER_NAME (decl) = get_identifier (asmspec);
                   5951:          make_decl_rtl (decl, asmspec, 0);
                   5952:        }
                   5953:     }
                   5954:   /* If `start_decl' didn't like having an initialization, ignore it now.  */
                   5955:   else if (init != NULL_TREE && DECL_INITIAL (decl) == NULL_TREE)
                   5956:     init = NULL_TREE;
                   5957:   else if (DECL_EXTERNAL (decl))
                   5958:     ;
                   5959:   else if (TREE_CODE (type) == REFERENCE_TYPE)
                   5960:     {
                   5961:       grok_reference_init (decl, type, init, &cleanup);
                   5962:       init = NULL_TREE;
                   5963:     }
                   5964: 
                   5965:   GNU_xref_decl (current_function_decl, decl);
                   5966: 
                   5967:   if (TREE_CODE (decl) == FIELD_DECL || DECL_EXTERNAL (decl))
                   5968:     ;
                   5969:   else if (TREE_CODE (decl) == CONST_DECL)
                   5970:     {
                   5971:       my_friendly_assert (TREE_CODE (decl) != REFERENCE_TYPE, 148);
                   5972: 
                   5973:       DECL_INITIAL (decl) = init;
                   5974: 
                   5975:       /* This will keep us from needing to worry about our obstacks.  */
                   5976:       my_friendly_assert (init != NULL_TREE, 149);
                   5977:       init = NULL_TREE;
                   5978:     }
                   5979:   else if (init)
                   5980:     {
                   5981:       if (TYPE_NEEDS_CONSTRUCTING (type))
                   5982:        {
                   5983:          if (TREE_CODE (type) == ARRAY_TYPE)
                   5984:            init = digest_init (type, init, (tree *) 0);
                   5985:          else if (TREE_CODE (init) == CONSTRUCTOR
                   5986:                   && CONSTRUCTOR_ELTS (init) != NULL_TREE)
                   5987:            {
                   5988:              cp_error ("`%D' must be initialized by constructor, not by `{...}'", decl);
                   5989:              init = error_mark_node;
                   5990:            }
                   5991: #if 0
                   5992:          /* fix this in `build_functional_cast' instead.
                   5993:             Here's the trigger code:
                   5994: 
                   5995:                struct ostream
                   5996:                {
                   5997:                  ostream ();
                   5998:                  ostream (int, char *);
                   5999:                  ostream (char *);
                   6000:                  operator char *();
                   6001:                  ostream (void *);
                   6002:                  operator void *();
                   6003:                  operator << (int);
                   6004:                };
                   6005:                int buf_size = 1024;
                   6006:                static char buf[buf_size];
                   6007:                const char *debug(int i) {
                   6008:                  char *b = &buf[0];
                   6009:                  ostream o = ostream(buf_size, b);
                   6010:                  o << i;
                   6011:                  return buf;
                   6012:                }
                   6013:                */
                   6014: 
                   6015:          else if (TREE_CODE (init) == TARGET_EXPR
                   6016:                   && TREE_CODE (TREE_OPERAND (init, 1) == NEW_EXPR))
                   6017:            {
                   6018:              /* User wrote something like `foo x = foo (args)'  */
                   6019:              my_friendly_assert (TREE_CODE (TREE_OPERAND (init, 0)) == VAR_DECL, 150);
                   6020:              my_friendly_assert (DECL_NAME (TREE_OPERAND (init, 0)) == NULL_TREE, 151);
                   6021: 
                   6022:              /* User wrote exactly `foo x = foo (args)'  */
                   6023:              if (TYPE_MAIN_VARIANT (type) == TREE_TYPE (init))
                   6024:                {
                   6025:                  init = build (CALL_EXPR, TREE_TYPE (init),
                   6026:                                TREE_OPERAND (TREE_OPERAND (init, 1), 0),
                   6027:                                TREE_OPERAND (TREE_OPERAND (init, 1), 1), 0);
                   6028:                  TREE_SIDE_EFFECTS (init) = 1;
                   6029:                }
                   6030:            }
                   6031: #endif
                   6032: 
                   6033:          /* We must hide the initializer so that expand_decl
                   6034:             won't try to do something it does not understand.  */
                   6035:          if (current_binding_level == global_binding_level)
                   6036:            {
                   6037:              tree value = digest_init (type, empty_init_node, (tree *) 0);
                   6038:              DECL_INITIAL (decl) = value;
                   6039:            }
                   6040:          else
                   6041:            DECL_INITIAL (decl) = error_mark_node;
                   6042:        }
                   6043:       else
                   6044:        {
                   6045:          if (TREE_CODE (init) != TREE_VEC)
                   6046:            init = store_init_value (decl, init);
                   6047: 
                   6048:          if (init)
                   6049:            /* Don't let anyone try to initialize this variable
                   6050:               until we are ready to do so.  */
                   6051:            DECL_INITIAL (decl) = error_mark_node;
                   6052:        }
                   6053:     }
                   6054:   else if (TREE_CODE_CLASS (TREE_CODE (type)) == 't'
                   6055:           && (IS_AGGR_TYPE (type) || TYPE_NEEDS_CONSTRUCTING (type))
                   6056:           && init != NULL_TREE)
                   6057:     {
                   6058:       tree ctype = type;
                   6059:       while (TREE_CODE (ctype) == ARRAY_TYPE)
                   6060:        ctype = TREE_TYPE (ctype);
                   6061:       if (! TYPE_NEEDS_CONSTRUCTOR (ctype))
                   6062:        {
                   6063:          if (CLASSTYPE_READONLY_FIELDS_NEED_INIT (ctype))
                   6064:            cp_error ("structure `%D' with uninitialized const members", decl);
                   6065:          if (CLASSTYPE_REF_FIELDS_NEED_INIT (ctype))
                   6066:            cp_error ("structure `%D' with uninitialized reference members", decl);
                   6067:        }
                   6068: 
                   6069:       if (TREE_CODE (decl) == VAR_DECL
                   6070:          && !TYPE_NEEDS_CONSTRUCTING (type)
                   6071:          && (TYPE_READONLY (type) || TREE_READONLY (decl)))
                   6072:        cp_error ("uninitialized const `%D'", decl);
                   6073: 
                   6074:       /* Initialize variables in need of static initialization
                   6075:         with `empty_init_node' to keep assemble_variable from putting them
                   6076:         in the wrong program space.  (Common storage is okay for non-public
                   6077:         uninitialized data; the linker can't match it with storage from other
                   6078:         files, and we may save some disk space.)  */
                   6079:       if (flag_pic == 0
                   6080:          && TREE_STATIC (decl)
                   6081:          && TREE_PUBLIC (decl)
                   6082:          && ! DECL_EXTERNAL (decl)
                   6083:          && TREE_CODE (decl) == VAR_DECL
                   6084:          && TYPE_NEEDS_CONSTRUCTING (type)
                   6085:          && (DECL_INITIAL (decl) == NULL_TREE
                   6086:              || DECL_INITIAL (decl) == error_mark_node))
                   6087:        {
                   6088:          tree value = digest_init (type, empty_init_node, (tree *) 0);
                   6089:          DECL_INITIAL (decl) = value;
                   6090:        }
                   6091:     }
                   6092:   else if (TREE_CODE (decl) == VAR_DECL
                   6093:           && TREE_CODE (type) != REFERENCE_TYPE
                   6094:           && (TYPE_READONLY (type) || TREE_READONLY (decl)))
                   6095:     {
                   6096:       /* ``Unless explicitly declared extern, a const object does not have
                   6097:         external linkage and must be initialized. ($8.4; $12.1)'' ARM 7.1.6
                   6098:         However, if it's `const int foo = 1; const int foo;', don't complain
                   6099:         about the second decl, since it does have an initializer before.
                   6100:         We deliberately don't complain about arrays, because they're
                   6101:         supposed to be initialized by a constructor.  */
                   6102:       if (! DECL_INITIAL (decl)
                   6103:          && TREE_CODE (type) != ARRAY_TYPE
                   6104:          && (!pedantic || !current_class_type))
                   6105:        cp_error ("uninitialized const `%#D'", decl);
                   6106:     }
                   6107: 
                   6108:   /* For top-level declaration, the initial value was read in
                   6109:      the temporary obstack.  MAXINDEX, rtl, etc. to be made below
                   6110:      must go in the permanent obstack; but don't discard the
                   6111:      temporary data yet.  */
                   6112: 
                   6113:   if (current_binding_level == global_binding_level && temporary)
                   6114:     end_temporary_allocation ();
                   6115: 
                   6116:   /* Deduce size of array from initialization, if not already known.  */
                   6117: 
                   6118:   if (TREE_CODE (type) == ARRAY_TYPE
                   6119:       && TYPE_DOMAIN (type) == NULL_TREE
                   6120:       && TREE_CODE (decl) != TYPE_DECL)
                   6121:     {
                   6122:       int do_default
                   6123:        = (TREE_STATIC (decl)
                   6124:           /* Even if pedantic, an external linkage array
                   6125:              may have incomplete type at first.  */
                   6126:           ? pedantic && DECL_EXTERNAL (decl)
                   6127:           : !DECL_EXTERNAL (decl));
                   6128:       tree initializer = init ? init : DECL_INITIAL (decl);
                   6129:       int failure = complete_array_type (type, initializer, do_default);
                   6130: 
                   6131:       if (failure == 1)
                   6132:        cp_error ("initializer fails to determine size of `%D'", decl);
                   6133: 
                   6134:       if (failure == 2)
                   6135:        {
                   6136:          if (do_default)
                   6137:            cp_error ("array size missing in `%D'", decl);
                   6138:          /* If a `static' var's size isn't known, make it extern as
                   6139:             well as static, so it does not get allocated.  If it's not
                   6140:             `static', then don't mark it extern; finish_incomplete_decl
                   6141:             will give it a default size and it will get allocated.  */
                   6142:          else if (!pedantic && TREE_STATIC (decl) && !TREE_PUBLIC (decl))
                   6143:            DECL_EXTERNAL (decl) = 1;
                   6144:        }
                   6145: 
                   6146:       if (pedantic && TYPE_DOMAIN (type) != NULL_TREE
                   6147:          && tree_int_cst_lt (TYPE_MAX_VALUE (TYPE_DOMAIN (type)),
                   6148:                              integer_zero_node))
                   6149:        cp_error ("zero-size array `%D'", decl);
                   6150: 
                   6151:       layout_decl (decl, 0);
                   6152:     }
                   6153: 
                   6154:   if (TREE_CODE (decl) == VAR_DECL)
                   6155:     {
                   6156:       if (DECL_SIZE (decl) == NULL_TREE
                   6157:          && TYPE_SIZE (TREE_TYPE (decl)) != NULL_TREE)
                   6158:        layout_decl (decl, 0);
                   6159: 
                   6160:       if (TREE_STATIC (decl) && DECL_SIZE (decl) == NULL_TREE)
                   6161:        {
                   6162:          /* A static variable with an incomplete type:
                   6163:             that is an error if it is initialized or `static'.
                   6164:             Otherwise, let it through, but if it is not `extern'
                   6165:             then it may cause an error message later.  */
                   6166:          if (!DECL_EXTERNAL (decl) || DECL_INITIAL (decl) != NULL_TREE)
                   6167:            cp_error ("storage size of `%D' isn't known", decl);
                   6168:          init = NULL_TREE;
                   6169:        }
                   6170:       else if (!DECL_EXTERNAL (decl) && DECL_SIZE (decl) == NULL_TREE)
                   6171:        {
                   6172:          /* An automatic variable with an incomplete type: that is an error.
                   6173:             Don't talk about array types here, since we took care of that
                   6174:             message in grokdeclarator.  */
                   6175:          cp_error ("storage size of `%D' isn't known", decl);
                   6176:          TREE_TYPE (decl) = error_mark_node;
                   6177:        }
                   6178:       else if (!DECL_EXTERNAL (decl) && IS_AGGR_TYPE (ttype))
                   6179:        /* Let debugger know it should output info for this type.  */
                   6180:        note_debug_info_needed (ttype);
                   6181: 
                   6182:       if ((DECL_EXTERNAL (decl) || TREE_STATIC (decl))
                   6183:          && DECL_SIZE (decl) != NULL_TREE
                   6184:          && ! TREE_CONSTANT (DECL_SIZE (decl)))
                   6185:        {
                   6186:          if (TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST)
                   6187:            constant_expression_warning (DECL_SIZE (decl));
                   6188:          else
                   6189:            cp_error ("storage size of `%D' isn't constant", decl);
                   6190:        }
                   6191: 
                   6192:       if (!DECL_EXTERNAL (decl) && TYPE_NEEDS_DESTRUCTOR (type))
                   6193:        {
                   6194:          int yes = suspend_momentary ();
                   6195: 
                   6196:          /* If INIT comes from a functional cast, use the cleanup
                   6197:             we built for that.  Otherwise, make our own cleanup.  */
                   6198:          if (init && TREE_CODE (init) == WITH_CLEANUP_EXPR
                   6199:              && comptypes (TREE_TYPE (decl), TREE_TYPE (init), 1))
                   6200:            {
                   6201:              cleanup = TREE_OPERAND (init, 2);
                   6202:              init = TREE_OPERAND (init, 0);
                   6203:              current_binding_level->have_cleanups = 1;
                   6204:              current_binding_level->more_exceptions_ok = 0;
                   6205:            }
                   6206:          else
                   6207:            cleanup = maybe_build_cleanup (decl);
                   6208:          resume_momentary (yes);
                   6209:        }
                   6210:     }
                   6211:   /* PARM_DECLs get cleanups, too.  */
                   6212:   else if (TREE_CODE (decl) == PARM_DECL && TYPE_NEEDS_DESTRUCTOR (type))
                   6213:     {
                   6214:       if (temporary)
                   6215:        end_temporary_allocation ();
                   6216:       cleanup = maybe_build_cleanup (decl);
                   6217:       if (temporary)
                   6218:        resume_temporary_allocation ();
                   6219:     }
                   6220: 
                   6221:   /* Output the assembler code and/or RTL code for variables and functions,
                   6222:      unless the type is an undefined structure or union.
                   6223:      If not, it will get done when the type is completed.  */
                   6224: 
                   6225:   if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL
                   6226:       || TREE_CODE (decl) == RESULT_DECL)
                   6227:     {
                   6228:       /* ??? FIXME: What about nested classes?  */
                   6229:       int toplev = (current_binding_level == global_binding_level
                   6230:                    || pseudo_global_level_p ());
                   6231:       int was_temp
                   6232:        = ((flag_traditional
                   6233:            || (TREE_STATIC (decl) && TYPE_NEEDS_DESTRUCTOR (type)))
                   6234:           && allocation_temporary_p ());
                   6235: 
                   6236:       if (was_temp)
                   6237:        end_temporary_allocation ();
                   6238: 
                   6239:       /* If we are in need of a cleanup, get out of any implicit
                   6240:         handlers that have been established so far.  */
                   6241:       if (cleanup && current_binding_level->parm_flag == 3)
                   6242:        {
                   6243:          pop_implicit_try_blocks (decl);
                   6244:          current_binding_level->more_exceptions_ok = 0;
                   6245:        }
                   6246: 
                   6247:       if (TREE_CODE (decl) == VAR_DECL
                   6248:          && current_binding_level != global_binding_level
                   6249:          && ! TREE_STATIC (decl)
                   6250:          && type_needs_gc_entry (type))
                   6251:        DECL_GC_OFFSET (decl) = size_int (++current_function_obstack_index);
                   6252: 
                   6253:       if (TREE_CODE (decl) == VAR_DECL && DECL_VIRTUAL_P (decl))
                   6254:        make_decl_rtl (decl, NULL_PTR, toplev);
                   6255:       else if (TREE_CODE (decl) == VAR_DECL
                   6256:               && TREE_READONLY (decl)
                   6257:               && DECL_INITIAL (decl) != NULL_TREE
                   6258:               && DECL_INITIAL (decl) != error_mark_node
                   6259:               && DECL_INITIAL (decl) != empty_init_node)
                   6260:        {
                   6261:          DECL_INITIAL (decl) = save_expr (DECL_INITIAL (decl));
                   6262: 
                   6263:          if (asmspec)
                   6264:            DECL_ASSEMBLER_NAME (decl) = get_identifier (asmspec);
                   6265: 
                   6266:          if (! toplev
                   6267:              && TREE_STATIC (decl)
                   6268:              && ! TREE_SIDE_EFFECTS (decl)
                   6269:              && ! TREE_PUBLIC (decl)
                   6270:              && ! DECL_EXTERNAL (decl)
                   6271:              && ! TYPE_NEEDS_DESTRUCTOR (type)
                   6272:              && DECL_MODE (decl) != BLKmode)
                   6273:            {
                   6274:              /* If this variable is really a constant, then fill its DECL_RTL
                   6275:                 slot with something which won't take up storage.
                   6276:                 If something later should take its address, we can always give
                   6277:                 it legitimate RTL at that time.  */
                   6278:              DECL_RTL (decl) = gen_reg_rtx (DECL_MODE (decl));
                   6279:              store_expr (DECL_INITIAL (decl), DECL_RTL (decl), 0);
                   6280:              TREE_ASM_WRITTEN (decl) = 1;
                   6281:            }
                   6282:          else if (toplev)
                   6283:            {
                   6284:              /* Keep GCC from complaining that this variable
                   6285:                 is defined but never used.  */
                   6286:              TREE_USED (decl) = 1;
                   6287:              /* If this is a static const, change its apparent linkage
                   6288:                 if it belongs to a #pragma interface.  */
                   6289:              if (TREE_STATIC (decl) && !interface_unknown)
                   6290:                {
                   6291:                  TREE_PUBLIC (decl) = 1;
                   6292:                  DECL_EXTERNAL (decl) = interface_only;
                   6293:                }
                   6294:              make_decl_rtl (decl, asmspec, toplev);
                   6295:            }
                   6296:          else
                   6297:            rest_of_decl_compilation (decl, asmspec, toplev, 0);
                   6298:        }
                   6299:       else if (TREE_CODE (decl) == VAR_DECL
                   6300:               && DECL_LANG_SPECIFIC (decl)
                   6301:               && DECL_IN_AGGR_P (decl))
                   6302:        {
                   6303:          if (TREE_STATIC (decl))
                   6304:            {
                   6305:              if (init == NULL_TREE
                   6306: #ifdef DEFAULT_STATIC_DEFS
                   6307:                  /* If this code is dead, then users must
                   6308:                     explicitly declare static member variables
                   6309:                     outside the class def'n as well.  */
                   6310:                  && TYPE_NEEDS_CONSTRUCTING (type)
                   6311: #endif
                   6312:                  )
                   6313:                {
                   6314:                  DECL_EXTERNAL (decl) = 1;
                   6315:                  make_decl_rtl (decl, asmspec, 1);
                   6316:                }
                   6317:              else
                   6318:                rest_of_decl_compilation (decl, asmspec, toplev, 0);
                   6319:            }
                   6320:          else
                   6321:            /* Just a constant field.  Should not need any rtl.  */
                   6322:            goto finish_end0;
                   6323:        }
                   6324:       else
                   6325:        rest_of_decl_compilation (decl, asmspec, toplev, 0);
                   6326: 
                   6327:       if (was_temp)
                   6328:        resume_temporary_allocation ();
                   6329: 
                   6330:       if (type != error_mark_node
                   6331:          && TYPE_LANG_SPECIFIC (type)
                   6332:          && CLASSTYPE_ABSTRACT_VIRTUALS (type))
                   6333:        abstract_virtuals_error (decl, type);
                   6334:       else if ((TREE_CODE (type) == FUNCTION_TYPE
                   6335:                || TREE_CODE (type) == METHOD_TYPE)
                   6336:               && TYPE_LANG_SPECIFIC (TREE_TYPE (type))
                   6337:               && CLASSTYPE_ABSTRACT_VIRTUALS (TREE_TYPE (type)))
                   6338:        abstract_virtuals_error (decl, TREE_TYPE (type));
                   6339: 
                   6340:       if (TREE_CODE (decl) == FUNCTION_DECL)
                   6341:        {
                   6342:          /* C++: Handle overloaded functions with default parameters.  */
                   6343:          if (DECL_OVERLOADED (decl))
                   6344:            {
                   6345:              tree parmtypes = TYPE_ARG_TYPES (type);
                   6346:              tree prev = NULL_TREE;
                   6347:              tree original_name = DECL_NAME (decl);
                   6348:              struct lang_decl *tmp_lang_decl = DECL_LANG_SPECIFIC (decl);
                   6349:              /* All variants will share an uncollectible lang_decl.  */
                   6350:              copy_decl_lang_specific (decl);
                   6351: 
                   6352:              while (parmtypes && parmtypes != void_list_node)
                   6353:                {
                   6354:                  /* The default value for the parameter in parmtypes is
                   6355:                     stored in the TREE_PURPOSE of the TREE_LIST.  */ 
                   6356:                  if (TREE_PURPOSE (parmtypes))
                   6357:                    {
                   6358:                      tree fnname, fndecl;
                   6359:                      tree *argp;
                   6360: 
                   6361:                      argp = prev ? & TREE_CHAIN (prev)
                   6362:                        : & TYPE_ARG_TYPES (type);
                   6363: 
                   6364:                      *argp = NULL_TREE;
                   6365:                      fnname = build_decl_overload (original_name, TYPE_ARG_TYPES (type), 0);
                   6366:                      *argp = parmtypes;
                   6367:                      fndecl = build_decl (FUNCTION_DECL, fnname, type);
                   6368:                      DECL_EXTERNAL (fndecl) = DECL_EXTERNAL (decl);
                   6369:                      TREE_PUBLIC (fndecl) = TREE_PUBLIC (decl);
                   6370:                      DECL_INLINE (fndecl) = DECL_INLINE (decl);
                   6371:                      /* Keep G++ from thinking this function is unused.
                   6372:                         It is only used to speed up search in name space.  */
                   6373:                      TREE_USED (fndecl) = 1;
                   6374:                      TREE_ASM_WRITTEN (fndecl) = 1;
                   6375:                      DECL_INITIAL (fndecl) = NULL_TREE;
                   6376:                      DECL_LANG_SPECIFIC (fndecl) = DECL_LANG_SPECIFIC (decl);
                   6377:                      fndecl = pushdecl (fndecl);
                   6378:                      DECL_INITIAL (fndecl) = error_mark_node;
                   6379:                      DECL_RTL (fndecl) = DECL_RTL (decl);
                   6380:                    }
                   6381:                  prev = parmtypes;
                   6382:                  parmtypes = TREE_CHAIN (parmtypes);
                   6383:                }
                   6384:              DECL_LANG_SPECIFIC (decl) = tmp_lang_decl;
                   6385:            }
                   6386:        }
                   6387:       else if (DECL_EXTERNAL (decl))
                   6388:        ;
                   6389:       else if (TREE_STATIC (decl) && type != error_mark_node)
                   6390:        {
                   6391:          /* Cleanups for static variables are handled by `finish_file'.  */
                   6392:          if (TYPE_NEEDS_CONSTRUCTING (type) || init != NULL_TREE)
                   6393:            expand_static_init (decl, init);
                   6394:          else if (TYPE_NEEDS_DESTRUCTOR (type))
                   6395:            static_aggregates = perm_tree_cons (NULL_TREE, decl,
                   6396:                                                static_aggregates);
                   6397: 
                   6398:          /* Make entry in appropriate vector.  */
                   6399:          if (flag_gc && type_needs_gc_entry (type))
                   6400:            build_static_gc_entry (decl, type);
                   6401:        }
                   6402:       else if (! toplev)
                   6403:        {
                   6404:          /* This is a declared decl which must live until the
                   6405:             end of the binding contour.  It may need a cleanup.  */
                   6406: 
                   6407:          /* Recompute the RTL of a local array now
                   6408:             if it used to be an incomplete type.  */
                   6409:          if (was_incomplete && ! TREE_STATIC (decl))
                   6410:            {
                   6411:              /* If we used it already as memory, it must stay in memory.  */
                   6412:              TREE_ADDRESSABLE (decl) = TREE_USED (decl);
                   6413:              /* If it's still incomplete now, no init will save it.  */
                   6414:              if (DECL_SIZE (decl) == NULL_TREE)
                   6415:                DECL_INITIAL (decl) = NULL_TREE;
                   6416:              expand_decl (decl);
                   6417:            }
                   6418:          else if (! TREE_ASM_WRITTEN (decl)
                   6419:                   && (TYPE_SIZE (type) != NULL_TREE
                   6420:                       || TREE_CODE (type) == ARRAY_TYPE))
                   6421:            {
                   6422:              /* Do this here, because we did not expand this decl's
                   6423:                 rtl in start_decl.  */
                   6424:              if (DECL_RTL (decl) == NULL_RTX)
                   6425:                expand_decl (decl);
                   6426:              else if (cleanup)
                   6427:                {
                   6428:                  expand_decl_cleanup (NULL_TREE, cleanup);
                   6429:                  /* Cleanup used up here.  */
                   6430:                  cleanup = NULL_TREE;
                   6431:                }
                   6432:            }
                   6433: 
                   6434:          if (DECL_SIZE (decl) && type != error_mark_node)
                   6435:            {
                   6436:              /* Compute and store the initial value.  */
                   6437:              expand_decl_init (decl);
                   6438: 
                   6439:              if (init || TYPE_NEEDS_CONSTRUCTING (type))
                   6440:                {
                   6441:                  emit_line_note (DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
                   6442:                  expand_aggr_init (decl, init, 0);
                   6443:                }
                   6444: 
                   6445:              /* Set this to 0 so we can tell whether an aggregate
                   6446:                 which was initialized was ever used.  */
                   6447:              if (TYPE_NEEDS_CONSTRUCTING (type))
                   6448:                TREE_USED (decl) = 0;
                   6449: 
                   6450:              /* Store the cleanup, if there was one.  */
                   6451:              if (cleanup)
                   6452:                {
                   6453:                  if (! expand_decl_cleanup (decl, cleanup))
                   6454:                    cp_error ("parser lost in parsing declaration of `%D'", decl);
                   6455:                }
                   6456:            }
                   6457:        }
                   6458:     finish_end0:
                   6459: 
                   6460:       /* Undo call to `pushclass' that was done in `start_decl'
                   6461:         due to initialization of qualified member variable.
                   6462:         I.e., Foo::x = 10;  */
                   6463:       {
                   6464:        tree context = DECL_CONTEXT (decl);
                   6465:        if (context
                   6466:            && TREE_CODE_CLASS (TREE_CODE (context)) == 't'
                   6467:            && (TREE_CODE (decl) == VAR_DECL
                   6468:                /* We also have a pushclass done that we need to undo here
                   6469:                   if we're at top level and declare a method.  */
                   6470:                || (TREE_CODE (decl) == FUNCTION_DECL
                   6471:                    /* If size hasn't been set, we're still defining it,
                   6472:                       and therefore inside the class body; don't pop
                   6473:                       the binding level..  */
                   6474:                    && TYPE_SIZE (context) != NULL_TREE
                   6475:                    /* The binding level gets popped elsewhere for a
                   6476:                       friend declaration inside another class.  */
                   6477:                    && TYPE_IDENTIFIER (context) == current_class_name
                   6478:                    )))
                   6479:          popclass (1);
                   6480:       }
                   6481:     }
                   6482: 
                   6483:  finish_end:
                   6484: 
                   6485:   if (need_pop)
                   6486:     {
                   6487:       /* Resume permanent allocation, if not within a function.  */
                   6488:       /* The corresponding push_obstacks_nochange is in start_decl,
                   6489:         start_method, groktypename, and in grokfield.  */
                   6490:       pop_obstacks ();
                   6491:     }
                   6492: 
                   6493:   if (was_readonly)
                   6494:     TREE_READONLY (decl) = 1;
                   6495: 
                   6496:   if (flag_cadillac)
                   6497:     cadillac_finish_decl (decl);
                   6498: }
                   6499: 
                   6500: static void
                   6501: expand_static_init (decl, init)
                   6502:      tree decl;
                   6503:      tree init;
                   6504: {
                   6505:   tree oldstatic = value_member (decl, static_aggregates);
                   6506:   if (oldstatic)
                   6507:     {
                   6508:       if (TREE_PURPOSE (oldstatic) && init != NULL_TREE)
                   6509:        cp_error ("multiple initializations given for `%D'", decl);
                   6510:     }
                   6511:   else if (current_binding_level != global_binding_level)
                   6512:     {
                   6513:       /* Emit code to perform this initialization but once.  */
                   6514:       tree temp;
                   6515: 
                   6516:       /* Remember this information until end of file. */
                   6517:       push_obstacks (&permanent_obstack, &permanent_obstack);
                   6518: 
                   6519:       /* Emit code to perform this initialization but once.  */
                   6520:       temp = get_temp_name (integer_type_node, 1);
                   6521:       rest_of_decl_compilation (temp, NULL_PTR, 0, 0);
                   6522:       expand_start_cond (build_binary_op (EQ_EXPR, temp,
                   6523:                                          integer_zero_node, 1), 0);
                   6524:       expand_assignment (temp, integer_one_node, 0, 0);
                   6525:       if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (decl)))
                   6526:        {
                   6527:          expand_aggr_init (decl, init, 0);
                   6528:          do_pending_stack_adjust ();
                   6529:        }
                   6530:       else
                   6531:        expand_assignment (decl, init, 0, 0);
                   6532:       expand_end_cond ();
                   6533:       if (TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (decl)))
                   6534:        {
                   6535:          static_aggregates = perm_tree_cons (temp, decl, static_aggregates);
                   6536:          TREE_STATIC (static_aggregates) = 1;
                   6537:        }
                   6538: 
                   6539:       /* Resume old (possibly temporary) allocation. */
                   6540:       pop_obstacks ();
                   6541:     }
                   6542:   else
                   6543:     {
                   6544:       /* This code takes into account memory allocation
                   6545:         policy of `start_decl'.  Namely, if TYPE_NEEDS_CONSTRUCTING
                   6546:         does not hold for this object, then we must make permanent
                   6547:         the storage currently in the temporary obstack.  */
                   6548:       if (! TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (decl)))
                   6549:        preserve_initializer ();
                   6550:       static_aggregates = perm_tree_cons (init, decl, static_aggregates);
                   6551:     }
                   6552: }
                   6553: 
                   6554: /* Make TYPE a complete type based on INITIAL_VALUE.
                   6555:    Return 0 if successful, 1 if INITIAL_VALUE can't be deciphered,
                   6556:    2 if there was no information (in which case assume 1 if DO_DEFAULT).  */
                   6557: 
                   6558: int
                   6559: complete_array_type (type, initial_value, do_default)
                   6560:      tree type, initial_value;
                   6561:      int do_default;
                   6562: {
                   6563:   register tree maxindex = NULL_TREE;
                   6564:   int value = 0;
                   6565: 
                   6566:   if (initial_value)
                   6567:     {
                   6568:       /* Note MAXINDEX  is really the maximum index,
                   6569:         one less than the size.  */
                   6570:       if (TREE_CODE (initial_value) == STRING_CST)
                   6571:        maxindex = build_int_2 (TREE_STRING_LENGTH (initial_value) - 1, 0);
                   6572:       else if (TREE_CODE (initial_value) == CONSTRUCTOR)
                   6573:        {
                   6574:          register int nelts
                   6575:            = list_length (CONSTRUCTOR_ELTS (initial_value));
                   6576:          maxindex = build_int_2 (nelts - 1, - (nelts == 0));
                   6577:        }
                   6578:       else
                   6579:        {
                   6580:          /* Make an error message unless that happened already.  */
                   6581:          if (initial_value != error_mark_node)
                   6582:            value = 1;
                   6583: 
                   6584:          /* Prevent further error messages.  */
                   6585:          maxindex = build_int_2 (0, 0);
                   6586:        }
                   6587:     }
                   6588: 
                   6589:   if (!maxindex)
                   6590:     {
                   6591:       if (do_default)
                   6592:        maxindex = build_int_2 (0, 0);
                   6593:       value = 2;
                   6594:     }
                   6595: 
                   6596:   if (maxindex)
                   6597:     {
                   6598:       TYPE_DOMAIN (type) = build_index_type (maxindex);
                   6599:       if (!TREE_TYPE (maxindex))
                   6600:        TREE_TYPE (maxindex) = TYPE_DOMAIN (type);
                   6601:     }
                   6602: 
                   6603:   /* Lay out the type now that we can get the real answer.  */
                   6604: 
                   6605:   layout_type (type);
                   6606: 
                   6607:   return value;
                   6608: }
                   6609: 
                   6610: /* Return zero if something is declared to be a member of type
                   6611:    CTYPE when in the context of CUR_TYPE.  STRING is the error
                   6612:    message to print in that case.  Otherwise, quietly return 1.  */
                   6613: static int
                   6614: member_function_or_else (ctype, cur_type, string)
                   6615:      tree ctype, cur_type;
                   6616:      char *string;
                   6617: {
                   6618:   if (ctype && ctype != cur_type)
                   6619:     {
                   6620:       error (string, TYPE_NAME_STRING (ctype));
                   6621:       return 0;
                   6622:     }
                   6623:   return 1;
                   6624: }
                   6625: 
                   6626: /* Subroutine of `grokdeclarator'.  */
                   6627: 
                   6628: /* Generate errors possibly applicable for a given set of specifiers.
                   6629:    This is for ARM $7.1.2.  */
                   6630: static void
                   6631: bad_specifiers (object, type, virtualp, quals, inlinep, friendp, raises)
                   6632:      tree object;
                   6633:      char *type;
                   6634:      int virtualp, quals, inlinep, friendp, raises;
                   6635: {
                   6636:   if (virtualp)
                   6637:     cp_error ("`%D' declared as a `virtual' %s", object, type);
                   6638:   if (inlinep)
                   6639:     cp_error ("`%D' declared as an `inline' %s", object, type);
                   6640:   if (quals)
                   6641:     cp_error ("`const' and `volatile' function specifiers on `%D' invalid in %s declaration", object, type);
                   6642:   if (friendp)
                   6643:     cp_error_at ("invalid friend declaration", object);
                   6644:   if (raises)
                   6645:     cp_error_at ("invalid raises declaration", object);
                   6646: }
                   6647: 
                   6648: /* CTYPE is class type, or null if non-class.
                   6649:    TYPE is type this FUNCTION_DECL should have, either FUNCTION_TYPE
                   6650:    or METHOD_TYPE.
                   6651:    DECLARATOR is the function's name.
                   6652:    VIRTUALP is truthvalue of whether the function is virtual or not.
                   6653:    FLAGS are to be passed through to `grokclassfn'.
                   6654:    QUALS are qualifiers indicating whether the function is `const'
                   6655:    or `volatile'.
                   6656:    RAISES is a list of exceptions that this function can raise.
                   6657:    CHECK is 1 if we must find this method in CTYPE, 0 if we should
                   6658:    not look, and -1 if we should not call `grokclassfn' at all.  */
                   6659: static tree
                   6660: grokfndecl (ctype, type, declarator, virtualp, flags, quals, raises, check, publicp)
                   6661:      tree ctype, type;
                   6662:      tree declarator;
                   6663:      int virtualp;
                   6664:      enum overload_flags flags;
                   6665:      tree quals, raises;
                   6666:      int check, publicp;
                   6667: {
                   6668:   tree cname, decl;
                   6669:   int staticp = ctype && TREE_CODE (type) == FUNCTION_TYPE;
                   6670: 
                   6671:   if (ctype)
                   6672:     cname = TREE_CODE (TYPE_NAME (ctype)) == TYPE_DECL
                   6673:       ? TYPE_IDENTIFIER (ctype) : TYPE_NAME (ctype);
                   6674:   else
                   6675:     cname = NULL_TREE;
                   6676: 
                   6677:   if (raises)
                   6678:     {
                   6679:       type = build_exception_variant (ctype, type, raises);
                   6680:       raises = TYPE_RAISES_EXCEPTIONS (type);
                   6681:     }
                   6682:   decl = build_lang_decl (FUNCTION_DECL, declarator, type);
                   6683:   /* propagate volatile out from type to decl */
                   6684:   if (TYPE_VOLATILE (type))
                   6685:       TREE_THIS_VOLATILE (decl) = 1;
                   6686: 
                   6687:   /* Should probably propagate const out from type to decl I bet (mrs).  */
                   6688:   if (staticp)
                   6689:     {
                   6690:       DECL_STATIC_FUNCTION_P (decl) = 1;
                   6691:       DECL_CONTEXT (decl) = ctype;
                   6692:       DECL_CLASS_CONTEXT (decl) = ctype;
                   6693:     }
                   6694: 
                   6695:   if (publicp)
                   6696:     TREE_PUBLIC (decl) = 1;
                   6697: 
                   6698:   DECL_EXTERNAL (decl) = 1;
                   6699:   if (quals != NULL_TREE && TREE_CODE (type) == FUNCTION_TYPE)
                   6700:     {
                   6701:       cp_error ("%smember function `%D' cannot have `%T' method qualifier",
                   6702:                (ctype ? "static " : "non-"), decl, TREE_VALUE (quals));
                   6703:       quals = NULL_TREE;
                   6704:     }
                   6705: 
                   6706:   if (IDENTIFIER_OPNAME_P (DECL_NAME (decl)))
                   6707:     grok_op_properties (decl, virtualp);
                   6708: 
                   6709:   /* Caller will do the rest of this.  */
                   6710:   if (check < 0)
                   6711:     return decl;
                   6712: 
                   6713:   if (flags == NO_SPECIAL && ctype && constructor_name (cname) == declarator)
                   6714:     {
                   6715:       tree tmp;
                   6716:       /* Just handle constructors here.  We could do this
                   6717:         inside the following if stmt, but I think
                   6718:         that the code is more legible by breaking this
                   6719:         case out.  See comments below for what each of
                   6720:         the following calls is supposed to do.  */
                   6721:       DECL_CONSTRUCTOR_P (decl) = 1;
                   6722: 
                   6723:       grokclassfn (ctype, declarator, decl, flags, quals);
                   6724:       if (check)
                   6725:        check_classfn (ctype, declarator, decl);
                   6726:       grok_ctor_properties (ctype, decl);
                   6727:       if (check == 0)
                   6728:        {
                   6729:          /* FIXME: this should only need to look at IDENTIFIER_GLOBAL_VALUE.  */
                   6730:          tmp = lookup_name (DECL_ASSEMBLER_NAME (decl), 0);
                   6731:          if (tmp == NULL_TREE)
                   6732:            IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (decl)) = decl;
                   6733:          else if (TREE_CODE (tmp) != TREE_CODE (decl))
                   6734:            cp_error ("inconsistent declarations for `%D'", decl);
                   6735:          else
                   6736:            {
                   6737:              duplicate_decls (decl, tmp);
                   6738:              decl = tmp;
                   6739:              /* avoid creating circularities.  */
                   6740:              DECL_CHAIN (decl) = NULL_TREE;
                   6741:            }
                   6742:          make_decl_rtl (decl, NULL_PTR, 1);
                   6743:        }
                   6744:     }
                   6745:   else
                   6746:     {
                   6747:       tree tmp;
                   6748: 
                   6749:       /* Function gets the ugly name, field gets the nice one.
                   6750:         This call may change the type of the function (because
                   6751:         of default parameters)!  */
                   6752:       if (ctype != NULL_TREE)
                   6753:        grokclassfn (ctype, cname, decl, flags, quals);
                   6754: 
                   6755:       if (ctype != NULL_TREE && check)
                   6756:        check_classfn (ctype, cname, decl);
                   6757: 
                   6758:       if (ctype == NULL_TREE || check)
                   6759:        return decl;
                   6760: 
                   6761:       /* Now install the declaration of this function so that
                   6762:         others may find it (esp. its DECL_FRIENDLIST).
                   6763:         Pretend we are at top level, we will get true
                   6764:         reference later, perhaps.
                   6765: 
                   6766:         FIXME: This should only need to look at IDENTIFIER_GLOBAL_VALUE.  */
                   6767:       tmp = lookup_name (DECL_ASSEMBLER_NAME (decl), 0);
                   6768:       if (tmp == NULL_TREE)
                   6769:        IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (decl)) = decl;
                   6770:       else if (TREE_CODE (tmp) != TREE_CODE (decl))
                   6771:        cp_error ("inconsistent declarations for `%D'", decl);
                   6772:       else
                   6773:        {
                   6774:          duplicate_decls (decl, tmp);
                   6775:          decl = tmp;
                   6776:          /* avoid creating circularities.  */
                   6777:          DECL_CHAIN (decl) = NULL_TREE;
                   6778:        }
                   6779:       make_decl_rtl (decl, NULL_PTR, 1);
                   6780: 
                   6781:       /* If this declaration supersedes the declaration of
                   6782:         a method declared virtual in the base class, then
                   6783:         mark this field as being virtual as well.  */
                   6784:       {
                   6785:        tree binfos = BINFO_BASETYPES (TYPE_BINFO (ctype));
                   6786:        int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
                   6787: 
                   6788:        for (i = 0; i < n_baselinks; i++)
                   6789:          {
                   6790:            tree base_binfo = TREE_VEC_ELT (binfos, i);
                   6791:            if (TYPE_VIRTUAL_P (BINFO_TYPE (base_binfo)) || flag_all_virtual == 1)
                   6792:              {
                   6793:                tmp = get_first_matching_virtual (base_binfo, decl,
                   6794:                                                  flags == DTOR_FLAG);
                   6795:                if (tmp)
                   6796:                  {
                   6797:                    /* If this function overrides some virtual in some base
                   6798:                       class, then the function itself is also necessarily
                   6799:                       virtual, even if the user didn't explicitly say so.  */
                   6800:                    DECL_VIRTUAL_P (decl) = 1;
                   6801: 
                   6802:                    /* The TMP we really want is the one from the deepest
                   6803:                       baseclass on this path, taking care not to
                   6804:                       duplicate if we have already found it (via another
                   6805:                       path to its virtual baseclass.  */
                   6806:                    if (staticp)
                   6807:                      {
                   6808:                        cp_error ("method `%D' may not be declared static", decl);
                   6809:                        cp_error_at ("(since `%D' declared virtual in base class.)", tmp);
                   6810:                        break;
                   6811:                      }
                   6812:                    virtualp = 1;
                   6813: 
                   6814:                    if ((TYPE_USES_VIRTUAL_BASECLASSES (BINFO_TYPE (base_binfo))
                   6815:                         || TYPE_USES_MULTIPLE_INHERITANCE (ctype))
                   6816:                        && BINFO_TYPE (base_binfo) != DECL_CONTEXT (tmp))
                   6817:                      tmp = get_first_matching_virtual (TYPE_BINFO (DECL_CONTEXT (tmp)),
                   6818:                                                        decl, flags == DTOR_FLAG);
                   6819:                    if (value_member (tmp, DECL_VINDEX (decl)) == NULL_TREE)
                   6820:                      {
                   6821:                        /* The argument types may have changed... */
                   6822:                        tree argtypes = TYPE_ARG_TYPES (TREE_TYPE (decl));
                   6823:                        tree base_variant = TREE_TYPE (TREE_VALUE (argtypes));
                   6824: 
                   6825:                        argtypes = commonparms (TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (tmp))),
                   6826:                                                TREE_CHAIN (argtypes));
                   6827:                        /* But the return type has not.  */
                   6828:                        type = build_cplus_method_type (base_variant, TREE_TYPE (type), argtypes);
                   6829:                        if (raises)
                   6830:                          {
                   6831:                            type = build_exception_variant (ctype, type, raises);
                   6832:                            raises = TYPE_RAISES_EXCEPTIONS (type);
                   6833:                          }
                   6834:                        TREE_TYPE (decl) = type;
                   6835:                        DECL_VINDEX (decl)
                   6836:                          = tree_cons (NULL_TREE, tmp, DECL_VINDEX (decl));
                   6837:                      }
                   6838:                  }
                   6839:              }
                   6840:          }
                   6841:       }
                   6842:       if (virtualp)
                   6843:        {
                   6844:          if (DECL_VINDEX (decl) == NULL_TREE)
                   6845:            DECL_VINDEX (decl) = error_mark_node;
                   6846:          IDENTIFIER_VIRTUAL_P (DECL_NAME (decl)) = 1;
                   6847:          if (ctype && CLASSTYPE_VTABLE_NEEDS_WRITING (ctype)
                   6848:              /* If this function is derived from a template, don't
                   6849:                 make it public.  This shouldn't be here, but there's
                   6850:                 no good way to override the interface pragmas for one
                   6851:                 function or class only.  Bletch.  */
                   6852:              && IDENTIFIER_TEMPLATE (TYPE_IDENTIFIER (ctype)) == NULL_TREE
                   6853:              && (write_virtuals == 2
                   6854:                  || (write_virtuals == 3
                   6855:                      && CLASSTYPE_INTERFACE_KNOWN (ctype))))
                   6856:            TREE_PUBLIC (decl) = 1;
                   6857:        }
                   6858:     }
                   6859:   return decl;
                   6860: }
                   6861: 
                   6862: static tree
                   6863: grokvardecl (type, declarator, specbits, initialized)
                   6864:      tree type;
                   6865:      tree declarator;
                   6866:      RID_BIT_TYPE specbits;
                   6867:      int initialized;
                   6868: {
                   6869:   tree decl;
                   6870: 
                   6871:   if (TREE_CODE (type) == OFFSET_TYPE)
                   6872:     {
                   6873:       /* If you declare a static member so that it
                   6874:         can be initialized, the code will reach here.  */
                   6875:       tree field = lookup_field (TYPE_OFFSET_BASETYPE (type),
                   6876:                                 declarator, 0, 0);
                   6877:       if (field == NULL_TREE || TREE_CODE (field) != VAR_DECL)
                   6878:        {
                   6879:          tree basetype = TYPE_OFFSET_BASETYPE (type);
                   6880:          error ("`%s' is not a static member of class `%s'",
                   6881:                 IDENTIFIER_POINTER (declarator),
                   6882:                 TYPE_NAME_STRING (basetype));
                   6883:          type = TREE_TYPE (type);
                   6884:          decl = build_lang_field_decl (VAR_DECL, declarator, type);
                   6885:          DECL_CONTEXT (decl) = basetype;
                   6886:          DECL_CLASS_CONTEXT (decl) = basetype;
                   6887:        }
                   6888:       else
                   6889:        {
                   6890:          tree f_type = TREE_TYPE (field);
                   6891:          tree o_type = TREE_TYPE (type);
                   6892: 
                   6893:          if (TYPE_SIZE (f_type) == NULL_TREE)
                   6894:            {
                   6895:              if (TREE_CODE (f_type) != TREE_CODE (o_type)
                   6896:                  || (TREE_CODE (f_type) == ARRAY_TYPE
                   6897:                      && TREE_TYPE (f_type) != TREE_TYPE (o_type)))
                   6898:                error ("redeclaration of type for `%s'",
                   6899:                       IDENTIFIER_POINTER (declarator));
                   6900:              else if (TYPE_SIZE (o_type) != NULL_TREE)
                   6901:                TREE_TYPE (field) = type;
                   6902:            }
                   6903:          else if (f_type != o_type)
                   6904:            error ("redeclaration of type for `%s'",
                   6905:                   IDENTIFIER_POINTER (declarator));
                   6906:          decl = field;
                   6907:          if (initialized && DECL_INITIAL (decl)
                   6908:              /* Complain about multiply-initialized
                   6909:                 member variables, but don't be faked
                   6910:                 out if initializer is faked up from `empty_init_node'.  */
                   6911:              && (TREE_CODE (DECL_INITIAL (decl)) != CONSTRUCTOR
                   6912:                  || CONSTRUCTOR_ELTS (DECL_INITIAL (decl)) != NULL_TREE))
                   6913:            error_with_aggr_type (DECL_CONTEXT (decl),
                   6914:                                  "multiple initializations of static member `%s::%s'",
                   6915:                                  IDENTIFIER_POINTER (DECL_NAME (decl)));
                   6916:        }
                   6917:     }
                   6918:   else
                   6919:     decl = build_decl (VAR_DECL, declarator, type);
                   6920: 
                   6921:   if (RIDBIT_SETP (RID_EXTERN, specbits))
                   6922:     {
                   6923:       DECL_THIS_EXTERN (decl) = 1;
                   6924:       DECL_EXTERNAL (decl) = !initialized;
                   6925:     }
                   6926: 
                   6927:   /* In class context, static means one per class,
                   6928:      public visibility, and static storage.  */
                   6929:   if (DECL_FIELD_CONTEXT (decl) != NULL_TREE
                   6930:       && IS_AGGR_TYPE (DECL_FIELD_CONTEXT (decl)))
                   6931:     {
                   6932:       TREE_PUBLIC (decl) = 1;
                   6933:       TREE_STATIC (decl) = 1;
                   6934:       DECL_EXTERNAL (decl) = !initialized;
                   6935:     }
                   6936:   /* At top level, either `static' or no s.c. makes a definition
                   6937:      (perhaps tentative), and absence of `static' makes it public.  */
                   6938:   else if (current_binding_level == global_binding_level)
                   6939:     {
                   6940:       TREE_PUBLIC (decl) = RIDBIT_NOTSETP (RID_STATIC, specbits);
                   6941:       TREE_STATIC (decl) = ! DECL_EXTERNAL (decl);
                   6942:     }
                   6943:   /* Not at top level, only `static' makes a static definition.  */
                   6944:   else
                   6945:     {
                   6946:       TREE_STATIC (decl) = !! RIDBIT_SETP (RID_STATIC, specbits);
                   6947:       TREE_PUBLIC (decl) = DECL_EXTERNAL (decl);
                   6948:     }
                   6949:   return decl;
                   6950: }
                   6951: 
                   6952: /* Create a canonical pointer to member function type. */
                   6953: 
                   6954: static tree
                   6955: build_ptrmemfunc_type (type)
                   6956:      tree type;
                   6957: {
                   6958:   tree fields[4];
                   6959:   tree t;
                   6960:   tree u;
                   6961: 
                   6962:   /* If a canonical type already exists for this type, use it.  We use
                   6963:      this method instead of type_hash_canon, because it only does a
                   6964:      simple equality check on the list of field members.  */
                   6965: 
                   6966:   if ((t = TYPE_GET_PTRMEMFUNC_TYPE (type)))
                   6967:     return t;
                   6968: 
                   6969:   u = make_lang_type (UNION_TYPE);
                   6970:   fields[0] = build_lang_field_decl (FIELD_DECL, pfn_identifier, type);
                   6971:   fields[1] = build_lang_field_decl (FIELD_DECL, delta2_identifier, short_integer_type_node);
                   6972:   finish_builtin_type (u, "__ptrmemfunc_type", fields, 1, ptr_type_node);
                   6973:   TYPE_NAME (u) = NULL_TREE;
                   6974: 
                   6975:   t = make_lang_type (RECORD_TYPE);
                   6976: 
                   6977:   /* Let the front-end know this is a pointer to member function. */
                   6978:   TYPE_PTRMEMFUNC_FLAG(t) = 1;
                   6979: 
                   6980:   fields[0] = build_lang_field_decl (FIELD_DECL, delta_identifier, short_integer_type_node);
                   6981:   fields[1] = build_lang_field_decl (FIELD_DECL, index_identifier, short_integer_type_node);
                   6982:   fields[2] = build_lang_field_decl (FIELD_DECL, pfn_or_delta2_identifier, u);
                   6983:   finish_builtin_type (t, "__ptrmemfunc_type", fields, 2, ptr_type_node);
                   6984: 
                   6985:   /* Zap out the name so that the back-end will give us the debugging
                   6986:      information for this anonymous RECORD_TYPE.  */
                   6987:   TYPE_NAME (t) = NULL_TREE;
                   6988: 
                   6989:   TYPE_SET_PTRMEMFUNC_TYPE (type, t);
                   6990: 
                   6991:   /* Seems to be wanted. */
                   6992:   CLASSTYPE_GOT_SEMICOLON (t) = 1;
                   6993:   return t;
                   6994: }
                   6995: 
                   6996: /* Given declspecs and a declarator,
                   6997:    determine the name and type of the object declared
                   6998:    and construct a ..._DECL node for it.
                   6999:    (In one case we can return a ..._TYPE node instead.
                   7000:     For invalid input we sometimes return 0.)
                   7001: 
                   7002:    DECLSPECS is a chain of tree_list nodes whose value fields
                   7003:     are the storage classes and type specifiers.
                   7004: 
                   7005:    DECL_CONTEXT says which syntactic context this declaration is in:
                   7006:      NORMAL for most contexts.  Make a VAR_DECL or FUNCTION_DECL or TYPE_DECL.
                   7007:      FUNCDEF for a function definition.  Like NORMAL but a few different
                   7008:       error messages in each case.  Return value may be zero meaning
                   7009:       this definition is too screwy to try to parse.
                   7010:      MEMFUNCDEF for a function definition.  Like FUNCDEF but prepares to
                   7011:       handle member functions (which have FIELD context).
                   7012:       Return value may be zero meaning this definition is too screwy to
                   7013:       try to parse.
                   7014:      PARM for a parameter declaration (either within a function prototype
                   7015:       or before a function body).  Make a PARM_DECL, or return void_type_node.
                   7016:      TYPENAME if for a typename (in a cast or sizeof).
                   7017:       Don't make a DECL node; just return the ..._TYPE node.
                   7018:      FIELD for a struct or union field; make a FIELD_DECL.
                   7019:      BITFIELD for a field with specified width.
                   7020:    INITIALIZED is 1 if the decl has an initializer.
                   7021: 
                   7022:    In the TYPENAME case, DECLARATOR is really an absolute declarator.
                   7023:    It may also be so in the PARM case, for a prototype where the
                   7024:    argument type is specified but not the name.
                   7025: 
                   7026:    This function is where the complicated C meanings of `static'
                   7027:    and `extern' are interpreted.
                   7028: 
                   7029:    For C++, if there is any monkey business to do, the function which
                   7030:    calls this one must do it, i.e., prepending instance variables,
                   7031:    renaming overloaded function names, etc.
                   7032: 
                   7033:    Note that for this C++, it is an error to define a method within a class
                   7034:    which does not belong to that class.
                   7035: 
                   7036:    Except in the case where SCOPE_REFs are implicitly known (such as
                   7037:    methods within a class being redundantly qualified),
                   7038:    declarations which involve SCOPE_REFs are returned as SCOPE_REFs
                   7039:    (class_name::decl_name).  The caller must also deal with this.
                   7040: 
                   7041:    If a constructor or destructor is seen, and the context is FIELD,
                   7042:    then the type gains the attribute TREE_HAS_x.  If such a declaration
                   7043:    is erroneous, NULL_TREE is returned.
                   7044: 
                   7045:    QUALS is used only for FUNCDEF and MEMFUNCDEF cases.  For a member
                   7046:    function, these are the qualifiers to give to the `this' pointer.
                   7047: 
                   7048:    May return void_type_node if the declarator turned out to be a friend.
                   7049:    See grokfield for details.  */
                   7050: 
                   7051: enum return_types { return_normal, return_ctor, return_dtor, return_conversion };
                   7052: 
                   7053: tree
                   7054: grokdeclarator (declarator, declspecs, decl_context, initialized, raises)
                   7055:      tree declspecs;
                   7056:      tree declarator;
                   7057:      enum decl_context decl_context;
                   7058:      int initialized;
                   7059:      tree raises;
                   7060: {
                   7061:   RID_BIT_TYPE specbits;
                   7062:   int nclasses = 0;
                   7063:   tree spec;
                   7064:   tree type = NULL_TREE;
                   7065:   int longlong = 0;
                   7066:   int constp;
                   7067:   int volatilep;
                   7068:   int virtualp, friendp, inlinep, staticp;
                   7069:   int explicit_int = 0;
                   7070:   int explicit_char = 0;
                   7071:   tree typedef_decl = NULL_TREE;
                   7072:   char *name;
                   7073:   tree typedef_type = NULL_TREE;
                   7074:   int funcdef_flag = 0;
                   7075:   enum tree_code innermost_code = ERROR_MARK;
                   7076:   int bitfield = 0;
                   7077:   int size_varies = 0;
                   7078:   /* Set this to error_mark_node for FIELD_DECLs we could not handle properly.
                   7079:      All FIELD_DECLs we build here have `init' put into their DECL_INITIAL.  */
                   7080:   tree init = NULL_TREE;
                   7081: 
                   7082:   /* Keep track of what sort of function is being processed
                   7083:      so that we can warn about default return values, or explicit
                   7084:      return values which do not match prescribed defaults.  */
                   7085:   enum return_types return_type = return_normal;
                   7086: 
                   7087:   tree dname = NULL_TREE;
                   7088:   tree ctype = current_class_type;
                   7089:   tree ctor_return_type = NULL_TREE;
                   7090:   enum overload_flags flags = NO_SPECIAL;
                   7091:   int seen_scope_ref = 0;
                   7092:   tree quals = NULL_TREE;
                   7093: 
                   7094:   RIDBIT_RESET_ALL (specbits);
                   7095:   if (decl_context == FUNCDEF)
                   7096:     funcdef_flag = 1, decl_context = NORMAL;
                   7097:   else if (decl_context == MEMFUNCDEF)
                   7098:     funcdef_flag = -1, decl_context = FIELD;
                   7099:   else if (decl_context == BITFIELD)
                   7100:     bitfield = 1, decl_context = FIELD;
                   7101: 
                   7102:   if (flag_traditional && allocation_temporary_p ())
                   7103:     end_temporary_allocation ();
                   7104: 
                   7105:   /* Look inside a declarator for the name being declared
                   7106:      and get it as a string, for an error message.  */
                   7107:   {
                   7108:     tree type, last = NULL_TREE;
                   7109:     register tree decl = declarator;
                   7110:     name = NULL;
                   7111: 
                   7112:     /* If we see something of the form `aggr_type xyzzy (a, b, c)'
                   7113:        it is either an old-style function declaration or a call to
                   7114:        a constructor.  The following conditional makes recognizes this
                   7115:        case as being a call to a constructor.  Too bad if it is not.  */
                   7116: 
                   7117:     /* For Doug Lea, also grok `aggr_type xyzzy (a, b, c)[10][10][10]'.  */
                   7118:     while (decl && TREE_CODE (decl) == ARRAY_REF)
                   7119:       {
                   7120:        last = decl;
                   7121:        decl = TREE_OPERAND (decl, 0);
                   7122:       }
                   7123: 
                   7124:     if (decl && declspecs
                   7125:         && TREE_CODE (decl) == CALL_EXPR
                   7126:         && TREE_OPERAND (decl, 0)
                   7127:         && (TREE_CODE (TREE_OPERAND (decl, 0)) == IDENTIFIER_NODE
                   7128:            || TREE_CODE (TREE_OPERAND (decl, 0)) == SCOPE_REF))
                   7129:       {
                   7130:         type = TREE_CODE (TREE_VALUE (declspecs)) == IDENTIFIER_NODE
                   7131:           ? lookup_name (TREE_VALUE (declspecs), 1) :
                   7132:         (IS_AGGR_TYPE (TREE_VALUE (declspecs))
                   7133:          ? TYPE_NAME (TREE_VALUE (declspecs)) : NULL_TREE);
                   7134: 
                   7135:        /* We used to restrict this to just aggregate types for
                   7136:           function-call notation for initialization.  But since it
                   7137:           can be done for more than aggregates (e.g., `int a(b);'),
                   7138:           it's no longer restrained.  */
                   7139:         if (type
                   7140:            && TREE_CODE (type) == TYPE_DECL
                   7141:             && parmlist_is_exprlist (TREE_OPERAND (decl, 1)))
                   7142:           {
                   7143:             if (decl_context == FIELD
                   7144:                 && TREE_CHAIN (TREE_OPERAND (decl, 1)))
                   7145:               {
                   7146:                 /* That was an initializer list.  */
                   7147:                 sorry ("initializer lists for field declarations");
                   7148:                 decl = TREE_OPERAND (decl, 0);
                   7149:                if (last)
                   7150:                  {
                   7151:                    TREE_OPERAND (last, 0) = decl;
                   7152:                    decl = declarator;
                   7153:                  }
                   7154:                 declarator = decl;
                   7155:                 init = error_mark_node;
                   7156:                 goto bot;
                   7157:               }
                   7158:             else
                   7159:               {
                   7160:                init = TREE_OPERAND (decl, 1);
                   7161:                if (last)
                   7162:                  {
                   7163:                    TREE_OPERAND (last, 0) = TREE_OPERAND (decl, 0);
                   7164:                    if (pedantic && init)
                   7165:                      {
                   7166:                      error ("arrays cannot take initializers");
                   7167:                      init = error_mark_node;
                   7168:                    }
                   7169:                  }
                   7170:                else
                   7171:                  declarator = TREE_OPERAND (declarator, 0);
                   7172: 
                   7173:                /* When dealing with scalar initializations we have to get
                   7174:                   rid of the surrounding TREE_LIST around the initializer.  */
                   7175:                if (! IS_AGGR_TYPE (TREE_TYPE (type)))
                   7176:                  init = TREE_VALUE (init);
                   7177: 
                   7178:                decl = start_decl (declarator, declspecs, 1, NULL_TREE);
                   7179:                finish_decl (decl, init, NULL_TREE, 1);
                   7180:                return 0;
                   7181:               }
                   7182:           }
                   7183: 
                   7184:         if (parmlist_is_random (TREE_OPERAND (decl, 1)))
                   7185:           {
                   7186:            decl = TREE_OPERAND (decl, 0);
                   7187:            if (TREE_CODE (decl) == SCOPE_REF)
                   7188:              {
                   7189:                if (TREE_COMPLEXITY (decl))
                   7190:                  my_friendly_abort (15);
                   7191:                decl = TREE_OPERAND (decl, 1);
                   7192:              }
                   7193:            if (TREE_CODE (decl) == IDENTIFIER_NODE)
                   7194:              name = IDENTIFIER_POINTER (decl);
                   7195:            if (name)
                   7196:              error ("bad parameter list specification for function `%s'",
                   7197:                     name);
                   7198:            else
                   7199:              error ("bad parameter list specification for function");
                   7200:             return void_type_node;
                   7201:           }
                   7202:       bot:
                   7203:         ;
                   7204:       }
                   7205:     else
                   7206:       /* It didn't look like we thought it would, leave the ARRAY_REFs on.  */
                   7207:       decl = declarator;
                   7208: 
                   7209:     while (decl)
                   7210:       switch (TREE_CODE (decl))
                   7211:         {
                   7212:        case COND_EXPR:
                   7213:          ctype = NULL_TREE;
                   7214:          decl = TREE_OPERAND (decl, 0);
                   7215:          break;
                   7216: 
                   7217:        case BIT_NOT_EXPR:      /* for C++ destructors!  */
                   7218:          {
                   7219:            tree name = TREE_OPERAND (decl, 0);
                   7220:            tree rename = NULL_TREE;
                   7221: 
                   7222:            my_friendly_assert (flags == NO_SPECIAL, 152);
                   7223:            flags = DTOR_FLAG;
                   7224:            return_type = return_dtor;
                   7225:            my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE, 153);
                   7226:            if (ctype == NULL_TREE)
                   7227:              {
                   7228:                if (current_class_type == NULL_TREE)
                   7229:                  {
                   7230:                    error ("destructors must be member functions");
                   7231:                    flags = NO_SPECIAL;
                   7232:                  }
                   7233:                else
                   7234:                  {
                   7235:                    tree t = constructor_name (current_class_name);
                   7236:                    if (t != name)
                   7237:                      rename = t;
                   7238:                  }
                   7239:              }
                   7240:            else
                   7241:              {
                   7242:                tree t = constructor_name (ctype);
                   7243:                if (t != name)
                   7244:                  rename = t;
                   7245:              }
                   7246: 
                   7247:            if (rename)
                   7248:              {
                   7249:                error ("destructor `%s' must match class name `%s'",
                   7250:                       IDENTIFIER_POINTER (name),
                   7251:                       IDENTIFIER_POINTER (rename));
                   7252:                TREE_OPERAND (decl, 0) = rename;
                   7253:              }
                   7254:            decl = name;
                   7255:          }
                   7256:          break;
                   7257: 
                   7258:        case ADDR_EXPR:         /* C++ reference declaration */
                   7259:          /* fall through */
                   7260:        case ARRAY_REF:
                   7261:        case INDIRECT_REF:
                   7262:          ctype = NULL_TREE;
                   7263:          innermost_code = TREE_CODE (decl);
                   7264:          decl = TREE_OPERAND (decl, 0);
                   7265:          break;
                   7266: 
                   7267:        case CALL_EXPR:
                   7268:          innermost_code = TREE_CODE (decl);
                   7269:          decl = TREE_OPERAND (decl, 0);
                   7270:          if (decl_context == FIELD && ctype == NULL_TREE)
                   7271:            ctype = current_class_type;
                   7272:          if (ctype != NULL_TREE
                   7273:              && decl != NULL_TREE && flags != DTOR_FLAG
                   7274:              && decl == constructor_name (ctype))
                   7275:            {
                   7276:              return_type = return_ctor;
                   7277:              ctor_return_type = ctype;
                   7278:            }
                   7279:          ctype = NULL_TREE;
                   7280:          break;
                   7281: 
                   7282:        case IDENTIFIER_NODE:
                   7283:          dname = decl;
                   7284:          name = IDENTIFIER_POINTER (decl);
                   7285:          decl = NULL_TREE;
                   7286:          break;
                   7287: 
                   7288:        case RECORD_TYPE:
                   7289:        case UNION_TYPE:
                   7290:        case ENUMERAL_TYPE:
                   7291:          /* Parse error puts this typespec where
                   7292:             a declarator should go.  */
                   7293:          error ("declarator name missing");
                   7294:          dname = TYPE_NAME (decl);
                   7295:          if (dname && TREE_CODE (dname) == TYPE_DECL)
                   7296:            dname = DECL_NAME (dname);
                   7297:          name = dname ? IDENTIFIER_POINTER (dname) : "<nameless>";
                   7298:          declspecs = temp_tree_cons (NULL_TREE, decl, declspecs);
                   7299:          decl = NULL_TREE;
                   7300:          break;
                   7301: 
                   7302:        case TYPE_EXPR:
                   7303:          my_friendly_assert (flags == NO_SPECIAL, 154);
                   7304:          flags = TYPENAME_FLAG;
                   7305:          name = "operator <typename>"; /* We don't know the type yet.  */
                   7306:          /* Go to the absdcl.  */
                   7307:          decl = TREE_OPERAND (decl, 0);
                   7308:          return_type = return_conversion;
                   7309:          break;
                   7310: 
                   7311:          /* C++ extension */
                   7312:        case SCOPE_REF:
                   7313:          if (seen_scope_ref == 1)
                   7314:            error ("multiple `::' terms in declarator invalid");
                   7315:          seen_scope_ref += 1;
                   7316:          {
                   7317:            /* Perform error checking, and convert class names to types.
                   7318:               We may call grokdeclarator multiple times for the same
                   7319:               tree structure, so only do the conversion once.  In this
                   7320:               case, we have exactly what we want for `ctype'.  */
                   7321:            tree cname = TREE_OPERAND (decl, 0);
                   7322:            if (cname == NULL_TREE)
                   7323:              ctype = NULL_TREE;
                   7324:            /* Can't use IS_AGGR_TYPE because CNAME might not be a type.  */
                   7325:            else if (IS_AGGR_TYPE_CODE (TREE_CODE (cname))
                   7326:                     || TREE_CODE (cname) == UNINSTANTIATED_P_TYPE)
                   7327:              ctype = cname;
                   7328:            else if (! is_aggr_typedef (cname, 1))
                   7329:              {
                   7330:                TREE_OPERAND (decl, 0) = NULL_TREE;
                   7331:              }
                   7332:            /* Must test TREE_OPERAND (decl, 1), in case user gives
                   7333:               us `typedef (class::memfunc)(int); memfunc *memfuncptr;'  */
                   7334:            else if (TREE_OPERAND (decl, 1)
                   7335:                     && TREE_CODE (TREE_OPERAND (decl, 1)) == INDIRECT_REF)
                   7336:              {
                   7337:                TREE_OPERAND (decl, 0) = IDENTIFIER_TYPE_VALUE (cname);
                   7338:              }
                   7339:            else if (ctype == NULL_TREE)
                   7340:              {
                   7341:                ctype = IDENTIFIER_TYPE_VALUE (cname);
                   7342:                TREE_OPERAND (decl, 0) = ctype;
                   7343:              }
                   7344:            else if (TREE_COMPLEXITY (decl) == current_class_depth)
                   7345:              TREE_OPERAND (decl, 0) = ctype;
                   7346:            else
                   7347:              {
                   7348:                if (! UNIQUELY_DERIVED_FROM_P (IDENTIFIER_TYPE_VALUE (cname), ctype))
                   7349:                  {
                   7350:                    error ("type `%s' is not derived from type `%s'",
                   7351:                           IDENTIFIER_POINTER (cname),
                   7352:                           TYPE_NAME_STRING (ctype));
                   7353:                    TREE_OPERAND (decl, 0) = NULL_TREE;
                   7354:                  }
                   7355:                else
                   7356:                  {
                   7357:                    ctype = IDENTIFIER_TYPE_VALUE (cname);
                   7358:                    TREE_OPERAND (decl, 0) = ctype;
                   7359:                  }
                   7360:              }
                   7361: 
                   7362:            decl = TREE_OPERAND (decl, 1);
                   7363:            if (ctype)
                   7364:              {
                   7365:                if (TREE_CODE (decl) == IDENTIFIER_NODE
                   7366:                    && constructor_name (ctype) == decl)
                   7367:                  {
                   7368:                    return_type = return_ctor;
                   7369:                    ctor_return_type = ctype;
                   7370:                  }
                   7371:                else if (TREE_CODE (decl) == BIT_NOT_EXPR
                   7372:                         && TREE_CODE (TREE_OPERAND (decl, 0)) == IDENTIFIER_NODE
                   7373:                         && constructor_name (ctype) == TREE_OPERAND (decl, 0))
                   7374:                  {
                   7375:                    return_type = return_dtor;
                   7376:                    ctor_return_type = ctype;
                   7377:                    flags = DTOR_FLAG;
                   7378:                    decl = TREE_OPERAND (decl, 0);
                   7379:                  }
                   7380:              }
                   7381:          }
                   7382:          break;
                   7383: 
                   7384:        case ERROR_MARK:
                   7385:          decl = NULL_TREE;
                   7386:          break;
                   7387: 
                   7388:        default:
                   7389:          return 0; /* We used to do a 155 abort here.  */
                   7390:        }
                   7391:     if (name == NULL)
                   7392:       name = "type name";
                   7393:   }
                   7394: 
                   7395:   /* A function definition's declarator must have the form of
                   7396:      a function declarator.  */
                   7397: 
                   7398:   if (funcdef_flag && innermost_code != CALL_EXPR)
                   7399:     return 0;
                   7400: 
                   7401:   /* Anything declared one level down from the top level
                   7402:      must be one of the parameters of a function
                   7403:      (because the body is at least two levels down).  */
                   7404: 
                   7405:   /* This heuristic cannot be applied to C++ nodes! Fixed, however,
                   7406:      by not allowing C++ class definitions to specify their parameters
                   7407:      with xdecls (must be spec.d in the parmlist).
                   7408: 
                   7409:      Since we now wait to push a class scope until we are sure that
                   7410:      we are in a legitimate method context, we must set oldcname
                   7411:      explicitly (since current_class_name is not yet alive).  */
                   7412: 
                   7413:   if (decl_context == NORMAL
                   7414:       && current_binding_level->level_chain == global_binding_level)
                   7415:     decl_context = PARM;
                   7416: 
                   7417:   /* Look through the decl specs and record which ones appear.
                   7418:      Some typespecs are defined as built-in typenames.
                   7419:      Others, the ones that are modifiers of other types,
                   7420:      are represented by bits in SPECBITS: set the bits for
                   7421:      the modifiers that appear.  Storage class keywords are also in SPECBITS.
                   7422: 
                   7423:      If there is a typedef name or a type, store the type in TYPE.
                   7424:      This includes builtin typedefs such as `int'.
                   7425: 
                   7426:      Set EXPLICIT_INT if the type is `int' or `char' and did not
                   7427:      come from a user typedef.
                   7428: 
                   7429:      Set LONGLONG if `long' is mentioned twice.
                   7430: 
                   7431:      For C++, constructors and destructors have their own fast treatment.  */
                   7432: 
                   7433:   for (spec = declspecs; spec; spec = TREE_CHAIN (spec))
                   7434:     {
                   7435:       register int i;
                   7436:       register tree id = TREE_VALUE (spec);
                   7437: 
                   7438:       /* Certain parse errors slip through.  For example,
                   7439:         `int class;' is not caught by the parser. Try
                   7440:         weakly to recover here.  */
                   7441:       if (TREE_CODE (spec) != TREE_LIST)
                   7442:        return 0;
                   7443: 
                   7444:       if (TREE_CODE (id) == IDENTIFIER_NODE)
                   7445:        {
                   7446:          if (id == ridpointers[(int) RID_INT])
                   7447:            {
                   7448:              if (type)
                   7449:                error ("extraneous `int' ignored");
                   7450:              else
                   7451:                {
                   7452:                  explicit_int = 1;
                   7453:                  type = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (id));
                   7454:                }
                   7455:              goto found;
                   7456:            }
                   7457:          if (id == ridpointers[(int) RID_CHAR])
                   7458:            {
                   7459:              if (type)
                   7460:                error ("extraneous `char' ignored");
                   7461:              else
                   7462:                {
                   7463:                  explicit_char = 1;
                   7464:                  type = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (id));
                   7465:                }
                   7466:              goto found;
                   7467:            }
                   7468:          if (id == ridpointers[(int) RID_WCHAR])
                   7469:            {
                   7470:              if (type)
                   7471:                error ("extraneous `__wchar_t' ignored");
                   7472:              else
                   7473:                {
                   7474:                  type = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (id));
                   7475:                }
                   7476:              goto found;
                   7477:            }
                   7478:          /* C++ aggregate types.  */
                   7479:          if (IDENTIFIER_HAS_TYPE_VALUE (id))
                   7480:            {
                   7481:              if (type)
                   7482:                error ("multiple declarations `%s' and `%s'",
                   7483:                       IDENTIFIER_POINTER (type),
                   7484:                       IDENTIFIER_POINTER (id));
                   7485:              else
                   7486:                type = IDENTIFIER_TYPE_VALUE (id);
                   7487:              goto found;
                   7488:            }
                   7489: 
                   7490:          for (i = (int) RID_FIRST_MODIFIER; i < (int) RID_MAX; i++)
                   7491:            {
                   7492:              if (ridpointers[i] == id)
                   7493:                {
                   7494:                  if (i == (int) RID_LONG && RIDBIT_SETP (i, specbits))
                   7495:                    {
                   7496: #if 0
                   7497:                      if (pedantic)
                   7498:                        pedwarn ("duplicate `%s'", IDENTIFIER_POINTER (id));
                   7499:                      else
                   7500: #endif
                   7501:                        if (longlong)
                   7502:                        error ("`long long long' is too long for GCC");
                   7503:                      else
                   7504:                        longlong = 1;
                   7505:                    }
                   7506:                  else if (RIDBIT_SETP (i, specbits))
                   7507:                    warning ("duplicate `%s'", IDENTIFIER_POINTER (id));
                   7508:                  RIDBIT_SET (i, specbits);
                   7509:                  goto found;
                   7510:                }
                   7511:            }
                   7512:        }
                   7513:       if (type)
                   7514:        error ("two or more data types in declaration of `%s'", name);
                   7515:       else if (TREE_CODE (id) == IDENTIFIER_NODE)
                   7516:        {
                   7517:          register tree t = lookup_name (id, 1);
                   7518:          if (!t || TREE_CODE (t) != TYPE_DECL)
                   7519:            error ("`%s' fails to be a typedef or built in type",
                   7520:                   IDENTIFIER_POINTER (id));
                   7521:          else
                   7522:            {
                   7523:              type = TREE_TYPE (t);
                   7524:              typedef_decl = t;
                   7525:            }
                   7526:        }
                   7527:       else if (TREE_CODE (id) != ERROR_MARK)
                   7528:        /* Can't change CLASS nodes into RECORD nodes here!  */
                   7529:        type = id;
                   7530: 
                   7531:     found: {}
                   7532:     }
                   7533: 
                   7534:   typedef_type = type;
                   7535: 
                   7536:   /* No type at all: default to `int', and set EXPLICIT_INT
                   7537:      because it was not a user-defined typedef.  */
                   7538: 
                   7539:   if (type == NULL_TREE)
                   7540:     {
                   7541:       explicit_int = -1;
                   7542:       if (return_type == return_dtor)
                   7543:        type = void_type_node;
                   7544:       else if (return_type == return_ctor)
                   7545:        type = TYPE_POINTER_TO (ctor_return_type);
                   7546:       else
                   7547:        {
                   7548:          if (funcdef_flag && explicit_warn_return_type
                   7549:              && return_type == return_normal
                   7550:              && ! (RIDBIT_SETP (RID_SIGNED, specbits)
                   7551:                    || RIDBIT_SETP (RID_UNSIGNED, specbits)
                   7552:                    || RIDBIT_SETP (RID_LONG, specbits)
                   7553:                    || RIDBIT_SETP (RID_SHORT, specbits)))
                   7554:            warn_about_return_type = 1;
                   7555:          /* Save warning until we know what is really going on.  */
                   7556:          type = integer_type_node;
                   7557:        }
                   7558:     }
                   7559:   else if (return_type == return_dtor)
                   7560:     {
                   7561:       error ("return type specification for destructor invalid");
                   7562:       type = void_type_node;
                   7563:     }
                   7564:   else if (return_type == return_ctor)
                   7565:     {
                   7566:       error ("return type specification for constructor invalid");
                   7567:       type = TYPE_POINTER_TO (ctor_return_type);
                   7568:     }
                   7569:   else if (RIDBIT_SETP (RID_FRIEND, specbits)
                   7570:           && IS_AGGR_TYPE (type)
                   7571:           && ! TYPE_BEING_DEFINED (type)
                   7572:           && TYPE_SIZE (type) == NULL_TREE
                   7573:           && ! ANON_AGGRNAME_P (TYPE_IDENTIFIER (type))
                   7574:           && current_function_decl == NULL_TREE
                   7575:           && decl_context != PARM)
                   7576:     {
                   7577:       /* xref_tag will make friend class declarations look like
                   7578:         nested class declarations.  Retroactively change that
                   7579:         if the type has not yet been defined.
                   7580: 
                   7581:         ??? ANSI C++ doesn't say what to do in this case yet.  */
                   7582:       globalize_nested_type (type);
                   7583:     }
                   7584: 
                   7585:   ctype = NULL_TREE;
                   7586: 
                   7587:   /* Now process the modifiers that were specified
                   7588:      and check for invalid combinations.  */
                   7589: 
                   7590:   /* Long double is a special combination.  */
                   7591: 
                   7592:   if (RIDBIT_SETP (RID_LONG, specbits)
                   7593:       && TYPE_MAIN_VARIANT (type) == double_type_node)
                   7594:     {
                   7595:       RIDBIT_RESET (RID_LONG, specbits);
                   7596:       type = build_type_variant (long_double_type_node, TYPE_READONLY (type),
                   7597:                                 TYPE_VOLATILE (type));
                   7598:     }
                   7599: 
                   7600:   /* Check all other uses of type modifiers.  */
                   7601: 
                   7602:   if (RIDBIT_SETP (RID_UNSIGNED, specbits)
                   7603:       || RIDBIT_SETP (RID_SIGNED, specbits)
                   7604:       || RIDBIT_SETP (RID_LONG, specbits)
                   7605:       || RIDBIT_SETP (RID_SHORT, specbits))
                   7606:     {
                   7607:       int ok = 0;
                   7608: 
                   7609:       if (TREE_CODE (type) == REAL_TYPE)
                   7610:        error ("short, signed or unsigned invalid for `%s'", name);
                   7611:       else if (TREE_CODE (type) != INTEGER_TYPE || type == wchar_type_node)
                   7612:        error ("long, short, signed or unsigned invalid for `%s'", name);
                   7613:       else if (RIDBIT_SETP (RID_LONG, specbits)
                   7614:               && RIDBIT_SETP (RID_SHORT, specbits))
                   7615:        error ("long and short specified together for `%s'", name);
                   7616:       else if ((RIDBIT_SETP (RID_LONG, specbits)
                   7617:                || RIDBIT_SETP (RID_SHORT, specbits))
                   7618:               && explicit_char)
                   7619:        error ("long or short specified with char for `%s'", name);
                   7620:       else if ((RIDBIT_SETP (RID_LONG, specbits)
                   7621:                || RIDBIT_SETP (RID_SHORT, specbits))
                   7622:               && TREE_CODE (type) == REAL_TYPE)
                   7623:        error ("long or short specified with floating type for `%s'", name);
                   7624:       else if (RIDBIT_SETP (RID_SIGNED, specbits)
                   7625:               && RIDBIT_SETP (RID_UNSIGNED, specbits))
                   7626:        error ("signed and unsigned given together for `%s'", name);
                   7627:       else
                   7628:        {
                   7629:          ok = 1;
                   7630:          if (!explicit_int && !explicit_char && pedantic)
                   7631:            {
                   7632:              pedwarn ("long, short, signed or unsigned used invalidly for `%s'",
                   7633:                       name);
                   7634:              if (flag_pedantic_errors)
                   7635:                ok = 0;
                   7636:            }
                   7637:        }
                   7638: 
                   7639:       /* Discard the type modifiers if they are invalid.  */
                   7640:       if (! ok)
                   7641:        {
                   7642:          RIDBIT_RESET (RID_UNSIGNED, specbits);
                   7643:          RIDBIT_RESET (RID_SIGNED, specbits);
                   7644:          RIDBIT_RESET (RID_LONG, specbits);
                   7645:          RIDBIT_RESET (RID_SHORT, specbits);
                   7646:          longlong = 0;
                   7647:        }
                   7648:     }
                   7649: 
                   7650:   /* Decide whether an integer type is signed or not.
                   7651:      Optionally treat bitfields as signed by default.  */
                   7652:   if (RIDBIT_SETP (RID_UNSIGNED, specbits)
                   7653:       /* Traditionally, all bitfields are unsigned.  */
                   7654:       || (bitfield && flag_traditional)
                   7655:       || (bitfield && ! flag_signed_bitfields
                   7656:          && (explicit_int || explicit_char
                   7657:              /* A typedef for plain `int' without `signed'
                   7658:                 can be controlled just like plain `int'.  */
                   7659:              || ! (typedef_decl != NULL_TREE
                   7660:                    && C_TYPEDEF_EXPLICITLY_SIGNED (typedef_decl)))
                   7661:          && TREE_CODE (type) != ENUMERAL_TYPE
                   7662:          && RIDBIT_NOTSETP (RID_SIGNED, specbits)))
                   7663:     {
                   7664:       if (longlong)
                   7665:        type = long_long_unsigned_type_node;
                   7666:       else if (RIDBIT_SETP (RID_LONG, specbits))
                   7667:        type = long_unsigned_type_node;
                   7668:       else if (RIDBIT_SETP (RID_SHORT, specbits))
                   7669:        type = short_unsigned_type_node;
                   7670:       else if (type == char_type_node)
                   7671:        type = unsigned_char_type_node;
                   7672:       else if (typedef_decl)
                   7673:        type = unsigned_type (type);
                   7674:       else
                   7675:        type = unsigned_type_node;
                   7676:     }
                   7677:   else if (RIDBIT_SETP (RID_SIGNED, specbits)
                   7678:           && type == char_type_node)
                   7679:     type = signed_char_type_node;
                   7680:   else if (longlong)
                   7681:     type = long_long_integer_type_node;
                   7682:   else if (RIDBIT_SETP (RID_LONG, specbits))
                   7683:     type = long_integer_type_node;
                   7684:   else if (RIDBIT_SETP (RID_SHORT, specbits))
                   7685:     type = short_integer_type_node;
                   7686: 
                   7687:   /* Set CONSTP if this declaration is `const', whether by
                   7688:      explicit specification or via a typedef.
                   7689:      Likewise for VOLATILEP.  */
                   7690: 
                   7691:   constp = !! RIDBIT_SETP (RID_CONST, specbits) + TYPE_READONLY (type);
                   7692:   volatilep = !! RIDBIT_SETP (RID_VOLATILE, specbits) + TYPE_VOLATILE (type);
                   7693:   staticp = 0;
                   7694:   inlinep = !! RIDBIT_SETP (RID_INLINE, specbits);
                   7695:   if (constp > 1)
                   7696:     warning ("duplicate `const'");
                   7697:   if (volatilep > 1)
                   7698:     warning ("duplicate `volatile'");
                   7699:   virtualp = RIDBIT_SETP (RID_VIRTUAL, specbits);
                   7700:   if (RIDBIT_SETP (RID_STATIC, specbits))
                   7701:     staticp = 1 + (decl_context == FIELD);
                   7702: 
                   7703:   if (virtualp && staticp == 2)
                   7704:     {
                   7705:       error ("member `%s' cannot be declared both virtual and static", name);
                   7706:       staticp = 0;
                   7707:     }
                   7708:   friendp = RIDBIT_SETP (RID_FRIEND, specbits);
                   7709:   RIDBIT_RESET (RID_VIRTUAL, specbits);
                   7710:   RIDBIT_RESET (RID_FRIEND, specbits);
                   7711: 
                   7712:   if (RIDBIT_SETP (RID_MUTABLE, specbits))
                   7713:     {
                   7714:       if (decl_context == PARM)
                   7715:        {
                   7716:          error ("non-member `%s' cannot be declared mutable", name);
                   7717:          RIDBIT_RESET (RID_MUTABLE, specbits);
                   7718:        }
                   7719:       else if (friendp || decl_context == TYPENAME)
                   7720:        {
                   7721:          error ("non-object member `%s' cannot be declared mutable", name);
                   7722:          RIDBIT_RESET (RID_MUTABLE, specbits);
                   7723:        }
                   7724:       else if (staticp)
                   7725:        {
                   7726:          error ("static `%s' cannot be declared mutable", name);
                   7727:          RIDBIT_RESET (RID_MUTABLE, specbits);
                   7728:        }
                   7729: #if 0
                   7730:       if (RIDBIT_SETP (RID_TYPEDEF, specbits))
                   7731:        {
                   7732:          error ("non-object member `%s' cannot be declared mutable", name);
                   7733:          RIDBIT_RESET (RID_MUTABLE, specbits);
                   7734:        }
                   7735:       /* Because local typedefs are parsed twice, we don't want this
                   7736:         message here. */
                   7737:       else if (decl_context != FIELD)
                   7738:        {
                   7739:          error ("non-member `%s' cannot be declared mutable", name);
                   7740:          RIDBIT_RESET (RID_MUTABLE, specbits);
                   7741:        }
                   7742: #endif
                   7743:     }
                   7744: 
                   7745:   /* Warn if two storage classes are given. Default to `auto'.  */
                   7746: 
                   7747:   if (RIDBIT_ANY_SET (specbits))
                   7748:     {
                   7749:       if (RIDBIT_SETP (RID_STATIC, specbits)) nclasses++;
                   7750:       if (RIDBIT_SETP (RID_EXTERN, specbits)) nclasses++;
                   7751:       if (decl_context == PARM && nclasses > 0)
                   7752:        error ("storage class specifiers invalid in parameter declarations");
                   7753:       if (RIDBIT_SETP (RID_TYPEDEF, specbits))
                   7754:        {
                   7755:          if (decl_context == PARM)
                   7756:            error ("typedef declaration invalid in parameter declaration");
                   7757:          nclasses++;
                   7758:        }
                   7759:       if (RIDBIT_SETP (RID_AUTO, specbits)) nclasses++;
                   7760:       if (RIDBIT_SETP (RID_REGISTER, specbits)) nclasses++;
                   7761:     }
                   7762: 
                   7763:   /* Give error if `virtual' is used outside of class declaration.  */
                   7764:   if (virtualp && current_class_name == NULL_TREE)
                   7765:     {
                   7766:       error ("virtual outside class declaration");
                   7767:       virtualp = 0;
                   7768:     }
                   7769:   if (current_class_name == NULL_TREE && RIDBIT_SETP (RID_MUTABLE, specbits))
                   7770:     {
                   7771:       error ("only members can be declared mutable");
                   7772:       RIDBIT_RESET (RID_MUTABLE, specbits);
                   7773:     }
                   7774: 
                   7775:   /* Static anonymous unions are dealt with here.  */
                   7776:   if (staticp && decl_context == TYPENAME
                   7777:       && TREE_CODE (declspecs) == TREE_LIST
                   7778:       && TREE_CODE (TREE_VALUE (declspecs)) == UNION_TYPE
                   7779:       && ANON_AGGRNAME_P (TYPE_IDENTIFIER (TREE_VALUE (declspecs))))
                   7780:     decl_context = FIELD;
                   7781: 
                   7782:   /* Warn about storage classes that are invalid for certain
                   7783:      kinds of declarations (parameters, typenames, etc.).  */
                   7784: 
                   7785:   if (nclasses > 1)
                   7786:     error ("multiple storage classes in declaration of `%s'", name);
                   7787:   else if (decl_context != NORMAL && nclasses > 0)
                   7788:     {
                   7789:       if (decl_context == PARM
                   7790:          && (RIDBIT_SETP (RID_REGISTER, specbits)
                   7791:              || RIDBIT_SETP (RID_AUTO, specbits)))
                   7792:        ;
                   7793:       else if (decl_context == FIELD
                   7794:               && RIDBIT_SETP (RID_TYPEDEF, specbits))
                   7795:        {
                   7796:          /* Processing a typedef declaration nested within a class type
                   7797:             definition.  */
                   7798:          register tree scanner;
                   7799:          register tree previous_declspec;
                   7800:          tree loc_typedecl;
                   7801:   
                   7802:          if (initialized)
                   7803:            error ("typedef declaration includes an initializer");
                   7804:   
                   7805:          /* To process a class-local typedef declaration, we descend down
                   7806:             the chain of declspecs looking for the `typedef' spec.  When we
                   7807:             find it, we splice it out of the chain of declspecs, and then
                   7808:             recursively call `grokdeclarator' with the original declarator
                   7809:             and with the newly adjusted declspecs.  This call should return
                   7810:             a FIELD_DECL node with the TREE_TYPE (and other parts) set
                   7811:             appropriately.  We can then just change the TREE_CODE on that
                   7812:             from FIELD_DECL to TYPE_DECL and we're done.  */
                   7813: 
                   7814:          for (previous_declspec = NULL_TREE, scanner = declspecs;
                   7815:               scanner;
                   7816:               previous_declspec = scanner, scanner = TREE_CHAIN (scanner))
                   7817:            {
                   7818:              if (TREE_VALUE (scanner) == ridpointers[(int) RID_TYPEDEF])
                   7819:                break;
                   7820:            }
                   7821:          if (previous_declspec)
                   7822:            TREE_CHAIN (previous_declspec) = TREE_CHAIN (scanner);
                   7823:          else
                   7824:            declspecs = TREE_CHAIN (scanner);
                   7825:   
                   7826:          loc_typedecl =
                   7827:            grokdeclarator (declarator, declspecs, FIELD, 0, NULL_TREE);
                   7828:   
                   7829:          if (loc_typedecl != error_mark_node)
                   7830:            {
                   7831:              register int i = sizeof (struct lang_decl_flags) / sizeof (int);
                   7832:              register int *pi;
                   7833:   
                   7834:              TREE_SET_CODE (loc_typedecl, TYPE_DECL);
                   7835:   
                   7836:              pi = (int *) permalloc (sizeof (struct lang_decl_flags));
                   7837:              while (i > 0)
                   7838:                pi[--i] = 0;
                   7839:              DECL_LANG_SPECIFIC (loc_typedecl) = (struct lang_decl *) pi;
                   7840:            }
                   7841:   
                   7842:          return loc_typedecl;
                   7843:        }
                   7844:       else if (decl_context == FIELD
                   7845:               /* C++ allows static class elements  */
                   7846:               && RIDBIT_SETP (RID_STATIC, specbits))
                   7847:        /* C++ also allows inlines and signed and unsigned elements,
                   7848:           but in those cases we don't come in here.  */
                   7849:        ;
                   7850:       else
                   7851:        {
                   7852:          if (decl_context == FIELD)
                   7853:            {
                   7854:              tree tmp = TREE_OPERAND (declarator, 0);
                   7855:              register int op = IDENTIFIER_OPNAME_P (tmp);
                   7856:              error ("storage class specified for %s `%s'",
                   7857:                     op ? "member operator" : "structure field",
                   7858:                     op ? operator_name_string (tmp) : name);
                   7859:            }
                   7860:          else
                   7861:            error ((decl_context == PARM
                   7862:                    ? "storage class specified for parameter `%s'"
                   7863:                    : "storage class specified for typename"), name);
                   7864:          RIDBIT_RESET (RID_REGISTER, specbits);
                   7865:          RIDBIT_RESET (RID_AUTO, specbits);
                   7866:          RIDBIT_RESET (RID_EXTERN, specbits);
                   7867:        }
                   7868:     }
                   7869:   else if (RIDBIT_SETP (RID_EXTERN, specbits) && initialized && !funcdef_flag)
                   7870:     {
                   7871:       if (current_binding_level == global_binding_level)
                   7872:        {
                   7873:          /* It's common practice (and completely legal) to have a const
                   7874:             be initialized and declared extern.  */
                   7875:          if (! constp)
                   7876:            warning ("`%s' initialized and declared `extern'", name);
                   7877:        }
                   7878:       else
                   7879:        error ("`%s' has both `extern' and initializer", name);
                   7880:     }
                   7881:   else if (RIDBIT_SETP (RID_EXTERN, specbits) && funcdef_flag
                   7882:           && current_binding_level != global_binding_level)
                   7883:     error ("nested function `%s' declared `extern'", name);
                   7884:   else if (current_binding_level == global_binding_level)
                   7885:     {
                   7886:       if (RIDBIT_SETP (RID_AUTO, specbits))
                   7887:        error ("top-level declaration of `%s' specifies `auto'", name);
                   7888: #if 0
                   7889:       if (RIDBIT_SETP (RID_REGISTER, specbits))
                   7890:        error ("top-level declaration of `%s' specifies `register'", name);
                   7891: #endif
                   7892: #if 0
                   7893:       /* I'm not sure under what circumstances we should turn
                   7894:         on the extern bit, and under what circumstances we should
                   7895:         warn if other bits are turned on.  */
                   7896:       if (decl_context == NORMAL
                   7897:          && RIDBIT_NOSETP (RID_EXTERN, specbits)
                   7898:          && ! root_lang_context_p ())
                   7899:        {
                   7900:          RIDBIT_SET (RID_EXTERN, specbits);
                   7901:        }
                   7902: #endif
                   7903:     }
                   7904: 
                   7905:   /* Now figure out the structure of the declarator proper.
                   7906:      Descend through it, creating more complex types, until we reach
                   7907:      the declared identifier (or NULL_TREE, in an absolute declarator).  */
                   7908: 
                   7909:   while (declarator && TREE_CODE (declarator) != IDENTIFIER_NODE)
                   7910:     {
                   7911:       /* Each level of DECLARATOR is either an ARRAY_REF (for ...[..]),
                   7912:         an INDIRECT_REF (for *...),
                   7913:         a CALL_EXPR (for ...(...)),
                   7914:         an identifier (for the name being declared)
                   7915:         or a null pointer (for the place in an absolute declarator
                   7916:         where the name was omitted).
                   7917:         For the last two cases, we have just exited the loop.
                   7918: 
                   7919:         For C++ it could also be
                   7920:         a SCOPE_REF (for class :: ...).  In this case, we have converted
                   7921:         sensible names to types, and those are the values we use to
                   7922:         qualify the member name.
                   7923:         an ADDR_EXPR (for &...),
                   7924:         a BIT_NOT_EXPR (for destructors)
                   7925:         a TYPE_EXPR (for operator typenames)
                   7926: 
                   7927:         At this point, TYPE is the type of elements of an array,
                   7928:         or for a function to return, or for a pointer to point to.
                   7929:         After this sequence of ifs, TYPE is the type of the
                   7930:         array or function or pointer, and DECLARATOR has had its
                   7931:         outermost layer removed.  */
                   7932: 
                   7933:       if (TREE_CODE (type) == ERROR_MARK)
                   7934:        {
                   7935:          if (TREE_CODE (declarator) == SCOPE_REF)
                   7936:            declarator = TREE_OPERAND (declarator, 1);
                   7937:          else
                   7938:            declarator = TREE_OPERAND (declarator, 0);
                   7939:          continue;
                   7940:        }
                   7941:       if (quals != NULL_TREE
                   7942:          && (declarator == NULL_TREE
                   7943:              || TREE_CODE (declarator) != SCOPE_REF))
                   7944:        {
                   7945:          if (ctype == NULL_TREE && TREE_CODE (type) == METHOD_TYPE)
                   7946:            ctype = TYPE_METHOD_BASETYPE (type);
                   7947:          if (ctype != NULL_TREE)
                   7948:            {
                   7949: #if 0 /* not yet, should get fixed properly later */
                   7950:              tree dummy = make_type_decl (NULL_TREE, type);
                   7951: #else
                   7952:              tree dummy = build_decl (TYPE_DECL, NULL_TREE, type);
                   7953: #endif
                   7954:              ctype = grok_method_quals (ctype, dummy, quals);
                   7955:              type = TREE_TYPE (dummy);
                   7956:              quals = NULL_TREE;
                   7957:            }
                   7958:        }
                   7959:       switch (TREE_CODE (declarator))
                   7960:        {
                   7961:        case ARRAY_REF:
                   7962:          maybe_globalize_type (type);
                   7963:          {
                   7964:            register tree itype = NULL_TREE;
                   7965:            register tree size = TREE_OPERAND (declarator, 1);
                   7966: 
                   7967:            declarator = TREE_OPERAND (declarator, 0);
                   7968: 
                   7969:            /* Check for some types that there cannot be arrays of.  */
                   7970: 
                   7971:            if (TYPE_MAIN_VARIANT (type) == void_type_node)
                   7972:              {
                   7973:                cp_error ("declaration of `%D' as array of voids", dname);
                   7974:                type = error_mark_node;
                   7975:              }
                   7976: 
                   7977:            if (TREE_CODE (type) == FUNCTION_TYPE)
                   7978:              {
                   7979:                cp_error ("declaration of `%D' as array of functions", dname);
                   7980:                type = error_mark_node;
                   7981:              }
                   7982: 
                   7983:            /* ARM $8.4.3: Since you can't have a pointer to a reference,
                   7984:               you can't have arrays of references.  If we allowed them,
                   7985:               then we'd be saying x[i] is legal for an array x, but
                   7986:               then you'd have to ask: what does `*(x + i)' mean?  */
                   7987:            if (TREE_CODE (type) == REFERENCE_TYPE)
                   7988:              {
                   7989:                cp_error ("declaration of `%D' as array of references", dname);
                   7990:                type = error_mark_node;
                   7991:              }
                   7992: 
                   7993:            if (TREE_CODE (type) == OFFSET_TYPE)
                   7994:              {
                   7995:                cp_error ("declaration of `%D' as array of data members",
                   7996:                          dname);
                   7997:                type = error_mark_node;
                   7998:              }
                   7999: 
                   8000:            if (TREE_CODE (type) == METHOD_TYPE)
                   8001:              {
                   8002:                cp_error ("declaration of `%D' as array of function members",
                   8003:                       dname);
                   8004:                type = error_mark_node;
                   8005:              }
                   8006: 
                   8007:            if (size == error_mark_node)
                   8008:              type = error_mark_node;
                   8009: 
                   8010:            if (type == error_mark_node)
                   8011:              continue;
                   8012: 
                   8013:            if (size)
                   8014:              {
                   8015:                /* Must suspend_momentary here because the index
                   8016:                   type may need to live until the end of the function.
                   8017:                   For example, it is used in the declaration of a
                   8018:                   variable which requires destructing at the end of
                   8019:                   the function; then build_vec_delete will need this
                   8020:                   value.  */
                   8021:                int yes = suspend_momentary ();
                   8022:                /* might be a cast */
                   8023:                if (TREE_CODE (size) == NOP_EXPR
                   8024:                    && TREE_TYPE (size) == TREE_TYPE (TREE_OPERAND (size, 0)))
                   8025:                  size = TREE_OPERAND (size, 0);
                   8026: 
                   8027:                /* If this is a template parameter, it'll be constant, but
                   8028:                   we don't know what the value is yet.  */
                   8029:                if (TREE_CODE (size) == TEMPLATE_CONST_PARM)
                   8030:                  goto dont_grok_size;
                   8031: 
                   8032:                if (TREE_CODE (TREE_TYPE (size)) != INTEGER_TYPE
                   8033:                    && TREE_CODE (TREE_TYPE (size)) != ENUMERAL_TYPE)
                   8034:                  {
                   8035:                    cp_error ("size of array `%D' has non-integer type",
                   8036:                              dname);
                   8037:                    size = integer_one_node;
                   8038:                  }
                   8039:                if (TREE_READONLY_DECL_P (size))
                   8040:                  size = decl_constant_value (size);
                   8041:                if (pedantic && integer_zerop (size))
                   8042:                  cp_pedwarn ("ANSI C++ forbids zero-size array `%D'", dname);
                   8043:                if (TREE_CONSTANT (size))
                   8044:                  {
                   8045:                    constant_expression_warning (size);
                   8046:                    if (INT_CST_LT (size, integer_zero_node))
                   8047:                      {
                   8048:                        cp_error ("size of array `%D' is negative", dname);
                   8049:                        size = integer_one_node;
                   8050:                      }
                   8051:                    itype = build_index_type (size_binop (MINUS_EXPR, size,
                   8052:                                                          integer_one_node));
                   8053:                  }
                   8054:                else
                   8055:                  {
                   8056:                    if (pedantic)
                   8057:                      cp_pedwarn ("ANSI C++ forbids variable-size array `%D'", dname);
                   8058:                  dont_grok_size:
                   8059:                    itype =
                   8060:                      build_binary_op (MINUS_EXPR, size, integer_one_node, 1);
                   8061:                    /* Make sure the array size remains visibly nonconstant
                   8062:                       even if it is (eg) a const variable with known value.  */
                   8063:                    size_varies = 1;
                   8064:                    itype = variable_size (itype);
                   8065:                    itype = build_index_type (itype);
                   8066:                  }
                   8067:                resume_momentary (yes);
                   8068:              }
                   8069: 
                   8070:          /* Build the array type itself, then merge any constancy or
                   8071:             volatility into the target type.  We must do it in this order
                   8072:             to ensure that the TYPE_MAIN_VARIANT field of the array type
                   8073:             is set correctly.  */
                   8074: 
                   8075:            type = build_cplus_array_type (type, itype);
                   8076:            if (constp || volatilep)
                   8077:              type = build_type_variant (type, constp, volatilep);
                   8078: 
                   8079:            ctype = NULL_TREE;
                   8080:          }
                   8081:          break;
                   8082: 
                   8083:        case CALL_EXPR:
                   8084:          maybe_globalize_type (type);
                   8085:          {
                   8086:            tree arg_types;
                   8087: 
                   8088:            /* Declaring a function type.
                   8089:               Make sure we have a valid type for the function to return.  */
                   8090: #if 0
                   8091:            /* Is this an error?  Should they be merged into TYPE here?  */
                   8092:            if (pedantic && (constp || volatilep))
                   8093:              pedwarn ("function declared to return const or volatile result");
                   8094: #else
                   8095:            /* Merge any constancy or volatility into the target type
                   8096:               for the pointer.  */
                   8097: 
                   8098:            if (constp || volatilep)
                   8099:              {
                   8100:                type = build_type_variant (type, constp, volatilep);
                   8101:                if (IS_AGGR_TYPE (type))
                   8102:                  build_pointer_type (type);
                   8103:                constp = 0;
                   8104:                volatilep = 0;
                   8105:              }
                   8106: #endif
                   8107: 
                   8108:            /* Warn about some types functions can't return.  */
                   8109: 
                   8110:            if (TREE_CODE (type) == FUNCTION_TYPE)
                   8111:              {
                   8112:                error ("`%s' declared as function returning a function", name);
                   8113:                type = integer_type_node;
                   8114:              }
                   8115:            if (TREE_CODE (type) == ARRAY_TYPE)
                   8116:              {
                   8117:                error ("`%s' declared as function returning an array", name);
                   8118:                type = integer_type_node;
                   8119:              }
                   8120: 
                   8121:            if (ctype == NULL_TREE
                   8122:                && decl_context == FIELD
                   8123:                && (friendp == 0 || dname == current_class_name))
                   8124:              ctype = current_class_type;
                   8125: 
                   8126:            if (ctype && flags == TYPENAME_FLAG)
                   8127:              TYPE_HAS_CONVERSION (ctype) = 1;
                   8128:            if (ctype && constructor_name (ctype) == dname)
                   8129:              {
                   8130:                /* We are within a class's scope. If our declarator name
                   8131:                   is the same as the class name, and we are defining
                   8132:                   a function, then it is a constructor/destructor, and
                   8133:                   therefore returns a void type.  */
                   8134: 
                   8135:                if (flags == DTOR_FLAG)
                   8136:                  {
                   8137:                    /* ANSI C++ June 5 1992 WP 12.4.1.  A destructor may
                   8138:                       not be declared const or volatile.  A destructor
                   8139:                       may not be static.  */
                   8140:                    if (staticp == 2)
                   8141:                      error ("destructor cannot be static member function");
                   8142:                    if (TYPE_READONLY (type))
                   8143:                      {
                   8144:                        error ("destructors cannot be declared `const'");
                   8145:                        return void_type_node;
                   8146:                      }
                   8147:                    if (TYPE_VOLATILE (type))
                   8148:                      {
                   8149:                        error ("destructors cannot be declared `volatile'");
                   8150:                        return void_type_node;
                   8151:                      }
                   8152:                    if (decl_context == FIELD)
                   8153:                      {
                   8154:                        if (! member_function_or_else (ctype, current_class_type,
                   8155:                                                       "destructor for alien class `%s' cannot be a member"))
                   8156:                          return void_type_node;
                   8157:                      }
                   8158:                  }
                   8159:                else            /* it's a constructor. */
                   8160:                  {
                   8161:                    /* ANSI C++ June 5 1992 WP 12.1.2.  A constructor may
                   8162:                       not be declared const or volatile.  A constructor may
                   8163:                       not be virtual.  A constructor may not be static.  */
                   8164:                    if (staticp == 2)
                   8165:                      error ("constructor cannot be static member function");
                   8166:                    if (virtualp)
                   8167:                      {
                   8168:                        pedwarn ("constructors cannot be declared virtual");
                   8169:                        virtualp = 0;
                   8170:                      }
                   8171:                    if (TYPE_READONLY (type))
                   8172:                      {
                   8173:                        error ("constructors cannot be declared `const'");
                   8174:                        return void_type_node;
                   8175:                      }
                   8176:                    if (TYPE_VOLATILE (type))
                   8177:                      {
                   8178:                        error ("constructors cannot be declared `volatile'");
                   8179:                        return void_type_node;
                   8180:                      }
                   8181:                    {
                   8182:                      int inlinep, staticp;
                   8183:                      inlinep = RIDBIT_SETP (RID_INLINE, specbits);
                   8184:                      staticp = RIDBIT_SETP (RID_STATIC, specbits);
                   8185:                      RIDBIT_RESET (RID_INLINE, specbits);
                   8186:                      RIDBIT_RESET (RID_STATIC, specbits);
                   8187:                      if (RIDBIT_ANY_SET (specbits))
                   8188:                        error ("return value type specifier for constructor ignored");
                   8189:                      if (inlinep)
                   8190:                        RIDBIT_SET (RID_INLINE, specbits);
                   8191:                      if (staticp)
                   8192:                        RIDBIT_SET (RID_STATIC, specbits);
                   8193:                    }
                   8194:                    type = TYPE_POINTER_TO (ctype);
                   8195:                    if (decl_context == FIELD)
                   8196:                      {
                   8197:                        if (! member_function_or_else (ctype, current_class_type,
                   8198:                                                       "constructor for alien class `%s' cannot be member"))
                   8199:                          return void_type_node;
                   8200:                        TYPE_HAS_CONSTRUCTOR (ctype) = 1;
                   8201:                        if (return_type != return_ctor)
                   8202:                          return NULL_TREE;
                   8203:                      }
                   8204:                  }
                   8205:                if (decl_context == FIELD)
                   8206:                  staticp = 0;
                   8207:              }
                   8208:            else if (friendp && virtualp)
                   8209:              {
                   8210:                /* Cannot be both friend and virtual.  */
                   8211:                error ("virtual functions cannot be friends");
                   8212:                RIDBIT_RESET (RID_FRIEND, specbits);
                   8213:              }
                   8214: 
                   8215:            if (decl_context == NORMAL && friendp)
                   8216:              error ("friend declaration not in class definition");
                   8217: 
                   8218:            /* Pick up type qualifiers which should be applied to `this'.  */
                   8219:            quals = TREE_OPERAND (declarator, 2);
                   8220: 
                   8221:            /* Traditionally, declaring return type float means double.  */
                   8222: 
                   8223:            if (flag_traditional
                   8224:                && TYPE_MAIN_VARIANT (type) == float_type_node)
                   8225:              {
                   8226:                type = build_type_variant (double_type_node,
                   8227:                                           TYPE_READONLY (type),
                   8228:                                           TYPE_VOLATILE (type));
                   8229:              }
                   8230: 
                   8231:            /* Construct the function type and go to the next
                   8232:               inner layer of declarator.  */
                   8233: 
                   8234:            {
                   8235:              int funcdef_p;
                   8236:              tree inner_parms = TREE_OPERAND (declarator, 1);
                   8237:              tree inner_decl = TREE_OPERAND (declarator, 0);
                   8238: 
                   8239:              declarator = TREE_OPERAND (declarator, 0);
                   8240: 
                   8241:              if (inner_decl && TREE_CODE (inner_decl) == SCOPE_REF)
                   8242:                inner_decl = TREE_OPERAND (inner_decl, 1);
                   8243: 
                   8244:              /* Say it's a definition only for the CALL_EXPR
                   8245:                 closest to the identifier.  */
                   8246:              funcdef_p =
                   8247:                (inner_decl &&
                   8248:                 (TREE_CODE (inner_decl) == IDENTIFIER_NODE
                   8249:                  || TREE_CODE (inner_decl) == TYPE_EXPR)) ? funcdef_flag : 0;
                   8250: 
                   8251:              /* FIXME: This is where default args should be fully processed.  */
                   8252: 
                   8253:              arg_types = grokparms (inner_parms, funcdef_p);
                   8254:            }
                   8255: 
                   8256:            if (declarator)
                   8257:              {
                   8258:                /* Get past destructors, etc.
                   8259:                   We know we have one because FLAGS will be non-zero.
                   8260: 
                   8261:                   Complain about improper parameter lists here.  */
                   8262:                if (TREE_CODE (declarator) == BIT_NOT_EXPR)
                   8263:                  {
                   8264:                    declarator = TREE_OPERAND (declarator, 0);
                   8265: 
                   8266:                    if (strict_prototype == 0 && arg_types == NULL_TREE)
                   8267:                      arg_types = void_list_node;
                   8268:                    else if (arg_types == NULL_TREE
                   8269:                             || arg_types != void_list_node)
                   8270:                      {
                   8271:                        error ("destructors cannot be specified with parameters");
                   8272:                        arg_types = void_list_node;
                   8273:                      }
                   8274:                  }
                   8275:              }
                   8276:            /* the top level const or volatile is attached semantically only
                   8277:               to the function not the actual type. */
                   8278:            if (TYPE_READONLY (type) || TYPE_VOLATILE (type))
                   8279:              {
                   8280:                int constp = TYPE_READONLY (type);
                   8281:                int volatilep = TYPE_VOLATILE (type);
                   8282:                type = build_function_type (TYPE_MAIN_VARIANT (type),
                   8283:                                            flag_traditional
                   8284:                                            ? 0
                   8285:                                            : arg_types);
                   8286:                type = build_type_variant (type, constp, volatilep);
                   8287:              }
                   8288:            else
                   8289:              type = build_function_type (type,
                   8290:                                          flag_traditional
                   8291:                                          ? 0
                   8292:                                          : arg_types);
                   8293:          }
                   8294:          break;
                   8295: 
                   8296:        case ADDR_EXPR:
                   8297:        case INDIRECT_REF:
                   8298:          maybe_globalize_type (type);
                   8299: 
                   8300:          /* Filter out pointers-to-references and references-to-references.
                   8301:             We can get these if a TYPE_DECL is used.  */
                   8302: 
                   8303:          if (TREE_CODE (type) == REFERENCE_TYPE)
                   8304:            {
                   8305:              error ("cannot declare %s to references",
                   8306:                     TREE_CODE (declarator) == ADDR_EXPR
                   8307:                     ? "references" : "pointers");
                   8308:              declarator = TREE_OPERAND (declarator, 0);
                   8309:              continue;
                   8310:            }
                   8311: 
                   8312:          /* Merge any constancy or volatility into the target type
                   8313:             for the pointer.  */
                   8314: 
                   8315:          if (constp || volatilep)
                   8316:            {
                   8317:              type = build_type_variant (type, constp, volatilep);
                   8318:              if (IS_AGGR_TYPE (type))
                   8319:                build_pointer_type (type);
                   8320:              constp = 0;
                   8321:              volatilep = 0;
                   8322:            }
                   8323: 
                   8324:          if (TREE_CODE (declarator) == ADDR_EXPR)
                   8325:            {
                   8326:              if (TREE_CODE (type) == FUNCTION_TYPE)
                   8327:                {
                   8328:                  error ("cannot declare references to functions; use pointer to function instead");
                   8329:                  type = build_pointer_type (type);
                   8330:                }
                   8331:              else
                   8332:                {
                   8333:                  if (TYPE_MAIN_VARIANT (type) == void_type_node)
                   8334:                    error ("invalid type: `void &'");
                   8335:                  else
                   8336:                    type = build_reference_type (type);
                   8337:                }
                   8338:            }
                   8339:          else if (TREE_CODE (type) == METHOD_TYPE)
                   8340:            {
                   8341:              type = build_ptrmemfunc_type (build_pointer_type (type));
                   8342:            }
                   8343:          else
                   8344:            type = build_pointer_type (type);
                   8345: 
                   8346:          /* Process a list of type modifier keywords (such as
                   8347:             const or volatile) that were given inside the `*' or `&'.  */
                   8348: 
                   8349:          if (TREE_TYPE (declarator))
                   8350:            {
                   8351:              register tree typemodlist;
                   8352:              int erred = 0;
                   8353:              for (typemodlist = TREE_TYPE (declarator); typemodlist;
                   8354:                   typemodlist = TREE_CHAIN (typemodlist))
                   8355:                {
                   8356:                  if (TREE_VALUE (typemodlist) == ridpointers[(int) RID_CONST])
                   8357:                    constp++;
                   8358:                  else if (TREE_VALUE (typemodlist) == ridpointers[(int) RID_VOLATILE])
                   8359:                    volatilep++;
                   8360:                  else if (!erred)
                   8361:                    {
                   8362:                      erred = 1;
                   8363:                      error ("invalid type modifier within %s declarator",
                   8364:                             TREE_CODE (declarator) == ADDR_EXPR
                   8365:                             ? "reference" : "pointer");
                   8366:                    }
                   8367:                }
                   8368:              if (constp > 1)
                   8369:                warning ("duplicate `const'");
                   8370:              if (volatilep > 1)
                   8371:                warning ("duplicate `volatile'");
                   8372:            }
                   8373:          declarator = TREE_OPERAND (declarator, 0);
                   8374:          ctype = NULL_TREE;
                   8375:          break;
                   8376: 
                   8377:        case SCOPE_REF:
                   8378:          {
                   8379:            /* We have converted type names to NULL_TREE if the
                   8380:               name was bogus, or to a _TYPE node, if not.
                   8381: 
                   8382:               The variable CTYPE holds the type we will ultimately
                   8383:               resolve to.  The code here just needs to build
                   8384:               up appropriate member types.  */
                   8385:            tree sname = TREE_OPERAND (declarator, 1);
                   8386:            /* Destructors can have their visibilities changed as well.  */
                   8387:            if (TREE_CODE (sname) == BIT_NOT_EXPR)
                   8388:              sname = TREE_OPERAND (sname, 0);
                   8389: 
                   8390:            if (TREE_COMPLEXITY (declarator) == 0)
                   8391:              /* This needs to be here, in case we are called
                   8392:                 multiple times.  */ ;
                   8393:            else if (friendp && (TREE_COMPLEXITY (declarator) < 2))
                   8394:              /* don't fall out into global scope. Hides real bug? --eichin */ ;
                   8395:            else if (TREE_COMPLEXITY (declarator) == current_class_depth)
                   8396:              {
                   8397:                /* I'm not really sure what pushclass calls this popclass
                   8398:                   corresponds to.  One is in build_push_scope and that has
                   8399:                   been changed to a push_nested_class call, that's why I
                   8400:                   try to use pop_nested_class here instead.
                   8401:                   [email protected] */
                   8402: #if NEW_CLASS_SCOPING
                   8403:                pop_nested_class (1);
                   8404:                TREE_COMPLEXITY (declarator) = current_class_depth;
                   8405: #else
                   8406:                TREE_COMPLEXITY (declarator) -= 1;
                   8407:                /* This popclass conflicts with the poplevel over in
                   8408:                   grokdeclarator.  See ``This poplevel conflicts'' */
                   8409:                popclass (1);
                   8410: #endif
                   8411:              }
                   8412:            else
                   8413:              my_friendly_abort (16);
                   8414: 
                   8415:            if (TREE_OPERAND (declarator, 0) == NULL_TREE)
                   8416:              {
                   8417:                /* We had a reference to a global decl, or
                   8418:                   perhaps we were given a non-aggregate typedef,
                   8419:                   in which case we cleared this out, and should just
                   8420:                   keep going as though it wasn't there.  */
                   8421:                declarator = sname;
                   8422:                continue;
                   8423:              }
                   8424:            ctype = TREE_OPERAND (declarator, 0);
                   8425: 
                   8426:            if (sname == NULL_TREE)
                   8427:              goto done_scoping;
                   8428: 
                   8429:            if (TREE_CODE (sname) == IDENTIFIER_NODE)
                   8430:              {
                   8431:                /* This is the `standard' use of the scoping operator:
                   8432:                   basetype :: member .  */
                   8433: 
                   8434:                if (TREE_CODE (type) == FUNCTION_TYPE)
                   8435:                  {
                   8436:                    if (current_class_type == NULL_TREE
                   8437:                        || TYPE_MAIN_VARIANT (ctype) == current_class_type
                   8438:                        || friendp)
                   8439:                      type = build_cplus_method_type (build_type_variant (ctype, constp, volatilep),
                   8440:                                                      TREE_TYPE (type), TYPE_ARG_TYPES (type));
                   8441:                    else
                   8442:                      {
                   8443:                        error ("cannot declare member function `%s::%s' within this class",
                   8444:                               TYPE_NAME_STRING (ctype), name);
                   8445:                        return void_type_node;
                   8446:                      }
                   8447:                  }
                   8448:                else if (TYPE_MAIN_VARIANT (ctype) == current_class_type)
                   8449:                  {
                   8450:                    if (extra_warnings)
                   8451:                      warning ("extra qualification `%s' on member `%s' ignored",
                   8452:                               TYPE_NAME_STRING (ctype), name);
                   8453:                    type = build_offset_type (ctype, type);
                   8454:                  }
                   8455:                else if (TYPE_SIZE (ctype) != NULL_TREE
                   8456:                         || (RIDBIT_SETP (RID_TYPEDEF, specbits)))
                   8457:                  {
                   8458:                    tree t;
                   8459:                    /* have to move this code elsewhere in this function.
                   8460:                       this code is used for i.e., typedef int A::M; M *pm; */
                   8461: 
                   8462:                    if (explicit_int == -1 && decl_context == FIELD
                   8463:                        && funcdef_flag == 0)
                   8464:                      {
                   8465:                        /* The code in here should only be used to build
                   8466:                           stuff that will be grokked as visibility decls.  */
                   8467:                        t = lookup_field (ctype, sname, 0, 0);
                   8468:                        if (t)
                   8469:                          {
                   8470:                            t = build_lang_field_decl (FIELD_DECL, build_nt (SCOPE_REF, ctype, t), type);
                   8471:                            DECL_INITIAL (t) = init;
                   8472:                            return t;
                   8473:                          }
                   8474:                        /* No such field, try member functions.  */
                   8475:                        t = lookup_fnfields (TYPE_BINFO (ctype), sname, 0);
                   8476:                        if (t)
                   8477:                          {
                   8478:                            if (flags == DTOR_FLAG)
                   8479:                              t = TREE_VALUE (t);
                   8480:                            else if (CLASSTYPE_METHOD_VEC (ctype)
                   8481:                                     && TREE_VALUE (t) == TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (ctype), 0))
                   8482:                              {
                   8483:                                /* Don't include destructor with constructors.  */
                   8484:                                t = DECL_CHAIN (TREE_VALUE (t));
                   8485:                                if (t == NULL_TREE)
                   8486:                                  error ("class `%s' does not have any constructors", IDENTIFIER_POINTER (sname));
                   8487:                                t = build_tree_list (NULL_TREE, t);
                   8488:                              }
                   8489:                            t = build_lang_field_decl (FIELD_DECL, build_nt (SCOPE_REF, ctype, t), type);
                   8490:                            DECL_INITIAL (t) = init;
                   8491:                            return t;
                   8492:                          }
                   8493: 
                   8494:                        if (flags == TYPENAME_FLAG)
                   8495:                          cp_error ("type conversion is not a member of structure `%T'", ctype);
                   8496:                        else
                   8497:                          cp_error
                   8498:                            ("field `%D' is not a member of structure `%T'",
                   8499:                             sname, ctype);
                   8500:                      }
                   8501: 
                   8502:                    if (current_class_type)
                   8503:                      {
                   8504:                        if (TYPE_MAIN_VARIANT (ctype) != current_class_type)
                   8505:                          {
                   8506:                            cp_error ("cannot declare member `%T::%s' within `%T'",
                   8507:                                   ctype, name, current_class_type);
                   8508:                            return void_type_node;
                   8509:                          }
                   8510:                        else if (extra_warnings)
                   8511:                          cp_warning ("extra qualification `%T' on member `%s' ignored",
                   8512:                                   ctype, name);
                   8513:                      }
                   8514:                    type = build_offset_type (ctype, type);
                   8515:                  }
                   8516:                else if (uses_template_parms (ctype))
                   8517:                  {
                   8518:                     enum tree_code c;
                   8519:                     if (TREE_CODE (type) == FUNCTION_TYPE)
                   8520:                      {
                   8521:                        type = build_cplus_method_type (build_type_variant (ctype, constp, volatilep),
                   8522:                                                        TREE_TYPE (type),
                   8523:                                                        TYPE_ARG_TYPES (type));
                   8524:                        c = FUNCTION_DECL;
                   8525:                      }
                   8526:                  }
                   8527:                else
                   8528:                  {
                   8529:                    cp_error ("structure `%T' not yet defined", ctype);
                   8530:                    return error_mark_node;
                   8531:                  }
                   8532: 
                   8533:                declarator = sname;
                   8534:              }
                   8535:            else if (TREE_CODE (sname) == TYPE_EXPR)
                   8536:              {
                   8537:                /* A TYPE_EXPR will change types out from under us.
                   8538:                   So do the TYPE_EXPR now, and make this SCOPE_REF
                   8539:                   inner to the TYPE_EXPR's CALL_EXPR.
                   8540: 
                   8541:                   This does not work if we don't get a CALL_EXPR back.
                   8542:                   I did not think about error recovery, hence the
                   8543:                   my_friendly_abort.  */
                   8544: 
                   8545:                /* Get the CALL_EXPR.  */
                   8546:                sname = grokoptypename (sname, 0);
                   8547:                my_friendly_assert (TREE_CODE (sname) == CALL_EXPR, 157);
                   8548:                type = TREE_TYPE (TREE_OPERAND (sname, 0));
                   8549:                /* Scope the CALL_EXPR's name.  */
                   8550:                TREE_OPERAND (declarator, 1) = TREE_OPERAND (sname, 0);
                   8551:                /* Put the SCOPE_EXPR in the CALL_EXPR's innermost position.  */
                   8552:                TREE_OPERAND (sname, 0) = declarator;
                   8553:                /* Now work from the CALL_EXPR.  */
                   8554:                declarator = sname;
                   8555:                continue;
                   8556:              }
                   8557:            else if (TREE_CODE (sname) == SCOPE_REF)
                   8558:              my_friendly_abort (17);
                   8559:            else
                   8560:              {
                   8561:              done_scoping:
                   8562:                declarator = TREE_OPERAND (declarator, 1);
                   8563:                if (declarator && TREE_CODE (declarator) == CALL_EXPR)
                   8564:                  /* In this case, we will deal with it later.  */
                   8565:                  ;
                   8566:                else
                   8567:                  {
                   8568:                    if (TREE_CODE (type) == FUNCTION_TYPE)
                   8569:                      type = build_cplus_method_type (build_type_variant (ctype, constp, volatilep), TREE_TYPE (type), TYPE_ARG_TYPES (type));
                   8570:                    else
                   8571:                      type = build_offset_type (ctype, type);
                   8572:                  }
                   8573:              }
                   8574:          }
                   8575:          break;
                   8576: 
                   8577:        case BIT_NOT_EXPR:
                   8578:          declarator = TREE_OPERAND (declarator, 0);
                   8579:          break;
                   8580: 
                   8581:        case TYPE_EXPR:
                   8582:          declarator = grokoptypename (declarator, 0);
                   8583:          if (explicit_int != -1)
                   8584:            {
                   8585:              tree stype = TREE_TYPE (TREE_OPERAND (declarator, 0));
                   8586:              if (comp_target_types (type, stype, 1) == 0)
                   8587:                cp_error ("`operator %T' declared to return `%T'", stype,
                   8588:                          type);
                   8589:              else
                   8590:                cp_pedwarn ("return type specified for `operator %T'", type);
                   8591:            }
                   8592:          dname = declarator;
                   8593:          type = TREE_TYPE (TREE_OPERAND (declarator, 0));
                   8594:          maybe_globalize_type (type);
                   8595:          break;
                   8596: 
                   8597:        case RECORD_TYPE:
                   8598:        case UNION_TYPE:
                   8599:        case ENUMERAL_TYPE:
                   8600:          declarator = NULL_TREE;
                   8601:          break;
                   8602: 
                   8603:        case ERROR_MARK:
                   8604:          declarator = NULL_TREE;
                   8605:          break;
                   8606: 
                   8607:        default:
                   8608:          my_friendly_abort (158);
                   8609:        }
                   8610:     }
                   8611: 
                   8612:   /* Now TYPE has the actual type.  */
                   8613: 
                   8614:   /* If this is declaring a typedef name, return a TYPE_DECL.  */
                   8615: 
                   8616:   if (RIDBIT_SETP (RID_TYPEDEF, specbits))
                   8617:     {
                   8618:       tree decl;
                   8619: 
                   8620:       /* Note that the grammar rejects storage classes
                   8621:         in typenames, fields or parameters.  */
                   8622:       if (constp || volatilep)
                   8623:        type = build_type_variant (type, constp, volatilep);
                   8624: 
                   8625:       /* If the user declares "struct {...} foo" then `foo' will have
                   8626:         an anonymous name.  Fill that name in now.  Nothing can
                   8627:         refer to it, so nothing needs know about the name change.
                   8628:         The TYPE_NAME field was filled in by build_struct_xref.  */
                   8629:       if (type != error_mark_node
                   8630:          && TYPE_NAME (type)
                   8631:          && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
                   8632:          && ANON_AGGRNAME_P (TYPE_IDENTIFIER (type)))
                   8633:        {
                   8634:          /* replace the anonymous name with the real name everywhere.  */
                   8635:          lookup_tag_reverse (type, declarator);
                   8636:          TYPE_IDENTIFIER (type) = declarator;
                   8637:        }
                   8638: 
                   8639: #if 0 /* not yet, should get fixed properly later */
                   8640:       decl = make_type_decl (declarator, type);
                   8641: #else
                   8642:       decl = build_decl (TYPE_DECL, declarator, type);
                   8643: #endif
                   8644:       if (TREE_CODE (type) == OFFSET_TYPE || TREE_CODE (type) == METHOD_TYPE)
                   8645:        {
                   8646:          cp_error_at ("typedef name may not be class-qualified", decl);
                   8647:          TREE_TYPE (decl) = error_mark_node;
                   8648:        }
                   8649:       else if (quals)
                   8650:        {
                   8651:          if (ctype == NULL_TREE)
                   8652:            {
                   8653:              if (TREE_CODE (type) != METHOD_TYPE)
                   8654:                cp_error_at ("invalid type qualifier for non-method type", decl);
                   8655:              else
                   8656:                ctype = TYPE_METHOD_BASETYPE (type);
                   8657:            }
                   8658:          if (ctype != NULL_TREE)
                   8659:            grok_method_quals (ctype, decl, quals);
                   8660:        }
                   8661: 
                   8662:       if (RIDBIT_SETP (RID_SIGNED, specbits)
                   8663:          || (typedef_decl && C_TYPEDEF_EXPLICITLY_SIGNED (typedef_decl)))
                   8664:        C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1;
                   8665: 
                   8666:       if (RIDBIT_SETP (RID_MUTABLE, specbits))
                   8667:        {
                   8668:          error ("non-object member `%s' cannot be declared mutable", name);
                   8669:        }
                   8670: 
                   8671:       return decl;
                   8672:     }
                   8673: 
                   8674:   /* Detect the case of an array type of unspecified size
                   8675:      which came, as such, direct from a typedef name.
                   8676:      We must copy the type, so that each identifier gets
                   8677:      a distinct type, so that each identifier's size can be
                   8678:      controlled separately by its own initializer.  */
                   8679: 
                   8680:   if (type == typedef_type && TREE_CODE (type) == ARRAY_TYPE
                   8681:       && TYPE_DOMAIN (type) == NULL_TREE)
                   8682:     {
                   8683:       type = build_cplus_array_type (TREE_TYPE (type), TYPE_DOMAIN (type));
                   8684:     }
                   8685: 
                   8686:   /* If this is a type name (such as, in a cast or sizeof),
                   8687:      compute the type and return it now.  */
                   8688: 
                   8689:   if (decl_context == TYPENAME)
                   8690:     {
                   8691:       /* Note that the grammar rejects storage classes
                   8692:         in typenames, fields or parameters.  */
                   8693:       if (constp || volatilep)
                   8694:        type = build_type_variant (type, constp, volatilep);
                   8695: 
                   8696:       /* Special case: "friend class foo" looks like a TYPENAME context.  */
                   8697:       if (friendp)
                   8698:        {
                   8699:          /* A friendly class?  */
                   8700:          if (current_class_type)
                   8701:            make_friend_class (current_class_type, TYPE_MAIN_VARIANT (type));
                   8702:          else
                   8703:            error("trying to make class `%s' a friend of global scope",
                   8704:                  TYPE_NAME_STRING (type));
                   8705:          type = void_type_node;
                   8706:        }
                   8707:       else if (quals)
                   8708:        {
                   8709: #if 0 /* not yet, should get fixed properly later */
                   8710:          tree dummy = make_type_decl (declarator, type);
                   8711: #else
                   8712:          tree dummy = build_decl (TYPE_DECL, declarator, type);
                   8713: #endif
                   8714:          if (ctype == NULL_TREE)
                   8715:            {
                   8716:              my_friendly_assert (TREE_CODE (type) == METHOD_TYPE, 159);
                   8717:              ctype = TYPE_METHOD_BASETYPE (type);
                   8718:            }
                   8719:          grok_method_quals (ctype, dummy, quals);
                   8720:          type = TREE_TYPE (dummy);
                   8721:        }
                   8722: 
                   8723:       return type;
                   8724:     }
                   8725: 
                   8726:   /* `void' at top level (not within pointer)
                   8727:      is allowed only in typedefs or type names.
                   8728:      We don't complain about parms either, but that is because
                   8729:      a better error message can be made later.  */
                   8730: 
                   8731:   if (TYPE_MAIN_VARIANT (type) == void_type_node && decl_context != PARM)
                   8732:     {
                   8733:       if (declarator != NULL_TREE
                   8734:          && TREE_CODE (declarator) == IDENTIFIER_NODE)
                   8735:        {
                   8736:          if (IDENTIFIER_OPNAME_P (declarator))
                   8737: #if 0                          /* How could this happen? */
                   8738:            error ("operator `%s' declared void",
                   8739:                   operator_name_string (declarator));
                   8740: #else
                   8741:            my_friendly_abort (356);
                   8742: #endif
                   8743:          else
                   8744:            error ("variable or field `%s' declared void", name);
                   8745:        }
                   8746:       else
                   8747:        error ("variable or field declared void");
                   8748:       type = integer_type_node;
                   8749:     }
                   8750: 
                   8751:   /* Now create the decl, which may be a VAR_DECL, a PARM_DECL
                   8752:      or a FUNCTION_DECL, depending on DECL_CONTEXT and TYPE.  */
                   8753: 
                   8754:   {
                   8755:     register tree decl;
                   8756: 
                   8757:     if (decl_context == PARM)
                   8758:       {
                   8759:        tree parmtype = type;
                   8760: 
                   8761:        if (ctype)
                   8762:          error ("cannot use `::' in parameter declaration");
                   8763: 
                   8764:        /* A parameter declared as an array of T is really a pointer to T.
                   8765:           One declared as a function is really a pointer to a function.
                   8766:           One declared as a member is really a pointer to member.
                   8767: 
                   8768:           Don't be misled by references.  */
                   8769: 
                   8770:        if (TREE_CODE (type) == REFERENCE_TYPE)
                   8771:          type = TREE_TYPE (type);
                   8772: 
                   8773:        if (TREE_CODE (type) == ARRAY_TYPE)
                   8774:          {
                   8775:            if (parmtype == type)
                   8776:              {
                   8777:                /* Transfer const-ness of array into that of type
                   8778:                   pointed to.  */
                   8779:                type = build_pointer_type
                   8780:                  (build_type_variant (TREE_TYPE (type), constp, volatilep));
                   8781:                volatilep = constp = 0;
                   8782:              }
                   8783:            else
                   8784:              type = build_pointer_type (TREE_TYPE (type));
                   8785:          }
                   8786:        else if (TREE_CODE (type) == FUNCTION_TYPE)
                   8787:          type = build_pointer_type (type);
                   8788:        else if (TREE_CODE (type) == OFFSET_TYPE)
                   8789:          type = build_pointer_type (type);
                   8790: 
                   8791:        if (TREE_CODE (parmtype) == REFERENCE_TYPE)
                   8792:          {
                   8793:            /* Transfer const-ness of reference into that of type pointed to.  */
                   8794:            type = build_type_variant (build_reference_type (type), constp, volatilep);
                   8795:            constp = volatilep = 0;
                   8796:          }
                   8797: 
                   8798:        decl = build_decl (PARM_DECL, declarator, type);
                   8799: 
                   8800:        bad_specifiers (decl, "parameter", virtualp, quals != NULL_TREE,
                   8801:                        inlinep, friendp, raises != NULL_TREE);
                   8802: 
                   8803:        /* Compute the type actually passed in the parmlist,
                   8804:           for the case where there is no prototype.
                   8805:           (For example, shorts and chars are passed as ints.)
                   8806:           When there is a prototype, this is overridden later.  */
                   8807: 
                   8808:        DECL_ARG_TYPE (decl) = type;
                   8809:        if (TYPE_MAIN_VARIANT (type) == float_type_node)
                   8810:          DECL_ARG_TYPE (decl) = build_type_variant (double_type_node,
                   8811:                                                     TYPE_READONLY (type),
                   8812:                                                     TYPE_VOLATILE (type));
                   8813:        else if (C_PROMOTING_INTEGER_TYPE_P (type))
                   8814:          {
                   8815:            tree argtype;
                   8816: 
                   8817:            /* Retain unsignedness if traditional or if not really
                   8818:               getting wider.  */
                   8819:            if (TREE_UNSIGNED (type)
                   8820:                && (flag_traditional
                   8821:                    || TYPE_PRECISION (type)
                   8822:                        == TYPE_PRECISION (integer_type_node)))
                   8823:              argtype = unsigned_type_node;
                   8824:            else
                   8825:              argtype = integer_type_node;
                   8826:            DECL_ARG_TYPE (decl) = build_type_variant (argtype,
                   8827:                                                       TYPE_READONLY (type),
                   8828:                                                       TYPE_VOLATILE (type));
                   8829:          }
                   8830:       }
                   8831:     else if (decl_context == FIELD)
                   8832:       {
                   8833:        if (type == error_mark_node)
                   8834:          {
                   8835:            /* Happens when declaring arrays of sizes which
                   8836:               are error_mark_node, for example.  */
                   8837:            decl = NULL_TREE;
                   8838:          }
                   8839:        else if (TREE_CODE (type) == FUNCTION_TYPE)
                   8840:          {
                   8841:            int publicp = 0;
                   8842: 
                   8843:            if (friendp == 0)
                   8844:              {
                   8845:                if (ctype == NULL_TREE)
                   8846:                  ctype = current_class_type;
                   8847: 
                   8848:                if (ctype == NULL_TREE)
                   8849:                  {
                   8850:                    cp_error ("can't make `%D' into a method -- not in a class",
                   8851:                              declarator);
                   8852:                    return void_type_node;
                   8853:                  }
                   8854: 
                   8855:                /* ``A union may [ ... ] not [ have ] virtual functions.''
                   8856:                   ARM 9.5 */
                   8857:                if (virtualp && TREE_CODE (ctype) == UNION_TYPE)
                   8858:                  {
                   8859:                    error ("function `%s' declared virtual inside a union",
                   8860:                           IDENTIFIER_POINTER (declarator));
                   8861:                    return void_type_node;
                   8862:                  }
                   8863: 
                   8864:                /* Don't convert type of operators new and delete to
                   8865:                   METHOD_TYPE; they remain FUNCTION_TYPEs.  */
                   8866:                if (staticp < 2
                   8867:                    && declarator != ansi_opname[(int) NEW_EXPR]
                   8868:                    && declarator != ansi_opname[(int) DELETE_EXPR])
                   8869:                  type = build_cplus_method_type (build_type_variant (ctype, constp, volatilep),
                   8870:                                                  TREE_TYPE (type), TYPE_ARG_TYPES (type));
                   8871:              }
                   8872: 
                   8873:            /* Tell grokfndecl if it needs to set TREE_PUBLIC on the node.  */
                   8874:            publicp = (RIDBIT_SETP (RID_EXTERN, specbits)
                   8875:                       || (ctype != NULL_TREE && funcdef_flag >= 0)
                   8876:                       || (friendp
                   8877:                           && RIDBIT_NOTSETP (RID_STATIC, specbits)
                   8878:                           && RIDBIT_NOTSETP (RID_INLINE, specbits))
                   8879:                       );
                   8880:            decl = grokfndecl (ctype, type, declarator,
                   8881:                               virtualp, flags, quals,
                   8882:                               raises, friendp ? -1 : 0, publicp);
                   8883:            DECL_INLINE (decl) = inlinep;
                   8884:          }
                   8885:        else if (TREE_CODE (type) == METHOD_TYPE)
                   8886:          {
                   8887:            /* All method decls are public, so tell grokfndecl to set
                   8888:               TREE_PUBLIC, also.  */
                   8889:            decl = grokfndecl (ctype, type, declarator,
                   8890:                               virtualp, flags, quals,
                   8891:                               raises, friendp ? -1 : 0, 1);
                   8892:            DECL_INLINE (decl) = inlinep;
                   8893:          }
                   8894:        else if (TREE_CODE (type) == RECORD_TYPE
                   8895:                 && CLASSTYPE_DECLARED_EXCEPTION (type))
                   8896:          {
                   8897:            /* Handle a class-local exception declaration.  */
                   8898:            decl = build_lang_field_decl (VAR_DECL, declarator, type);
                   8899:            if (ctype == NULL_TREE)
                   8900:              ctype = current_class_type;
                   8901:            finish_exception_decl (TREE_CODE (TYPE_NAME (ctype)) == TYPE_DECL
                   8902:                                   ? TYPE_IDENTIFIER (ctype) : TYPE_NAME (ctype), decl);
                   8903:            return void_type_node;
                   8904:          }
                   8905:        else if (TYPE_SIZE (type) == NULL_TREE && !staticp
                   8906:                 && (TREE_CODE (type) != ARRAY_TYPE || initialized == 0))
                   8907:          {
                   8908:            if (declarator)
                   8909:              error ("field `%s' has incomplete type",
                   8910:                     IDENTIFIER_POINTER (declarator));
                   8911:            else
                   8912:              error ("field has incomplete type");
                   8913: 
                   8914:            /* If we're instantiating a template, tell them which
                   8915:               instantiation made the field's type be incomplete.  */
                   8916:            if (current_class_type
                   8917:                && TYPE_NAME (current_class_type)
                   8918:                && IDENTIFIER_TEMPLATE (DECL_NAME (TYPE_NAME (current_class_type)))
                   8919:                && declspecs && TREE_VALUE (declspecs)
                   8920:                && TREE_TYPE (TREE_VALUE (declspecs)) == type)
                   8921:              error ("  in instantiation of template `%s'",
                   8922:                     TYPE_NAME_STRING (current_class_type));
                   8923:                
                   8924:            type = error_mark_node;
                   8925:            decl = NULL_TREE;
                   8926:          }
                   8927:        else
                   8928:          {
                   8929:            if (friendp)
                   8930:              {
                   8931:                if (declarator)
                   8932:                  error ("`%s' is neither function nor method; cannot be declared friend",
                   8933:                         IDENTIFIER_POINTER (declarator));
                   8934:                else
                   8935:                  {
                   8936:                    error ("invalid friend declaration");
                   8937:                    return void_type_node;
                   8938:                  }
                   8939:                friendp = 0;
                   8940:              }
                   8941:            decl = NULL_TREE;
                   8942:          }
                   8943: 
                   8944:        if (friendp)
                   8945:          {
                   8946:            /* Friends are treated specially.  */
                   8947:            if (ctype == current_class_type)
                   8948:              warning ("member functions are implicitly friends of their class");
                   8949:            else if (decl && DECL_NAME (decl))
                   8950:              return do_friend (ctype, declarator, decl,
                   8951:                                last_function_parms, flags, quals);
                   8952:            else
                   8953:              return void_type_node;
                   8954:          }
                   8955: 
                   8956:        /* Structure field.  It may not be a function, except for C++ */
                   8957: 
                   8958:        if (decl == NULL_TREE)
                   8959:          {
                   8960:            /* ANSI C++ June 5 1992 WP 9.2.2 and 9.4.2.  A member-declarator
                   8961:               cannot have an initializer, and a static member declaration must
                   8962:               be defined elsewhere.  */
                   8963:            if (initialized)
                   8964:              {
                   8965:                if (staticp)
                   8966:                  error ("static member `%s' must be defined separately from its declaration",
                   8967:                          IDENTIFIER_POINTER (declarator));
                   8968:                /* Note that initialization of const members is prohibited
                   8969:                   by the draft ANSI standard, though it appears to be in
                   8970:                   common practice.  12.6.2: The argument list is used to
                   8971:                   initialize the named nonstatic member....  This (or an
                   8972:                   aggregate) is the only way to initialize nonstatic const
                   8973:                   and reference members.  */
                   8974:                else if (pedantic && (!constp || flag_ansi))
                   8975:                  warning ("ANSI C++ forbids initialization of %s `%s'",
                   8976:                           constp ? "const member" : "member",
                   8977:                           IDENTIFIER_POINTER (declarator));
                   8978:              }
                   8979: 
                   8980:            if (staticp || (constp && initialized))
                   8981:              {
                   8982:                /* C++ allows static class members.
                   8983:                   All other work for this is done by grokfield.
                   8984:                   This VAR_DECL is built by build_lang_field_decl.
                   8985:                   All other VAR_DECLs are built by build_decl.  */
                   8986:                decl = build_lang_field_decl (VAR_DECL, declarator, type);
                   8987:                if (staticp || TREE_CODE (type) == ARRAY_TYPE)
                   8988:                  TREE_STATIC (decl) = 1;
                   8989:                /* In class context, static means public visibility.  */
                   8990:                TREE_PUBLIC (decl) = 1;
                   8991:                DECL_EXTERNAL (decl) = !initialized;
                   8992:              }
                   8993:            else
                   8994:              {
                   8995:                decl = build_lang_field_decl (FIELD_DECL, declarator, type);
                   8996:                if (RIDBIT_SETP (RID_MUTABLE, specbits))
                   8997:                  {
                   8998:                    DECL_MUTABLE_P (decl) = 1;
                   8999:                    RIDBIT_RESET (RID_MUTABLE, specbits);
                   9000:                  }
                   9001:              }
                   9002: 
                   9003:            bad_specifiers (decl, "field", virtualp, quals != NULL_TREE,
                   9004:                            inlinep, friendp, raises != NULL_TREE);
                   9005:          }
                   9006:       }
                   9007:     else if (TREE_CODE (type) == FUNCTION_TYPE || TREE_CODE (type) == METHOD_TYPE)
                   9008:       {
                   9009:        int was_overloaded = 0;
                   9010:        tree original_name = declarator;
                   9011:        int publicp = 0;
                   9012: 
                   9013:        if (! declarator)
                   9014:          return NULL_TREE;
                   9015: 
                   9016:        if (RIDBIT_SETP (RID_AUTO, specbits)
                   9017:            || RIDBIT_SETP (RID_REGISTER, specbits))
                   9018:          error ("invalid storage class for function `%s'", name);
                   9019: 
                   9020:        /* Function declaration not at top level.
                   9021:           Storage classes other than `extern' are not allowed
                   9022:           and `extern' makes no difference.  */
                   9023:        if (current_binding_level != global_binding_level
                   9024:            && (RIDBIT_SETP (RID_STATIC, specbits) || RIDBIT_SETP (RID_INLINE, specbits))
                   9025:            && pedantic)
                   9026:          pedwarn ("invalid storage class for function `%s'", name);
                   9027: 
                   9028:        if (ctype == NULL_TREE)
                   9029:          {
                   9030:            if (virtualp)
                   9031:              {
                   9032:                error ("virtual non-class function `%s'", name);
                   9033:                virtualp = 0;
                   9034:              }
                   9035: 
                   9036:            if (current_lang_name == lang_name_cplusplus
                   9037:                && ! (IDENTIFIER_LENGTH (original_name) == 4
                   9038:                      && IDENTIFIER_POINTER (original_name)[0] == 'm'
                   9039:                      && strcmp (IDENTIFIER_POINTER (original_name), "main") == 0)
                   9040:                && ! (IDENTIFIER_LENGTH (original_name) > 10
                   9041:                      && IDENTIFIER_POINTER (original_name)[0] == '_'
                   9042:                      && IDENTIFIER_POINTER (original_name)[1] == '_'
                   9043:                      && strncmp (IDENTIFIER_POINTER (original_name)+2, "builtin_", 8) == 0))
                   9044:              {
                   9045:                /* Plain overloading: will not be grok'd by grokclassfn.  */
                   9046:                declarator = build_decl_overload (dname, TYPE_ARG_TYPES (type), 0);
                   9047:                was_overloaded = 1;
                   9048:              }
                   9049:          }
                   9050:        else if (TREE_CODE (type) == FUNCTION_TYPE && staticp < 2)
                   9051:          type = build_cplus_method_type (build_type_variant (ctype, constp, volatilep),
                   9052:                                          TREE_TYPE (type), TYPE_ARG_TYPES (type));
                   9053: 
                   9054:        /* Record presence of `static'.  In C++, `inline' is like `static'.
                   9055:           Methods of classes should be public, unless we're dropping them
                   9056:           into some other file, so we don't clear TREE_PUBLIC for them.  */
                   9057:        publicp
                   9058:          = ((ctype
                   9059:              && CLASSTYPE_INTERFACE_KNOWN (ctype)
                   9060:              && ! CLASSTYPE_INTERFACE_ONLY (ctype))
                   9061:             || !(RIDBIT_SETP (RID_STATIC, specbits)
                   9062:                  || RIDBIT_SETP (RID_INLINE, specbits)));
                   9063: 
                   9064:        decl = grokfndecl (ctype, type, original_name,
                   9065:                           virtualp, flags, quals,
                   9066:                           raises,
                   9067:                           processing_template_decl ? 0 : friendp ? 2 : 1,
                   9068:                           publicp);
                   9069: 
                   9070:        
                   9071:        if (ctype == NULL_TREE && DECL_HAS_CPLUSPLUS_LINKAGE(decl))
                   9072:          DECL_ASSEMBLER_NAME (decl) = declarator;
                   9073: 
                   9074:        if (staticp == 1)
                   9075:          {
                   9076:            int illegal_static = 0;
                   9077: 
                   9078:            /* Don't allow a static member function in a class, and forbid
                   9079:               declaring main to be static.  */
                   9080:            if (TREE_CODE (type) == METHOD_TYPE)
                   9081:              {
                   9082:                cp_error_at ("cannot declare member function `%D' to have static linkage", decl);
                   9083:                illegal_static = 1;
                   9084:              }
                   9085:            else if (! was_overloaded
                   9086:                     && ! ctype
                   9087:                     && IDENTIFIER_LENGTH (original_name) == 4
                   9088:                     && IDENTIFIER_POINTER (original_name)[0] == 'm'
                   9089:                     && ! strcmp (IDENTIFIER_POINTER (original_name), "main"))
                   9090:              {
                   9091:                error ("cannot declare function `main' to have static linkage");
                   9092:                illegal_static = 1;
                   9093:              }
                   9094: 
                   9095:            if (illegal_static)
                   9096:              {
                   9097:                staticp = 0;
                   9098:                RIDBIT_RESET (RID_STATIC, specbits);
                   9099:              }
                   9100:          }
                   9101: 
                   9102: #ifdef NeXT
                   9103: #ifdef HPPA
                   9104:   {
                   9105:     tree last = tree_last (TYPE_ARG_TYPES (type));
                   9106: 
                   9107:     if (last && (TYPE_MAIN_VARIANT (TREE_VALUE (last)) != void_type_node))
                   9108:        add_vararg_func(IDENTIFIER_POINTER(declarator), '1');
                   9109:     else
                   9110:        add_vararg_func(IDENTIFIER_POINTER(declarator), '0');
                   9111:   }
                   9112: #endif
                   9113: #endif
                   9114: 
                   9115:        /* Record presence of `inline', if it is reasonable.  */
                   9116:        if (inlinep)
                   9117:          {
                   9118:            tree last = tree_last (TYPE_ARG_TYPES (type));
                   9119: 
                   9120:            if (! was_overloaded
                   9121:                && ! ctype
                   9122:                && ! strcmp (IDENTIFIER_POINTER (original_name), "main"))
                   9123:              error ("cannot inline function `main'");
                   9124:            else if (last && last != void_list_node)
                   9125:              cp_warning ("cannot inline function `%D' which takes `...'", original_name);
                   9126:            else
                   9127:              /* Assume that otherwise the function can be inlined.  */
                   9128:              DECL_INLINE (decl) = 1;
                   9129: 
                   9130:            if (RIDBIT_SETP (RID_EXTERN, specbits))
                   9131:              {
                   9132:                current_extern_inline = 1;
                   9133:                if (flag_ansi || pedantic || flag_pedantic_errors)
                   9134:                  pedwarn ("ANSI C++ does not permit `extern inline'");
                   9135:              }
                   9136:          }
                   9137:        if (was_overloaded)
                   9138:          DECL_OVERLOADED (decl) = 1;
                   9139:       }
                   9140:     else
                   9141:       {
                   9142:        /* It's a variable.  */
                   9143: 
                   9144:        /* An uninitialized decl with `extern' is a reference.  */
                   9145:        decl = grokvardecl (type, declarator, specbits, initialized);
                   9146:        bad_specifiers (decl, "variable", virtualp, quals != NULL_TREE,
                   9147:                        inlinep, friendp, raises != NULL_TREE);
                   9148: 
                   9149:        if (ctype)
                   9150:          {
                   9151:            if (staticp == 1)
                   9152:              {
                   9153:                cp_error ("static member `%D' re-declared as static",
                   9154:                          decl);
                   9155:                staticp = 0;
                   9156:                RIDBIT_RESET (RID_STATIC, specbits);
                   9157:              }
                   9158:            if (RIDBIT_SETP (RID_EXTERN, specbits))
                   9159:              {
                   9160:                cp_error ("cannot explicitly declare member `%#D' to have extern linkage",
                   9161:                          decl);
                   9162:                RIDBIT_RESET (RID_EXTERN, specbits);
                   9163:              }
                   9164:          }
                   9165:       }
                   9166: 
                   9167:     if (RIDBIT_SETP (RID_MUTABLE, specbits))
                   9168:       {
                   9169:        error ("`%s' cannot be declared mutable", name);
                   9170:       }
                   9171: 
                   9172:     /* Record `register' declaration for warnings on &
                   9173:        and in case doing stupid register allocation.  */
                   9174: 
                   9175:     if (RIDBIT_SETP (RID_REGISTER, specbits))
                   9176:       DECL_REGISTER (decl) = 1;
                   9177: 
                   9178:     /* Record constancy and volatility.  */
                   9179: 
                   9180:     if (constp)
                   9181:       TREE_READONLY (decl) = TREE_CODE (type) != REFERENCE_TYPE;
                   9182:     if (volatilep)
                   9183:       {
                   9184:        TREE_SIDE_EFFECTS (decl) = 1;
                   9185:        TREE_THIS_VOLATILE (decl) = 1;
                   9186:       }
                   9187: 
                   9188:     return decl;
                   9189:   }
                   9190: }
                   9191: 
                   9192: /* Tell if a parmlist/exprlist looks like an exprlist or a parmlist.
                   9193:    An empty exprlist is a parmlist.  An exprlist which
                   9194:    contains only identifiers at the global level
                   9195:    is a parmlist.  Otherwise, it is an exprlist.  */
                   9196: int
                   9197: parmlist_is_exprlist (exprs)
                   9198:      tree exprs;
                   9199: {
                   9200:   if (exprs == NULL_TREE || TREE_PARMLIST (exprs))
                   9201:     return 0;
                   9202: 
                   9203:   if (current_binding_level == global_binding_level)
                   9204:     {
                   9205:       /* At the global level, if these are all identifiers,
                   9206:         then it is a parmlist.  */
                   9207:       while (exprs)
                   9208:        {
                   9209:          if (TREE_CODE (TREE_VALUE (exprs)) != IDENTIFIER_NODE)
                   9210:            return 1;
                   9211:          exprs = TREE_CHAIN (exprs);
                   9212:        }
                   9213:       return 0;
                   9214:     }
                   9215:   return 1;
                   9216: }
                   9217: 
                   9218: /* Make sure that the this list of PARMS has a chance of being
                   9219:    grokked by `grokparms'.
                   9220: 
                   9221:    @@ This is really weak, but the grammar does not allow us
                   9222:    @@ to easily reject things that this has to catch as syntax errors.  */
                   9223: static int
                   9224: parmlist_is_random (parms)
                   9225:      tree parms;
                   9226: {
                   9227:   if (parms == NULL_TREE)
                   9228:     return 0;
                   9229: 
                   9230:   if (TREE_CODE (parms) != TREE_LIST)
                   9231:     return 1;
                   9232: 
                   9233:   while (parms)
                   9234:     {
                   9235:       if (parms == void_list_node)
                   9236:        return 0;
                   9237: 
                   9238:       if (TREE_CODE (TREE_VALUE (parms)) != TREE_LIST)
                   9239:        return 1;
                   9240:       /* Don't get faked out by overloaded functions, which
                   9241:         masquerade as TREE_LISTs!  */
                   9242:       if (TREE_TYPE (TREE_VALUE (parms)) == unknown_type_node)
                   9243:        return 1;
                   9244:       parms = TREE_CHAIN (parms);
                   9245:     }
                   9246:   return 0;
                   9247: }
                   9248: 
                   9249: /* Subroutine of `grokparms'.  In a fcn definition, arg types must
                   9250:    be complete.
                   9251: 
                   9252:    C++: also subroutine of `start_function'.  */
                   9253: static void
                   9254: require_complete_types_for_parms (parms)
                   9255:      tree parms;
                   9256: {
                   9257:   while (parms)
                   9258:     {
                   9259:       tree type = TREE_TYPE (parms);
                   9260:       if (TYPE_SIZE (type) == NULL_TREE)
                   9261:        {
                   9262:          if (DECL_NAME (parms))
                   9263:            error ("parameter `%s' has incomplete type",
                   9264:                   IDENTIFIER_POINTER (DECL_NAME (parms)));
                   9265:          else
                   9266:            error ("parameter has incomplete type");
                   9267:          TREE_TYPE (parms) = error_mark_node;
                   9268:        }
                   9269: #if 0
                   9270:       /* If the arg types are incomplete in a declaration,
                   9271:         they must include undefined tags.
                   9272:         These tags can never be defined in the scope of the declaration,
                   9273:         so the types can never be completed,
                   9274:         and no call can be compiled successfully.  */
                   9275:       /* This is not the right behavior for C++, but not having
                   9276:         it is also probably wrong.  */
                   9277:       else
                   9278:        {
                   9279:          /* Now warn if is a pointer to an incomplete type.  */
                   9280:          while (TREE_CODE (type) == POINTER_TYPE
                   9281:                 || TREE_CODE (type) == REFERENCE_TYPE)
                   9282:            type = TREE_TYPE (type);
                   9283:          type = TYPE_MAIN_VARIANT (type);
                   9284:          if (TYPE_SIZE (type) == NULL_TREE)
                   9285:            {
                   9286:              if (DECL_NAME (parm) != NULL_TREE)
                   9287:                warning ("parameter `%s' points to incomplete type",
                   9288:                         IDENTIFIER_POINTER (DECL_NAME (parm)));
                   9289:              else
                   9290:                warning ("parameter points to incomplete type");
                   9291:            }
                   9292:        }
                   9293: #endif
                   9294:       parms = TREE_CHAIN (parms);
                   9295:     }
                   9296: }
                   9297: 
                   9298: /* Decode the list of parameter types for a function type.
                   9299:    Given the list of things declared inside the parens,
                   9300:    return a list of types.
                   9301: 
                   9302:    The list we receive can have three kinds of elements:
                   9303:    an IDENTIFIER_NODE for names given without types,
                   9304:    a TREE_LIST node for arguments given as typespecs or names with typespecs,
                   9305:    or void_type_node, to mark the end of an argument list
                   9306:    when additional arguments are not permitted (... was not used).
                   9307: 
                   9308:    FUNCDEF_FLAG is nonzero for a function definition, 0 for
                   9309:    a mere declaration.  A nonempty identifier-list gets an error message
                   9310:    when FUNCDEF_FLAG is zero.
                   9311:    If FUNCDEF_FLAG is 1, then parameter types must be complete.
                   9312:    If FUNCDEF_FLAG is -1, then parameter types may be incomplete.
                   9313: 
                   9314:    If all elements of the input list contain types,
                   9315:    we return a list of the types.
                   9316:    If all elements contain no type (except perhaps a void_type_node
                   9317:    at the end), we return a null list.
                   9318:    If some have types and some do not, it is an error, and we
                   9319:    return a null list.
                   9320: 
                   9321:    Also set last_function_parms to either
                   9322:    a list of names (IDENTIFIER_NODEs) or a chain of PARM_DECLs.
                   9323:    A list of names is converted to a chain of PARM_DECLs
                   9324:    by store_parm_decls so that ultimately it is always a chain of decls.
                   9325: 
                   9326:    Note that in C++, parameters can take default values.  These default
                   9327:    values are in the TREE_PURPOSE field of the TREE_LIST.  It is
                   9328:    an error to specify default values which are followed by parameters
                   9329:    that have no default values, or an ELLIPSES.  For simplicities sake,
                   9330:    only parameters which are specified with their types can take on
                   9331:    default values.  */
                   9332: 
                   9333: tree
                   9334: grokparms (first_parm, funcdef_flag)
                   9335:      tree first_parm;
                   9336:      int funcdef_flag;
                   9337: {
                   9338:   tree result = NULL_TREE;
                   9339:   tree decls = NULL_TREE;
                   9340: 
                   9341:   if (first_parm != NULL_TREE
                   9342:       && TREE_CODE (TREE_VALUE (first_parm)) == IDENTIFIER_NODE)
                   9343:     {
                   9344:       if (! funcdef_flag)
                   9345:        warning ("parameter names (without types) in function declaration");
                   9346:       last_function_parms = first_parm;
                   9347:       return NULL_TREE;
                   9348:     }
                   9349:   else
                   9350:     {
                   9351:       /* Types were specified.  This is a list of declarators
                   9352:         each represented as a TREE_LIST node.  */
                   9353:       register tree parm, chain;
                   9354:       int any_init = 0, any_error = 0, saw_void = 0;
                   9355: 
                   9356:       if (first_parm != NULL_TREE)
                   9357:        {
                   9358:          tree last_result = NULL_TREE;
                   9359:          tree last_decl = NULL_TREE;
                   9360: 
                   9361:          for (parm = first_parm; parm != NULL_TREE; parm = chain)
                   9362:            {
                   9363:              tree type, list_node = parm;
                   9364:              register tree decl = TREE_VALUE (parm);
                   9365:              tree init = TREE_PURPOSE (parm);
                   9366: 
                   9367:              chain = TREE_CHAIN (parm);
                   9368:              /* @@ weak defense against parse errors.  */
                   9369:              if (decl != void_type_node && TREE_CODE (decl) != TREE_LIST)
                   9370:                {
                   9371:                  /* Give various messages as the need arises.  */
                   9372:                  if (TREE_CODE (decl) == STRING_CST)
                   9373:                    error ("invalid string constant `%s'",
                   9374:                           TREE_STRING_POINTER (decl));
                   9375:                  else if (TREE_CODE (decl) == INTEGER_CST)
                   9376:                    error ("invalid integer constant in parameter list, did you forget to give parameter name?");
                   9377:                  continue;
                   9378:                }
                   9379: 
                   9380:              if (decl != void_type_node)
                   9381:                {
                   9382:                  /* @@ May need to fetch out a `raises' here.  */
                   9383:                  decl = grokdeclarator (TREE_VALUE (decl),
                   9384:                                         TREE_PURPOSE (decl),
                   9385:                                         PARM, init != NULL_TREE, NULL_TREE);
                   9386:                  if (! decl)
                   9387:                    continue;
                   9388:                  type = TREE_TYPE (decl);
                   9389:                  if (TYPE_MAIN_VARIANT (type) == void_type_node)
                   9390:                    decl = void_type_node;
                   9391:                  else if (TREE_CODE (type) == METHOD_TYPE)
                   9392:                    {
                   9393:                      if (DECL_NAME (decl))
                   9394:                        /* Cannot use `error_with_decl' here because
                   9395:                           we don't have DECL_CONTEXT set up yet.  */
                   9396:                        error ("parameter `%s' invalidly declared method type",
                   9397:                               IDENTIFIER_POINTER (DECL_NAME (decl)));
                   9398:                      else
                   9399:                        error ("parameter invalidly declared method type");
                   9400:                      type = build_pointer_type (type);
                   9401:                      TREE_TYPE (decl) = type;
                   9402:                    }
                   9403:                  else if (TREE_CODE (type) == OFFSET_TYPE)
                   9404:                    {
                   9405:                      if (DECL_NAME (decl))
                   9406:                        error ("parameter `%s' invalidly declared offset type",
                   9407:                               IDENTIFIER_POINTER (DECL_NAME (decl)));
                   9408:                      else
                   9409:                        error ("parameter invalidly declared offset type");
                   9410:                      type = build_pointer_type (type);
                   9411:                      TREE_TYPE (decl) = type;
                   9412:                    }
                   9413:                   else if (TREE_CODE (type) == RECORD_TYPE
                   9414:                            && TYPE_LANG_SPECIFIC (type)
                   9415:                            && CLASSTYPE_ABSTRACT_VIRTUALS (type))
                   9416:                     {
                   9417:                       abstract_virtuals_error (decl, type);
                   9418:                       any_error = 1;  /* seems like a good idea */
                   9419:                     }
                   9420:                }
                   9421: 
                   9422:              if (decl == void_type_node)
                   9423:                {
                   9424:                  if (result == NULL_TREE)
                   9425:                    {
                   9426:                      result = void_list_node;
                   9427:                      last_result = result;
                   9428:                    }
                   9429:                  else
                   9430:                    {
                   9431:                      TREE_CHAIN (last_result) = void_list_node;
                   9432:                      last_result = void_list_node;
                   9433:                    }
                   9434:                  saw_void = 1;
                   9435:                  if (chain
                   9436:                      && (chain != void_list_node || TREE_CHAIN (chain)))
                   9437:                    error ("`void' in parameter list must be entire list");
                   9438:                  break;
                   9439:                }
                   9440: 
                   9441:              /* Since there is a prototype, args are passed in their own types.  */
                   9442:              DECL_ARG_TYPE (decl) = TREE_TYPE (decl);
                   9443: #ifdef PROMOTE_PROTOTYPES
                   9444:              if ((TREE_CODE (type) == INTEGER_TYPE
                   9445:                   || TREE_CODE (type) == ENUMERAL_TYPE)
                   9446:                  && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
                   9447:                DECL_ARG_TYPE (decl) = integer_type_node;
                   9448: #endif
                   9449:              if (!any_error)
                   9450:                {
                   9451:                  if (init)
                   9452:                    {
                   9453:                      any_init++;
                   9454:                      if (TREE_CODE (init) == SAVE_EXPR)
                   9455:                        PARM_DECL_EXPR (init) = 1;
                   9456:                      else if (TREE_CODE (init) == VAR_DECL)
                   9457:                        {
                   9458:                          if (IDENTIFIER_LOCAL_VALUE (DECL_NAME (init)))
                   9459:                            {
                   9460:                              /* ``Local variables may not be used in default
                   9461:                                 argument expressions.'' dpANSI C++ 8.2.6 */
                   9462:                              /* If extern int i; within a function is not
                   9463:                                 considered a local variable, then this code is
                   9464:                                 wrong. */
                   9465:                              cp_error ("local variable `%D' may not be used as a default argument", init);
                   9466:                              any_error = 1;
                   9467:                            }
                   9468:                          else if (TREE_READONLY_DECL_P (init))
                   9469:                            init = decl_constant_value (init);
                   9470:                        }
                   9471:                      else
                   9472:                        init = require_instantiated_type (type, init, integer_zero_node);
                   9473:                    }
                   9474:                  else if (any_init)
                   9475:                    {
                   9476:                      error ("all trailing parameters must have default arguments");
                   9477:                      any_error = 1;
                   9478:                    }
                   9479:                }
                   9480:              else
                   9481:                init = NULL_TREE;
                   9482: 
                   9483:              if (decls == NULL_TREE)
                   9484:                {
                   9485:                  decls = decl;
                   9486:                  last_decl = decls;
                   9487:                }
                   9488:              else
                   9489:                {
                   9490:                  TREE_CHAIN (last_decl) = decl;
                   9491:                  last_decl = decl;
                   9492:                }
                   9493:              if (TREE_PERMANENT (list_node))
                   9494:                {
                   9495:                  TREE_PURPOSE (list_node) = init;
                   9496:                  TREE_VALUE (list_node) = type;
                   9497:                  TREE_CHAIN (list_node) = NULL_TREE;
                   9498:                }
                   9499:              else
                   9500:                list_node = saveable_tree_cons (init, type, NULL_TREE);
                   9501:              if (result == NULL_TREE)
                   9502:                {
                   9503:                  result = list_node;
                   9504:                  last_result = result;
                   9505:                }
                   9506:              else
                   9507:                {
                   9508:                  TREE_CHAIN (last_result) = list_node;
                   9509:                  last_result = list_node;
                   9510:                }
                   9511:            }
                   9512:          if (last_result)
                   9513:            TREE_CHAIN (last_result) = NULL_TREE;
                   9514:          /* If there are no parameters, and the function does not end
                   9515:             with `...', then last_decl will be NULL_TREE.  */
                   9516:          if (last_decl != NULL_TREE)
                   9517:            TREE_CHAIN (last_decl) = NULL_TREE;
                   9518:        }
                   9519:     }
                   9520: 
                   9521:   last_function_parms = decls;
                   9522: 
                   9523:   /* In a fcn definition, arg types must be complete.  */
                   9524:   if (funcdef_flag > 0)
                   9525:     require_complete_types_for_parms (last_function_parms);
                   9526: 
                   9527:   return result;
                   9528: }
                   9529: 
                   9530: /* These memoizing functions keep track of special properties which
                   9531:    a class may have.  `grok_ctor_properties' notices whether a class
                   9532:    has a constructor of the form X(X&), and also complains
                   9533:    if the class has a constructor of the form X(X).
                   9534:    `grok_op_properties' takes notice of the various forms of
                   9535:    operator= which are defined, as well as what sorts of type conversion
                   9536:    may apply.  Both functions take a FUNCTION_DECL as an argument.  */
                   9537: void
                   9538: grok_ctor_properties (ctype, decl)
                   9539:      tree ctype, decl;
                   9540: {
                   9541:   tree parmtypes = FUNCTION_ARG_CHAIN (decl);
                   9542:   tree parmtype = parmtypes ? TREE_VALUE (parmtypes) : void_type_node;
                   9543: 
                   9544:   /* When a type has virtual baseclasses, a magical first int argument is
                   9545:      added to any ctor so we can tell if the class has been initialized
                   9546:      yet.  This could screw things up in this function, so we deliberately
                   9547:      ignore the leading int if we're in that situation.  */
                   9548:   if (parmtypes
                   9549:       && TREE_VALUE (parmtypes) == integer_type_node
                   9550:       && TYPE_USES_VIRTUAL_BASECLASSES (ctype))
                   9551:     {
                   9552:       parmtypes = TREE_CHAIN (parmtypes);
                   9553:       parmtype = TREE_VALUE (parmtypes);
                   9554:     }
                   9555: 
                   9556:   if (TREE_CODE (parmtype) == REFERENCE_TYPE
                   9557:       && TYPE_MAIN_VARIANT (TREE_TYPE (parmtype)) == ctype)
                   9558:     {
                   9559:       if (TREE_CHAIN (parmtypes) == NULL_TREE
                   9560:          || TREE_CHAIN (parmtypes) == void_list_node
                   9561:          || TREE_PURPOSE (TREE_CHAIN (parmtypes)))
                   9562:        {
                   9563:          TYPE_HAS_INIT_REF (ctype) = 1;
                   9564:          TYPE_GETS_INIT_REF (ctype) = 1;
                   9565:          if (TYPE_READONLY (TREE_TYPE (parmtype)))
                   9566:            TYPE_GETS_CONST_INIT_REF (ctype) = 1;
                   9567:        }
                   9568:       else
                   9569:        TYPE_GETS_INIT_AGGR (ctype) = 1;
                   9570:     }
                   9571:   else if (TYPE_MAIN_VARIANT (parmtype) == ctype)
                   9572:     {
                   9573:       if (TREE_CHAIN (parmtypes) != NULL_TREE
                   9574:          && TREE_CHAIN (parmtypes) == void_list_node)
                   9575:        error ("invalid constructor; you probably meant `%s (%s&)'",
                   9576:               TYPE_NAME_STRING (ctype),
                   9577:               TYPE_NAME_STRING (ctype));
                   9578:       SET_IDENTIFIER_ERROR_LOCUS (DECL_NAME (decl), ctype);
                   9579:       TYPE_GETS_INIT_AGGR (ctype) = 1;
                   9580:     }
                   9581:   else if (TREE_CODE (parmtype) == VOID_TYPE
                   9582:           || TREE_PURPOSE (parmtypes) != NULL_TREE)
                   9583:     TYPE_HAS_DEFAULT_CONSTRUCTOR (ctype) = 1;
                   9584: }
                   9585: 
                   9586: /* An operator with this name can be either unary or binary.  */
                   9587: int ambi_op_p (name)
                   9588:      tree name;
                   9589: {
                   9590:   return (name == ansi_opname [(int) INDIRECT_REF]
                   9591:          || name == ansi_opname [(int) ADDR_EXPR]
                   9592:          || name == ansi_opname [(int) NEGATE_EXPR]
                   9593:          || name == ansi_opname[(int) POSTINCREMENT_EXPR]
                   9594:          || name == ansi_opname[(int) POSTDECREMENT_EXPR]
                   9595:          || name == ansi_opname [(int) CONVERT_EXPR]);
                   9596: }
                   9597: 
                   9598: /* An operator with this name can only be unary.  */
                   9599: int unary_op_p (name)
                   9600:      tree name;
                   9601: {
                   9602:   return (name == ansi_opname [(int) TRUTH_NOT_EXPR]
                   9603:          || name == ansi_opname [(int) BIT_NOT_EXPR]
                   9604:          || name == ansi_opname [(int) COMPONENT_REF]
                   9605:          || OPERATOR_TYPENAME_P (name));
                   9606: }
                   9607: 
                   9608: /* Do a little sanity-checking on how they declared their operator.  */
                   9609: static void
                   9610: grok_op_properties (decl, virtualp)
                   9611:      tree decl;
                   9612:      int virtualp;
                   9613: {
                   9614:   tree argtypes = TYPE_ARG_TYPES (TREE_TYPE (decl));
                   9615:   int methodp = (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE);
                   9616:   tree name = DECL_NAME (decl);
                   9617: 
                   9618:   if (name == ansi_opname[(int) NEW_EXPR])
                   9619:     {
                   9620: #if 0 /* When the compiler encounters the definition of A::operator new, it
                   9621:         doesn't look at the class declaration to find out if it's static.  */
                   9622:        my_friendly_assert (!methodp, 355);
                   9623: #endif
                   9624:      
                   9625:       /* Take care of function decl if we had syntax errors.  */
                   9626:       if (argtypes == NULL_TREE)
                   9627:        TREE_TYPE (decl) =
                   9628:          build_function_type (ptr_type_node,
                   9629:                               hash_tree_chain (integer_type_node,
                   9630:                                                void_list_node));
                   9631:       else
                   9632:        decl = coerce_new_type (TREE_TYPE (decl));
                   9633:     }
                   9634:   else if (name == ansi_opname[(int) DELETE_EXPR])
                   9635:     {
                   9636: #if 0
                   9637:        my_friendly_assert (!methodp, 355);
                   9638: #endif
                   9639:      
                   9640:       if (argtypes == NULL_TREE)
                   9641:        TREE_TYPE (decl) =
                   9642:          build_function_type (void_type_node,
                   9643:                               hash_tree_chain (ptr_type_node,
                   9644:                                                void_list_node));
                   9645:       else
                   9646:        decl = coerce_delete_type (TREE_TYPE (decl));
                   9647:     }
                   9648:   /* 13.4.0.3 */
                   9649:   else if (name == ansi_opname[(int) COND_EXPR])
                   9650:     error("`operator ?:' cannot be overloaded");
                   9651:   else
                   9652:     {
                   9653:       /* An operator function must either be a non-static member function
                   9654:         or have at least one parameter of a class, a reference to a class,
                   9655:         an enumeration, or a reference to an enumeration.  13.4.0.6 */
                   9656:       if (! methodp)
                   9657:        {
                   9658:          if (OPERATOR_TYPENAME_P (name)
                   9659:              || name == ansi_opname[(int) CALL_EXPR]
                   9660:              || name == ansi_opname[(int) MODIFY_EXPR]
                   9661:              || name == ansi_opname[(int) COMPONENT_REF]
                   9662:              || name == ansi_opname[(int) ARRAY_REF])
                   9663:            cp_error ("`%D' must be a nonstatic member function", decl);
                   9664:          else
                   9665:            {
                   9666:              tree p = argtypes;
                   9667: 
                   9668:              if (p)
                   9669:                for (; TREE_VALUE (p) != void_type_node ; p = TREE_CHAIN (p))
                   9670:                  {
                   9671:                    tree arg = TREE_VALUE (p);
                   9672:                    if (TREE_CODE (arg) == REFERENCE_TYPE)
                   9673:                      arg = TREE_TYPE (arg);
                   9674: 
                   9675:                    /* This lets bad template code slip through.  */
                   9676:                    if (IS_AGGR_TYPE (arg)
                   9677:                        || TREE_CODE (arg) == ENUMERAL_TYPE
                   9678:                        || TREE_CODE (arg) == TEMPLATE_TYPE_PARM)
                   9679:                      goto foundaggr;
                   9680:                  }
                   9681:              cp_error
                   9682:                ("`%D' must have an argument of class or enumerated type",
                   9683:                 decl);
                   9684:            foundaggr:
                   9685:              ;
                   9686:            }
                   9687:        }
                   9688:       
                   9689:       if (name == ansi_opname[(int) CALL_EXPR]
                   9690:          || name == ansi_opname[(int) METHOD_CALL_EXPR])
                   9691:        return;                 /* no restrictions on args */
                   9692: 
                   9693:       if (name == ansi_opname[(int) MODIFY_EXPR])
                   9694:        {
                   9695:          tree parmtype;
                   9696: 
                   9697:          if (list_length (argtypes) != 3 && methodp)
                   9698:            {
                   9699:              cp_error ("`%D' must take exactly one argument", decl);
                   9700:              return;
                   9701:            }
                   9702:          parmtype = TREE_VALUE (TREE_CHAIN (argtypes));
                   9703: 
                   9704:          if (TREE_CODE (parmtype) == REFERENCE_TYPE
                   9705:              && TREE_TYPE (parmtype) == current_class_type)
                   9706:            {
                   9707:              TYPE_HAS_ASSIGN_REF (current_class_type) = 1;
                   9708:              TYPE_GETS_ASSIGN_REF (current_class_type) = 1;
                   9709:              if (TYPE_READONLY (TREE_TYPE (parmtype)))
                   9710:                TYPE_GETS_CONST_INIT_REF (current_class_type) = 1;
                   9711:            }
                   9712:        }
                   9713:       else if (ambi_op_p (name))
                   9714:        {
                   9715:          if (list_length (argtypes) == 2)
                   9716:            /* prefix */;
                   9717:          else if (list_length (argtypes) == 3)
                   9718:            {
                   9719:              if ((name == ansi_opname[(int) POSTINCREMENT_EXPR]
                   9720:                   || name == ansi_opname[(int) POSTDECREMENT_EXPR])
                   9721:                  && TREE_VALUE (TREE_CHAIN (argtypes)) != integer_type_node)
                   9722:                {
                   9723:                  if (methodp)
                   9724:                    cp_error ("postfix `%D' must take `int' as its argument",
                   9725:                              decl);
                   9726:                  else
                   9727:                    cp_error
                   9728:                      ("postfix `%D' must take `int' as its second argument",
                   9729:                       decl);
                   9730:                }
                   9731:            }
                   9732:          else
                   9733:            {
                   9734:              if (methodp)
                   9735:                cp_error ("`%D' must take either zero or one argument", decl);
                   9736:              else
                   9737:                cp_error ("`%D' must take either one or two arguments", decl);
                   9738:            }
                   9739:        }
                   9740:       else if (unary_op_p (name))
                   9741:        {
                   9742:          if (list_length (argtypes) != 2)
                   9743:            {
                   9744:              if (methodp)
                   9745:                cp_error ("`%D' must take `void'", decl);
                   9746:              else
                   9747:                cp_error ("`%D' must take exactly one argument", decl);
                   9748:            }
                   9749:        }
                   9750:       else /* if (binary_op_p (name)) */
                   9751:        {
                   9752:          if (list_length (argtypes) != 3)
                   9753:            {
                   9754:              if (methodp)
                   9755:                cp_error ("`%D' must take exactly one argument", decl);
                   9756:              else
                   9757:                cp_error ("`%D' must take exactly two arguments", decl);
                   9758:            }
                   9759:        }
                   9760: 
                   9761:       /* 13.4.0.8 */
                   9762:       if (argtypes)
                   9763:        for (; argtypes != void_list_node ; argtypes = TREE_CHAIN (argtypes))
                   9764:          if (TREE_PURPOSE (argtypes))
                   9765:            {
                   9766:              TREE_PURPOSE (argtypes) = NULL_TREE;
                   9767:              cp_error ("`%D' cannot have default arguments", decl);
                   9768:            }
                   9769:     }
                   9770: }
                   9771: 
                   9772: /* Get the struct, enum or union (CODE says which) with tag NAME.
                   9773:    Define the tag as a forward-reference if it is not defined.
                   9774: 
                   9775:    C++: If a class derivation is given, process it here, and report
                   9776:    an error if multiple derivation declarations are not identical.
                   9777: 
                   9778:    If this is a definition, come in through xref_tag and only look in
                   9779:    the current frame for the name (since C++ allows new names in any
                   9780:    scope.)  */
                   9781: 
                   9782: /* avoid rewriting all callers of xref_tag */
                   9783: static int xref_next_defn = 0;
                   9784: 
                   9785: tree
                   9786: xref_defn_tag (code_type_node, name, binfo)
                   9787:      tree code_type_node;
                   9788:      tree name, binfo;
                   9789: {
                   9790:   tree rv, ncp;
                   9791:   xref_next_defn = 1;
                   9792: 
                   9793:   if (class_binding_level)
                   9794:     {
                   9795:       tree n1;
                   9796:       char *buf;
                   9797:       /* we need to build a new IDENTIFIER_NODE for name which nukes
                   9798:        * the pieces... */
                   9799:       n1 = IDENTIFIER_LOCAL_VALUE (current_class_name);
                   9800:       if (n1)
                   9801:        n1 = DECL_NAME (n1);
                   9802:       else
                   9803:        n1 = current_class_name;
                   9804:       
                   9805:       buf = (char *) alloca (4 + IDENTIFIER_LENGTH (n1)
                   9806:                             + IDENTIFIER_LENGTH (name));
                   9807:       
                   9808:       sprintf (buf, "%s::%s", IDENTIFIER_POINTER (n1),
                   9809:               IDENTIFIER_POINTER (name));
                   9810:       ncp = get_identifier (buf);
                   9811: #ifdef SPEW_DEBUG
                   9812:       if (spew_debug)
                   9813:        printf("*** %s ***\n", IDENTIFIER_POINTER (ncp));
                   9814: #endif
                   9815: #if 0
                   9816:       IDENTIFIER_LOCAL_VALUE (name) =
                   9817:        build_lang_decl (TYPE_DECL, ncp, NULL_TREE);
                   9818: #endif
                   9819:       rv = xref_tag (code_type_node, name, binfo);
                   9820:       {
                   9821:        register tree type_decl = build_lang_decl (TYPE_DECL, ncp, rv);
                   9822: #ifdef DWARF_DEBUGGING_INFO
                   9823:        /* Mark the TYPE_DECL node created just above as a gratuitous one
                   9824:           so that dwarfout.c will know not to generate a TAG_typedef DIE
                   9825:           for it.  */
                   9826:        if (write_symbols == DWARF_DEBUG)
                   9827:          DECL_IGNORED_P (type_decl) = 1;
                   9828: #endif /* DWARF_DEBUGGING_INFO */
                   9829:        pushdecl_top_level (type_decl);
                   9830:       }
                   9831:     }
                   9832:   else
                   9833:     {
                   9834:       rv = xref_tag (code_type_node, name, binfo);
                   9835:     }
                   9836:   xref_next_defn = 0;
                   9837:   return rv;
                   9838: }
                   9839: 
                   9840: tree
                   9841: xref_tag (code_type_node, name, binfo)
                   9842:      tree code_type_node;
                   9843:      tree name, binfo;
                   9844: {
                   9845:   enum tag_types tag_code;
                   9846:   enum tree_code code;
                   9847:   int temp = 0;
                   9848:   int i, len;
                   9849:   register tree ref;
                   9850:   struct binding_level *b
                   9851:     = (class_binding_level ? class_binding_level : current_binding_level);
                   9852: 
                   9853:   tag_code = (enum tag_types) TREE_INT_CST_LOW (code_type_node);
                   9854:   switch (tag_code)
                   9855:     {
                   9856:     case record_type:
                   9857:     case class_type:
                   9858:     case exception_type:
                   9859:       code = RECORD_TYPE;
                   9860:       len = list_length (binfo);
                   9861:       break;
                   9862:     case union_type:
                   9863:       code = UNION_TYPE;
                   9864:       if (binfo)
                   9865:        {
                   9866:          cp_error ("derived union `%T' invalid", name);
                   9867:          binfo = NULL_TREE;
                   9868:        }
                   9869:       len = 0;
                   9870:       break;
                   9871:     case enum_type:
                   9872:       code = ENUMERAL_TYPE;
                   9873:       break;
                   9874:     default:
                   9875:       my_friendly_abort (18);
                   9876:     }
                   9877: 
                   9878:   /* If a cross reference is requested, look up the type
                   9879:      already defined for this tag and return it.  */
                   9880:   if (xref_next_defn)
                   9881:     {
                   9882:       /* If we know we are defining this tag, only look it up in this scope
                   9883:        * and don't try to find it as a type. */
                   9884:       xref_next_defn = 0;
                   9885:       ref = lookup_tag (code, name, b, 1);
                   9886:     }
                   9887:   else
                   9888:     {
                   9889:       ref = lookup_tag (code, name, b, 0);
                   9890: 
                   9891:       if (! ref)
                   9892:        {
                   9893:          /* Try finding it as a type declaration.  If that wins, use it.  */
                   9894:          ref = lookup_name (name, 1);
                   9895:          if (ref && TREE_CODE (ref) == TYPE_DECL
                   9896:              && TREE_CODE (TREE_TYPE (ref)) == code)
                   9897:            ref = TREE_TYPE (ref);
                   9898:          else
                   9899:            ref = NULL_TREE;
                   9900:        }
                   9901:     }
                   9902: 
                   9903:   push_obstacks_nochange ();
                   9904: 
                   9905:   if (! ref)
                   9906:     {
                   9907:       /* If no such tag is yet defined, create a forward-reference node
                   9908:         and record it as the "definition".
                   9909:         When a real declaration of this type is found,
                   9910:         the forward-reference will be altered into a real type.  */
                   9911: 
                   9912:       /* In C++, since these migrate into the global scope, we must
                   9913:         build them on the permanent obstack.  */
                   9914: 
                   9915:       temp = allocation_temporary_p ();
                   9916:       if (temp)
                   9917:        end_temporary_allocation ();
                   9918: 
                   9919:       if (code == ENUMERAL_TYPE)
                   9920:        {
                   9921:          ref = make_node (ENUMERAL_TYPE);
                   9922: 
                   9923:          /* Give the type a default layout like unsigned int
                   9924:             to avoid crashing if it does not get defined.  */
                   9925:          TYPE_MODE (ref) = TYPE_MODE (unsigned_type_node);
                   9926:          TYPE_ALIGN (ref) = TYPE_ALIGN (unsigned_type_node);
                   9927:          TREE_UNSIGNED (ref) = 1;
                   9928:          TYPE_PRECISION (ref) = TYPE_PRECISION (unsigned_type_node);
                   9929:          TYPE_MIN_VALUE (ref) = TYPE_MIN_VALUE (unsigned_type_node);
                   9930:          TYPE_MAX_VALUE (ref) = TYPE_MAX_VALUE (unsigned_type_node);
                   9931: 
                   9932:          /* Enable us to recognize when a type is created in class context.
                   9933:             To do nested classes correctly, this should probably be cleared
                   9934:             out when we leave this classes scope.  Currently this in only
                   9935:             done in `start_enum'.  */
                   9936: 
                   9937:          pushtag (name, ref);
                   9938:          if (flag_cadillac)
                   9939:            cadillac_start_enum (ref);
                   9940:        }
                   9941:       else if (tag_code == exception_type)
                   9942:        {
                   9943:          ref = make_lang_type (code);
                   9944:          /* Enable us to recognize when an exception type is created in
                   9945:             class context.  To do nested classes correctly, this should
                   9946:             probably be cleared out when we leave this class's scope.  */
                   9947:          CLASSTYPE_DECLARED_EXCEPTION (ref) = 1;
                   9948:          pushtag (name, ref);
                   9949:          if (flag_cadillac)
                   9950:            cadillac_start_struct (ref);
                   9951:        }
                   9952:       else
                   9953:        {
                   9954:          extern tree pending_vtables;
                   9955:          struct binding_level *old_b = class_binding_level;
                   9956:          int needs_writing;
                   9957: 
                   9958:          ref = make_lang_type (code);
                   9959: 
                   9960:          /* Record how to set the visibility of this class's
                   9961:             virtual functions.  If write_virtuals == 2 or 3, then
                   9962:             inline virtuals are ``extern inline''.  */
                   9963:          switch (write_virtuals)
                   9964:            {
                   9965:            case 0:
                   9966:            case 1:
                   9967:              needs_writing = 1;
                   9968:              break;
                   9969:            case 2:
                   9970:              needs_writing = !! value_member (name, pending_vtables);
                   9971:              break;
                   9972:            case 3:
                   9973:              needs_writing = ! CLASSTYPE_INTERFACE_ONLY (ref)
                   9974:                && CLASSTYPE_INTERFACE_KNOWN (ref);
                   9975:              break;
                   9976:            default:
                   9977:              needs_writing = 0;
                   9978:            }
                   9979: 
                   9980:          CLASSTYPE_VTABLE_NEEDS_WRITING (ref) = needs_writing;
                   9981: 
                   9982: #ifdef NONNESTED_CLASSES
                   9983:          /* Class types don't nest the way enums do.  */
                   9984:          class_binding_level = (struct binding_level *)0;
                   9985: #endif
                   9986:          pushtag (name, ref);
                   9987:          class_binding_level = old_b;
                   9988: 
                   9989:          if (flag_cadillac)
                   9990:            cadillac_start_struct (ref);
                   9991:        }
                   9992:     }
                   9993:   else
                   9994:     {
                   9995:       if (IS_AGGR_TYPE_CODE (code))
                   9996:        {
                   9997:          if (IS_AGGR_TYPE (ref)
                   9998:              && ((tag_code == exception_type)
                   9999:                  != (CLASSTYPE_DECLARED_EXCEPTION (ref) == 1)))
                   10000:            {
                   10001:              cp_error ("type `%T' is both exception and aggregate type", ref);
                   10002:              CLASSTYPE_DECLARED_EXCEPTION (ref) = (tag_code == exception_type);
                   10003:            }
                   10004:        }
                   10005: 
                   10006:       /* If it no longer looks like a nested type, make sure it's
                   10007:         in global scope.  */
                   10008:       if (b == global_binding_level && !class_binding_level
                   10009:          && IDENTIFIER_GLOBAL_VALUE (name) == NULL_TREE)
                   10010:        IDENTIFIER_GLOBAL_VALUE (name) = TYPE_NAME (ref);
                   10011: 
                   10012:       if (binfo)
                   10013:        {
                   10014:          tree tt1 = binfo;
                   10015:          tree tt2 = TYPE_BINFO_BASETYPES (ref);
                   10016: 
                   10017:          if (TYPE_BINFO_BASETYPES (ref))
                   10018:            for (i = 0; tt1; i++, tt1 = TREE_CHAIN (tt1))
                   10019:              if (TREE_VALUE (tt1) != TYPE_IDENTIFIER (BINFO_TYPE (TREE_VEC_ELT (tt2, i))))
                   10020:                {
                   10021:                  cp_error ("redeclaration of derivation chain of type `%#T'",
                   10022:                            ref);
                   10023:                  break;
                   10024:                }
                   10025: 
                   10026:          if (tt1 == NULL_TREE)
                   10027:            /* The user told us something we already knew.  */
                   10028:            goto just_return;
                   10029: 
                   10030:          /* In C++, since these migrate into the global scope, we must
                   10031:             build them on the permanent obstack.  */
                   10032:          end_temporary_allocation ();
                   10033:        }
                   10034:     }
                   10035: 
                   10036:   if (binfo)
                   10037:     {
                   10038:       /* In the declaration `A : X, Y, ... Z' we mark all the types
                   10039:         (A, X, Y, ..., Z) so we can check for duplicates.  */
                   10040:       tree binfos;
                   10041: 
                   10042:       SET_CLASSTYPE_MARKED (ref);
                   10043:       BINFO_BASETYPES (TYPE_BINFO (ref)) = binfos = make_tree_vec (len);
                   10044: 
                   10045:       for (i = 0; binfo; binfo = TREE_CHAIN (binfo))
                   10046:        {
                   10047:          /* The base of a derived struct is public.  */
                   10048:          int via_public = (tag_code != class_type
                   10049:                            || TREE_PURPOSE (binfo) == (tree)visibility_public
                   10050:                            || TREE_PURPOSE (binfo) == (tree)visibility_public_virtual);
                   10051:          int via_protected = TREE_PURPOSE (binfo) == (tree)visibility_protected;
                   10052:          int via_virtual = (TREE_PURPOSE (binfo) == (tree)visibility_private_virtual
                   10053:                             || TREE_PURPOSE (binfo) == (tree)visibility_public_virtual
                   10054:                             || TREE_PURPOSE (binfo) == (tree)visibility_default_virtual);
                   10055:          tree basetype = TREE_TYPE (TREE_VALUE (binfo));
                   10056:          tree base_binfo;
                   10057: 
                   10058:          GNU_xref_hier (IDENTIFIER_POINTER (name),
                   10059:                         IDENTIFIER_POINTER (TREE_VALUE (binfo)),
                   10060:                         via_public, via_virtual, 0);
                   10061: 
                   10062:          if (basetype && TREE_CODE (basetype) == TYPE_DECL)
                   10063:            basetype = TREE_TYPE (basetype);
                   10064:          if (!basetype || TREE_CODE (basetype) != RECORD_TYPE)
                   10065:            {
                   10066:              error ("base type `%s' fails to be a struct or class type",
                   10067:                     IDENTIFIER_POINTER (TREE_VALUE (binfo)));
                   10068:              continue;
                   10069:            }
                   10070: #if 1
                   10071:          /* This code replaces similar code in layout_basetypes.  */
                   10072:          else if (TYPE_SIZE (basetype) == NULL_TREE)
                   10073:            {
                   10074:              cp_error ("base class `%T' has incomplete type", basetype);
                   10075:              continue;
                   10076:            }
                   10077: #endif
                   10078:          else
                   10079:            {
                   10080:              if (CLASSTYPE_MARKED (basetype))
                   10081:                {
                   10082:                  if (basetype == ref)
                   10083:                    cp_error ("recursive type `%T' undefined", basetype);
                   10084:                  else
                   10085:                    cp_error ("duplicate base type `%T' invalid", basetype);
                   10086:                  continue;
                   10087:                }
                   10088: 
                   10089:              /* Note that the BINFO records which describe individual
                   10090:                 inheritances are *not* shared in the lattice!  They
                   10091:                 cannot be shared because a given baseclass may be
                   10092:                 inherited with different `accessibility' by different
                   10093:                 derived classes.  (Each BINFO record describing an
                   10094:                 individual inheritance contains flags which say what
                   10095:                 the `accessibility' of that particular inheritance is.)  */
                   10096:   
                   10097:              base_binfo = make_binfo (integer_zero_node, basetype,
                   10098:                                  TYPE_BINFO_VTABLE (basetype),
                   10099:                                  TYPE_BINFO_VIRTUALS (basetype), 0);
                   10100:  
                   10101:              TREE_VEC_ELT (binfos, i) = base_binfo;
                   10102:              TREE_VIA_PUBLIC (base_binfo) = via_public;
                   10103:              TREE_VIA_PROTECTED (base_binfo) = via_protected;
                   10104:              TREE_VIA_VIRTUAL (base_binfo) = via_virtual;
                   10105: 
                   10106:              SET_CLASSTYPE_MARKED (basetype);
                   10107: #if 0
                   10108: /* XYZZY TEST VIRTUAL BASECLASSES */
                   10109: if (CLASSTYPE_N_BASECLASSES (basetype) == NULL_TREE
                   10110:     && TYPE_HAS_DEFAULT_CONSTRUCTOR (basetype)
                   10111:     && via_virtual == 0)
                   10112:   {
                   10113:     warning ("making type `%s' a virtual baseclass",
                   10114:             TYPE_NAME_STRING (basetype));
                   10115:     via_virtual = 1;
                   10116:   }
                   10117: #endif
                   10118:              /* We are free to modify these bits because they are meaningless
                   10119:                 at top level, and BASETYPE is a top-level type.  */
                   10120:              if (via_virtual || TYPE_USES_VIRTUAL_BASECLASSES (basetype))
                   10121:                {
                   10122:                  TYPE_USES_VIRTUAL_BASECLASSES (ref) = 1;
                   10123:                  TYPE_USES_COMPLEX_INHERITANCE (ref) = 1;
                   10124:                }
                   10125: 
                   10126:              TYPE_GETS_ASSIGNMENT (ref) |= TYPE_GETS_ASSIGNMENT (basetype);
                   10127:              TYPE_OVERLOADS_METHOD_CALL_EXPR (ref) |= TYPE_OVERLOADS_METHOD_CALL_EXPR (basetype);
                   10128:              TREE_GETS_NEW (ref) |= TREE_GETS_NEW (basetype);
                   10129:              TREE_GETS_DELETE (ref) |= TREE_GETS_DELETE (basetype);
                   10130:              CLASSTYPE_LOCAL_TYPEDECLS (ref) |= CLASSTYPE_LOCAL_TYPEDECLS (basetype);
                   10131:              i += 1;
                   10132:            }
                   10133:        }
                   10134:       if (i)
                   10135:        TREE_VEC_LENGTH (binfos) = i;
                   10136:       else
                   10137:        BINFO_BASETYPES (TYPE_BINFO (ref)) = NULL_TREE;
                   10138: 
                   10139:       if (i > 1)
                   10140:        TYPE_USES_MULTIPLE_INHERITANCE (ref) = 1;
                   10141:       else if (i == 1)
                   10142:        TYPE_USES_MULTIPLE_INHERITANCE (ref)
                   10143:          = TYPE_USES_MULTIPLE_INHERITANCE (BINFO_TYPE (TREE_VEC_ELT (binfos, 0)));
                   10144:       if (TYPE_USES_MULTIPLE_INHERITANCE (ref))
                   10145:        TYPE_USES_COMPLEX_INHERITANCE (ref) = 1;
                   10146: 
                   10147:       /* Unmark all the types.  */
                   10148:       while (--i >= 0)
                   10149:        CLEAR_CLASSTYPE_MARKED (BINFO_TYPE (TREE_VEC_ELT (binfos, i)));
                   10150:       CLEAR_CLASSTYPE_MARKED (ref);
                   10151:     }
                   10152: 
                   10153:  just_return:
                   10154: 
                   10155:   /* Until the type is defined, tentatively accept whatever
                   10156:      structure tag the user hands us.  */
                   10157:   if (TYPE_SIZE (ref) == NULL_TREE
                   10158:       && ref != current_class_type
                   10159:       /* Have to check this, in case we have contradictory tag info.  */
                   10160:       && IS_AGGR_TYPE_CODE (TREE_CODE (ref)))
                   10161:     {
                   10162:       if (tag_code == class_type)
                   10163:        CLASSTYPE_DECLARED_CLASS (ref) = 1;
                   10164:       else if (tag_code == record_type)
                   10165:        CLASSTYPE_DECLARED_CLASS (ref) = 0;
                   10166:     }
                   10167: 
                   10168:   pop_obstacks ();
                   10169: 
                   10170:   return ref;
                   10171: }
                   10172: 
                   10173: static tree current_local_enum = NULL_TREE;
                   10174: 
                   10175: /* Begin compiling the definition of an enumeration type.
                   10176:    NAME is its name (or null if anonymous).
                   10177:    Returns the type object, as yet incomplete.
                   10178:    Also records info about it so that build_enumerator
                   10179:    may be used to declare the individual values as they are read.  */
                   10180: 
                   10181: tree
                   10182: start_enum (name)
                   10183:      tree name;
                   10184: {
                   10185:   register tree enumtype = NULL_TREE;
                   10186:   struct binding_level *b
                   10187:     = (class_binding_level ? class_binding_level : current_binding_level);
                   10188: 
                   10189:   /* If this is the real definition for a previous forward reference,
                   10190:      fill in the contents in the same object that used to be the
                   10191:      forward reference.  */
                   10192: 
                   10193:   if (name != NULL_TREE)
                   10194:     enumtype = lookup_tag (ENUMERAL_TYPE, name, b, 1);
                   10195: 
                   10196:   if (enumtype != NULL_TREE && TREE_CODE (enumtype) == ENUMERAL_TYPE)
                   10197:     cp_error ("multiple definition of enum `%T'", enumtype);
                   10198:   else
                   10199:     {
                   10200:       enumtype = make_node (ENUMERAL_TYPE);
                   10201:       pushtag (name, enumtype);
                   10202:     }
                   10203: 
                   10204:   if (current_class_type)
                   10205:     TREE_ADDRESSABLE (b->tags) = 1;
                   10206:   current_local_enum = NULL_TREE;
                   10207: 
                   10208:   if (TYPE_VALUES (enumtype) != NULL_TREE)
                   10209:     /* Completely replace its old definition.
                   10210:        The old enumerators remain defined, however.  */
                   10211:     TYPE_VALUES (enumtype) = NULL_TREE;
                   10212: 
                   10213:   /* Initially, set up this enum as like `int'
                   10214:      so that we can create the enumerators' declarations and values.
                   10215:      Later on, the precision of the type may be changed and
                   10216:      it may be laid out again.  */
                   10217: 
                   10218:   TYPE_PRECISION (enumtype) = TYPE_PRECISION (integer_type_node);
                   10219:   TYPE_SIZE (enumtype) = NULL_TREE;
                   10220:   fixup_unsigned_type (enumtype);
                   10221: 
                   10222:   /* We copy this value because enumerated type constants
                   10223:      are really of the type of the enumerator, not integer_type_node.  */
                   10224:   enum_next_value = copy_node (integer_zero_node);
                   10225: 
                   10226:   GNU_xref_decl (current_function_decl, enumtype);
                   10227:   return enumtype;
                   10228: }
                   10229: 
                   10230: /* After processing and defining all the values of an enumeration type,
                   10231:    install their decls in the enumeration type and finish it off.
                   10232:    ENUMTYPE is the type object and VALUES a list of name-value pairs.
                   10233:    Returns ENUMTYPE.  */
                   10234: 
                   10235: tree
                   10236: finish_enum (enumtype, values)
                   10237:      register tree enumtype, values;
                   10238: {
                   10239:   register tree pair, tem;
                   10240:   register HOST_WIDE_INT maxvalue = 0;
                   10241:   register HOST_WIDE_INT minvalue = 0;
                   10242:   register HOST_WIDE_INT i;
                   10243: 
                   10244:   TYPE_VALUES (enumtype) = values;
                   10245: 
                   10246:   /* Calculate the maximum value of any enumerator in this type.  */
                   10247: 
                   10248:   if (values)
                   10249:     {
                   10250:       /* Speed up the main loop by performing some precalculations */
                   10251: 
                   10252:       HOST_WIDE_INT value = TREE_INT_CST_LOW (TREE_VALUE (values));
                   10253:       TREE_TYPE (TREE_VALUE (values)) = enumtype;
                   10254:       minvalue = maxvalue = value;
                   10255:       
                   10256:       for (pair = TREE_CHAIN (values); pair; pair = TREE_CHAIN (pair))
                   10257:        {
                   10258:          value = TREE_INT_CST_LOW (TREE_VALUE (pair));
                   10259:          if (value > maxvalue)
                   10260:            maxvalue = value;
                   10261:          else if (value < minvalue)
                   10262:            minvalue = value;
                   10263:          TREE_TYPE (TREE_VALUE (pair)) = enumtype;
                   10264:        }
                   10265:     }
                   10266: 
                   10267:   if (flag_short_enums)
                   10268:     {
                   10269:       /* Determine the precision this type needs, lay it out, and define it.  */
                   10270: 
                   10271:       for (i = maxvalue; i; i >>= 1)
                   10272:        TYPE_PRECISION (enumtype)++;
                   10273: 
                   10274:       if (!TYPE_PRECISION (enumtype))
                   10275:        TYPE_PRECISION (enumtype) = 1;
                   10276: 
                   10277:       /* Cancel the laying out previously done for the enum type,
                   10278:         so that fixup_unsigned_type will do it over.  */
                   10279:       TYPE_SIZE (enumtype) = NULL_TREE;
                   10280: 
                   10281:       fixup_unsigned_type (enumtype);
                   10282:     }
                   10283: 
                   10284:   TREE_INT_CST_LOW (TYPE_MAX_VALUE (enumtype)) = maxvalue;
                   10285: 
                   10286:   /* An enum can have some negative values; then it is signed.  */
                   10287:   if (minvalue < 0)
                   10288:     {
                   10289:       TREE_INT_CST_LOW (TYPE_MIN_VALUE (enumtype)) = minvalue;
                   10290:       TREE_INT_CST_HIGH (TYPE_MIN_VALUE (enumtype)) = -1;
                   10291:       TREE_UNSIGNED (enumtype) = 0;
                   10292:     }
                   10293:   if (flag_cadillac)
                   10294:     cadillac_finish_enum (enumtype);
                   10295: 
                   10296:   /* Fix up all variant types of this enum type.  */
                   10297:   for (tem = TYPE_MAIN_VARIANT (enumtype); tem; tem = TYPE_NEXT_VARIANT (tem))
                   10298:     {
                   10299:       TYPE_VALUES (tem) = TYPE_VALUES (enumtype);
                   10300:       TYPE_MIN_VALUE (tem) = TYPE_MIN_VALUE (enumtype);
                   10301:       TYPE_MAX_VALUE (tem) = TYPE_MAX_VALUE (enumtype);
                   10302:       TYPE_SIZE (tem) = TYPE_SIZE (enumtype);
                   10303:       TYPE_MODE (tem) = TYPE_MODE (enumtype);
                   10304:       TYPE_PRECISION (tem) = TYPE_PRECISION (enumtype);
                   10305:       TYPE_ALIGN (tem) = TYPE_ALIGN (enumtype);
                   10306:       TREE_UNSIGNED (tem) = TREE_UNSIGNED (enumtype);
                   10307:     }
                   10308: 
                   10309:   /* Finish debugging output for this type.  */
                   10310: #if 0
                   10311:   /* @@ Do we ever generate generate ENUMERAL_TYPE nodes for which debugging
                   10312:      information should *not* be generated?  I think not.  */
                   10313:   if (! DECL_IGNORED_P (TYPE_NAME (enumtype)))
                   10314: #endif
                   10315:     rest_of_type_compilation (enumtype, global_bindings_p ());
                   10316: 
                   10317:   return enumtype;
                   10318: }
                   10319: 
                   10320: /* Build and install a CONST_DECL for one value of the
                   10321:    current enumeration type (one that was begun with start_enum).
                   10322:    Return a tree-list containing the name and its value.
                   10323:    Assignment of sequential values by default is handled here.  */
                   10324: 
                   10325: tree
                   10326: build_enumerator (name, value)
                   10327:      tree name, value;
                   10328: {
                   10329:   tree decl, result;
                   10330:   /* Change this to zero if we find VALUE is not shareable.  */
                   10331:   int shareable = 1;
                   10332: 
                   10333:   /* Remove no-op casts from the value.  */
                   10334:   if (value)
                   10335:     STRIP_TYPE_NOPS (value);
                   10336: 
                   10337:   /* Validate and default VALUE.  */
                   10338:   if (value != NULL_TREE)
                   10339:     {
                   10340:       if (TREE_READONLY_DECL_P (value))
                   10341:        {
                   10342:          value = decl_constant_value (value);
                   10343:          shareable = 0;
                   10344:        }
                   10345: 
                   10346:       if (TREE_CODE (value) == INTEGER_CST)
                   10347:        {
                   10348:          value = default_conversion (value);
                   10349:          constant_expression_warning (value);
                   10350:        }
                   10351:       else
                   10352:        {
                   10353:          error ("enumerator value for `%s' not integer constant",
                   10354:                 IDENTIFIER_POINTER (name));
                   10355:          value = NULL_TREE;
                   10356:        }
                   10357:     }
                   10358: 
                   10359:   /* The order of things is reversed here so that we
                   10360:      can check for possible sharing of enum values,
                   10361:      to keep that from happening.  */
                   10362:   /* Default based on previous value.  */
                   10363:   if (value == NULL_TREE)
                   10364:     value = enum_next_value;
                   10365: 
                   10366:   /* Remove no-op casts from the value.  */
                   10367:   if (value)
                   10368:     STRIP_TYPE_NOPS (value);
                   10369: 
                   10370:   /* Make up for hacks in cp-lex.c.  */
                   10371:   if (value == integer_zero_node)
                   10372:     value = build_int_2 (0, 0);
                   10373:   else if (value == integer_one_node)
                   10374:     value = build_int_2 (1, 0);
                   10375:   else if (TREE_CODE (value) == INTEGER_CST
                   10376:           && (shareable == 0
                   10377:               || TREE_CODE (TREE_TYPE (value)) == ENUMERAL_TYPE))
                   10378:     {
                   10379:       value = copy_node (value);
                   10380:       TREE_TYPE (value) = integer_type_node;
                   10381:     }
                   10382: 
                   10383:   result = saveable_tree_cons (name, value, NULL_TREE);
                   10384: 
                   10385:   /* C++ associates enums with global, function, or class declarations.  */
                   10386: 
                   10387:   /* There are a number of cases we need to be aware of here:
                   10388:                                current_class_type      current_function_decl
                   10389:      * global enums            NULL                    NULL
                   10390:      * fn-local enum           NULL                    SET
                   10391:      * class-local enum                SET                     NULL
                   10392:      * class->fn->enum         SET                     SET
                   10393:      * fn->class->enum         SET                     SET
                   10394: 
                   10395:      Those last two make life interesting.  If it's a fn-local enum which is
                   10396:      itself inside a class, we need the enum to go into the fn's decls (our
                   10397:      second case below).  But if it's a class-local enum and the class itself
                   10398:      is inside a function, we need that enum to go into the decls for the
                   10399:      class.  To achieve this last goal, we must see if, when both
                   10400:      current_class_decl and current_function_decl are set, the class was
                   10401:      declared inside that function.  If so, we know to put the enum into
                   10402:      the class's scope.  */
                   10403:      
                   10404:   if ((current_class_type && ! current_function_decl)
                   10405:       || (current_class_type && current_function_decl
                   10406:          && TYPE_CONTEXT (current_class_type) == current_function_decl))
                   10407:     {
                   10408:       /* This enum declaration is local to the class, so we must put
                   10409:         it in that class's list of decls.  */
                   10410:       decl = build_lang_field_decl (CONST_DECL, name, integer_type_node);
                   10411:       DECL_INITIAL (decl) = value;
                   10412:       TREE_READONLY (decl) = 1;
                   10413:       pushdecl_class_level (decl);
                   10414:       TREE_CHAIN (decl) = current_local_enum;
                   10415:       current_local_enum = decl;
                   10416:     }
                   10417:   else
                   10418:     {
                   10419:       /* It's a global enum, or it's local to a function.  (Note local to
                   10420:         a function could mean local to a class method.  */
                   10421:       decl = build_decl (CONST_DECL, name, integer_type_node);
                   10422:       DECL_INITIAL (decl) = value;
                   10423: 
                   10424:       pushdecl (decl);
                   10425:       GNU_xref_decl (current_function_decl, decl);
                   10426:     }
                   10427: 
                   10428:   /* Set basis for default for next value.  */
                   10429:   enum_next_value = build_binary_op_nodefault (PLUS_EXPR, value,
                   10430:                                               integer_one_node, PLUS_EXPR);
                   10431:   if (enum_next_value == integer_one_node)
                   10432:     enum_next_value = copy_node (enum_next_value);
                   10433: 
                   10434:   return result;
                   10435: }
                   10436: 
                   10437: tree
                   10438: grok_enum_decls (type, decl)
                   10439:      tree type, decl;
                   10440: {
                   10441:   tree d = current_local_enum;
                   10442:   
                   10443:   if (d == NULL_TREE)
                   10444:     return decl;
                   10445:   
                   10446:   while (1)
                   10447:     {
                   10448:       TREE_TYPE (d) = type;
                   10449:       if (TREE_CHAIN (d) == NULL_TREE)
                   10450:        {
                   10451:          TREE_CHAIN (d) = decl;
                   10452:          break;
                   10453:        }
                   10454:       d = TREE_CHAIN (d);
                   10455:     }
                   10456: 
                   10457:   decl = current_local_enum;
                   10458:   current_local_enum = NULL_TREE;
                   10459:   
                   10460:   return decl;
                   10461: }
                   10462: 
                   10463: /* Create the FUNCTION_DECL for a function definition.
                   10464:    DECLSPECS and DECLARATOR are the parts of the declaration;
                   10465:    they describe the function's name and the type it returns,
                   10466:    but twisted together in a fashion that parallels the syntax of C.
                   10467: 
                   10468:    This function creates a binding context for the function body
                   10469:    as well as setting up the FUNCTION_DECL in current_function_decl.
                   10470: 
                   10471:    Returns 1 on success.  If the DECLARATOR is not suitable for a function
                   10472:    (it defines a datum instead), we return 0, which tells
                   10473:    yyparse to report a parse error.
                   10474: 
                   10475:    For C++, we must first check whether that datum makes any sense.
                   10476:    For example, "class A local_a(1,2);" means that variable local_a
                   10477:    is an aggregate of type A, which should have a constructor
                   10478:    applied to it with the argument list [1, 2].
                   10479: 
                   10480:    @@ There is currently no way to retrieve the storage
                   10481:    @@ allocated to FUNCTION (or all of its parms) if we return
                   10482:    @@ something we had previously.  */
                   10483: 
                   10484: int
                   10485: start_function (declspecs, declarator, raises, pre_parsed_p)
                   10486:      tree declarator, declspecs, raises;
                   10487:      int pre_parsed_p;
                   10488: {
                   10489:   extern tree EHS_decl;
                   10490:   tree decl1, olddecl;
                   10491:   tree ctype = NULL_TREE;
                   10492:   tree fntype;
                   10493:   tree restype;
                   10494:   extern int have_extern_spec;
                   10495:   extern int used_extern_spec;
                   10496:   int doing_friend = 0;
                   10497: 
                   10498:   if (flag_handle_exceptions && EHS_decl == NULL_TREE)
                   10499:     init_exception_processing_1 ();
                   10500: 
                   10501:   /* Sanity check.  */
                   10502:   my_friendly_assert (TREE_VALUE (void_list_node) == void_type_node, 160);
                   10503:   my_friendly_assert (TREE_CHAIN (void_list_node) == NULL_TREE, 161);
                   10504: 
                   10505:   /* Assume, until we see it does. */
                   10506:   current_function_returns_value = 0;
                   10507:   current_function_returns_null = 0;
                   10508:   warn_about_return_type = 0;
                   10509:   current_extern_inline = 0;
                   10510:   current_function_assigns_this = 0;
                   10511:   current_function_just_assigned_this = 0;
                   10512:   current_function_parms_stored = 0;
                   10513:   original_result_rtx = NULL_RTX;
                   10514:   current_function_obstack_index = 0;
                   10515:   current_function_obstack_usage = 0;
                   10516: 
                   10517:   clear_temp_name ();
                   10518: 
                   10519:   /* This should only be done once on the top most decl. */
                   10520:   if (have_extern_spec && !used_extern_spec)
                   10521:     {
                   10522:       declspecs = decl_tree_cons (NULL_TREE, get_identifier ("extern"), declspecs);
                   10523:       used_extern_spec = 1;
                   10524:     }
                   10525: 
                   10526:   if (pre_parsed_p)
                   10527:     {
                   10528:       decl1 = declarator;
                   10529: 
                   10530:       if (! DECL_ARGUMENTS (decl1)
                   10531:          && !DECL_STATIC_FUNCTION_P (decl1)
                   10532:          && DECL_CONTEXT (decl1)
                   10533:          && DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl1)))
                   10534:          && IDENTIFIER_TEMPLATE (DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl1)))))
                   10535:        {
                   10536:          cp_error ("redeclaration of `%#D'", decl1);
                   10537:          if (IDENTIFIER_CLASS_VALUE (DECL_NAME (decl1)))
                   10538:            cp_error_at ("previous declaration here", IDENTIFIER_CLASS_VALUE (DECL_NAME (decl1)));
                   10539:          else if (IDENTIFIER_GLOBAL_VALUE (DECL_NAME (decl1)))
                   10540:            cp_error_at ("previous declaration here", IDENTIFIER_GLOBAL_VALUE (DECL_NAME (decl1)));
                   10541:        }
                   10542: 
                   10543:       last_function_parms = DECL_ARGUMENTS (decl1);
                   10544:       last_function_parm_tags = NULL_TREE;
                   10545:       fntype = TREE_TYPE (decl1);
                   10546:       if (TREE_CODE (fntype) == METHOD_TYPE)
                   10547:        ctype = TYPE_METHOD_BASETYPE (fntype);
                   10548: 
                   10549:       /* ANSI C++ June 5 1992 WP 11.4.5.  A friend function defined in a
                   10550:         class is in the (lexical) scope of the class in which it is
                   10551:         defined.  */
                   10552:       if (!ctype && DECL_FRIEND_P (decl1))
                   10553:        {
                   10554:          ctype = TREE_TYPE (TREE_CHAIN (decl1));
                   10555: 
                   10556:          /* CTYPE could be null here if we're dealing with a template;
                   10557:             for example, `inline friend float foo()' inside a template
                   10558:             will have no CTYPE set.  */
                   10559:          if (ctype && TREE_CODE (ctype) != RECORD_TYPE)
                   10560:            ctype = NULL_TREE;
                   10561:          else
                   10562:            doing_friend = 1;
                   10563:        }
                   10564: 
                   10565:       if ( !(DECL_VINDEX (decl1)
                   10566:             && write_virtuals >= 2
                   10567:             && CLASSTYPE_VTABLE_NEEDS_WRITING (ctype)))
                   10568:        current_extern_inline = TREE_PUBLIC (decl1) && DECL_INLINE (decl1);
                   10569: 
                   10570:       raises = TYPE_RAISES_EXCEPTIONS (fntype);
                   10571: 
                   10572:       /* In a fcn definition, arg types must be complete.  */
                   10573:       require_complete_types_for_parms (last_function_parms);
                   10574:     }
                   10575:   else
                   10576:     {
                   10577:       decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, raises);
                   10578:       /* If the declarator is not suitable for a function definition,
                   10579:         cause a syntax error.  */
                   10580:       if (decl1 == NULL_TREE || TREE_CODE (decl1) != FUNCTION_DECL) return 0;
                   10581: 
                   10582:       fntype = TREE_TYPE (decl1);
                   10583: 
                   10584:       restype = TREE_TYPE (fntype);
                   10585:       if (IS_AGGR_TYPE (restype) && ! TYPE_PTRMEMFUNC_P (restype)
                   10586:          && ! CLASSTYPE_GOT_SEMICOLON (restype))
                   10587:        {
                   10588:          cp_error ("semicolon missing after declaration of `%#T'", restype);
                   10589:          shadow_tag (build_tree_list (NULL_TREE, restype));
                   10590:          CLASSTYPE_GOT_SEMICOLON (restype) = 1;
                   10591:          if (TREE_CODE (fntype) == FUNCTION_TYPE)
                   10592:            fntype = build_function_type (integer_type_node,
                   10593:                                          TYPE_ARG_TYPES (fntype));
                   10594:          else
                   10595:            fntype = build_cplus_method_type (build_type_variant (TYPE_METHOD_BASETYPE (fntype), TREE_READONLY (decl1), TREE_SIDE_EFFECTS (decl1)),
                   10596:                                              integer_type_node,
                   10597:                                              TYPE_ARG_TYPES (fntype));
                   10598:          TREE_TYPE (decl1) = fntype;
                   10599:        }
                   10600: 
                   10601:       if (TREE_CODE (fntype) == METHOD_TYPE)
                   10602:        ctype = TYPE_METHOD_BASETYPE (fntype);
                   10603:       else if (IDENTIFIER_LENGTH (DECL_NAME (decl1)) == 4
                   10604:               && ! strcmp (IDENTIFIER_POINTER (DECL_NAME (decl1)), "main")
                   10605:               && DECL_CONTEXT (decl1) == NULL_TREE)
                   10606:        {
                   10607:          /* If this doesn't return integer_type, complain.  */
                   10608:          if (TREE_TYPE (TREE_TYPE (decl1)) != integer_type_node)
                   10609:            {
                   10610:              warning ("return type for `main' changed to integer type");
                   10611:              TREE_TYPE (decl1) = fntype = default_function_type;
                   10612:            }
                   10613:          warn_about_return_type = 0;
                   10614:        }
                   10615:     }
                   10616: 
                   10617:   /* Warn if function was previously implicitly declared
                   10618:      (but not if we warned then).  */
                   10619:   if (! warn_implicit
                   10620:       && IDENTIFIER_IMPLICIT_DECL (DECL_NAME (decl1)) != NULL_TREE)
                   10621:     cp_warning_at ("`%D' implicitly declared before its definition", IDENTIFIER_IMPLICIT_DECL (DECL_NAME (decl1)));
                   10622: 
                   10623:   current_function_decl = decl1;
                   10624: 
                   10625:   if (flag_cadillac)
                   10626:     cadillac_start_function (decl1);
                   10627:   else
                   10628:     announce_function (decl1);
                   10629: 
                   10630:   if (TYPE_SIZE (TREE_TYPE (fntype)) == NULL_TREE)
                   10631:     {
                   10632:       if (IS_AGGR_TYPE (TREE_TYPE (fntype)))
                   10633:        error_with_aggr_type (TREE_TYPE (fntype),
                   10634:                              "return-type `%s' is an incomplete type");
                   10635:       else
                   10636:        error ("return-type is an incomplete type");
                   10637: 
                   10638:       /* Make it return void instead, but don't change the
                   10639:         type of the DECL_RESULT, in case we have a named return value.  */
                   10640:       if (ctype)
                   10641:        TREE_TYPE (decl1)
                   10642:          = build_cplus_method_type (build_type_variant (ctype,
                   10643:                                                         TREE_READONLY (decl1),
                   10644:                                                         TREE_SIDE_EFFECTS (decl1)),
                   10645:                                     void_type_node,
                   10646:                                     FUNCTION_ARG_CHAIN (decl1));
                   10647:       else
                   10648:        TREE_TYPE (decl1)
                   10649:          = build_function_type (void_type_node,
                   10650:                                 TYPE_ARG_TYPES (TREE_TYPE (decl1)));
                   10651:       DECL_RESULT (decl1) = build_decl (RESULT_DECL, 0, TREE_TYPE (fntype));
                   10652:     }
                   10653: 
                   10654:   if (warn_about_return_type)
                   10655:     warning ("return-type defaults to `int'");
                   10656: 
                   10657:   /* Make the init_value nonzero so pushdecl knows this is not tentative.
                   10658:      error_mark_node is replaced below (in poplevel) with the BLOCK.  */
                   10659:   DECL_INITIAL (decl1) = error_mark_node;
                   10660: 
                   10661:   /* Didn't get anything from C.  */
                   10662:   olddecl = NULL_TREE;
                   10663: 
                   10664:   /* This function exists in static storage.
                   10665:      (This does not mean `static' in the C sense!)  */
                   10666:   TREE_STATIC (decl1) = 1;
                   10667: 
                   10668:   /* If this function belongs to an interface, it is public.
                   10669:      If it belongs to someone else's interface, it is also external.
                   10670:      It doesn't matter whether it's inline or not.  */
                   10671:   if (interface_unknown == 0)
                   10672:     {
                   10673:       TREE_PUBLIC (decl1) = 1;
                   10674:       DECL_EXTERNAL (decl1) = (interface_only
                   10675:                               || (DECL_INLINE (decl1)
                   10676:                                   && ! flag_implement_inlines));
                   10677:     }
                   10678:   else
                   10679:     /* This is a definition, not a reference.
                   10680:        So normally clear DECL_EXTERNAL.
                   10681:        However, `extern inline' acts like a declaration except for
                   10682:        defining how to inline.  So set DECL_EXTERNAL in that case.  */
                   10683:     DECL_EXTERNAL (decl1) = current_extern_inline;
                   10684: 
                   10685:   /* Now see if this is the implementation of a declared function.  */
                   10686:   if (ctype == NULL_TREE && current_lang_name == lang_name_cplusplus
                   10687:       && !DECL_CONTEXT (decl1))
                   10688:     {
                   10689:       olddecl = lookup_name_current_level (DECL_NAME (decl1));
                   10690:       if (olddecl && TREE_CODE (olddecl) != FUNCTION_DECL)
                   10691:        olddecl = NULL_TREE;
                   10692:       if (olddecl && DECL_NAME (decl1) != DECL_NAME (olddecl))
                   10693:        {
                   10694:          /* Collision between user and internal naming scheme.  */
                   10695:          olddecl = lookup_name_current_level (DECL_ASSEMBLER_NAME (decl1));
                   10696:          if (olddecl == NULL_TREE)
                   10697:            olddecl = decl1;
                   10698:        }
                   10699:       if (olddecl && olddecl != decl1
                   10700:          && DECL_NAME (decl1) == DECL_NAME (olddecl))
                   10701:        {
                   10702:          if (TREE_CODE (olddecl) == FUNCTION_DECL
                   10703:              && decls_match (decl1, olddecl))
                   10704:            {
                   10705:              olddecl = DECL_MAIN_VARIANT (olddecl);
                   10706:              /* The following copy is needed to handle forcing a function's
                   10707:                 linkage to obey the linkage of the original decl.  */
                   10708:              DECL_ASSEMBLER_NAME (decl1) = DECL_ASSEMBLER_NAME (olddecl);
                   10709:              DECL_OVERLOADED (decl1) = DECL_OVERLOADED (olddecl);
                   10710:              if (! DECL_BUILT_IN (olddecl) && DECL_INITIAL (olddecl))
                   10711:                redeclaration_error_message (decl1, olddecl);
                   10712:              if (duplicate_decls (decl1, olddecl))
                   10713:                decl1 = olddecl;
                   10714:              else
                   10715:                olddecl = NULL_TREE;
                   10716:            }
                   10717:          else
                   10718:            olddecl = NULL_TREE;
                   10719:        }
                   10720:     }
                   10721: 
                   10722:   /* Record the decl so that the function name is defined.
                   10723:      If we already have a decl for this name, and it is a FUNCTION_DECL,
                   10724:      use the old decl.  */
                   10725: 
                   10726:   if (olddecl)
                   10727:     current_function_decl = olddecl;
                   10728:   else if (pre_parsed_p == 0)
                   10729:     {
                   10730:       current_function_decl = pushdecl (decl1);
                   10731:       if (TREE_CODE (current_function_decl) == TREE_LIST)
                   10732:        {
                   10733:          /* @@ revert to modified original declaration.  */
                   10734:          decl1 = DECL_MAIN_VARIANT (decl1);
                   10735:          current_function_decl = decl1;
                   10736:        }
                   10737:       else
                   10738:        {
                   10739:          decl1 = current_function_decl;
                   10740:          DECL_MAIN_VARIANT (decl1) = decl1;
                   10741:        }
                   10742:       fntype = TREE_TYPE (decl1);
                   10743:     }
                   10744:   else
                   10745:     current_function_decl = decl1;
                   10746: 
                   10747:   if (DECL_OVERLOADED (decl1))
                   10748:     decl1 = push_overloaded_decl (decl1, 1);
                   10749: 
                   10750:   if (ctype != NULL_TREE && DECL_STATIC_FUNCTION_P (decl1))
                   10751:     {
                   10752:       if (TREE_CODE (fntype) == METHOD_TYPE)
                   10753:        TREE_TYPE (decl1) = fntype
                   10754:          = build_function_type (TREE_TYPE (fntype),
                   10755:                                 TREE_CHAIN (TYPE_ARG_TYPES (fntype)));
                   10756:       last_function_parms = TREE_CHAIN (last_function_parms);
                   10757:       DECL_ARGUMENTS (decl1) = last_function_parms;
                   10758:       ctype = NULL_TREE;
                   10759:     }
                   10760:   restype = TREE_TYPE (fntype);
                   10761: 
                   10762:   pushlevel (0);
                   10763:   current_binding_level->parm_flag = 1;
                   10764: 
                   10765:   /* Save the parm names or decls from this function's declarator
                   10766:      where store_parm_decls will find them.  */
                   10767:   current_function_parms = last_function_parms;
                   10768:   current_function_parm_tags = last_function_parm_tags;
                   10769: 
                   10770:   GNU_xref_function (decl1, current_function_parms);
                   10771: 
                   10772:   make_function_rtl (decl1);
                   10773: 
                   10774:   if (ctype)
                   10775:     {
                   10776: #if NEW_CLASS_SCOPING
                   10777:       push_nested_class (ctype, 1);
                   10778: #else
                   10779:       pushclass (ctype, 1);
                   10780: #endif
                   10781: 
                   10782:       /* If we're compiling a friend function, neither of the variables
                   10783:         current_class_decl nor current_class_type will have values.  */
                   10784:       if (! doing_friend)
                   10785:        {
                   10786:          /* We know that this was set up by `grokclassfn'.
                   10787:             We do not wait until `store_parm_decls', since evil
                   10788:             parse errors may never get us to that point.  Here
                   10789:             we keep the consistency between `current_class_type'
                   10790:             and `current_class_decl'.  */
                   10791:          current_class_decl = last_function_parms;
                   10792:          my_friendly_assert (current_class_decl != NULL_TREE
                   10793:                  && TREE_CODE (current_class_decl) == PARM_DECL, 162);
                   10794:          if (TREE_CODE (TREE_TYPE (current_class_decl)) == POINTER_TYPE)
                   10795:            {
                   10796:              tree variant = TREE_TYPE (TREE_TYPE (current_class_decl));
                   10797:              if (CLASSTYPE_INST_VAR (ctype) == NULL_TREE)
                   10798:                {
                   10799:                  /* Can't call build_indirect_ref here, because it has special
                   10800:                     logic to return C_C_D given this argument.  */
                   10801:                  C_C_D = build1 (INDIRECT_REF, current_class_type, current_class_decl);
                   10802:                  CLASSTYPE_INST_VAR (ctype) = C_C_D;
                   10803:                }
                   10804:              else
                   10805:                {
                   10806:                  C_C_D = CLASSTYPE_INST_VAR (ctype);
                   10807:                  /* `current_class_decl' is different for every
                   10808:                     function we compile.  */
                   10809:                  TREE_OPERAND (C_C_D, 0) = current_class_decl;
                   10810:                }
                   10811:              TREE_READONLY (C_C_D) = TYPE_READONLY (variant);
                   10812:              TREE_SIDE_EFFECTS (C_C_D) = TYPE_VOLATILE (variant);
                   10813:              TREE_THIS_VOLATILE (C_C_D) = TYPE_VOLATILE (variant);
                   10814:            }
                   10815:          else
                   10816:            C_C_D = current_class_decl;
                   10817:        }
                   10818:     }
                   10819:   else
                   10820:     {
                   10821:       if (DECL_STATIC_FUNCTION_P (decl1))
                   10822: #if NEW_CLASS_SCOPING
                   10823:        push_nested_class (DECL_CONTEXT (decl1), 2);
                   10824: #else
                   10825:        pushclass (DECL_CONTEXT (decl1), 2);
                   10826: #endif
                   10827:       else
                   10828:        push_memoized_context (0, 1);
                   10829:     }
                   10830: 
                   10831:   /* Allocate further tree nodes temporarily during compilation
                   10832:      of this function only.  Tiemann moved up here from bottom of fn.  */
                   10833:   temporary_allocation ();
                   10834: 
                   10835:   /* Promote the value to int before returning it.  */
                   10836:   if (C_PROMOTING_INTEGER_TYPE_P (restype))
                   10837:     {
                   10838:       /* It retains unsignedness if traditional or if it isn't
                   10839:         really getting wider.  */
                   10840:       if (TREE_UNSIGNED (restype)
                   10841:          && (flag_traditional
                   10842:              || TYPE_PRECISION (restype)
                   10843:                   == TYPE_PRECISION (integer_type_node)))
                   10844:        restype = unsigned_type_node;
                   10845:       else
                   10846:        restype = integer_type_node;
                   10847:     }
                   10848:   if (DECL_RESULT (decl1) == NULL_TREE)
                   10849:     DECL_RESULT (decl1) = build_decl (RESULT_DECL, 0, restype);
                   10850: 
                   10851:   if (DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (decl1)))
                   10852:     {
                   10853:       dtor_label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
                   10854:       ctor_label = NULL_TREE;
                   10855:     }
                   10856:   else
                   10857:     {
                   10858:       dtor_label = NULL_TREE;
                   10859:       if (DECL_CONSTRUCTOR_P (decl1))
                   10860:        ctor_label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
                   10861:     }
                   10862: 
                   10863:   /* If this fcn was already referenced via a block-scope `extern' decl
                   10864:      (or an implicit decl), propagate certain information about the usage.  */
                   10865:   if (TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl1)))
                   10866:     TREE_ADDRESSABLE (decl1) = 1;
                   10867: 
                   10868:   return 1;
                   10869: }
                   10870: 
                   10871: /* Store the parameter declarations into the current function declaration.
                   10872:    This is called after parsing the parameter declarations, before
                   10873:    digesting the body of the function.
                   10874: 
                   10875:    Also install to binding contour return value identifier, if any.  */
                   10876: 
                   10877: void
                   10878: store_parm_decls ()
                   10879: {
                   10880:   register tree fndecl = current_function_decl;
                   10881:   register tree parm;
                   10882:   int parms_have_cleanups = 0;
                   10883:   tree eh_decl;
                   10884: 
                   10885:   /* This is either a chain of PARM_DECLs (when a prototype is used).  */
                   10886:   tree specparms = current_function_parms;
                   10887: 
                   10888:   /* This is a list of types declared among parms in a prototype.  */
                   10889:   tree parmtags = current_function_parm_tags;
                   10890: 
                   10891:   /* This is a chain of any other decls that came in among the parm
                   10892:      declarations.  If a parm is declared with  enum {foo, bar} x;
                   10893:      then CONST_DECLs for foo and bar are put here.  */
                   10894:   tree nonparms = NULL_TREE;
                   10895: 
                   10896:   if (current_binding_level == global_binding_level)
                   10897:     fatal ("parse errors have confused me too much");
                   10898: 
                   10899:   /* Initialize RTL machinery.  */
                   10900:   init_function_start (fndecl, input_filename, lineno);
                   10901: 
                   10902:   /* Declare __FUNCTION__ and __PRETTY_FUNCTION__ for this function.  */
                   10903:   declare_function_name ();
                   10904: 
                   10905:   /* Create a binding level for the parms.  */
                   10906:   expand_start_bindings (0);
                   10907: 
                   10908:   /* Prepare to catch raises, if appropriate.  */
                   10909:   if (flag_handle_exceptions)
                   10910:     {
                   10911:       /* Get this cleanup to be run last, since it
                   10912:         is a call to `longjmp'.  */
                   10913:       setup_exception_throw_decl ();
                   10914:       eh_decl = current_binding_level->names;
                   10915:       current_binding_level->names = TREE_CHAIN (current_binding_level->names);
                   10916:     }
                   10917:   if (flag_handle_exceptions)
                   10918:     expand_start_try (integer_one_node, 0, 1);
                   10919: 
                   10920:   if (specparms != NULL_TREE)
                   10921:     {
                   10922:       /* This case is when the function was defined with an ANSI prototype.
                   10923:         The parms already have decls, so we need not do anything here
                   10924:         except record them as in effect
                   10925:         and complain if any redundant old-style parm decls were written.  */
                   10926: 
                   10927:       register tree next;
                   10928: 
                   10929:       /* Must clear this because it might contain TYPE_DECLs declared
                   10930:         at class level.  */
                   10931:       storedecls (NULL_TREE);
                   10932:       for (parm = nreverse (specparms); parm; parm = next)
                   10933:        {
                   10934:          next = TREE_CHAIN (parm);
                   10935:          if (TREE_CODE (parm) == PARM_DECL)
                   10936:            {
                   10937:              tree cleanup = maybe_build_cleanup (parm);
                   10938:              if (DECL_NAME (parm) == NULL_TREE)
                   10939:                {
                   10940: #if 0
                   10941:                  cp_error_at ("parameter name omitted", parm);
                   10942: #else
                   10943:                  /* for C++, this is not an error.  */
                   10944:                  pushdecl (parm);
                   10945: #endif
                   10946:                }
                   10947:              else if (TYPE_MAIN_VARIANT (TREE_TYPE (parm)) == void_type_node)
                   10948:                cp_error ("parameter `%D' declared void", parm);
                   10949:              else
                   10950:                {
                   10951:                  /* Now fill in DECL_REFERENCE_SLOT for any of the parm decls.
                   10952:                     A parameter is assumed not to have any side effects.
                   10953:                     If this should change for any reason, then this
                   10954:                     will have to wrap the bashed reference type in a save_expr.
                   10955:                     
                   10956:                     Also, if the parameter type is declared to be an X
                   10957:                     and there is an X(X&) constructor, we cannot lay it
                   10958:                     into the stack (any more), so we make this parameter
                   10959:                     look like it is really of reference type.  Functions
                   10960:                     which pass parameters to this function will know to
                   10961:                     create a temporary in their frame, and pass a reference
                   10962:                     to that.  */
                   10963: 
                   10964:                  if (TREE_CODE (TREE_TYPE (parm)) == REFERENCE_TYPE
                   10965:                      && TYPE_SIZE (TREE_TYPE (TREE_TYPE (parm))))
                   10966:                    SET_DECL_REFERENCE_SLOT (parm, convert_from_reference (parm));
                   10967: 
                   10968:                  pushdecl (parm);
                   10969:                }
                   10970:              if (cleanup)
                   10971:                {
                   10972:                  expand_decl (parm);
                   10973:                  expand_decl_cleanup (parm, cleanup);
                   10974:                  parms_have_cleanups = 1;
                   10975:                }
                   10976:            }
                   10977:          else
                   10978:            {
                   10979:              /* If we find an enum constant or a type tag,
                   10980:                 put it aside for the moment.  */
                   10981:              TREE_CHAIN (parm) = NULL_TREE;
                   10982:              nonparms = chainon (nonparms, parm);
                   10983:            }
                   10984:        }
                   10985: 
                   10986:       /* Get the decls in their original chain order
                   10987:         and record in the function.  This is all and only the
                   10988:         PARM_DECLs that were pushed into scope by the loop above.  */
                   10989:       DECL_ARGUMENTS (fndecl) = getdecls ();
                   10990: 
                   10991:       storetags (chainon (parmtags, gettags ()));
                   10992:     }
                   10993:   else
                   10994:     DECL_ARGUMENTS (fndecl) = NULL_TREE;
                   10995: 
                   10996:   /* Now store the final chain of decls for the arguments
                   10997:      as the decl-chain of the current lexical scope.
                   10998:      Put the enumerators in as well, at the front so that
                   10999:      DECL_ARGUMENTS is not modified.  */
                   11000: 
                   11001:   storedecls (chainon (nonparms, DECL_ARGUMENTS (fndecl)));
                   11002: 
                   11003:   /* Initialize the RTL code for the function.  */
                   11004:   DECL_SAVED_INSNS (fndecl) = NULL_RTX;
                   11005:   expand_function_start (fndecl, parms_have_cleanups);
                   11006: 
                   11007:   if (flag_handle_exceptions)
                   11008:     {
                   11009:       /* Make the throw decl visible at this level, just
                   11010:         not in the way of the parameters.  */
                   11011:       pushdecl (eh_decl);
                   11012:       expand_decl_init (eh_decl);
                   11013:     }
                   11014: 
                   11015:   /* Create a binding contour which can be used to catch
                   11016:      cleanup-generated temporaries.  Also, if the return value needs or
                   11017:      has initialization, deal with that now.  */
                   11018:   if (parms_have_cleanups)
                   11019:     {
                   11020:       pushlevel (0);
                   11021:       expand_start_bindings (0);
                   11022:     }
                   11023: 
                   11024:   current_function_parms_stored = 1;
                   11025: 
                   11026:   if (flag_gc)
                   11027:     {
                   11028:       maybe_gc_cleanup = build_tree_list (NULL_TREE, error_mark_node);
                   11029:       expand_decl_cleanup (NULL_TREE, maybe_gc_cleanup);
                   11030:     }
                   11031: 
                   11032:   /* If this function is `main', emit a call to `__main'
                   11033:      to run global initializers, etc.  */
                   11034:   if (DECL_NAME (fndecl)
                   11035:       && IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 4
                   11036:       && strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "main") == 0
                   11037:       && DECL_CONTEXT (fndecl) == NULL_TREE)
                   11038:     {
                   11039:       expand_main_function ();
                   11040: 
                   11041:       if (flag_gc)
                   11042:        expand_expr (build_function_call (lookup_name (get_identifier ("__gc_main"), 0), NULL_TREE),
                   11043:                     0, VOIDmode, 0);
                   11044: 
                   11045:       if (flag_dossier)
                   11046:        output_builtin_tdesc_entries ();
                   11047:     }
                   11048: }
                   11049: 
                   11050: /* Bind a name and initialization to the return value of
                   11051:    the current function.  */
                   11052: void
                   11053: store_return_init (return_id, init)
                   11054:      tree return_id, init;
                   11055: {
                   11056:   tree decl = DECL_RESULT (current_function_decl);
                   11057: 
                   11058:   if (pedantic)
                   11059:     /* Give this error as many times as there are occurrences,
                   11060:        so that users can use Emacs compilation buffers to find
                   11061:        and fix all such places.  */
                   11062:     error ("ANSI C++ does not permit named return values");
                   11063: 
                   11064:   if (return_id != NULL_TREE)
                   11065:     {
                   11066:       if (DECL_NAME (decl) == NULL_TREE)
                   11067:        {
                   11068:          DECL_NAME (decl) = return_id;
                   11069:          DECL_ASSEMBLER_NAME (decl) = return_id;
                   11070:        }
                   11071:       else
                   11072:        error ("return identifier `%s' already in place",
                   11073:               IDENTIFIER_POINTER (DECL_NAME (decl)));
                   11074:     }
                   11075: 
                   11076:   /* Can't let this happen for constructors.  */
                   11077:   if (DECL_CONSTRUCTOR_P (current_function_decl))
                   11078:     {
                   11079:       error ("can't redefine default return value for constructors");
                   11080:       return;
                   11081:     }
                   11082: 
                   11083:   /* If we have a named return value, put that in our scope as well.  */
                   11084:   if (DECL_NAME (decl) != NULL_TREE)
                   11085:     {
                   11086:       /* If this named return value comes in a register,
                   11087:         put it in a pseudo-register.  */
                   11088:       if (DECL_REGISTER (decl))
                   11089:        {
                   11090:          original_result_rtx = DECL_RTL (decl);
                   11091:          DECL_RTL (decl) = gen_reg_rtx (DECL_MODE (decl));
                   11092:        }
                   11093: 
                   11094:       /* Let `finish_decl' know that this initializer is ok.  */
                   11095:       DECL_INITIAL (decl) = init;
                   11096:       pushdecl (decl);
                   11097:       finish_decl (decl, init, 0, 0);
                   11098:     }
                   11099: }
                   11100: 
                   11101: /* Generate code for default X(X&) constructor.  */
                   11102: static void
                   11103: build_default_constructor (fndecl)
                   11104:      tree fndecl;
                   11105: {
                   11106:   int i = CLASSTYPE_N_BASECLASSES (current_class_type);
                   11107:   tree parm = TREE_CHAIN (DECL_ARGUMENTS (fndecl));
                   11108:   tree fields = TYPE_FIELDS (current_class_type);
                   11109:   tree binfos = TYPE_BINFO_BASETYPES (current_class_type);
                   11110: 
                   11111:   if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type))
                   11112:     parm = TREE_CHAIN (parm);
                   11113:   parm = DECL_REFERENCE_SLOT (parm);
                   11114: 
                   11115:   while (--i >= 0)
                   11116:     {
                   11117:       tree basetype = TREE_VEC_ELT (binfos, i);
                   11118:       if (TYPE_GETS_INIT_REF (basetype))
                   11119:        {
                   11120:          tree name = TYPE_NAME (basetype);
                   11121:          if (TREE_CODE (name) == TYPE_DECL)
                   11122:            name = DECL_NAME (name);
                   11123:          current_base_init_list = tree_cons (name, parm, current_base_init_list);
                   11124:        }
                   11125:     }
                   11126:   for (; fields; fields = TREE_CHAIN (fields))
                   11127:     {
                   11128:       tree name, init;
                   11129:       if (TREE_STATIC (fields))
                   11130:        continue;
                   11131:       if (TREE_CODE (fields) != FIELD_DECL)
                   11132:        continue;
                   11133:       if (DECL_NAME (fields))
                   11134:        {
                   11135:          if (VFIELD_NAME_P (DECL_NAME (fields)))
                   11136:            continue;
                   11137:          if (VBASE_NAME_P (DECL_NAME (fields)))
                   11138:            continue;
                   11139: 
                   11140:          /* True for duplicate members.  */
                   11141:          if (IDENTIFIER_CLASS_VALUE (DECL_NAME (fields)) != fields)
                   11142:            continue;
                   11143:        }
                   11144: 
                   11145:       init = build (COMPONENT_REF, TREE_TYPE (fields), parm, fields);
                   11146:       init = build_tree_list (NULL_TREE, init);
                   11147: 
                   11148:       current_member_init_list
                   11149:        = tree_cons (DECL_NAME (fields), init, current_member_init_list);
                   11150:     }
                   11151: }
                   11152: 
                   11153: 
                   11154: /* Get the binfo associated with the vfield. */
                   11155: 
                   11156: tree
                   11157: get_binfo_from_vfield (vfield)
                   11158:      tree vfield;
                   11159: {
                   11160:   if (VF_BINFO_VALUE (vfield))
                   11161:     return VF_BINFO_VALUE (vfield);
                   11162:   /* Not sure where it is.  maybe get_binfo on
                   11163:      VF_BASETYPE_VALUE (vfield), VF_DERIVED_VALUE (vfield)... */
                   11164:   my_friendly_abort (350);
                   11165:   return NULL_TREE;
                   11166: }
                   11167: 
                   11168: /* Finish up a function declaration and compile that function
                   11169:    all the way to assembler language output.  The free the storage
                   11170:    for the function definition.
                   11171: 
                   11172:    This is called after parsing the body of the function definition.
                   11173:    LINENO is the current line number.
                   11174: 
                   11175:    C++: CALL_POPLEVEL is non-zero if an extra call to poplevel
                   11176:    (and expand_end_bindings) must be made to take care of the binding
                   11177:    contour for the base initializers.  This is only relevant for
                   11178:    constructors.  */
                   11179: 
                   11180: void
                   11181: finish_function (lineno, call_poplevel)
                   11182:      int lineno;
                   11183:      int call_poplevel;
                   11184: {
                   11185:   register tree fndecl = current_function_decl;
                   11186:   tree fntype, ctype = NULL_TREE;
                   11187:   rtx head, last_parm_insn, mark;
                   11188:   extern int sets_exception_throw_decl;
                   11189:   /* Label to use if this function is supposed to return a value.  */
                   11190:   tree no_return_label = NULL_TREE;
                   11191:   tree decls = NULL_TREE;
                   11192: 
                   11193:   /* When we get some parse errors, we can end up without a
                   11194:      current_function_decl, so cope.  */
                   11195:   if (fndecl == NULL_TREE)
                   11196:     return;
                   11197: 
                   11198:   fntype = TREE_TYPE (fndecl);
                   11199: 
                   11200: /*  TREE_READONLY (fndecl) = 1;
                   11201:     This caused &foo to be of type ptr-to-const-function
                   11202:     which then got a warning when stored in a ptr-to-function variable.  */
                   11203: 
                   11204:   /* This happens on strange parse errors.  */
                   11205:   if (! current_function_parms_stored)
                   11206:     {
                   11207:       call_poplevel = 0;
                   11208:       store_parm_decls ();
                   11209:     }
                   11210: 
                   11211:   if (write_symbols != NO_DEBUG && TREE_CODE (fntype) != METHOD_TYPE)
                   11212:     {
                   11213:       tree ttype = target_type (fntype);
                   11214:       tree parmdecl;
                   11215: 
                   11216:       if (IS_AGGR_TYPE (ttype))
                   11217:        /* Let debugger know it should output info for this type.  */
                   11218:        note_debug_info_needed (ttype);
                   11219: 
                   11220:       for (parmdecl = DECL_ARGUMENTS (fndecl); parmdecl; parmdecl = TREE_CHAIN (parmdecl))
                   11221:        {
                   11222:          ttype = target_type (TREE_TYPE (parmdecl));
                   11223:          if (IS_AGGR_TYPE (ttype))
                   11224:            /* Let debugger know it should output info for this type.  */
                   11225:            note_debug_info_needed (ttype);
                   11226:        }
                   11227:     }
                   11228: 
                   11229:   /* Clean house because we will need to reorder insns here.  */
                   11230:   do_pending_stack_adjust ();
                   11231: 
                   11232:   if (dtor_label)
                   11233:     {
                   11234:       tree binfo = TYPE_BINFO (current_class_type);
                   11235:       tree cond = integer_one_node;
                   11236:       tree exprstmt, vfields;
                   11237:       tree in_charge_node = lookup_name (in_charge_identifier, 0);
                   11238:       tree virtual_size;
                   11239:       int ok_to_optimize_dtor = 0;
                   11240: 
                   11241:       if (current_function_assigns_this)
                   11242:        cond = build (NE_EXPR, integer_type_node,
                   11243:                      current_class_decl, integer_zero_node);
                   11244:       else
                   11245:        {
                   11246:          int n_baseclasses = CLASSTYPE_N_BASECLASSES (current_class_type);
                   11247: 
                   11248:          /* If this destructor is empty, then we don't need to check
                   11249:             whether `this' is NULL in some cases.  */
                   11250:          mark = get_last_insn ();
                   11251:          last_parm_insn = get_first_nonparm_insn ();
                   11252: 
                   11253:          if ((flag_this_is_variable & 1) == 0)
                   11254:            ok_to_optimize_dtor = 1;
                   11255:          else if (mark == last_parm_insn)
                   11256:            ok_to_optimize_dtor
                   11257:              = (n_baseclasses == 0
                   11258:                 || (n_baseclasses == 1
                   11259:                     && TYPE_HAS_DESTRUCTOR (TYPE_BINFO_BASETYPE (current_class_type, 0))));
                   11260:        }
                   11261: 
                   11262:       /* These initializations might go inline.  Protect
                   11263:         the binding level of the parms.  */
                   11264:       pushlevel (0);
                   11265:       expand_start_bindings (0);
                   11266: 
                   11267:       if (current_function_assigns_this)
                   11268:        {
                   11269:          current_function_assigns_this = 0;
                   11270:          current_function_just_assigned_this = 0;
                   11271:        }
                   11272: 
                   11273:       /* Generate the code to call destructor on base class.
                   11274:         If this destructor belongs to a class with virtual
                   11275:         functions, then set the virtual function table
                   11276:         pointer to represent the type of our base class.  */
                   11277: 
                   11278:       /* This side-effect makes call to `build_delete' generate the
                   11279:         code we have to have at the end of this destructor.  */
                   11280:       TYPE_HAS_DESTRUCTOR (current_class_type) = 0;
                   11281: 
                   11282:       /* These are two cases where we cannot delegate deletion.  */
                   11283:       if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type)
                   11284:          || TREE_GETS_DELETE (current_class_type))
                   11285:        exprstmt = build_delete (current_class_type, C_C_D, integer_zero_node,
                   11286:                                 LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR, 0);
                   11287:       else
                   11288:        exprstmt = build_delete (current_class_type, C_C_D, in_charge_node,
                   11289:                                 LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR, 0);
                   11290: 
                   11291:       /* If we did not assign to this, then `this' is non-zero at
                   11292:         the end of a destructor.  As a special optimization, don't
                   11293:         emit test if this is an empty destructor.  If it does nothing,
                   11294:         it does nothing.  If it calls a base destructor, the base
                   11295:         destructor will perform the test.  */
                   11296: 
                   11297:       if (exprstmt != error_mark_node
                   11298:          && (TREE_CODE (exprstmt) != NOP_EXPR
                   11299:              || TREE_OPERAND (exprstmt, 0) != integer_zero_node
                   11300:              || TYPE_USES_VIRTUAL_BASECLASSES (current_class_type)))
                   11301:        {
                   11302:          expand_label (dtor_label);
                   11303:          if (cond != integer_one_node)
                   11304:            expand_start_cond (cond, 0);
                   11305:          if (exprstmt != void_zero_node)
                   11306:            /* Don't call `expand_expr_stmt' if we're not going to do
                   11307:               anything, since -Wall will give a diagnostic.  */
                   11308:            expand_expr_stmt (exprstmt);
                   11309: 
                   11310:          /* Run destructor on all virtual baseclasses.  */
                   11311:          if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type))
                   11312:            {
                   11313:              tree vbases = nreverse (copy_list (CLASSTYPE_VBASECLASSES (current_class_type)));
                   11314:              expand_start_cond (build (BIT_AND_EXPR, integer_type_node,
                   11315:                                        in_charge_node, integer_two_node), 0);
                   11316:              while (vbases)
                   11317:                {
                   11318:                  if (TYPE_NEEDS_DESTRUCTOR (BINFO_TYPE (vbases)))
                   11319:                    {
                   11320:                      tree ptr = convert_pointer_to_vbase (vbases, current_class_decl);
                   11321:                      expand_expr_stmt (build_delete (TYPE_POINTER_TO (BINFO_TYPE (vbases)),
                   11322:                                                      ptr, integer_zero_node,
                   11323:                                                      LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR|LOOKUP_HAS_IN_CHARGE, 0));
                   11324:                    }
                   11325:                  vbases = TREE_CHAIN (vbases);
                   11326:                }
                   11327:              expand_end_cond ();
                   11328:            }
                   11329: 
                   11330:          do_pending_stack_adjust ();
                   11331:          if (cond != integer_one_node)
                   11332:            expand_end_cond ();
                   11333:        }
                   11334: 
                   11335:       TYPE_HAS_DESTRUCTOR (current_class_type) = 1;
                   11336: 
                   11337:       virtual_size = c_sizeof (current_class_type);
                   11338: 
                   11339:       /* At the end, call delete if that's what's requested.  */
                   11340:       if (TREE_GETS_DELETE (current_class_type))
                   11341:        /* This NOP_EXPR means we are in a static call context.  */
                   11342:        exprstmt =
                   11343:          build_method_call
                   11344:            (build1 (NOP_EXPR,
                   11345:                     TYPE_POINTER_TO (current_class_type), error_mark_node),
                   11346:             ansi_opname[(int) DELETE_EXPR],
                   11347:             tree_cons (NULL_TREE, current_class_decl,
                   11348:                        build_tree_list (NULL_TREE, virtual_size)),
                   11349:             NULL_TREE, LOOKUP_NORMAL);
                   11350:       else if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type))
                   11351:        exprstmt = build_x_delete (ptr_type_node, current_class_decl, 0,
                   11352:                                   virtual_size);
                   11353:       else
                   11354:        exprstmt = NULL_TREE;
                   11355: 
                   11356:       if (exprstmt)
                   11357:        {
                   11358:          cond = build (BIT_AND_EXPR, integer_type_node,
                   11359:                        in_charge_node, integer_one_node);
                   11360:          expand_start_cond (cond, 0);
                   11361:          expand_expr_stmt (exprstmt);
                   11362:          expand_end_cond ();
                   11363:        }
                   11364: 
                   11365:       /* End of destructor.  */
                   11366:       expand_end_bindings (NULL_TREE, getdecls() != NULL_TREE, 0);
                   11367:       poplevel (2, 0, 0); /* XXX change to 1 */
                   11368: 
                   11369:       /* Back to the top of destructor.  */
                   11370:       /* Dont execute destructor code if `this' is NULL.  */
                   11371:       mark = get_last_insn ();
                   11372:       last_parm_insn = get_first_nonparm_insn ();
                   11373:       if (last_parm_insn == NULL_RTX)
                   11374:        last_parm_insn = mark;
                   11375:       else
                   11376:        last_parm_insn = previous_insn (last_parm_insn);
                   11377: 
                   11378:       /* Make all virtual function table pointers point to CURRENT_CLASS_TYPE's
                   11379:         virtual function tables.  */
                   11380:       if (CLASSTYPE_VFIELDS (current_class_type))
                   11381:        {
                   11382:          for (vfields = CLASSTYPE_VFIELDS (current_class_type);
                   11383:               TREE_CHAIN (vfields);
                   11384:               vfields = TREE_CHAIN (vfields))
                   11385:            {
                   11386:              tree vf_decl = current_class_decl;
                   11387:              /* ??? This may need to be a loop if there are multiple
                   11388:                 levels of replication.  */
                   11389:              if (VF_BINFO_VALUE (vfields))
                   11390:                vf_decl = convert_pointer_to (VF_BINFO_VALUE (vfields), vf_decl);
                   11391:              if (vf_decl != error_mark_node)
                   11392:                {
                   11393:                  expand_expr_stmt (build_virtual_init (binfo,
                   11394:                                                        get_binfo_from_vfield (vfields),
                   11395:                                                        vf_decl));
                   11396:                }
                   11397:            }
                   11398:          expand_expr_stmt (build_virtual_init (binfo, binfo,
                   11399:                                                current_class_decl));
                   11400:        }
                   11401:       if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type))
                   11402:        expand_expr_stmt (build_vbase_vtables_init (binfo, binfo,
                   11403:                                                    C_C_D, current_class_decl, 0));
                   11404:       if (! ok_to_optimize_dtor)
                   11405:        {
                   11406:          cond = build_binary_op (NE_EXPR,
                   11407:                                  current_class_decl, integer_zero_node, 1);
                   11408:          expand_start_cond (cond, 0);
                   11409:        }
                   11410:       if (mark != get_last_insn ())
                   11411:        reorder_insns (next_insn (mark), get_last_insn (), last_parm_insn);
                   11412:       if (! ok_to_optimize_dtor)
                   11413:        expand_end_cond ();
                   11414:     }
                   11415:   else if (current_function_assigns_this)
                   11416:     {
                   11417:       /* Does not need to call emit_base_init, because
                   11418:         that is done (if needed) just after assignment to this
                   11419:         is seen.  */
                   11420: 
                   11421:       if (DECL_CONSTRUCTOR_P (current_function_decl))
                   11422:        {
                   11423:          expand_label (ctor_label);
                   11424:          ctor_label = NULL_TREE;
                   11425: 
                   11426:          if (call_poplevel)
                   11427:            {
                   11428:              decls = getdecls ();
                   11429:              if (flag_handle_exceptions == 2)
                   11430:                deactivate_exception_cleanups ();
                   11431:              expand_end_bindings (decls, decls != NULL_TREE, 0);
                   11432:              poplevel (decls != NULL_TREE, 0, 0);
                   11433:            }
                   11434:          c_expand_return (current_class_decl);
                   11435:        }
                   11436:       else if (TYPE_MAIN_VARIANT (TREE_TYPE (
                   11437:                        DECL_RESULT (current_function_decl))) != void_type_node
                   11438:               && return_label != NULL_RTX)
                   11439:        no_return_label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
                   11440: 
                   11441:       current_function_assigns_this = 0;
                   11442:       current_function_just_assigned_this = 0;
                   11443:       base_init_insns = NULL_RTX;
                   11444:     }
                   11445:   else if (DECL_CONSTRUCTOR_P (fndecl))
                   11446:     {
                   11447:       tree allocated_this;
                   11448:       tree cond, thenclause;
                   11449:       /* Allow constructor for a type to get a new instance of the object
                   11450:         using `build_new'.  */
                   11451:       tree abstract_virtuals = CLASSTYPE_ABSTRACT_VIRTUALS (current_class_type);
                   11452:       CLASSTYPE_ABSTRACT_VIRTUALS (current_class_type) = NULL_TREE;
                   11453: 
                   11454:       DECL_RETURNS_FIRST_ARG (fndecl) = 1;
                   11455: 
                   11456:       if (flag_this_is_variable > 0)
                   11457:        {
                   11458:          cond = build_binary_op (EQ_EXPR,
                   11459:                                  current_class_decl, integer_zero_node, 1);
                   11460:          thenclause = build_modify_expr (current_class_decl, NOP_EXPR,
                   11461:                                          build_new (NULL_TREE, current_class_type, void_type_node, 0));
                   11462:          if (flag_handle_exceptions == 2)
                   11463:            {
                   11464:              tree cleanup, cleanup_deallocate;
                   11465:              tree virtual_size;
                   11466: 
                   11467:              /* This is the size of the virtual object pointed to by
                   11468:                 allocated_this.  In this case, it is simple.  */
                   11469:              virtual_size = c_sizeof (current_class_type);
                   11470: 
                   11471:              allocated_this = build_decl (VAR_DECL, NULL_TREE, ptr_type_node);
                   11472:              DECL_REGISTER (allocated_this) = 1;
                   11473:              DECL_INITIAL (allocated_this) = error_mark_node;
                   11474:              expand_decl (allocated_this);
                   11475:              expand_decl_init (allocated_this);
                   11476:              /* How we cleanup `this' if an exception was raised before
                   11477:                 we are ready to bail out.  */
                   11478:              cleanup = TREE_GETS_DELETE (current_class_type)
                   11479:                ? build_opfncall (DELETE_EXPR, LOOKUP_NORMAL, allocated_this, virtual_size, NULL_TREE)
                   11480:                  /* The size of allocated_this is wrong, and hence the
                   11481:                     second argument to operator delete will be wrong. */
                   11482:                  : build_delete (TREE_TYPE (allocated_this), allocated_this,
                   11483:                                  integer_three_node,
                   11484:                                  LOOKUP_NORMAL|LOOKUP_HAS_IN_CHARGE, 1);
                   11485:              cleanup_deallocate
                   11486:                = build_modify_expr (current_class_decl, NOP_EXPR, integer_zero_node);
                   11487:              cleanup = tree_cons (NULL_TREE, cleanup,
                   11488:                                   build_tree_list (NULL_TREE, cleanup_deallocate));
                   11489: 
                   11490:              expand_decl_cleanup (allocated_this,
                   11491:                                   build (COND_EXPR, integer_type_node,
                   11492:                                          build (NE_EXPR, integer_type_node,
                   11493:                                                 allocated_this, integer_zero_node),
                   11494:                                          build_compound_expr (cleanup),
                   11495:                                          integer_zero_node));
                   11496:            }
                   11497:        }
                   11498:       else if (TREE_GETS_NEW (current_class_type))
                   11499:        /* Just check visibility here.  */
                   11500:        build_method_call (build1 (NOP_EXPR, TYPE_POINTER_TO (current_class_type), error_mark_node),
                   11501:                           ansi_opname[(int) NEW_EXPR],
                   11502:                           build_tree_list (NULL_TREE, integer_zero_node),
                   11503:                           NULL_TREE, LOOKUP_NORMAL);
                   11504: 
                   11505:       CLASSTYPE_ABSTRACT_VIRTUALS (current_class_type) = abstract_virtuals;
                   11506: 
                   11507:       /* must keep the first insn safe.  */
                   11508:       head = get_insns ();
                   11509: 
                   11510:       /* this note will come up to the top with us.  */
                   11511:       mark = get_last_insn ();
                   11512: 
                   11513:       if (flag_this_is_variable > 0)
                   11514:        {
                   11515:          expand_start_cond (cond, 0);
                   11516:          expand_expr_stmt (thenclause);
                   11517:          if (flag_handle_exceptions == 2)
                   11518:            expand_assignment (allocated_this, current_class_decl, 0, 0);
                   11519:          expand_end_cond ();
                   11520:        }
                   11521: 
                   11522:       if (DECL_NAME (fndecl) == NULL_TREE
                   11523:          && TREE_CHAIN (DECL_ARGUMENTS (fndecl)) != NULL_TREE)
                   11524:        build_default_constructor (fndecl);
                   11525: 
                   11526:       /* Emit insns from `emit_base_init' which sets up virtual
                   11527:         function table pointer(s).  */
                   11528:       emit_insns (base_init_insns);
                   11529:       base_init_insns = NULL_RTX;
                   11530: 
                   11531:       /* This is where the body of the constructor begins.
                   11532:         If there were no insns in this function body, then the
                   11533:         last_parm_insn is also the last insn.
                   11534: 
                   11535:         If optimization is enabled, last_parm_insn may move, so
                   11536:         we don't hold on to it (across emit_base_init).  */
                   11537:       last_parm_insn = get_first_nonparm_insn ();
                   11538:       if (last_parm_insn == NULL_RTX)
                   11539:        last_parm_insn = mark;
                   11540:       else
                   11541:        last_parm_insn = previous_insn (last_parm_insn);
                   11542: 
                   11543:       if (mark != get_last_insn ())
                   11544:        reorder_insns (next_insn (mark), get_last_insn (), last_parm_insn);
                   11545: 
                   11546:       /* This is where the body of the constructor ends.  */
                   11547:       expand_label (ctor_label);
                   11548:       ctor_label = NULL_TREE;
                   11549:       if (flag_handle_exceptions == 2)
                   11550:        {
                   11551:          expand_assignment (allocated_this, integer_zero_node, 0, 0);
                   11552:          if (call_poplevel)
                   11553:            deactivate_exception_cleanups ();
                   11554:        }
                   11555: 
                   11556:       pop_implicit_try_blocks (NULL_TREE);
                   11557: 
                   11558:       if (call_poplevel)
                   11559:        {
                   11560:          expand_end_bindings (decls = getdecls (), decls != NULL_TREE, 0);
                   11561:          poplevel (decls != NULL_TREE, 1, 0);
                   11562:        }
                   11563: 
                   11564:       c_expand_return (current_class_decl);
                   11565: 
                   11566:       current_function_assigns_this = 0;
                   11567:       current_function_just_assigned_this = 0;
                   11568:     }
                   11569:   else if (IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 4
                   11570:           && ! strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "main")
                   11571:           && DECL_CONTEXT (fndecl) == NULL_TREE)
                   11572:     {
                   11573:       /* Make it so that `main' always returns 0 by default.  */
                   11574: #ifdef VMS
                   11575:       c_expand_return (integer_one_node);
                   11576: #else
                   11577:       c_expand_return (integer_zero_node);
                   11578: #endif
                   11579:     }
                   11580:   else if (return_label != NULL_RTX
                   11581:           && current_function_return_value == NULL_TREE
                   11582:           && ! DECL_NAME (DECL_RESULT (current_function_decl)))
                   11583:     no_return_label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
                   11584: 
                   11585:   if (flag_gc)
                   11586:     expand_gc_prologue_and_epilogue ();
                   11587: 
                   11588:   /* That's the end of the vtable decl's life.  Need to mark it such
                   11589:      if doing stupid register allocation.
                   11590: 
                   11591:      Note that current_vtable_decl is really an INDIRECT_REF
                   11592:      on top of a VAR_DECL here.  */
                   11593:   if (obey_regdecls && current_vtable_decl)
                   11594:     use_variable (DECL_RTL (TREE_OPERAND (current_vtable_decl, 0)));
                   11595: 
                   11596:   /* If this function is supposed to return a value, ensure that
                   11597:      we do not fall into the cleanups by mistake.  The end of our
                   11598:      function will look like this:
                   11599: 
                   11600:        user code (may have return stmt somewhere)
                   11601:        goto no_return_label
                   11602:        cleanup_label:
                   11603:        cleanups
                   11604:        goto return_label
                   11605:        no_return_label:
                   11606:        NOTE_INSN_FUNCTION_END
                   11607:        return_label:
                   11608:        things for return
                   11609: 
                   11610:      If the user omits a return stmt in the USER CODE section, we
                   11611:      will have a control path which reaches NOTE_INSN_FUNCTION_END.
                   11612:      Otherwise, we won't.  */
                   11613:   if (no_return_label)
                   11614:     {
                   11615:       DECL_CONTEXT (no_return_label) = fndecl;
                   11616:       DECL_INITIAL (no_return_label) = error_mark_node;
                   11617:       DECL_SOURCE_FILE (no_return_label) = input_filename;
                   11618:       DECL_SOURCE_LINE (no_return_label) = lineno;
                   11619:       expand_goto (no_return_label);
                   11620:     }
                   11621: 
                   11622:   if (cleanup_label)
                   11623:     {
                   11624:       /* remove the binding contour which is used
                   11625:         to catch cleanup-generated temporaries.  */
                   11626:       expand_end_bindings (0, 0, 0);
                   11627:       poplevel (0, 0, 0);
                   11628:     }
                   11629: 
                   11630:   if (cleanup_label)
                   11631:     /* Emit label at beginning of cleanup code for parameters.  */
                   11632:     emit_label (cleanup_label);
                   11633: 
                   11634: #if 1
                   11635:   /* Cheap hack to get better code from GNU C++.  Remove when cse is fixed.  */
                   11636:   if (exception_throw_decl && sets_exception_throw_decl == 0)
                   11637:     expand_assignment (exception_throw_decl, integer_zero_node, 0, 0);
                   11638: #endif
                   11639: 
                   11640:   if (flag_handle_exceptions)
                   11641:     {
                   11642:       expand_end_try ();
                   11643:       expand_start_except (0, 0);
                   11644:       expand_end_except ();
                   11645:     }
                   11646: 
                   11647:   /* Get return value into register if that's where it's supposed to be.  */
                   11648:   if (original_result_rtx)
                   11649:     fixup_result_decl (DECL_RESULT (fndecl), original_result_rtx);
                   11650: 
                   11651:   /* Finish building code that will trigger warnings if users forget
                   11652:      to make their functions return values.  */
                   11653:   if (no_return_label || cleanup_label)
                   11654:     emit_jump (return_label);
                   11655:   if (no_return_label)
                   11656:     {
                   11657:       /* We don't need to call `expand_*_return' here because we
                   11658:         don't need any cleanups here--this path of code is only
                   11659:         for error checking purposes.  */
                   11660:       expand_label (no_return_label);
                   11661:     }
                   11662: 
                   11663:   /* reset scope for C++: if we were in the scope of a class,
                   11664:      then when we finish this function, we are not longer so.
                   11665:      This cannot be done until we know for sure that no more
                   11666:      class members will ever be referenced in this function
                   11667:      (i.e., calls to destructors).  */
                   11668:   if (current_class_name)
                   11669:     {
                   11670:       ctype = current_class_type;
                   11671: #if NEW_CLASS_SCOPING
                   11672:       pop_nested_class (1);
                   11673: #else
                   11674:       popclass (1);
                   11675: #endif
                   11676:     }
                   11677:   else
                   11678:     pop_memoized_context (1);
                   11679: 
                   11680:   /* Forget about all overloaded functions defined in
                   11681:      this scope which go away.  */
                   11682:   while (overloads_to_forget)
                   11683:     {
                   11684:       IDENTIFIER_GLOBAL_VALUE (TREE_PURPOSE (overloads_to_forget))
                   11685:        = TREE_VALUE (overloads_to_forget);
                   11686:       overloads_to_forget = TREE_CHAIN (overloads_to_forget);
                   11687:     }
                   11688: 
                   11689:   /* Generate rtl for function exit.  */
                   11690:   expand_function_end (input_filename, lineno, 1);
                   11691: 
                   11692:   /* This must come after expand_function_end because cleanups might
                   11693:      have declarations (from inline functions) that need to go into
                   11694:      this function's blocks.  */
                   11695:   if (current_binding_level->parm_flag != 1)
                   11696:     my_friendly_abort (122);
                   11697:   poplevel (1, 0, 1);
                   11698: 
                   11699:   /* Must mark the RESULT_DECL as being in this function.  */
                   11700:   DECL_CONTEXT (DECL_RESULT (fndecl)) = DECL_INITIAL (fndecl);
                   11701: 
                   11702:   /* Obey `register' declarations if `setjmp' is called in this fn.  */
                   11703:   if (flag_traditional && current_function_calls_setjmp)
                   11704:     setjmp_protect (DECL_INITIAL (fndecl));
                   11705: 
                   11706:   /* Set the BLOCK_SUPERCONTEXT of the outermost function scope to point
                   11707:      to the FUNCTION_DECL node itself.  */
                   11708:   BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
                   11709: 
                   11710:   /* So we can tell if jump_optimize sets it to 1.  */
                   11711:   can_reach_end = 0;
                   11712: 
                   11713:   /* ??? Compensate for Sun brain damage in dealing with data segments
                   11714:      of PIC code.  */
                   11715:   if (flag_pic
                   11716:       && (DECL_CONSTRUCTOR_P (fndecl)
                   11717:          || DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (fndecl)))
                   11718:       && CLASSTYPE_NEEDS_VIRTUAL_REINIT (TYPE_METHOD_BASETYPE (fntype)))
                   11719:     DECL_INLINE (fndecl) = 0;
                   11720: 
                   11721:   if (DECL_EXTERNAL (fndecl)
                   11722:       /* This function is just along for the ride.  If we can make
                   11723:         it inline, that's great.  Otherwise, just punt it.  */
                   11724:       && (DECL_INLINE (fndecl) == 0
                   11725:          || flag_no_inline
                   11726:          || function_cannot_inline_p (fndecl)))
                   11727:     {
                   11728:       extern int rtl_dump_and_exit;
                   11729:       int old_rtl_dump_and_exit = rtl_dump_and_exit;
                   11730:       int inline_spec = DECL_INLINE (fndecl);
                   11731: 
                   11732:       /* This throws away the code for FNDECL.  */
                   11733:       rtl_dump_and_exit = 1;
                   11734:       /* This throws away the memory of the code for FNDECL.  */
                   11735:       if (flag_no_inline)
                   11736:        DECL_INLINE (fndecl) = 0;
                   11737:       rest_of_compilation (fndecl);
                   11738:       rtl_dump_and_exit = old_rtl_dump_and_exit;
                   11739:       DECL_INLINE (fndecl) = inline_spec;
                   11740:     }
                   11741:   else
                   11742:     {
                   11743:       /* Run the optimizers and output the assembler code for this function.  */
                   11744:       rest_of_compilation (fndecl);
                   11745:     }
                   11746: 
                   11747:   if (ctype && TREE_ASM_WRITTEN (fndecl))
                   11748:     note_debug_info_needed (ctype);
                   11749: 
                   11750:   current_function_returns_null |= can_reach_end;
                   11751: 
                   11752:   /* Since we don't normally go through c_expand_return for constructors,
                   11753:      this normally gets the wrong value.
                   11754:      Also, named return values have their return codes emitted after
                   11755:      NOTE_INSN_FUNCTION_END, confusing jump.c.  */
                   11756:   if (DECL_CONSTRUCTOR_P (fndecl)
                   11757:       || DECL_NAME (DECL_RESULT (fndecl)) != NULL_TREE)
                   11758:     current_function_returns_null = 0;
                   11759: 
                   11760:   if (TREE_THIS_VOLATILE (fndecl) && current_function_returns_null)
                   11761:     warning ("`volatile' function does return");
                   11762:   else if (warn_return_type && current_function_returns_null
                   11763:           && TYPE_MAIN_VARIANT (TREE_TYPE (fntype)) != void_type_node)
                   11764:     {
                   11765:       /* If this function returns non-void and control can drop through,
                   11766:         complain.  */
                   11767:       pedwarn ("control reaches end of non-void function");
                   11768:     }
                   11769:   /* With just -W, complain only if function returns both with
                   11770:      and without a value.  */
                   11771:   else if (extra_warnings
                   11772:           && current_function_returns_value && current_function_returns_null)
                   11773:     warning ("this function may return with or without a value");
                   11774: 
                   11775:   /* Free all the tree nodes making up this function.  */
                   11776:   /* Switch back to allocating nodes permanently
                   11777:      until we start another function.  */
                   11778:   permanent_allocation ();
                   11779: 
                   11780:   if (flag_cadillac)
                   11781:     cadillac_finish_function (fndecl);
                   11782: 
                   11783:   if (DECL_SAVED_INSNS (fndecl) == NULL_RTX)
                   11784:     {
                   11785:       /* Stop pointing to the local nodes about to be freed.  */
                   11786:       /* But DECL_INITIAL must remain nonzero so we know this
                   11787:         was an actual function definition.  */
                   11788:       DECL_INITIAL (fndecl) = error_mark_node;
                   11789:       if (! DECL_CONSTRUCTOR_P (fndecl)
                   11790:          || !TYPE_USES_VIRTUAL_BASECLASSES (TYPE_METHOD_BASETYPE (fntype)))
                   11791:        DECL_ARGUMENTS (fndecl) = NULL_TREE;
                   11792:     }
                   11793: 
                   11794:   /* Let the error reporting routines know that we're outside a function.  */
                   11795:   current_function_decl = NULL_TREE;
                   11796:   named_label_uses = NULL_TREE;
                   11797: }
                   11798: 
                   11799: /* Create the FUNCTION_DECL for a function definition.
                   11800:    LINE1 is the line number that the definition absolutely begins on.
                   11801:    LINE2 is the line number that the name of the function appears on.
                   11802:    DECLSPECS and DECLARATOR are the parts of the declaration;
                   11803:    they describe the function's name and the type it returns,
                   11804:    but twisted together in a fashion that parallels the syntax of C.
                   11805: 
                   11806:    This function creates a binding context for the function body
                   11807:    as well as setting up the FUNCTION_DECL in current_function_decl.
                   11808: 
                   11809:    Returns a FUNCTION_DECL on success.
                   11810: 
                   11811:    If the DECLARATOR is not suitable for a function (it defines a datum
                   11812:    instead), we return 0, which tells yyparse to report a parse error.
                   11813: 
                   11814:    May return void_type_node indicating that this method is actually
                   11815:    a friend.  See grokfield for more details.
                   11816: 
                   11817:    Came here with a `.pushlevel' .
                   11818: 
                   11819:    DO NOT MAKE ANY CHANGES TO THIS CODE WITHOUT MAKING CORRESPONDING
                   11820:    CHANGES TO CODE IN `grokfield'.  */
                   11821: tree
                   11822: start_method (declspecs, declarator, raises)
                   11823:      tree declarator, declspecs, raises;
                   11824: {
                   11825:   tree fndecl = grokdeclarator (declarator, declspecs, MEMFUNCDEF, 0, raises);
                   11826: 
                   11827:   /* Something too ugly to handle.  */
                   11828:   if (fndecl == NULL_TREE)
                   11829:     return NULL_TREE;
                   11830: 
                   11831:   /* Pass friends other than inline friend functions back.  */
                   11832:   if (TYPE_MAIN_VARIANT (fndecl) == void_type_node)
                   11833:     return fndecl;
                   11834: 
                   11835:   if (TREE_CODE (fndecl) != FUNCTION_DECL)
                   11836:     /* Not a function, tell parser to report parse error.  */
                   11837:     return NULL_TREE;
                   11838: 
                   11839:   if (DECL_IN_AGGR_P (fndecl))
                   11840:     {
                   11841:       if (IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (fndecl)) != current_class_type)
                   11842:        {
                   11843:          if (DECL_CONTEXT (fndecl))
                   11844:            cp_error ("`%D' is already defined in class %s", fndecl,
                   11845:                             TYPE_NAME_STRING (DECL_CONTEXT (fndecl)));
                   11846:        }
                   11847:       return void_type_node;
                   11848:     }
                   11849: 
                   11850:   /* If we're expanding a template, a function must be explicitly declared
                   11851:      inline if we're to compile it now.  If it isn't, we have to wait to see
                   11852:      whether it's needed, and whether an override exists.  */
                   11853:   if (flag_default_inline && !processing_template_defn)
                   11854:     DECL_INLINE (fndecl) = 1;
                   11855: 
                   11856:   /* We read in the parameters on the maybepermanent_obstack,
                   11857:      but we won't be getting back to them until after we
                   11858:      may have clobbered them.  So the call to preserve_data
                   11859:      will keep them safe.  */
                   11860:   preserve_data ();
                   11861: 
                   11862:   if (! DECL_FRIEND_P (fndecl))
                   11863:     {
                   11864:       if (DECL_CHAIN (fndecl) != NULL_TREE)
                   11865:        {
                   11866:          /* Need a fresh node here so that we don't get circularity
                   11867:             when we link these together.  If FNDECL was a friend, then
                   11868:             `pushdecl' does the right thing, which is nothing wrt its
                   11869:             current value of DECL_CHAIN.  */
                   11870:          fndecl = copy_node (fndecl);
                   11871:        }
                   11872:       if (TREE_CHAIN (fndecl))
                   11873:        {
                   11874:          fndecl = copy_node (fndecl);
                   11875:          TREE_CHAIN (fndecl) = NULL_TREE;
                   11876:        }
                   11877: 
                   11878:       if (DECL_CONSTRUCTOR_P (fndecl))
                   11879:        grok_ctor_properties (current_class_type, fndecl);
                   11880:       else if (IDENTIFIER_OPNAME_P (DECL_NAME (fndecl)))
                   11881:        grok_op_properties (fndecl, DECL_VIRTUAL_P (fndecl));
                   11882:     }
                   11883: 
                   11884:   finish_decl (fndecl, NULL_TREE, NULL_TREE, 0);
                   11885: 
                   11886:   /* Make a place for the parms */
                   11887:   pushlevel (0);
                   11888:   current_binding_level->parm_flag = 1;
                   11889:   
                   11890:   DECL_IN_AGGR_P (fndecl) = 1;
                   11891:   return fndecl;
                   11892: }
                   11893: 
                   11894: /* Go through the motions of finishing a function definition.
                   11895:    We don't compile this method until after the whole class has
                   11896:    been processed.
                   11897: 
                   11898:    FINISH_METHOD must return something that looks as though it
                   11899:    came from GROKFIELD (since we are defining a method, after all).
                   11900: 
                   11901:    This is called after parsing the body of the function definition.
                   11902:    STMTS is the chain of statements that makes up the function body.
                   11903: 
                   11904:    DECL is the ..._DECL that `start_method' provided.  */
                   11905: 
                   11906: tree
                   11907: finish_method (decl)
                   11908:      tree decl;
                   11909: {
                   11910:   register tree fndecl = decl;
                   11911:   tree old_initial;
                   11912:   tree context = DECL_CONTEXT (fndecl);
                   11913: 
                   11914:   register tree link;
                   11915: 
                   11916:   if (TYPE_MAIN_VARIANT (decl) == void_type_node)
                   11917:     return decl;
                   11918: 
                   11919:   old_initial = DECL_INITIAL (fndecl);
                   11920: 
                   11921:   /* Undo the level for the parms (from start_method).
                   11922:      This is like poplevel, but it causes nothing to be
                   11923:      saved.  Saving information here confuses symbol-table
                   11924:      output routines.  Besides, this information will
                   11925:      be correctly output when this method is actually
                   11926:      compiled.  */
                   11927: 
                   11928:   /* Clear out the meanings of the local variables of this level;
                   11929:      also record in each decl which block it belongs to.  */
                   11930: 
                   11931:   for (link = current_binding_level->names; link; link = TREE_CHAIN (link))
                   11932:     {
                   11933:       if (DECL_NAME (link) != NULL_TREE)
                   11934:        IDENTIFIER_LOCAL_VALUE (DECL_NAME (link)) = 0;
                   11935:       my_friendly_assert (TREE_CODE (link) != FUNCTION_DECL, 163);
                   11936:       DECL_CONTEXT (link) = NULL_TREE;
                   11937:     }
                   11938: 
                   11939:   /* Restore all name-meanings of the outer levels
                   11940:      that were shadowed by this level.  */
                   11941: 
                   11942:   for (link = current_binding_level->shadowed; link; link = TREE_CHAIN (link))
                   11943:       IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
                   11944:   for (link = current_binding_level->class_shadowed;
                   11945:        link; link = TREE_CHAIN (link))
                   11946:     IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
                   11947:   for (link = current_binding_level->type_shadowed;
                   11948:        link; link = TREE_CHAIN (link))
                   11949:     IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
                   11950: 
                   11951:   GNU_xref_end_scope ((HOST_WIDE_INT) current_binding_level,
                   11952:                      (HOST_WIDE_INT) current_binding_level->level_chain,
                   11953:                      current_binding_level->parm_flag,
                   11954:                      current_binding_level->keep,
                   11955:                      current_binding_level->tag_transparent);
                   11956: 
                   11957:   poplevel (0, 0, 0);
                   11958: 
                   11959:   DECL_INITIAL (fndecl) = old_initial;
                   11960: 
                   11961:   /* We used to check if the context of FNDECL was different from
                   11962:      current_class_type as another way to get inside here.  This didn't work
                   11963:      for String.cc in libg++.  */
                   11964:   if (DECL_FRIEND_P (fndecl))
                   11965:     {
                   11966:       CLASSTYPE_INLINE_FRIENDS (current_class_type)
                   11967:        = tree_cons (NULL_TREE, fndecl, CLASSTYPE_INLINE_FRIENDS (current_class_type));
                   11968:       decl = void_type_node;
                   11969:     }
                   11970: 
                   11971:   return decl;
                   11972: }
                   11973: 
                   11974: /* Called when a new struct TYPE is defined.
                   11975:    If this structure or union completes the type of any previous
                   11976:    variable declaration, lay it out and output its rtl.  */
                   11977: 
                   11978: void
                   11979: hack_incomplete_structures (type)
                   11980:      tree type;
                   11981: {
                   11982:   tree decl;
                   11983: 
                   11984:   if (current_binding_level->n_incomplete == 0)
                   11985:     return;
                   11986: 
                   11987:   if (!type) /* Don't do this for class templates.  */
                   11988:     return;
                   11989: 
                   11990:   for (decl = current_binding_level->names; decl; decl = TREE_CHAIN (decl))
                   11991:     if (TREE_TYPE (decl) == type
                   11992:        || (TREE_TYPE (decl)
                   11993:            && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
                   11994:            && TREE_TYPE (TREE_TYPE (decl)) == type))
                   11995:       {
                   11996:        if (TREE_CODE (decl) == TYPE_DECL)
                   11997:          layout_type (TREE_TYPE (decl));
                   11998:        else
                   11999:          {
                   12000:            int toplevel = global_binding_level == current_binding_level;
                   12001:            if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
                   12002:                && TREE_TYPE (TREE_TYPE (decl)) == type)
                   12003:              layout_type (TREE_TYPE (decl));
                   12004:            layout_decl (decl, 0);
                   12005:            rest_of_decl_compilation (decl, NULL_PTR, toplevel, 0);
                   12006:            if (! toplevel)
                   12007:              {
                   12008:                expand_decl (decl);
                   12009:                expand_decl_cleanup (decl, maybe_build_cleanup (decl));
                   12010:                expand_decl_init (decl);
                   12011:              }
                   12012:          }
                   12013:        my_friendly_assert (current_binding_level->n_incomplete > 0, 164);
                   12014:        --current_binding_level->n_incomplete;
                   12015:       }
                   12016: }
                   12017: 
                   12018: /* Nonzero if presently building a cleanup.  Needed because
                   12019:    SAVE_EXPRs are not the right things to use inside of cleanups.
                   12020:    They are only ever evaluated once, where the cleanup
                   12021:    might be evaluated several times.  In this case, a later evaluation
                   12022:    of the cleanup might fill in the SAVE_EXPR_RTL, and it will
                   12023:    not be valid for an earlier cleanup.  */
                   12024: 
                   12025: int building_cleanup;
                   12026: 
                   12027: /* If DECL is of a type which needs a cleanup, build that cleanup here.
                   12028:    We don't build cleanups if just going for syntax checking, since
                   12029:    fixup_cleanups does not know how to not handle them.
                   12030: 
                   12031:    Don't build these on the momentary obstack; they must live
                   12032:    the life of the binding contour.  */
                   12033: tree
                   12034: maybe_build_cleanup (decl)
                   12035:      tree decl;
                   12036: {
                   12037:   tree type = TREE_TYPE (decl);
                   12038:   if (TYPE_NEEDS_DESTRUCTOR (type))
                   12039:     {
                   12040:       int temp = 0, flags = LOOKUP_NORMAL|LOOKUP_DESTRUCTOR;
                   12041:       tree rval;
                   12042:       int old_building_cleanup = building_cleanup;
                   12043:       building_cleanup = 1;
                   12044: 
                   12045:       if (TREE_CODE (decl) != PARM_DECL)
                   12046:        temp = suspend_momentary ();
                   12047: 
                   12048:       if (TREE_CODE (type) == ARRAY_TYPE)
                   12049:        rval = decl;
                   12050:       else
                   12051:        {
                   12052:          mark_addressable (decl);
                   12053:          rval = build_unary_op (ADDR_EXPR, decl, 0);
                   12054:        }
                   12055: 
                   12056:       /* Optimize for space over speed here.  */
                   12057:       if (! TYPE_USES_VIRTUAL_BASECLASSES (type)
                   12058:          || flag_expensive_optimizations)
                   12059:        flags |= LOOKUP_NONVIRTUAL;
                   12060: 
                   12061:       /* Use TYPE_MAIN_VARIANT so we don't get a warning about
                   12062:         calling delete on a `const' variable.  */
                   12063:       if (TYPE_READONLY (TREE_TYPE (TREE_TYPE (rval))))
                   12064:        rval = build1 (NOP_EXPR, TYPE_POINTER_TO (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (rval)))), rval);
                   12065: 
                   12066:       rval = build_delete (TREE_TYPE (rval), rval, integer_two_node, flags, 0);
                   12067: 
                   12068:       if (TYPE_USES_VIRTUAL_BASECLASSES (type)
                   12069:          && ! TYPE_HAS_DESTRUCTOR (type))
                   12070:        rval = build_compound_expr (tree_cons (NULL_TREE, rval,
                   12071:                                               build_tree_list (NULL_TREE, build_vbase_delete (type, decl))));
                   12072: 
                   12073:       current_binding_level->have_cleanups = 1;
                   12074:       current_binding_level->more_exceptions_ok = 0;
                   12075: 
                   12076:       if (TREE_CODE (decl) != PARM_DECL)
                   12077:        resume_momentary (temp);
                   12078: 
                   12079:       building_cleanup = old_building_cleanup;
                   12080: 
                   12081:       return rval;
                   12082:     }
                   12083:   return 0;
                   12084: }
                   12085: 
                   12086: /* Expand a C++ expression at the statement level.
                   12087:    This is needed to ferret out nodes which have UNKNOWN_TYPE.
                   12088:    The C++ type checker should get all of these out when
                   12089:    expressions are combined with other, type-providing, expressions,
                   12090:    leaving only orphan expressions, such as:
                   12091: 
                   12092:    &class::bar;                / / takes its address, but does nothing with it.
                   12093: 
                   12094:    */
                   12095: void
                   12096: cplus_expand_expr_stmt (exp)
                   12097:      tree exp;
                   12098: {
                   12099:   if (TREE_TYPE (exp) == unknown_type_node)
                   12100:     {
                   12101:       if (TREE_CODE (exp) == ADDR_EXPR || TREE_CODE (exp) == TREE_LIST)
                   12102:        error ("address of overloaded function with no contextual type information");
                   12103:       else if (TREE_CODE (exp) == COMPONENT_REF)
                   12104:        warning ("useless reference to a member function name, did you forget the ()?");
                   12105:     }
                   12106:   else
                   12107:     {
                   12108:       int remove_implicit_immediately = 0;
                   12109: 
                   12110:       if (TREE_CODE (exp) == FUNCTION_DECL)
                   12111:        {
                   12112:          cp_warning ("reference, not call, to function `%D'", exp);
                   12113:          warning ("at this point in file");
                   12114:        }
                   12115:       if (TREE_RAISES (exp))
                   12116:        {
                   12117:          my_friendly_assert (flag_handle_exceptions, 165);
                   12118:          if (flag_handle_exceptions == 2)
                   12119:            {
                   12120:              if (! current_binding_level->more_exceptions_ok)
                   12121:                {
                   12122:                  extern struct nesting *nesting_stack, *block_stack;
                   12123: 
                   12124:                  remove_implicit_immediately
                   12125:                    = (nesting_stack != block_stack);
                   12126:                  cplus_expand_start_try (1);
                   12127:                }
                   12128:              current_binding_level->have_exceptions = 1;
                   12129:            }
                   12130:        }
                   12131: 
                   12132:       expand_expr_stmt (break_out_cleanups (exp));
                   12133: 
                   12134:       if (remove_implicit_immediately)
                   12135:        pop_implicit_try_blocks (NULL_TREE);
                   12136:     }
                   12137: 
                   12138:   /* Clean up any pending cleanups.  This happens when a function call
                   12139:      returns a cleanup-needing value that nobody uses.  */
                   12140:   expand_cleanups_to (NULL_TREE);
                   12141: }
                   12142: 
                   12143: /* When a stmt has been parsed, this function is called.
                   12144: 
                   12145:    Currently, this function only does something within a
                   12146:    constructor's scope: if a stmt has just assigned to this,
                   12147:    and we are in a derived class, we call `emit_base_init'.  */
                   12148: 
                   12149: void
                   12150: finish_stmt ()
                   12151: {
                   12152:   extern struct nesting *cond_stack, *loop_stack, *case_stack;
                   12153: 
                   12154:   
                   12155:   if (current_function_assigns_this
                   12156:       || ! current_function_just_assigned_this)
                   12157:     return;
                   12158:   if (DECL_CONSTRUCTOR_P (current_function_decl))
                   12159:     {
                   12160:       /* Constructors must wait until we are out of control
                   12161:         zones before calling base constructors.  */
                   12162:       if (cond_stack || loop_stack || case_stack)
                   12163:        return;
                   12164:       emit_insns (base_init_insns);
                   12165:       check_base_init (current_class_type);
                   12166:     }
                   12167:   current_function_assigns_this = 1;
                   12168: 
                   12169:   if (flag_cadillac)
                   12170:     cadillac_finish_stmt ();
                   12171: }
                   12172: 
                   12173: void
                   12174: pop_implicit_try_blocks (decl)
                   12175:      tree decl;
                   12176: {
                   12177:   if (decl)
                   12178:     {
                   12179:       my_friendly_assert (current_binding_level->parm_flag == 3, 166);
                   12180:       current_binding_level->names = TREE_CHAIN (decl);
                   12181:     }
                   12182: 
                   12183:   while (current_binding_level->parm_flag == 3)
                   12184:     {
                   12185:       tree name = get_identifier ("(compiler error)");
                   12186:       tree orig_ex_type = current_exception_type;
                   12187:       tree orig_ex_decl = current_exception_decl;
                   12188:       tree orig_ex_obj = current_exception_object;
                   12189:       tree decl = cplus_expand_end_try (2);
                   12190: 
                   12191:       /* @@ It would be nice to make all these point
                   12192:         to exactly the same handler.  */
                   12193:       /* Start hidden EXCEPT.  */
                   12194:       cplus_expand_start_except (name, decl);
                   12195:       /* reraise ALL.  */
                   12196:       cplus_expand_reraise (NULL_TREE);
                   12197:       current_exception_type = orig_ex_type;
                   12198:       current_exception_decl = orig_ex_decl;
                   12199:       current_exception_object = orig_ex_obj;
                   12200:       /* This will reraise for us.  */
                   12201:       cplus_expand_end_except (error_mark_node);
                   12202:     }
                   12203: 
                   12204:   if (decl)
                   12205:     {
                   12206:       TREE_CHAIN (decl) = current_binding_level->names;
                   12207:       current_binding_level->names = decl;
                   12208:     }
                   12209: }
                   12210: 
                   12211: /* Push a cleanup onto the current binding contour that will cause
                   12212:    ADDR to be cleaned up, in the case that an exception propagates
                   12213:    through its binding contour.  */
                   12214: 
                   12215: void
                   12216: push_exception_cleanup (addr)
                   12217:      tree addr;
                   12218: {
                   12219:   tree decl = build_decl (VAR_DECL, get_identifier (EXCEPTION_CLEANUP_NAME), ptr_type_node);
                   12220:   tree cleanup;
                   12221: 
                   12222:   decl = pushdecl (decl);
                   12223:   DECL_REGISTER (decl) = 1;
                   12224:   store_init_value (decl, addr);
                   12225:   expand_decl (decl);
                   12226:   expand_decl_init (decl);
                   12227: 
                   12228:   cleanup = build (COND_EXPR, integer_type_node,
                   12229:                   build (NE_EXPR, integer_type_node,
                   12230:                          decl, integer_zero_node),
                   12231:                   build_delete (TREE_TYPE (addr), decl,
                   12232:                                 lookup_name (in_charge_identifier, 0),
                   12233:                                 LOOKUP_NORMAL|LOOKUP_DESTRUCTOR, 0),
                   12234:                   integer_zero_node);
                   12235:   expand_decl_cleanup (decl, cleanup);
                   12236: }
                   12237: 
                   12238: /* For each binding contour, emit code that deactivates the
                   12239:    exception cleanups.  All other cleanups are left as they were.  */
                   12240: 
                   12241: static void
                   12242: deactivate_exception_cleanups ()
                   12243: {
                   12244:   struct binding_level *b = current_binding_level;
                   12245:   tree xyzzy = get_identifier (EXCEPTION_CLEANUP_NAME);
                   12246:   while (b != class_binding_level)
                   12247:     {
                   12248:       if (b->parm_flag == 3)
                   12249:        {
                   12250:          tree decls = b->names;
                   12251:          while (decls)
                   12252:            {
                   12253:              if (DECL_NAME (decls) == xyzzy)
                   12254:                expand_assignment (decls, integer_zero_node, 0, 0);
                   12255:              decls = TREE_CHAIN (decls);
                   12256:            }
                   12257:        }
                   12258:       b = b->level_chain;
                   12259:     }
                   12260: }
                   12261: 
                   12262: /* Change a static member function definition into a FUNCTION_TYPE, instead
                   12263:    of the METHOD_TYPE that we create when it's originally parsed.  */
                   12264: void
                   12265: revert_static_member_fn (fn, decl, argtypes)
                   12266:      tree *fn, *decl, *argtypes;
                   12267: {
                   12268:   tree tmp, function = *fn;
                   12269: 
                   12270:   *argtypes = TREE_CHAIN (*argtypes);
                   12271:   tmp = build_function_type (TREE_TYPE (function), *argtypes);
                   12272:   tmp = build_type_variant (tmp, TYPE_READONLY (function),
                   12273:                            TYPE_VOLATILE (function));
                   12274:   tmp = build_exception_variant (TYPE_METHOD_BASETYPE (function), tmp,
                   12275:                                 TYPE_RAISES_EXCEPTIONS (function));
                   12276:   TREE_TYPE (*decl) = tmp;
                   12277:   *fn = tmp;
                   12278:   DECL_STATIC_FUNCTION_P (*decl) = 1;
                   12279: }

unix.superglobalmegacorp.com

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