Annotation of gcc/cp/decl2.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 "config.h"
                     30: #include <stdio.h>
                     31: #include "tree.h"
                     32: #include "rtl.h"
                     33: #include "flags.h"
                     34: #include "cp-tree.h"
                     35: #include "decl.h"
                     36: #include "lex.h"
                     37: 
                     38: extern tree grokdeclarator ();
                     39: extern tree get_file_function_name ();
                     40: extern tree cleanups_this_call;
                     41: static void grok_function_init ();
                     42: 
                     43: /* A list of virtual function tables we must make sure to write out.  */
                     44: tree pending_vtables;
                     45: 
                     46: /* A list of static class variables.  This is needed, because a
                     47:    static class variable can be declared inside the class without
                     48:    an initializer, and then initialized, staticly, outside the class.  */
                     49: tree pending_statics;
                     50: 
                     51: /* A list of functions which were declared inline, but which we
                     52:    may need to emit outline anyway. */
                     53: static tree saved_inlines;
                     54: 
                     55: /* Used to help generate temporary names which are unique within
                     56:    a function.  Reset to 0 by start_function.  */
                     57: 
                     58: static int temp_name_counter;
                     59: 
                     60: /* Same, but not reset.  Local temp variables and global temp variables
                     61:    can have the same name.  */
                     62: static int global_temp_name_counter;
                     63: 
                     64: /* Flag used when debugging spew.c */
                     65: 
                     66: extern int spew_debug;
                     67: 
                     68: /* C (and C++) language-specific option variables.  */
                     69: 
                     70: /* Nonzero means allow type mismatches in conditional expressions;
                     71:    just make their values `void'.   */
                     72: 
                     73: int flag_cond_mismatch;
                     74: 
                     75: /* Nonzero means give `double' the same size as `float'.  */
                     76: 
                     77: int flag_short_double;
                     78: 
                     79: /* Nonzero means don't recognize the keyword `asm'.  */
                     80: 
                     81: int flag_no_asm;
                     82: 
                     83: /* Nonzero means don't recognize the non-ANSI builtin functions.  */
                     84: 
                     85: int flag_no_builtin;
                     86: 
                     87: /* Nonzero means don't recognize the non-ANSI builtin functions.
                     88:    -ansi sets this.  */
                     89: 
                     90: int flag_no_nonansi_builtin;
                     91: 
                     92: /* Nonzero means do some things the same way PCC does.  */
                     93: 
                     94: int flag_traditional;
                     95: 
                     96: /* Nonzero means to treat bitfields as unsigned unless they say `signed'.  */
                     97: 
                     98: int flag_signed_bitfields = 1;
                     99: 
                    100: /* Nonzero means handle `#ident' directives.  0 means ignore them.  */
                    101: 
                    102: int flag_no_ident = 0;
                    103: 
                    104: /* Nonzero means disable GNU extensions.  */
                    105: 
                    106: int flag_ansi = 0;
                    107: 
                    108: /* Nonzero means do emit exported implementations of functions even if
                    109:    they can be inlined.  */
                    110: 
                    111: int flag_implement_inlines = 1;
                    112: 
                    113: /* Nonzero means do emit exported implementations of templates, instead of
                    114:    multiple static copies in each file that needs a definition. */
                    115: 
                    116: int flag_external_templates = 0;
                    117: 
                    118: /* Nonzero means that the decision to emit or not emit the implementation of a
                    119:    template depends on where the template is instantiated, rather than where
                    120:    it is defined.  */
                    121: 
                    122: int flag_alt_external_templates = 0;
                    123: 
                    124: /* Nonzero means that implicit instantiations will be emitted if needed.  */
                    125: 
                    126: int flag_implicit_templates = 1;
                    127: 
                    128: /* Nonzero means warn about implicit declarations.  */
                    129: 
                    130: int warn_implicit = 1;
                    131: 
                    132: /* Nonzero means warn when all ctors or dtors are private, and the class
                    133:    has no friends.  */
                    134: 
                    135: int warn_ctor_dtor_privacy = 1;
                    136: 
                    137: /* True if we want to implement vtbvales using "thunks".
                    138:    The default is off now, but will be on later.
                    139: 
                    140:    Also causes output of vtables to be controlled by whether
                    141:    we seen the class's first non-inline virtual function. */
                    142: int flag_vtable_thunks = 0;
                    143: 
                    144: /* Nonzero means give string constants the type `const char *'
                    145:    to get extra warnings from them.  These warnings will be too numerous
                    146:    to be useful, except in thoroughly ANSIfied programs.  */
                    147: 
                    148: int warn_write_strings;
                    149: 
                    150: /* Nonzero means warn about pointer casts that can drop a type qualifier
                    151:    from the pointer target type.  */
                    152: 
                    153: int warn_cast_qual;
                    154: 
                    155: /* Nonzero means warn that dbx info for template class methods isn't fully
                    156:    supported yet.  */
                    157: 
                    158: int warn_template_debugging;
                    159: 
                    160: /* Warn about traditional constructs whose meanings changed in ANSI C.  */
                    161: 
                    162: int warn_traditional;
                    163: 
                    164: /* Nonzero means warn about sizeof(function) or addition/subtraction
                    165:    of function pointers.  */
                    166: 
                    167: int warn_pointer_arith;
                    168: 
                    169: /* Nonzero means warn for non-prototype function decls
                    170:    or non-prototyped defs without previous prototype.  */
                    171: 
                    172: int warn_strict_prototypes;
                    173: 
                    174: /* Nonzero means warn for any function def without prototype decl.  */
                    175: 
                    176: int warn_missing_prototypes;
                    177: 
                    178: /* Nonzero means warn about multiple (redundant) decls for the same single
                    179:    variable or function.  */
                    180: 
                    181: int warn_redundant_decls;
                    182: 
                    183: /* Warn if initializer is not completely bracketed.  */
                    184: 
                    185: int warn_missing_braces;
                    186: 
                    187: /* Warn about *printf or *scanf format/argument anomalies. */
                    188: 
                    189: int warn_format;
                    190: 
                    191: /* Warn about a subscript that has type char.  */
                    192: 
                    193: int warn_char_subscripts;
                    194: 
                    195: /* Warn if a type conversion is done that might have confusing results.  */
                    196: 
                    197: int warn_conversion;
                    198: 
                    199: /* Warn if adding () is suggested.  */
                    200: 
                    201: int warn_parentheses = 1;
                    202: 
                    203: /* Non-zero means warn in function declared in derived class has the
                    204:    same name as a virtual in the base class, but fails to match the
                    205:    type signature of any virtual function in the base class.  */
                    206: int warn_overloaded_virtual;
                    207: 
                    208: /* Non-zero means warn when declaring a class that has a non virtual
                    209:    destructor, when it really ought to have a virtual one. */
                    210: int warn_nonvdtor;
                    211: 
                    212: /* Non-zero means warn when a function is declared extern and later inline.  */
                    213: int warn_extern_inline;
                    214: 
                    215: /* Non-zero means warn when the compiler will reorder code.  */
                    216: int warn_reorder;
                    217: 
                    218: /* Non-zero means warn when sysnthesis behavior differs from Cfront's.  */
                    219: int warn_synth;
                    220: 
                    221: /* Nonzero means `$' can be in an identifier.
                    222:    See cccp.c for reasons why this breaks some obscure ANSI C programs.  */
                    223: 
                    224: #ifndef DOLLARS_IN_IDENTIFIERS
                    225: #define DOLLARS_IN_IDENTIFIERS 1
                    226: #endif
                    227: int dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
                    228: 
                    229: /* Nonzero for -fno-strict-prototype switch: do not consider empty
                    230:    argument prototype to mean function takes no arguments.  */
                    231: 
                    232: int strict_prototype = 1;
                    233: int strict_prototypes_lang_c, strict_prototypes_lang_cplusplus = 1;
                    234: 
                    235: /* Nonzero means that labels can be used as first-class objects */
                    236: 
                    237: int flag_labels_ok;
                    238: 
                    239: /* Non-zero means to collect statistics which might be expensive
                    240:    and to print them when we are done.  */
                    241: int flag_detailed_statistics;
                    242: 
                    243: /* C++ specific flags.  */   
                    244: /* Nonzero for -fall-virtual: make every member function (except
                    245:    constructors) lay down in the virtual function table.  Calls
                    246:    can then either go through the virtual function table or not,
                    247:    depending.  */
                    248: 
                    249: int flag_all_virtual;
                    250: 
                    251: /* Zero means that `this' is a *const.  This gives nice behavior in the
                    252:    2.0 world.  1 gives 1.2-compatible behavior.  2 gives Spring behavior.
                    253:    -2 means we're constructing an object and it has fixed type.  */
                    254: 
                    255: int flag_this_is_variable;
                    256: 
                    257: /* Nonzero means memoize our member lookups.  */
                    258: 
                    259: int flag_memoize_lookups; int flag_save_memoized_contexts;
                    260: 
                    261: /* 3 means write out only virtuals function tables `defined'
                    262:    in this implementation file.
                    263:    2 means write out only specific virtual function tables
                    264:    and give them (C) public access.
                    265:    1 means write out virtual function tables and give them
                    266:    (C) public access.
                    267:    0 means write out virtual function tables and give them
                    268:    (C) static access (default).
                    269:    -1 means declare virtual function tables extern.  */
                    270: 
                    271: int write_virtuals;
                    272: 
                    273: /* Nonzero means we should attempt to elide constructors when possible.  */
                    274: 
                    275: int flag_elide_constructors;
                    276: 
                    277: /* Nonzero means recognize and handle exception handling constructs.
                    278:    Use ansi syntax and semantics.  WORK IN PROGRESS!  */
                    279: 
                    280: int flag_handle_exceptions;
                    281: 
                    282: /* Nonzero means recognize and handle signature language constructs.  */
                    283: 
                    284: int flag_handle_signatures;
                    285: 
                    286: /* Nonzero means that member functions defined in class scope are
                    287:    inline by default.  */
                    288: 
                    289: int flag_default_inline = 1;
                    290: 
                    291: /* Controls whether enums and ints freely convert.
                    292:    1 means with complete freedom.
                    293:    0 means enums can convert to ints, but not vice-versa.  */
                    294: int flag_int_enum_equivalence;
                    295: 
                    296: /* Controls whether compiler is operating under LUCID's Cadillac
                    297:    system.  1 means yes, 0 means no.  */
                    298: int flag_cadillac;
                    299: 
                    300: /* Controls whether compiler generates code to build objects
                    301:    that can be collected when they become garbage.  */
                    302: int flag_gc;
                    303: 
                    304: /* Controls whether compiler generates 'dossiers' that give
                    305:    run-time type information.  */
                    306: int flag_dossier;
                    307: 
                    308: /* Nonzero if we wish to output cross-referencing information
                    309:    for the GNU class browser.  */
                    310: extern int flag_gnu_xref;
                    311: 
                    312: /* Nonzero if compiler can make `reasonable' assumptions about
                    313:    references and objects.  For example, the compiler must be
                    314:    conservative about the following and not assume that `a' is nonnull:
                    315: 
                    316:    obj &a = g ();
                    317:    a.f (2);
                    318: 
                    319:    In general, it is `reasonable' to assume that for many programs,
                    320:    and better code can be generated in that case.  */
                    321: 
                    322: int flag_assume_nonnull_objects;
                    323: 
                    324: /* Nonzero if we want to support huge (> 2^(sizeof(short)*8-1) bytes)
                    325:    objects. */
                    326: int flag_huge_objects;
                    327: 
                    328: /* Nonzero if we want to conserve space in the .o files.  We do this
                    329:    by putting uninitialized data and runtime initialized data into
                    330:    .common instead of .data at the expense of not flaging multiple
                    331:    definitions.  */
                    332: int flag_conserve_space;
                    333: 
                    334: /* Nonzero if we want to obey access control semantics.  */
                    335: int flag_access_control = 1;
                    336: 
                    337: /* Table of language-dependent -f options.
                    338:    STRING is the option name.  VARIABLE is the address of the variable.
                    339:    ON_VALUE is the value to store in VARIABLE
                    340:     if `-fSTRING' is seen as an option.
                    341:    (If `-fno-STRING' is seen as an option, the opposite value is stored.)  */
                    342: 
                    343: static struct { char *string; int *variable; int on_value;} lang_f_options[] =
                    344: {
                    345:   {"signed-char", &flag_signed_char, 1},
                    346:   {"unsigned-char", &flag_signed_char, 0},
                    347:   {"signed-bitfields", &flag_signed_bitfields, 1},
                    348:   {"unsigned-bitfields", &flag_signed_bitfields, 0},
                    349:   {"short-enums", &flag_short_enums, 1},
                    350:   {"short-double", &flag_short_double, 1},
                    351:   {"cond-mismatch", &flag_cond_mismatch, 1},
                    352:   {"asm", &flag_no_asm, 0},
                    353:   {"builtin", &flag_no_builtin, 0},
                    354:   {"ident", &flag_no_ident, 0},
                    355:   {"labels-ok", &flag_labels_ok, 1},
                    356:   {"stats", &flag_detailed_statistics, 1},
                    357:   {"this-is-variable", &flag_this_is_variable, 1},
                    358:   {"strict-prototype", &strict_prototypes_lang_cplusplus, 1},
                    359:   {"all-virtual", &flag_all_virtual, 1},
                    360:   {"memoize-lookups", &flag_memoize_lookups, 1},
                    361:   {"elide-constructors", &flag_elide_constructors, 1},
                    362:   {"handle-exceptions", &flag_handle_exceptions, 1},
                    363:   {"handle-signatures", &flag_handle_signatures, 1},
                    364:   {"default-inline", &flag_default_inline, 1},
                    365:   {"dollars-in-identifiers", &dollars_in_ident, 1},
                    366:   {"enum-int-equiv", &flag_int_enum_equivalence, 1},
                    367:   {"gc", &flag_gc, 1},
                    368:   {"dossier", &flag_dossier, 1},
                    369:   {"xref", &flag_gnu_xref, 1},
                    370:   {"nonnull-objects", &flag_assume_nonnull_objects, 1},
                    371:   {"implement-inlines", &flag_implement_inlines, 1},
                    372:   {"external-templates", &flag_external_templates, 1},
                    373:   {"implicit-templates", &flag_implicit_templates, 1},
                    374:   {"huge-objects", &flag_huge_objects, 1},
                    375:   {"conserve-space", &flag_conserve_space, 1},
                    376:   {"vtable-thunks", &flag_vtable_thunks, 1},
                    377:   {"short-temps", &flag_short_temps, 1},
                    378:   {"access-control", &flag_access_control, 1},
                    379:   {"nonansi-builtins", &flag_no_nonansi_builtin, 0}
                    380: };
                    381: 
                    382: /* Decode the string P as a language-specific option.
                    383:    Return 1 if it is recognized (and handle it);
                    384:    return 0 if not recognized.  */
                    385: 
                    386: int   
                    387: lang_decode_option (p)
                    388:      char *p;
                    389: {
                    390:   if (!strcmp (p, "-ftraditional") || !strcmp (p, "-traditional"))
                    391:     flag_traditional = 1, dollars_in_ident = 1, flag_writable_strings = 1,
                    392:     flag_this_is_variable = 1;
                    393:   /* The +e options are for cfront compatibility.  They come in as
                    394:      `-+eN', to kludge around gcc.c's argument handling.  */
                    395:   else if (p[0] == '-' && p[1] == '+' && p[2] == 'e')
                    396:     {
                    397:       int old_write_virtuals = write_virtuals;
                    398:       if (p[3] == '1')
                    399:        write_virtuals = 1;
                    400:       else if (p[3] == '0')
                    401:        write_virtuals = -1;
                    402:       else if (p[3] == '2')
                    403:        write_virtuals = 2;
                    404:       else error ("invalid +e option");
                    405:       if (old_write_virtuals != 0
                    406:          && write_virtuals != old_write_virtuals)
                    407:        error ("conflicting +e options given");
                    408:     }
                    409:   else if (p[0] == '-' && p[1] == 'f')
                    410:     {
                    411:       /* Some kind of -f option.
                    412:         P's value is the option sans `-f'.
                    413:         Search for it in the table of options.  */
                    414:       int found = 0, j;
                    415: 
                    416:       p += 2;
                    417:       /* Try special -f options.  */
                    418: 
                    419:       if (!strcmp (p, "save-memoized"))
                    420:        {
                    421:          flag_memoize_lookups = 1;
                    422:          flag_save_memoized_contexts = 1;
                    423:          found = 1;
                    424:        }
                    425:       if (!strcmp (p, "no-save-memoized"))
                    426:        {
                    427:          flag_memoize_lookups = 0;
                    428:          flag_save_memoized_contexts = 0;
                    429:          found = 1;
                    430:        }
                    431:       else if (! strncmp (p, "cadillac", 8))
                    432:        {
                    433:          flag_cadillac = atoi (p+9);
                    434:          found = 1;
                    435:        }
                    436:       else if (! strncmp (p, "no-cadillac", 11))
                    437:        {
                    438:          flag_cadillac = 0;
                    439:          found = 1;
                    440:        }
                    441:       else if (! strcmp (p, "gc"))
                    442:        {
                    443:          flag_gc = 1;
                    444:          /* This must come along for the ride.  */
                    445:          flag_dossier = 1;
                    446:          found = 1;
                    447:        }
                    448:       else if (! strcmp (p, "no-gc"))
                    449:        {
                    450:          flag_gc = 0;
                    451:          /* This must come along for the ride.  */
                    452:          flag_dossier = 0;
                    453:          found = 1;
                    454:        }
                    455:       else if (! strcmp (p, "alt-external-templates"))
                    456:        {
                    457:          flag_external_templates = 1;
                    458:          flag_alt_external_templates = 1;
                    459:          found = 1;
                    460:        }
                    461:       else if (! strcmp (p, "no-alt-external-templates"))
                    462:        {
                    463:          flag_alt_external_templates = 0;
                    464:          found = 1;
                    465:        }
                    466:       else if (!strcmp (p, "ansi-overloading"))
                    467:        {
                    468:          warning ("-fansi-overloading is no longer meaningful");
                    469:        }
                    470:       else for (j = 0;
                    471:                !found && j < sizeof (lang_f_options) / sizeof (lang_f_options[0]);
                    472:                j++)
                    473:        {
                    474:          if (!strcmp (p, lang_f_options[j].string))
                    475:            {
                    476:              *lang_f_options[j].variable = lang_f_options[j].on_value;
                    477:              /* A goto here would be cleaner,
                    478:                 but breaks the vax pcc.  */
                    479:              found = 1;
                    480:            }
                    481:          if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
                    482:              && ! strcmp (p+3, lang_f_options[j].string))
                    483:            {
                    484:              *lang_f_options[j].variable = ! lang_f_options[j].on_value;
                    485:              found = 1;
                    486:            }
                    487:        }
                    488:       return found;
                    489:     }
                    490:   else if (p[0] == '-' && p[1] == 'W')
                    491:     {
                    492:       int setting = 1;
                    493: 
                    494:       /* The -W options control the warning behavior of the compiler.  */
                    495:       p += 2;
                    496: 
                    497:       if (p[0] == 'n' && p[1] == 'o' && p[2] == '-')
                    498:        setting = 0, p += 3;
                    499: 
                    500:       if (!strcmp (p, "implicit"))
                    501:        warn_implicit = setting;
                    502:       else if (!strcmp (p, "return-type"))
                    503:        warn_return_type = setting;
                    504:       else if (!strcmp (p, "ctor-dtor-privacy"))
                    505:        warn_ctor_dtor_privacy = setting;
                    506:       else if (!strcmp (p, "write-strings"))
                    507:        warn_write_strings = setting;
                    508:       else if (!strcmp (p, "cast-qual"))
                    509:        warn_cast_qual = setting;
                    510:       else if (!strcmp (p, "traditional"))
                    511:        warn_traditional = setting;
                    512:       else if (!strcmp (p, "char-subscripts"))
                    513:        warn_char_subscripts = setting;
                    514:       else if (!strcmp (p, "pointer-arith"))
                    515:        warn_pointer_arith = setting;
                    516:       else if (!strcmp (p, "strict-prototypes"))
                    517:        warn_strict_prototypes = setting;
                    518:       else if (!strcmp (p, "missing-prototypes"))
                    519:        warn_missing_prototypes = setting;
                    520:       else if (!strcmp (p, "redundant-decls"))
                    521:        warn_redundant_decls = setting;
                    522:       else if (!strcmp (p, "missing-braces"))
                    523:        warn_missing_braces = setting;
                    524:       else if (!strcmp (p, "format"))
                    525:        warn_format = setting;
                    526:       else if (!strcmp (p, "conversion"))
                    527:        warn_conversion = setting;
                    528:       else if (!strcmp (p, "parentheses"))
                    529:        warn_parentheses = setting;
                    530:       else if (!strcmp (p, "non-virtual-dtor"))
                    531:        warn_nonvdtor = setting;
                    532:       else if (!strcmp (p, "extern-inline"))
                    533:        warn_extern_inline = setting;
                    534:       else if (!strcmp (p, "reorder"))
                    535:        warn_reorder = setting;
                    536:       else if (!strcmp (p, "synth"))
                    537:        warn_synth = setting;
                    538:       else if (!strcmp (p, "comment"))
                    539:        ;                       /* cpp handles this one.  */
                    540:       else if (!strcmp (p, "comments"))
                    541:        ;                       /* cpp handles this one.  */
                    542:       else if (!strcmp (p, "trigraphs"))
                    543:        ;                       /* cpp handles this one.  */
                    544:       else if (!strcmp (p, "import"))
                    545:        ;                       /* cpp handles this one.  */
                    546:       else if (!strcmp (p, "all"))
                    547:        {
                    548:          extra_warnings = setting;
                    549:          warn_return_type = setting;
                    550:          warn_unused = setting;
                    551:          warn_implicit = setting;
                    552:          warn_ctor_dtor_privacy = setting;
                    553:          warn_switch = setting;
                    554:          warn_format = setting;
                    555:          warn_missing_braces = setting;
                    556:          warn_extern_inline = setting;
                    557:          warn_nonvdtor = setting;
                    558:          /* We save the value of warn_uninitialized, since if they put
                    559:             -Wuninitialized on the command line, we need to generate a
                    560:             warning about not using it without also specifying -O.  */
                    561:          if (warn_uninitialized != 1)
                    562:            warn_uninitialized = (setting ? 2 : 0);
                    563:          warn_template_debugging = setting;
                    564:          warn_reorder = setting;
                    565:        }
                    566: 
                    567:       else if (!strcmp (p, "overloaded-virtual"))
                    568:        warn_overloaded_virtual = setting;
                    569:       else return 0;
                    570:     }
                    571:   else if (!strcmp (p, "-ansi"))
                    572:     flag_no_asm = 1, dollars_in_ident = 0, flag_no_nonansi_builtin = 1,
                    573:     flag_ansi = 1;
                    574: #ifdef SPEW_DEBUG
                    575:   /* Undocumented, only ever used when you're invoking cc1plus by hand, since
                    576:      it's probably safe to assume no sane person would ever want to use this
                    577:      under normal circumstances.  */
                    578:   else if (!strcmp (p, "-spew-debug"))
                    579:     spew_debug = 1;
                    580: #endif
                    581:   else
                    582:     return 0;
                    583: 
                    584:   return 1;
                    585: }
                    586: 
                    587: /* Incorporate `const' and `volatile' qualifiers for member functions.
                    588:    FUNCTION is a TYPE_DECL or a FUNCTION_DECL.
                    589:    QUALS is a list of qualifiers.  */
                    590: tree
                    591: grok_method_quals (ctype, function, quals)
                    592:      tree ctype, function, quals;
                    593: {
                    594:   tree fntype = TREE_TYPE (function);
                    595:   tree raises = TYPE_RAISES_EXCEPTIONS (fntype);
                    596: 
                    597:   do
                    598:     {
                    599:       extern tree ridpointers[];
                    600: 
                    601:       if (TREE_VALUE (quals) == ridpointers[(int)RID_CONST])
                    602:        {
                    603:          if (TYPE_READONLY (ctype))
                    604:            error ("duplicate `%s' %s",
                    605:                   IDENTIFIER_POINTER (TREE_VALUE (quals)),
                    606:                   (TREE_CODE (function) == FUNCTION_DECL
                    607:                    ? "for member function" : "in type declaration"));
                    608:          ctype = build_type_variant (ctype, 1, TYPE_VOLATILE (ctype));
                    609:          build_pointer_type (ctype);
                    610:        }
                    611:       else if (TREE_VALUE (quals) == ridpointers[(int)RID_VOLATILE])
                    612:        {
                    613:          if (TYPE_VOLATILE (ctype))
                    614:            error ("duplicate `%s' %s",
                    615:                   IDENTIFIER_POINTER (TREE_VALUE (quals)),
                    616:                   (TREE_CODE (function) == FUNCTION_DECL
                    617:                    ? "for member function" : "in type declaration"));
                    618:          ctype = build_type_variant (ctype, TYPE_READONLY (ctype), 1);
                    619:          build_pointer_type (ctype);
                    620:        }
                    621:       else
                    622:        my_friendly_abort (20);
                    623:       quals = TREE_CHAIN (quals);
                    624:     }
                    625:   while (quals);
                    626:   fntype = build_cplus_method_type (ctype, TREE_TYPE (fntype),
                    627:                                    (TREE_CODE (fntype) == METHOD_TYPE
                    628:                                     ? TREE_CHAIN (TYPE_ARG_TYPES (fntype))
                    629:                                     : TYPE_ARG_TYPES (fntype)));
                    630:   if (raises)
                    631:     fntype = build_exception_variant (ctype, fntype, raises);
                    632: 
                    633:   TREE_TYPE (function) = fntype;
                    634:   return ctype;
                    635: }
                    636: 
                    637: #if 0                          /* Not used. */
                    638: /* This routine replaces cryptic DECL_NAMEs with readable DECL_NAMEs.
                    639:    It leaves DECL_ASSEMBLER_NAMEs with the correct value.  */
                    640: /* This does not yet work with user defined conversion operators
                    641:    It should.  */
                    642: static void
                    643: substitute_nice_name (decl)
                    644:      tree decl;
                    645: {
                    646:   if (DECL_NAME (decl) && TREE_CODE (DECL_NAME (decl)) == IDENTIFIER_NODE)
                    647:     {
                    648:       char *n = decl_as_string (DECL_NAME (decl), 1);
                    649:       if (n[strlen (n) - 1] == ' ')
                    650:        n[strlen (n) - 1] = 0;
                    651:       DECL_NAME (decl) = get_identifier (n);
                    652:     }
                    653: }
                    654: #endif
                    655: 
                    656: /* Warn when -fexternal-templates is used and #pragma
                    657:    interface/implementation is not used all the times it should be,
                    658:    inform the user.  */
                    659: void
                    660: warn_if_unknown_interface ()
                    661: {
                    662:   static int already_warned = 0;
                    663:   if (++already_warned == 1)
                    664:     warning ("templates that are built with -fexternal-templates should be in files that have #pragma interface/implementation");
                    665: }
                    666: 
                    667: /* A subroutine of the parser, to handle a component list.  */
                    668: tree
                    669: grok_x_components (specs, components)
                    670:      tree specs, components;
                    671: {
                    672:   register tree t, x, tcode;
                    673: 
                    674:   /* We just got some friends.  They have been recorded elsewhere.  */
                    675:   if (components == void_type_node)
                    676:     return NULL_TREE;
                    677: 
                    678:   if (components == NULL_TREE)
                    679:     {
                    680:       t = groktypename (build_decl_list (specs, NULL_TREE));
                    681: 
                    682:       if (t == NULL_TREE)
                    683:        {
                    684:          error ("error in component specification");
                    685:          return NULL_TREE;
                    686:        }
                    687: 
                    688:       switch (TREE_CODE (t))
                    689:        {
                    690:        case VAR_DECL:
                    691:          /* Static anonymous unions come out as VAR_DECLs.  */
                    692:          if (TREE_CODE (TREE_TYPE (t)) == UNION_TYPE
                    693:              && ANON_AGGRNAME_P (TYPE_IDENTIFIER (TREE_TYPE (t))))
                    694:            return t;
                    695: 
                    696:          /* We return SPECS here, because in the parser it was ending
                    697:             up with not doing anything to $$, which is what SPECS
                    698:             represents.  */
                    699:          return specs;
                    700:          break;
                    701: 
                    702:        case RECORD_TYPE:
                    703:          /* This code may be needed for UNION_TYPEs as
                    704:             well.  */
                    705:          tcode = record_type_node;
                    706:          if (CLASSTYPE_DECLARED_CLASS(t))
                    707:            tcode = class_type_node;
                    708:          else if (IS_SIGNATURE(t))
                    709:            tcode = signature_type_node;
                    710:          else if (CLASSTYPE_DECLARED_EXCEPTION(t))
                    711:            tcode = exception_type_node;
                    712:          
                    713:          t = xref_defn_tag(tcode, TYPE_IDENTIFIER(t), NULL_TREE);
                    714:          if (TYPE_CONTEXT(t))
                    715:            CLASSTYPE_NO_GLOBALIZE(t) = 1;
                    716:          if (TYPE_LANG_SPECIFIC (t)
                    717:              && CLASSTYPE_DECLARED_EXCEPTION (t))
                    718:            shadow_tag (specs);
                    719:          return NULL_TREE;
                    720:          break;
                    721: 
                    722:        case UNION_TYPE:
                    723:        case ENUMERAL_TYPE:
                    724:          if (TREE_CODE(t) == UNION_TYPE)
                    725:            tcode = union_type_node;
                    726:          else
                    727:            tcode = enum_type_node;
                    728: 
                    729:          t = xref_defn_tag(tcode, TYPE_IDENTIFIER(t), NULL_TREE);
                    730:          if (TREE_CODE(t) == UNION_TYPE && TYPE_CONTEXT(t))
                    731:            CLASSTYPE_NO_GLOBALIZE(t) = 1;
                    732:          if (TREE_CODE (t) == UNION_TYPE
                    733:              && ANON_AGGRNAME_P (TYPE_IDENTIFIER (t)))
                    734:            {
                    735:              struct pending_inline **p;
                    736:              x = build_lang_field_decl (FIELD_DECL, NULL_TREE, t);
                    737: 
                    738:              /* Wipe out memory of synthesized methods */
                    739:              TYPE_HAS_CONSTRUCTOR (t) = 0;
                    740:              TYPE_HAS_DEFAULT_CONSTRUCTOR (t) = 0;
                    741:              TYPE_HAS_INIT_REF (t) = 0;
                    742:              TYPE_HAS_CONST_INIT_REF (t) = 0;
                    743:              TYPE_HAS_ASSIGN_REF (t) = 0;
                    744:              TYPE_HAS_ASSIGNMENT (t) = 0;
                    745:              TYPE_HAS_CONST_ASSIGN_REF (t) = 0;
                    746: 
                    747:              p = &pending_inlines;
                    748:              for (; *p; *p = (*p)->next)
                    749:                if (DECL_CONTEXT ((*p)->fndecl) != t)
                    750:                  break;
                    751:            }
                    752:          else if (TREE_CODE (t) == ENUMERAL_TYPE)
                    753:            x = grok_enum_decls (t, NULL_TREE);
                    754:          else
                    755:            x = NULL_TREE;
                    756:          return x;
                    757:          break;
                    758: 
                    759:        default:
                    760:          if (t != void_type_node)
                    761:            error ("empty component declaration");
                    762:          return NULL_TREE;
                    763:        }
                    764:     }
                    765:   else
                    766:     {
                    767:       t = TREE_TYPE (components);
                    768:       if (TREE_CODE (t) == ENUMERAL_TYPE && TREE_NONLOCAL_FLAG (t))
                    769:        return grok_enum_decls (t, components);
                    770:       else
                    771:        return components;
                    772:     }
                    773: }
                    774: 
                    775: /* Classes overload their constituent function names automatically.
                    776:    When a function name is declared in a record structure,
                    777:    its name is changed to it overloaded name.  Since names for
                    778:    constructors and destructors can conflict, we place a leading
                    779:    '$' for destructors.
                    780: 
                    781:    CNAME is the name of the class we are grokking for.
                    782: 
                    783:    FUNCTION is a FUNCTION_DECL.  It was created by `grokdeclarator'.
                    784: 
                    785:    FLAGS contains bits saying what's special about today's
                    786:    arguments.  1 == DESTRUCTOR.  2 == OPERATOR.
                    787: 
                    788:    If FUNCTION is a destructor, then we must add the `auto-delete' field
                    789:    as a second parameter.  There is some hair associated with the fact
                    790:    that we must "declare" this variable in the manner consistent with the
                    791:    way the rest of the arguments were declared.
                    792: 
                    793:    QUALS are the qualifiers for the this pointer.  */
                    794: 
                    795: void
                    796: grokclassfn (ctype, cname, function, flags, quals)
                    797:      tree ctype, cname, function;
                    798:      enum overload_flags flags;
                    799:      tree quals;
                    800: {
                    801:   tree fn_name = DECL_NAME (function);
                    802:   tree arg_types;
                    803:   tree parm;
                    804:   tree qualtype;
                    805: 
                    806:   if (fn_name == NULL_TREE)
                    807:     {
                    808:       error ("name missing for member function");
                    809:       fn_name = get_identifier ("<anonymous>");
                    810:       DECL_NAME (function) = fn_name;
                    811:     }
                    812: 
                    813:   if (quals)
                    814:     qualtype = grok_method_quals (ctype, function, quals);
                    815:   else
                    816:     qualtype = ctype;
                    817: 
                    818:   arg_types = TYPE_ARG_TYPES (TREE_TYPE (function));
                    819:   if (TREE_CODE (TREE_TYPE (function)) == METHOD_TYPE)
                    820:     {
                    821:       /* Must add the class instance variable up front.  */
                    822:       /* Right now we just make this a pointer.  But later
                    823:         we may wish to make it special.  */
                    824:       tree type = TREE_VALUE (arg_types);
                    825: 
                    826:       if ((flag_this_is_variable > 0)
                    827:          && (flags == DTOR_FLAG || DECL_CONSTRUCTOR_P (function)))
                    828:        type = TYPE_MAIN_VARIANT (type);
                    829: 
                    830:       if (DECL_CONSTRUCTOR_P (function))
                    831:        {
                    832:          if (TYPE_USES_VIRTUAL_BASECLASSES (ctype))
                    833:            {
                    834:              DECL_CONSTRUCTOR_FOR_VBASE_P (function) = 1;
                    835:              /* In this case we need "in-charge" flag saying whether
                    836:                 this constructor is responsible for initialization
                    837:                 of virtual baseclasses or not.  */
                    838:              parm = build_decl (PARM_DECL, in_charge_identifier, integer_type_node);
                    839:              /* Mark the artificial `__in_chrg' parameter as "artificial".  */
                    840:              SET_DECL_ARTIFICIAL (parm);
                    841:              DECL_ARG_TYPE (parm) = integer_type_node;
                    842:              DECL_REGISTER (parm) = 1;
                    843:              TREE_CHAIN (parm) = last_function_parms;
                    844:              last_function_parms = parm;
                    845:            }
                    846:        }
                    847: 
                    848:       parm = build_decl (PARM_DECL, this_identifier, type);
                    849:       /* Mark the artificial `this' parameter as "artificial".  */
                    850:       SET_DECL_ARTIFICIAL (parm);
                    851:       DECL_ARG_TYPE (parm) = type;
                    852:       /* We can make this a register, so long as we don't
                    853:         accidentally complain if someone tries to take its address.  */
                    854:       DECL_REGISTER (parm) = 1;
                    855:       if (TYPE_READONLY (type))
                    856:        TREE_READONLY (parm) = 1;
                    857:       TREE_CHAIN (parm) = last_function_parms;
                    858:       last_function_parms = parm;
                    859:     }
                    860: 
                    861:   if (flags == DTOR_FLAG)
                    862:     {
                    863:       char *buf, *dbuf;
                    864:       tree const_integer_type = build_type_variant (integer_type_node, 1, 0);
                    865:       int len = sizeof (DESTRUCTOR_DECL_PREFIX)-1;
                    866: 
                    867:       arg_types = hash_tree_chain (const_integer_type, void_list_node);
                    868:       TREE_SIDE_EFFECTS (arg_types) = 1;
                    869:       /* Build the overload name.  It will look like `7Example'.  */
                    870:       if (IDENTIFIER_TYPE_VALUE (cname))
                    871:        dbuf = build_overload_name (IDENTIFIER_TYPE_VALUE (cname), 1, 1);
                    872:       else if (IDENTIFIER_LOCAL_VALUE (cname))
                    873:        dbuf = build_overload_name (TREE_TYPE (IDENTIFIER_LOCAL_VALUE (cname)), 1, 1);
                    874:       else
                    875:       /* Using ctype fixes the `X::Y::~Y()' crash.  The cname has no type when
                    876:         it's defined out of the class definition, since poplevel_class wipes
                    877:         it out.  This used to be internal error 346.  */
                    878:        dbuf = build_overload_name (ctype, 1, 1);
                    879:       buf = (char *) alloca (strlen (dbuf) + sizeof (DESTRUCTOR_DECL_PREFIX));
                    880:       bcopy (DESTRUCTOR_DECL_PREFIX, buf, len);
                    881:       buf[len] = '\0';
                    882:       strcat (buf, dbuf);
                    883:       DECL_ASSEMBLER_NAME (function) = get_identifier (buf);
                    884:       parm = build_decl (PARM_DECL, in_charge_identifier, const_integer_type);
                    885:       /* Mark the artificial `__in_chrg' parameter as "artificial".  */
                    886:       SET_DECL_ARTIFICIAL (parm);
                    887:       TREE_USED (parm) = 1;
                    888: #if 0
                    889:       /* We don't need to mark the __in_chrg parameter itself as `const'
                    890:         since its type is already `const int'.  In fact we MUST NOT mark
                    891:         it as `const' cuz that will screw up the debug info (causing it
                    892:         to say that the type of __in_chrg is `const const int').  */
                    893:       TREE_READONLY (parm) = 1;
                    894: #endif
                    895:       DECL_ARG_TYPE (parm) = const_integer_type;
                    896:       /* This is the same chain as DECL_ARGUMENTS (...).  */
                    897:       TREE_CHAIN (last_function_parms) = parm;
                    898: 
                    899:       TREE_TYPE (function) = build_cplus_method_type (qualtype, void_type_node,
                    900:                                                      arg_types);
                    901:       TYPE_HAS_DESTRUCTOR (ctype) = 1;
                    902:     }
                    903:   else
                    904:     {
                    905:       tree these_arg_types;
                    906: 
                    907:       if (DECL_CONSTRUCTOR_FOR_VBASE_P (function))
                    908:        {
                    909:          arg_types = hash_tree_chain (integer_type_node,
                    910:                                       TREE_CHAIN (arg_types));
                    911:          TREE_TYPE (function)
                    912:            = build_cplus_method_type (qualtype,
                    913:                                       TREE_TYPE (TREE_TYPE (function)),
                    914:                                       arg_types);
                    915:          arg_types = TYPE_ARG_TYPES (TREE_TYPE (function));
                    916:        }
                    917: 
                    918:       these_arg_types = arg_types;
                    919: 
                    920:       if (TREE_CODE (TREE_TYPE (function)) == FUNCTION_TYPE)
                    921:        /* Only true for static member functions.  */
                    922:        these_arg_types = hash_tree_chain (TYPE_POINTER_TO (qualtype),
                    923:                                           arg_types);
                    924: 
                    925:       DECL_ASSEMBLER_NAME (function)
                    926:        = build_decl_overload (fn_name, these_arg_types,
                    927:                               1 + DECL_CONSTRUCTOR_P (function));
                    928: 
                    929: #if 0
                    930:       /* This code is going into the compiler, but currently, it makes
                    931:         libg++/src/Interger.cc not compile.  The problem is that the nice name
                    932:         winds up going into the symbol table, and conversion operations look
                    933:         for the manged name.  */
                    934:       substitute_nice_name (function);
                    935: #endif
                    936:     }
                    937: 
                    938:   DECL_ARGUMENTS (function) = last_function_parms;
                    939:   /* First approximations.  */
                    940:   DECL_CONTEXT (function) = ctype;
                    941:   DECL_CLASS_CONTEXT (function) = ctype;
                    942: }
                    943: 
                    944: /* Work on the expr used by alignof (this is only called by the parser).  */
                    945: tree
                    946: grok_alignof (expr)
                    947:      tree expr;
                    948: {
                    949:   tree best, t;
                    950:   int bestalign;
                    951: 
                    952:   if (TREE_CODE (expr) == COMPONENT_REF
                    953:       && DECL_BIT_FIELD (TREE_OPERAND (expr, 1)))
                    954:     error ("`__alignof__' applied to a bit-field");
                    955: 
                    956:   if (TREE_CODE (expr) == INDIRECT_REF)
                    957:     {
                    958:       best = t = TREE_OPERAND (expr, 0);
                    959:       bestalign = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (t)));
                    960: 
                    961:       while (TREE_CODE (t) == NOP_EXPR
                    962:             && TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0))) == POINTER_TYPE)
                    963:        {
                    964:          int thisalign;
                    965:          t = TREE_OPERAND (t, 0);
                    966:          thisalign = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (t)));
                    967:          if (thisalign > bestalign)
                    968:            best = t, bestalign = thisalign;
                    969:        }
                    970:       return c_alignof (TREE_TYPE (TREE_TYPE (best)));
                    971:     }
                    972:   else
                    973:     {
                    974:       /* ANSI says arrays and fns are converted inside comma.
                    975:         But we can't convert them in build_compound_expr
                    976:         because that would break commas in lvalues.
                    977:         So do the conversion here if operand was a comma.  */
                    978:       if (TREE_CODE (expr) == COMPOUND_EXPR
                    979:          && (TREE_CODE (TREE_TYPE (expr)) == ARRAY_TYPE
                    980:              || TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE))
                    981:        expr = default_conversion (expr);
                    982:       return c_alignof (TREE_TYPE (expr));
                    983:     }
                    984: }
                    985: 
                    986: /* Create an ARRAY_REF, checking for the user doing things backwards
                    987:    along the way.  */
                    988: tree
                    989: grok_array_decl (array_expr, index_exp)
                    990:      tree array_expr, index_exp;
                    991: {
                    992:   tree type = TREE_TYPE (array_expr);
                    993: 
                    994:   if (type == error_mark_node || index_exp == error_mark_node)
                    995:     return error_mark_node;
                    996:   if (type == NULL_TREE)
                    997:     {
                    998:       /* Something has gone very wrong.  Assume we are mistakenly reducing
                    999:         an expression instead of a declaration.  */
                   1000:       error ("parser may be lost: is there a '{' missing somewhere?");
                   1001:       return NULL_TREE;
                   1002:     }
                   1003: 
                   1004:   if (TREE_CODE (type) == OFFSET_TYPE
                   1005:       || TREE_CODE (type) == REFERENCE_TYPE)
                   1006:     type = TREE_TYPE (type);
                   1007: 
                   1008:   /* If they have an `operator[]', use that.  */
                   1009:   if (TYPE_LANG_SPECIFIC (type)
                   1010:       && TYPE_OVERLOADS_ARRAY_REF (type))
                   1011:     return build_opfncall (ARRAY_REF, LOOKUP_NORMAL,
                   1012:                           array_expr, index_exp, NULL_TREE);
                   1013: 
                   1014:   /* Otherwise, create an ARRAY_REF for a pointer or array type.  */
                   1015:   if (TREE_CODE (type) == POINTER_TYPE
                   1016:       || TREE_CODE (type) == ARRAY_TYPE)
                   1017:     return build_array_ref (array_expr, index_exp);
                   1018: 
                   1019:   /* Woops, looks like they did something like `5[a]' instead of `a[5]'.
                   1020:      We don't emit a warning or error for this, since it's allowed
                   1021:      by ARM $8.2.4.  */
                   1022: 
                   1023:   type = TREE_TYPE (index_exp);
                   1024: 
                   1025:   if (TREE_CODE (type) == OFFSET_TYPE
                   1026:       || TREE_CODE (type) == REFERENCE_TYPE)
                   1027:     type = TREE_TYPE (type);
                   1028: 
                   1029:   if (TREE_CODE (type) == POINTER_TYPE
                   1030:       || TREE_CODE (type) == ARRAY_TYPE)
                   1031:     return build_array_ref (index_exp, array_expr);
                   1032: 
                   1033:   /* The expression E1[E2] is identical (by definition) to *((E1)+(E2)).  */
                   1034:   return build_indirect_ref (build_binary_op (PLUS_EXPR, array_expr,
                   1035:                                              index_exp, 1),
                   1036:                             "array indexing");
                   1037: }
                   1038: 
                   1039: /* Given the cast expression EXP, checking out its validity.   Either return
                   1040:    an error_mark_node if there was an unavoidable error, return a cast to
                   1041:    void for trying to delete a pointer w/ the value 0, or return the
                   1042:    call to delete.  If DOING_VEC is 1, we handle things differently
                   1043:    for doing an array delete.  If DOING_VEC is 2, they gave us the
                   1044:    array size as an argument to delete.
                   1045:    Implements ARM $5.3.4.  This is called from the parser.  */
                   1046: tree
                   1047: delete_sanity (exp, size, doing_vec, use_global_delete)
                   1048:      tree exp, size;
                   1049:      int doing_vec, use_global_delete;
                   1050: {
                   1051:   tree t = stabilize_reference (convert_from_reference (exp));
                   1052:   tree type = TREE_TYPE (t);
                   1053:   enum tree_code code = TREE_CODE (type);
                   1054:   /* For a regular vector delete (aka, no size argument) we will pass
                   1055:      this down as a NULL_TREE into build_vec_delete.  */
                   1056:   tree maxindex = NULL_TREE;
                   1057:   /* This is used for deleting arrays.  */
                   1058:   tree elt_size;
                   1059: 
                   1060:   switch (doing_vec)
                   1061:     {
                   1062:     case 2:
                   1063:       maxindex = build_binary_op (MINUS_EXPR, size, integer_one_node, 1);
                   1064:       if (! flag_traditional)
                   1065:        pedwarn ("anachronistic use of array size in vector delete");
                   1066:       /* Fall through.  */
                   1067:     case 1:
                   1068:       elt_size = c_sizeof (type);
                   1069:       break;
                   1070:     default:
                   1071:       if (code != POINTER_TYPE)
                   1072:        {
                   1073:          cp_error ("type `%#T' argument given to `delete', expected pointer",
                   1074:                    type);
                   1075:          return error_mark_node;
                   1076:        }
                   1077: 
                   1078:       /* Deleting a pointer with the value zero is legal and has no effect.  */
                   1079:       if (integer_zerop (t))
                   1080:        return build1 (NOP_EXPR, void_type_node, t);
                   1081:     }
                   1082: 
                   1083:   if (code == POINTER_TYPE)
                   1084:     {
                   1085:       /* You can't delete a pointer to constant.  */
                   1086:       if (TREE_READONLY (TREE_TYPE (type)))
                   1087:        {
                   1088:          error ("`const *' cannot be deleted");
                   1089:          return error_mark_node;
                   1090:        }
                   1091:       /* You also can't delete functions.  */
                   1092:       if (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
                   1093:        {
                   1094:          error ("cannot delete a function");
                   1095:          return error_mark_node;
                   1096:        }
                   1097:     }
                   1098: 
                   1099: #if 0
                   1100:   /* If the type has no destructor, then we should build a regular
                   1101:      delete, instead of a vector delete.  Otherwise, we would end
                   1102:      up passing a bogus offset into __builtin_delete, which is
                   1103:      not expecting it.  */ 
                   1104:   if (doing_vec
                   1105:       && TREE_CODE (type) == POINTER_TYPE
                   1106:       && !TYPE_HAS_DESTRUCTOR (TREE_TYPE (type)))
                   1107:     {
                   1108:       doing_vec = 0;
                   1109:       use_global_delete = 1;
                   1110:     }
                   1111: #endif
                   1112: 
                   1113:   if (doing_vec)
                   1114:     return build_vec_delete (t, maxindex, elt_size, integer_one_node,
                   1115:                             integer_two_node, use_global_delete);
                   1116:   else
                   1117:     return build_delete (type, t, integer_three_node,
                   1118:                         LOOKUP_NORMAL|LOOKUP_HAS_IN_CHARGE,
                   1119:                         use_global_delete);
                   1120: }
                   1121: 
                   1122: /* Sanity check: report error if this function FUNCTION is not
                   1123:    really a member of the class (CTYPE) it is supposed to belong to.
                   1124:    CNAME is the same here as it is for grokclassfn above.  */
                   1125: 
                   1126: void
                   1127: check_classfn (ctype, cname, function)
                   1128:      tree ctype, cname, function;
                   1129: {
                   1130:   tree fn_name = DECL_NAME (function);
                   1131:   tree fndecl;
                   1132:   tree method_vec = CLASSTYPE_METHOD_VEC (ctype);
                   1133:   tree *methods = 0;
                   1134:   tree *end = 0;
                   1135: 
                   1136:   if (method_vec != 0)
                   1137:     {
                   1138:       methods = &TREE_VEC_ELT (method_vec, 0);
                   1139:       end = TREE_VEC_END (method_vec);
                   1140: 
                   1141:       /* First suss out ctors and dtors.  */
                   1142:       if (*methods && fn_name == cname)
                   1143:        goto got_it;
                   1144: 
                   1145:       while (++methods != end)
                   1146:        {
                   1147:          if (fn_name == DECL_NAME (*methods))
                   1148:            {
                   1149:            got_it:
                   1150:              fndecl = *methods;
                   1151:              while (fndecl)
                   1152:                {
                   1153:                  if (DECL_ASSEMBLER_NAME (function) == DECL_ASSEMBLER_NAME (fndecl))
                   1154:                    return;
                   1155:                  fndecl = DECL_CHAIN (fndecl);
                   1156:                }
                   1157:              break;            /* loser */
                   1158:            }
                   1159:        }
                   1160:     }
                   1161: 
                   1162:   if (methods != end)
                   1163:     cp_error ("argument list for `%#D' does not match any in class `%T'",
                   1164:              function, ctype);
                   1165:   else
                   1166:     {
                   1167:       methods = 0;
                   1168:       cp_error ("no `%#D' member function declared in class `%T'",
                   1169:                function, ctype);
                   1170:     }
                   1171: 
                   1172:   /* If we did not find the method in the class, add it to
                   1173:      avoid spurious errors.  */
                   1174:   add_method (ctype, methods, function);
                   1175: }
                   1176: 
                   1177: /* Process the specs, declarator (NULL if omitted) and width (NULL if omitted)
                   1178:    of a structure component, returning a FIELD_DECL node.
                   1179:    QUALS is a list of type qualifiers for this decl (such as for declaring
                   1180:    const member functions).
                   1181: 
                   1182:    This is done during the parsing of the struct declaration.
                   1183:    The FIELD_DECL nodes are chained together and the lot of them
                   1184:    are ultimately passed to `build_struct' to make the RECORD_TYPE node.
                   1185: 
                   1186:    C++:
                   1187: 
                   1188:    If class A defines that certain functions in class B are friends, then
                   1189:    the way I have set things up, it is B who is interested in permission
                   1190:    granted by A.  However, it is in A's context that these declarations
                   1191:    are parsed.  By returning a void_type_node, class A does not attempt
                   1192:    to incorporate the declarations of the friends within its structure.
                   1193: 
                   1194:    DO NOT MAKE ANY CHANGES TO THIS CODE WITHOUT MAKING CORRESPONDING
                   1195:    CHANGES TO CODE IN `start_method'.  */
                   1196: 
                   1197: tree
                   1198: grokfield (declarator, declspecs, raises, init, asmspec_tree)
                   1199:      tree declarator, declspecs, raises, init, asmspec_tree;
                   1200: {
                   1201:   register tree value;
                   1202:   char *asmspec = 0;
                   1203: 
                   1204:   /* Convert () initializers to = initializers.  */
                   1205:   if (init == NULL_TREE && declarator != NULL_TREE
                   1206:       && TREE_CODE (declarator) == CALL_EXPR
                   1207:       && TREE_OPERAND (declarator, 0)
                   1208:       && (TREE_CODE (TREE_OPERAND (declarator, 0)) == IDENTIFIER_NODE
                   1209:          || TREE_CODE (TREE_OPERAND (declarator, 0)) == SCOPE_REF)
                   1210:       && parmlist_is_exprlist (TREE_OPERAND (declarator, 1)))
                   1211:     {
                   1212:       init = TREE_OPERAND (declarator, 1);
                   1213:       declarator = TREE_OPERAND (declarator, 0);
                   1214:     }
                   1215: 
                   1216:   if (init
                   1217:       && TREE_CODE (init) == TREE_LIST
                   1218:       && TREE_VALUE (init) == error_mark_node
                   1219:       && TREE_CHAIN (init) == NULL_TREE)
                   1220:        init = NULL_TREE;
                   1221: 
                   1222:   value = grokdeclarator (declarator, declspecs, FIELD, init != 0, raises);
                   1223:   if (! value)
                   1224:     return value; /* friend or constructor went bad.  */
                   1225: 
                   1226:   /* Pass friendly classes back.  */
                   1227:   if (TREE_CODE (value) == VOID_TYPE)
                   1228:     return void_type_node;
                   1229: 
                   1230:   if (DECL_NAME (value) != NULL_TREE
                   1231:       && IDENTIFIER_POINTER (DECL_NAME (value))[0] == '_'
                   1232:       && ! strcmp (IDENTIFIER_POINTER (DECL_NAME (value)), "_vptr"))
                   1233:     cp_error ("member `%D' conflicts with virtual function table field name", value);
                   1234: 
                   1235:   /* Stash away type declarations.  */
                   1236:   if (TREE_CODE (value) == TYPE_DECL)
                   1237:     {
                   1238:       DECL_NONLOCAL (value) = 1;
                   1239:       DECL_CONTEXT (value) = current_class_type;
                   1240:       DECL_CLASS_CONTEXT (value) = current_class_type;
                   1241:       CLASSTYPE_LOCAL_TYPEDECLS (current_class_type) = 1;
                   1242:       pushdecl_class_level (value);
                   1243:       return value;
                   1244:     }
                   1245: 
                   1246:   if (IS_SIGNATURE (current_class_type)
                   1247:       && TREE_CODE (value) != FUNCTION_DECL)
                   1248:     {
                   1249:       error ("field declaration not allowed in signature");
                   1250:       return void_type_node;
                   1251:     }
                   1252: 
                   1253:   if (DECL_IN_AGGR_P (value))
                   1254:     {
                   1255:       cp_error ("`%D' is already defined in the class %T", value,
                   1256:                  DECL_CONTEXT (value));
                   1257:       return void_type_node;
                   1258:     }
                   1259: 
                   1260:   if (flag_cadillac)
                   1261:     cadillac_start_decl (value);
                   1262: 
                   1263:   if (asmspec_tree)
                   1264:     asmspec = TREE_STRING_POINTER (asmspec_tree);
                   1265: 
                   1266:   if (init)
                   1267:     {
                   1268:       if (IS_SIGNATURE (current_class_type)
                   1269:          && TREE_CODE (value) == FUNCTION_DECL)
                   1270:        {
                   1271:          error ("function declarations cannot have initializers in signature");
                   1272:          init = NULL_TREE;
                   1273:        }
                   1274:       else if (TREE_CODE (value) == FUNCTION_DECL)
                   1275:        {
                   1276:          grok_function_init (value, init);
                   1277:          init = NULL_TREE;
                   1278:        }
                   1279:       else if (pedantic && TREE_CODE (value) != VAR_DECL)
                   1280:        /* Already complained in grokdeclarator.  */
                   1281:        init = NULL_TREE;
                   1282:       else
                   1283:        {
                   1284:          /* We allow initializers to become parameters to base
                   1285:              initializers.  */
                   1286:          if (TREE_CODE (init) == TREE_LIST)
                   1287:            {
                   1288:              if (TREE_CHAIN (init) == NULL_TREE)
                   1289:                init = TREE_VALUE (init);
                   1290:              else
                   1291:                init = digest_init (TREE_TYPE (value), init, (tree *)0);
                   1292:            }
                   1293:          
                   1294:          if (TREE_CODE (init) == CONST_DECL)
                   1295:            init = DECL_INITIAL (init);
                   1296:          else if (TREE_READONLY_DECL_P (init))
                   1297:            init = decl_constant_value (init);
                   1298:          else if (TREE_CODE (init) == CONSTRUCTOR)
                   1299:            init = digest_init (TREE_TYPE (value), init, (tree *)0);
                   1300:          my_friendly_assert (TREE_PERMANENT (init), 192);
                   1301:          if (init == error_mark_node)
                   1302:            /* We must make this look different than `error_mark_node'
                   1303:               because `decl_const_value' would mis-interpret it
                   1304:               as only meaning that this VAR_DECL is defined.  */
                   1305:            init = build1 (NOP_EXPR, TREE_TYPE (value), init);
                   1306:          else if (! TREE_CONSTANT (init))
                   1307:            {
                   1308:              /* We can allow references to things that are effectively
                   1309:                 static, since references are initialized with the address.  */
                   1310:              if (TREE_CODE (TREE_TYPE (value)) != REFERENCE_TYPE
                   1311:                  || (TREE_STATIC (init) == 0
                   1312:                      && (TREE_CODE_CLASS (TREE_CODE (init)) != 'd'
                   1313:                          || DECL_EXTERNAL (init) == 0)))
                   1314:                {
                   1315:                  error ("field initializer is not constant");
                   1316:                  init = error_mark_node;
                   1317:                }
                   1318:            }
                   1319:        }
                   1320:     }
                   1321: 
                   1322:   /* The corresponding pop_obstacks is in finish_decl.  */
                   1323:   push_obstacks_nochange ();
                   1324: 
                   1325:   if (TREE_CODE (value) == VAR_DECL)
                   1326:     {
                   1327:       /* We cannot call pushdecl here, because that would
                   1328:         fill in the value of our TREE_CHAIN.  Instead, we
                   1329:         modify finish_decl to do the right thing, namely, to
                   1330:         put this decl out straight away.  */
                   1331:       if (TREE_PUBLIC (value))
                   1332:        {
                   1333:          /* current_class_type can be NULL_TREE in case of error.  */
                   1334:          if (asmspec == 0 && current_class_type)
                   1335:            {
                   1336:              TREE_PUBLIC (value) = 1;
                   1337:              DECL_INITIAL (value) = error_mark_node;
                   1338:              DECL_ASSEMBLER_NAME (value)
                   1339:                = build_static_name (current_class_type, DECL_NAME (value));
                   1340:            }
                   1341:          pending_statics = perm_tree_cons (NULL_TREE, value, pending_statics);
                   1342: 
                   1343:          /* Static consts need not be initialized in the class definition.  */
                   1344:          if (init != NULL_TREE && TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (value)))
                   1345:            {
                   1346:              static int explanation = 0;
                   1347: 
                   1348:              error ("initializer invalid for static member with constructor");
                   1349:              if (explanation++ == 0)
                   1350:                error ("(you really want to initialize it separately)");
                   1351:              init = 0;
                   1352:            }
                   1353:          /* Force the compiler to know when an uninitialized static
                   1354:             const member is being used.  */
                   1355:          if (TYPE_READONLY (value) && init == 0)
                   1356:            TREE_USED (value) = 1;
                   1357:        }
                   1358:       DECL_INITIAL (value) = init;
                   1359:       DECL_IN_AGGR_P (value) = 1;
                   1360: 
                   1361:       finish_decl (value, init, asmspec_tree, 1);
                   1362:       pushdecl_class_level (value);
                   1363:       return value;
                   1364:     }
                   1365:   if (TREE_CODE (value) == FIELD_DECL)
                   1366:     {
                   1367:       if (asmspec)
                   1368:        DECL_ASSEMBLER_NAME (value) = get_identifier (asmspec);
                   1369:       if (DECL_INITIAL (value) == error_mark_node)
                   1370:        init = error_mark_node;
                   1371:       finish_decl (value, init, asmspec_tree, 1);
                   1372:       DECL_INITIAL (value) = init;
                   1373:       DECL_IN_AGGR_P (value) = 1;
                   1374:       return value;
                   1375:     }
                   1376:   if (TREE_CODE (value) == FUNCTION_DECL)
                   1377:     {
                   1378:       if (DECL_CHAIN (value) != NULL_TREE)
                   1379:        {
                   1380:          /* Need a fresh node here so that we don't get circularity
                   1381:             when we link these together.  */
                   1382:          value = copy_node (value);
                   1383:          /* When does this happen?  */
                   1384:          my_friendly_assert (init == NULL_TREE, 193);
                   1385:        }
                   1386:       finish_decl (value, init, asmspec_tree, 1);
                   1387: 
                   1388:       /* Pass friends back this way.  */
                   1389:       if (DECL_FRIEND_P (value))
                   1390:        return void_type_node;
                   1391: 
                   1392: #if 0 /* Just because a fn is declared doesn't mean we'll try to define it.  */
                   1393:       if (current_function_decl && ! IS_SIGNATURE (current_class_type))
                   1394:        cp_error ("method `%#D' of local class must be defined in class body",
                   1395:                  value);
                   1396: #endif
                   1397: 
                   1398:       DECL_IN_AGGR_P (value) = 1;
                   1399:       return value;
                   1400:     }
                   1401:   my_friendly_abort (21);
                   1402:   /* NOTREACHED */
                   1403:   return NULL_TREE;
                   1404: }
                   1405: 
                   1406: /* Like `grokfield', but for bitfields.
                   1407:    WIDTH is non-NULL for bit fields only, and is an INTEGER_CST node.  */
                   1408: 
                   1409: tree
                   1410: grokbitfield (declarator, declspecs, width)
                   1411:      tree declarator, declspecs, width;
                   1412: {
                   1413:   register tree value = grokdeclarator (declarator, declspecs, BITFIELD, 0, NULL_TREE);
                   1414: 
                   1415:   if (! value) return NULL_TREE; /* friends went bad.  */
                   1416: 
                   1417:   /* Pass friendly classes back.  */
                   1418:   if (TREE_CODE (value) == VOID_TYPE)
                   1419:     return void_type_node;
                   1420: 
                   1421:   if (TREE_CODE (value) == TYPE_DECL)
                   1422:     {
                   1423:       cp_error ("cannot declare `%D' to be a bitfield type", value);
                   1424:       return NULL_TREE;
                   1425:     }
                   1426: 
                   1427:   if (IS_SIGNATURE (current_class_type))
                   1428:     {
                   1429:       error ("field declaration not allowed in signature");
                   1430:       return void_type_node;
                   1431:     }
                   1432: 
                   1433:   if (DECL_IN_AGGR_P (value))
                   1434:     {
                   1435:       cp_error ("`%D' is already defined in the class %T", value,
                   1436:                  DECL_CONTEXT (value));
                   1437:       return void_type_node;
                   1438:     }
                   1439: 
                   1440:   GNU_xref_member (current_class_name, value);
                   1441: 
                   1442:   if (TREE_STATIC (value))
                   1443:     {
                   1444:       cp_error ("static member `%D' cannot be a bitfield", value);
                   1445:       return NULL_TREE;
                   1446:     }
                   1447:   finish_decl (value, NULL_TREE, NULL_TREE, 0);
                   1448: 
                   1449:   if (width != error_mark_node)
                   1450:     {
                   1451:       /* detect invalid field size.  */
                   1452:       if (TREE_CODE (width) == CONST_DECL)
                   1453:        width = DECL_INITIAL (width);
                   1454:       else if (TREE_READONLY_DECL_P (width))
                   1455:        width = decl_constant_value (width);
                   1456:       if (TREE_CODE (width) != INTEGER_CST)
                   1457:        {
                   1458:          cp_error ("structure field `%D' width not an integer constant",
                   1459:                      value);
                   1460:          DECL_INITIAL (value) = NULL_TREE;
                   1461:        }
                   1462:       else
                   1463:        {
                   1464:          constant_expression_warning (width);
                   1465:          DECL_INITIAL (value) = width;
                   1466:          DECL_BIT_FIELD (value) = 1;
                   1467:        }
                   1468:     }
                   1469: 
                   1470:   DECL_IN_AGGR_P (value) = 1;
                   1471:   return value;
                   1472: }
                   1473: 
                   1474: #if 0
                   1475: /* Like GROKFIELD, except that the declarator has been
                   1476:    buried in DECLSPECS.  Find the declarator, and
                   1477:    return something that looks like it came from
                   1478:    GROKFIELD.  */
                   1479: tree
                   1480: groktypefield (declspecs, parmlist)
                   1481:      tree declspecs;
                   1482:      tree parmlist;
                   1483: {
                   1484:   tree spec = declspecs;
                   1485:   tree prev = NULL_TREE;
                   1486: 
                   1487:   tree type_id = NULL_TREE;
                   1488:   tree quals = NULL_TREE;
                   1489:   tree lengths = NULL_TREE;
                   1490:   tree decl = NULL_TREE;
                   1491: 
                   1492:   while (spec)
                   1493:     {
                   1494:       register tree id = TREE_VALUE (spec);
                   1495: 
                   1496:       if (TREE_CODE (spec) != TREE_LIST)
                   1497:        /* Certain parse errors slip through.  For example,
                   1498:           `int class ();' is not caught by the parser. Try
                   1499:           weakly to recover here.  */
                   1500:        return NULL_TREE;
                   1501: 
                   1502:       if (TREE_CODE (id) == TYPE_DECL
                   1503:          || (TREE_CODE (id) == IDENTIFIER_NODE && TREE_TYPE (id)))
                   1504:        {
                   1505:          /* We have a constructor/destructor or
                   1506:             conversion operator.  Use it.  */
                   1507:          if (prev)
                   1508:            TREE_CHAIN (prev) = TREE_CHAIN (spec);
                   1509:          else
                   1510:            declspecs = TREE_CHAIN (spec);
                   1511: 
                   1512:          type_id = id;
                   1513:          goto found;
                   1514:        }
                   1515:       prev = spec;
                   1516:       spec = TREE_CHAIN (spec);
                   1517:     }
                   1518: 
                   1519:   /* Nope, we have a conversion operator to a scalar type or something
                   1520:      else, that includes things like constructor declarations for
                   1521:      templates.  */
                   1522:   spec = declspecs;
                   1523:   while (spec)
                   1524:     {
                   1525:       tree id = TREE_VALUE (spec);
                   1526: 
                   1527:       if (TREE_CODE (id) == IDENTIFIER_NODE)
                   1528:        {
                   1529:          if (id == ridpointers[(int)RID_INT]
                   1530:              || id == ridpointers[(int)RID_DOUBLE]
                   1531:              || id == ridpointers[(int)RID_FLOAT]
                   1532:              || id == ridpointers[(int)RID_WCHAR])
                   1533:            {
                   1534:              if (type_id)
                   1535:                error ("extra `%s' ignored",
                   1536:                       IDENTIFIER_POINTER (id));
                   1537:              else
                   1538:                type_id = id;
                   1539:            }
                   1540:          else if (id == ridpointers[(int)RID_LONG]
                   1541:                   || id == ridpointers[(int)RID_SHORT]
                   1542:                   || id == ridpointers[(int)RID_CHAR])
                   1543:            {
                   1544:              lengths = tree_cons (NULL_TREE, id, lengths);
                   1545:            }
                   1546:          else if (id == ridpointers[(int)RID_VOID])
                   1547:            {
                   1548:              if (type_id)
                   1549:                error ("spurious `void' type ignored");
                   1550:              else
                   1551:                error ("conversion to `void' type invalid");
                   1552:            }
                   1553:          else if (id == ridpointers[(int)RID_AUTO]
                   1554:                   || id == ridpointers[(int)RID_REGISTER]
                   1555:                   || id == ridpointers[(int)RID_TYPEDEF]
                   1556:                   || id == ridpointers[(int)RID_CONST]
                   1557:                   || id == ridpointers[(int)RID_VOLATILE])
                   1558:            {
                   1559:              error ("type specifier `%s' used invalidly",
                   1560:                     IDENTIFIER_POINTER (id));
                   1561:            }
                   1562:          else if (id == ridpointers[(int)RID_FRIEND]
                   1563:                   || id == ridpointers[(int)RID_VIRTUAL]
                   1564:                   || id == ridpointers[(int)RID_INLINE]
                   1565:                   || id == ridpointers[(int)RID_UNSIGNED]
                   1566:                   || id == ridpointers[(int)RID_SIGNED]
                   1567:                   || id == ridpointers[(int)RID_STATIC]
                   1568:                   || id == ridpointers[(int)RID_EXTERN])
                   1569:            {
                   1570:              quals = tree_cons (NULL_TREE, id, quals);
                   1571:            }
                   1572:          else
                   1573:            {
                   1574:              /* Happens when we have a global typedef
                   1575:                 and a class-local member function with
                   1576:                 the same name.  */
                   1577:              type_id = id;
                   1578:              goto found;
                   1579:            }
                   1580:        }
                   1581:       else if (TREE_CODE (id) == RECORD_TYPE)
                   1582:        {
                   1583:          type_id = TYPE_NAME (id);
                   1584:          if (TREE_CODE (type_id) == TYPE_DECL)
                   1585:            type_id = DECL_NAME (type_id);
                   1586:          if (type_id == NULL_TREE)
                   1587:            error ("identifier for aggregate type conversion omitted");
                   1588:        }
                   1589:       else if (TREE_CODE_CLASS (TREE_CODE (id)) == 't')
                   1590:        error ("`operator' missing on conversion operator or tag missing from type");
                   1591:       else
                   1592:        my_friendly_abort (194);
                   1593:       spec = TREE_CHAIN (spec);
                   1594:     }
                   1595: 
                   1596:   if (type_id)
                   1597:     declspecs = chainon (lengths, quals);
                   1598:   else if (lengths)
                   1599:     {
                   1600:       if (TREE_CHAIN (lengths))
                   1601:        error ("multiple length specifiers");
                   1602:       type_id = ridpointers[(int)RID_INT];
                   1603:       declspecs = chainon (lengths, quals);
                   1604:     }
                   1605:   else if (quals)
                   1606:     {
                   1607:       error ("no type given, defaulting to `operator int ...'");
                   1608:       type_id = ridpointers[(int)RID_INT];
                   1609:       declspecs = quals;
                   1610:     }
                   1611:   else
                   1612:     return NULL_TREE;
                   1613: 
                   1614:  found:
                   1615:   decl = grokdeclarator (build_parse_node (CALL_EXPR, type_id, parmlist, NULL_TREE),
                   1616:                         declspecs, FIELD, 0, NULL_TREE);
                   1617:   if (decl == NULL_TREE)
                   1618:     return NULL_TREE;
                   1619: 
                   1620:   if (TREE_CODE (decl) == FUNCTION_DECL && DECL_CHAIN (decl) != NULL_TREE)
                   1621:     {
                   1622:       /* Need a fresh node here so that we don't get circularity
                   1623:         when we link these together.  */
                   1624:       decl = copy_node (decl);
                   1625:     }
                   1626: 
                   1627:   if (decl == void_type_node
                   1628:       || (TREE_CODE (decl) == FUNCTION_DECL
                   1629:          && TREE_CODE (TREE_TYPE (decl)) != METHOD_TYPE))
                   1630:     /* bunch of friends.  */
                   1631:     return decl;
                   1632: 
                   1633:   if (DECL_IN_AGGR_P (decl))
                   1634:     {
                   1635:       cp_error ("`%D' already defined in the class ", decl);
                   1636:       return void_type_node;
                   1637:     }
                   1638: 
                   1639:   finish_decl (decl, NULL_TREE, NULL_TREE, 0);
                   1640: 
                   1641:   /* If this declaration is common to another declaration
                   1642:      complain about such redundancy, and return NULL_TREE
                   1643:      so that we don't build a circular list.  */
                   1644:   if (DECL_CHAIN (decl))
                   1645:     {
                   1646:       cp_error ("function `%D' declared twice in class %T", decl,
                   1647:                  DECL_CONTEXT (decl));
                   1648:       return NULL_TREE;
                   1649:     }
                   1650:   DECL_IN_AGGR_P (decl) = 1;
                   1651:   return decl;
                   1652: }
                   1653: #endif
                   1654: 
                   1655: tree
                   1656: grokoptypename (declspecs, declarator)
                   1657:      tree declspecs, declarator;
                   1658: {
                   1659:   tree t = grokdeclarator (declarator, declspecs, TYPENAME, 0, NULL_TREE);
                   1660:   return build_typename_overload (t);
                   1661: }
                   1662: 
                   1663: /* When a function is declared with an initializer,
                   1664:    do the right thing.  Currently, there are two possibilities:
                   1665: 
                   1666:    class B
                   1667:    {
                   1668:     public:
                   1669:      // initialization possibility #1.
                   1670:      virtual void f () = 0;
                   1671:      int g ();
                   1672:    };
                   1673:    
                   1674:    class D1 : B
                   1675:    {
                   1676:     public:
                   1677:      int d1;
                   1678:      // error, no f ();
                   1679:    };
                   1680:    
                   1681:    class D2 : B
                   1682:    {
                   1683:     public:
                   1684:      int d2;
                   1685:      void f ();
                   1686:    };
                   1687:    
                   1688:    class D3 : B
                   1689:    {
                   1690:     public:
                   1691:      int d3;
                   1692:      // initialization possibility #2
                   1693:      void f () = B::f;
                   1694:    };
                   1695: 
                   1696: */
                   1697: 
                   1698: int
                   1699: copy_assignment_arg_p (parmtype, virtualp)
                   1700:      tree parmtype;
                   1701:      int virtualp;
                   1702: {
                   1703:   if (TREE_CODE (parmtype) == REFERENCE_TYPE)
                   1704:     parmtype = TREE_TYPE (parmtype);
                   1705: 
                   1706:   if ((TYPE_MAIN_VARIANT (parmtype) == current_class_type)
                   1707:       || (virtualp && DERIVED_FROM_P (parmtype, current_class_type)))
                   1708:     return 1;
                   1709: 
                   1710:   return 0;
                   1711: }
                   1712: 
                   1713: static void
                   1714: grok_function_init (decl, init)
                   1715:      tree decl;
                   1716:      tree init;
                   1717: {
                   1718:   /* An initializer for a function tells how this function should
                   1719:      be inherited.  */
                   1720:   tree type = TREE_TYPE (decl);
                   1721: 
                   1722:   if (TREE_CODE (type) == FUNCTION_TYPE)
                   1723:     cp_error ("initializer specified for non-member function `%D'", decl);
                   1724:   else if (DECL_VINDEX (decl) == NULL_TREE)
                   1725:     cp_error ("initializer specified for non-virtual method `%D'", decl);
                   1726:   else if (integer_zerop (init))
                   1727:     {
                   1728: #if 0
                   1729:       /* Mark this function as being "defined".  */
                   1730:       DECL_INITIAL (decl) = error_mark_node;
                   1731:       /* pure virtual destructors must be defined. */
                   1732:       /* pure virtual needs to be defined (as abort) only when put in 
                   1733:         vtbl. For wellformed call, it should be itself. pr4737 */
                   1734:       if (!DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (decl)))
                   1735:        {
                   1736:          extern tree abort_fndecl;
                   1737:          /* Give this node rtl from `abort'.  */
                   1738:          DECL_RTL (decl) = DECL_RTL (abort_fndecl);
                   1739:        }
                   1740: #endif
                   1741:       DECL_ABSTRACT_VIRTUAL_P (decl) = 1;
                   1742:       if (DECL_NAME (decl) == ansi_opname [(int) MODIFY_EXPR])
                   1743:        {
                   1744:          tree parmtype
                   1745:            = TREE_VALUE (TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (decl))));
                   1746: 
                   1747:          if (copy_assignment_arg_p (parmtype, 1))
                   1748:            TYPE_HAS_ABSTRACT_ASSIGN_REF (current_class_type) = 1;
                   1749:        }
                   1750:     }
                   1751:   else if (TREE_CODE (init) == OFFSET_REF
                   1752:           && TREE_OPERAND (init, 0) == NULL_TREE
                   1753:           && TREE_CODE (TREE_TYPE (init)) == METHOD_TYPE)
                   1754:     {
                   1755:       tree basetype = DECL_CLASS_CONTEXT (init);
                   1756:       tree basefn = TREE_OPERAND (init, 1);
                   1757:       if (TREE_CODE (basefn) != FUNCTION_DECL)
                   1758:        cp_error ("non-method initializer invalid for method `%D'", decl);
                   1759:       else if (! BINFO_OFFSET_ZEROP (TYPE_BINFO (DECL_CLASS_CONTEXT (basefn))))
                   1760:        sorry ("base member function from other than first base class");
                   1761:       else
                   1762:        {
                   1763:          tree binfo = get_binfo (basetype, TYPE_METHOD_BASETYPE (type), 1);
                   1764:          if (binfo == error_mark_node)
                   1765:            ;
                   1766:          else if (binfo == 0)
                   1767:            error_not_base_type (TYPE_METHOD_BASETYPE (TREE_TYPE (init)),
                   1768:                                 TYPE_METHOD_BASETYPE (type));
                   1769:          else
                   1770:            {
                   1771:              /* Mark this function as being defined,
                   1772:                 and give it new rtl.  */
                   1773:              DECL_INITIAL (decl) = error_mark_node;
                   1774:              DECL_RTL (decl) = DECL_RTL (basefn);
                   1775:            }
                   1776:        }
                   1777:     }
                   1778:   else
                   1779:     cp_error ("invalid initializer for virtual method `%D'", decl);
                   1780: }
                   1781: 
                   1782: /* When we get a declaration of the form
                   1783: 
                   1784:    type cname::fname ...
                   1785: 
                   1786:    the node for `cname::fname' gets built here in a special way.
                   1787:    Namely, we push into `cname's scope.  When this declaration is
                   1788:    processed, we pop back out.  */
                   1789: tree
                   1790: build_push_scope (cname, name)
                   1791:      tree cname;
                   1792:      tree name;
                   1793: {
                   1794:   extern int current_class_depth;
                   1795:   tree ctype, rval;
                   1796:   int is_ttp = 0;
                   1797: 
                   1798:   if (cname == error_mark_node)
                   1799:     return error_mark_node;
                   1800: 
                   1801:   ctype = IDENTIFIER_TYPE_VALUE (cname);
                   1802: 
                   1803:   if (TREE_CODE (ctype) == TEMPLATE_TYPE_PARM)
                   1804:     is_ttp = 1;
                   1805:   else if (ctype == NULL_TREE || ! IS_AGGR_TYPE (ctype))
                   1806:     {
                   1807:       cp_error ("`%T' not defined as aggregate type", cname);
                   1808:       return name;
                   1809:     }
                   1810:   else if (IS_SIGNATURE (ctype))
                   1811:     {
                   1812:       error ("cannot push into signature scope, scope resolution operator ignored");
                   1813:       return name;
                   1814:     }
                   1815: 
                   1816:   rval = build_parse_node (SCOPE_REF, cname, name);
                   1817: 
                   1818:   /* Don't need to push the scope if we're already in it.
                   1819:      We also don't need to push the scope for a ptr-to-member/method.  */
                   1820: 
                   1821:   if (ctype == current_class_type || TREE_CODE (name) != IDENTIFIER_NODE
                   1822:       || is_ttp)
                   1823:     return rval;
                   1824: 
                   1825:   /* We do need to push the scope in this case, since CTYPE helps
                   1826:      determine subsequent intializers (i.e., Foo::Bar x = foo_enum_1;).  */
                   1827: 
                   1828:   push_nested_class (ctype, 3);
                   1829:   TREE_COMPLEXITY (rval) = current_class_depth;
                   1830:   return rval;
                   1831: }
                   1832: 
                   1833: void cplus_decl_attributes (decl, attributes)
                   1834:      tree decl, attributes;
                   1835: {
                   1836:   if (decl && decl != void_type_node)
                   1837:     decl_attributes (decl, attributes);
                   1838: }
                   1839: 
                   1840: /* CONSTRUCTOR_NAME:
                   1841:    Return the name for the constructor (or destructor) for the
                   1842:    specified class.  Argument can be RECORD_TYPE, TYPE_DECL, or
                   1843:    IDENTIFIER_NODE.  When given a template, this routine doesn't
                   1844:    lose the specialization.  */
                   1845: tree
                   1846: constructor_name_full (thing)
                   1847:      tree thing;
                   1848: {
                   1849:   if (TREE_CODE (thing) == UNINSTANTIATED_P_TYPE)
                   1850:     return DECL_NAME (UPT_TEMPLATE (thing));
                   1851:   if (IS_AGGR_TYPE_CODE (TREE_CODE (thing)))
                   1852:     {
                   1853:       if (TYPE_WAS_ANONYMOUS (thing) && TYPE_HAS_CONSTRUCTOR (thing))
                   1854:        thing = DECL_NAME (TREE_VEC_ELT (TYPE_METHODS (thing), 0));
                   1855:       else
                   1856:        thing = TYPE_NAME (thing);
                   1857:     }
                   1858:   if (TREE_CODE (thing) == TYPE_DECL
                   1859:       || (TREE_CODE (thing) == TEMPLATE_DECL
                   1860:          && DECL_TEMPLATE_IS_CLASS (thing)))
                   1861:     thing = DECL_NAME (thing);
                   1862:   my_friendly_assert (TREE_CODE (thing) == IDENTIFIER_NODE, 197);
                   1863:   return thing;
                   1864: }
                   1865: 
                   1866: /* CONSTRUCTOR_NAME:
                   1867:    Return the name for the constructor (or destructor) for the
                   1868:    specified class.  Argument can be RECORD_TYPE, TYPE_DECL, or
                   1869:    IDENTIFIER_NODE.  When given a template, return the plain
                   1870:    unspecialized name.  */
                   1871: tree
                   1872: constructor_name (thing)
                   1873:      tree thing;
                   1874: {
                   1875:   tree t;
                   1876:   thing = constructor_name_full (thing);
                   1877:   t = IDENTIFIER_TEMPLATE (thing);
                   1878:   if (!t)
                   1879:     return thing;
                   1880:   t = TREE_PURPOSE (t);
                   1881:   return DECL_NAME (t);
                   1882: }
                   1883: 
                   1884: /* Cache the value of this class's main virtual function table pointer
                   1885:    in a register variable.  This will save one indirection if a
                   1886:    more than one virtual function call is made this function.  */
                   1887: void
                   1888: setup_vtbl_ptr ()
                   1889: {
                   1890:   extern rtx base_init_insns;
                   1891: 
                   1892:   if (base_init_insns == 0
                   1893:       && DECL_CONSTRUCTOR_P (current_function_decl))
                   1894:     emit_base_init (current_class_type, 0);
                   1895: 
                   1896: #if 0
                   1897:   /* This has something a little wrong with it.
                   1898: 
                   1899:      On a sun4, code like:
                   1900: 
                   1901:         be L6
                   1902:         ld [%i0],%o1
                   1903: 
                   1904:      is generated, when the below is used when -O4 is given.  The delay
                   1905:      slot it filled with an instruction that is safe, when this isn't
                   1906:      used, like in:
                   1907: 
                   1908:         be L6
                   1909:         sethi %hi(LC1),%o0
                   1910:         ld [%i0],%o1
                   1911: 
                   1912:      on code like:
                   1913: 
                   1914:         struct A {
                   1915:           virtual void print() { printf("xxx"); }
                   1916:           void f();
                   1917:         };
                   1918: 
                   1919:         void A::f() {
                   1920:           if (this) {
                   1921:             print();
                   1922:           } else {
                   1923:             printf("0");
                   1924:           }
                   1925:         }
                   1926: 
                   1927:      And that is why this is disabled for now. (mrs)
                   1928:   */
                   1929: 
                   1930:   if ((flag_this_is_variable & 1) == 0
                   1931:       && optimize
                   1932:       && current_class_type
                   1933:       && CLASSTYPE_VSIZE (current_class_type)
                   1934:       && ! DECL_STATIC_FUNCTION_P (current_function_decl))
                   1935:     {
                   1936:       tree vfield = build_vfield_ref (C_C_D, current_class_type);
                   1937:       current_vtable_decl = CLASSTYPE_VTBL_PTR (current_class_type);
                   1938:       DECL_RTL (current_vtable_decl) = 0;
                   1939:       DECL_INITIAL (current_vtable_decl) = error_mark_node;
                   1940:       /* Have to cast the initializer, since it may have come from a
                   1941:         more base class then we ascribe CURRENT_VTABLE_DECL to be.  */
                   1942:       finish_decl (current_vtable_decl, convert_force (TREE_TYPE (current_vtable_decl), vfield), 0, 0);
                   1943:       current_vtable_decl = build_indirect_ref (current_vtable_decl, NULL_PTR);
                   1944:     }
                   1945:   else
                   1946: #endif
                   1947:     current_vtable_decl = NULL_TREE;
                   1948: }
                   1949: 
                   1950: /* Record the existence of an addressable inline function.  */
                   1951: void
                   1952: mark_inline_for_output (decl)
                   1953:      tree decl;
                   1954: {
                   1955:   if (DECL_SAVED_INLINE (decl))
                   1956:     return;
                   1957:   DECL_SAVED_INLINE (decl) = 1;
                   1958:   if (DECL_PENDING_INLINE_INFO (decl) != 0
                   1959:       && ! DECL_PENDING_INLINE_INFO (decl)->deja_vu)
                   1960:     {
                   1961:       struct pending_inline *t = pending_inlines;
                   1962:       my_friendly_assert (DECL_SAVED_INSNS (decl) == 0, 198);
                   1963:       while (t)
                   1964:        {
                   1965:          if (t == DECL_PENDING_INLINE_INFO (decl))
                   1966:            break;
                   1967:          t = t->next;
                   1968:        }
                   1969:       if (t == 0)
                   1970:        {
                   1971:          t = DECL_PENDING_INLINE_INFO (decl);
                   1972:          t->next = pending_inlines;
                   1973:          pending_inlines = t;
                   1974:        }
                   1975:       DECL_PENDING_INLINE_INFO (decl) = 0;
                   1976:     }
                   1977:   saved_inlines = perm_tree_cons (NULL_TREE, decl, saved_inlines);
                   1978: }
                   1979: 
                   1980: void
                   1981: clear_temp_name ()
                   1982: {
                   1983:   temp_name_counter = 0;
                   1984: }
                   1985: 
                   1986: /* Hand off a unique name which can be used for variable we don't really
                   1987:    want to know about anyway, for example, the anonymous variables which
                   1988:    are needed to make references work.  Declare this thing so we can use it.
                   1989:    The variable created will be of type TYPE.
                   1990: 
                   1991:    STATICP is nonzero if this variable should be static.  */
                   1992: 
                   1993: tree
                   1994: get_temp_name (type, staticp)
                   1995:      tree type;
                   1996:      int staticp;
                   1997: {
                   1998:   char buf[sizeof (AUTO_TEMP_FORMAT) + 20];
                   1999:   tree decl;
                   2000:   int toplev = global_bindings_p ();
                   2001: 
                   2002:   push_obstacks_nochange ();
                   2003:   if (toplev || staticp)
                   2004:     {
                   2005:       end_temporary_allocation ();
                   2006:       sprintf (buf, AUTO_TEMP_FORMAT, global_temp_name_counter++);
                   2007:       decl = pushdecl_top_level (build_decl (VAR_DECL, get_identifier (buf), type));
                   2008:     }
                   2009:   else
                   2010:     {
                   2011:       sprintf (buf, AUTO_TEMP_FORMAT, temp_name_counter++);
                   2012:       decl = pushdecl (build_decl (VAR_DECL, get_identifier (buf), type));
                   2013:     }
                   2014:   TREE_USED (decl) = 1;
                   2015:   TREE_STATIC (decl) = staticp;
                   2016: 
                   2017:   /* If this is a local variable, then lay out its rtl now.
                   2018:      Otherwise, callers of this function are responsible for dealing
                   2019:      with this variable's rtl.  */
                   2020:   if (! toplev)
                   2021:     {
                   2022:       expand_decl (decl);
                   2023:       expand_decl_init (decl);
                   2024:     }
                   2025:   pop_obstacks ();
                   2026: 
                   2027:   return decl;
                   2028: }
                   2029: 
                   2030: /* Get a variable which we can use for multiple assignments.
                   2031:    It is not entered into current_binding_level, because
                   2032:    that breaks things when it comes time to do final cleanups
                   2033:    (which take place "outside" the binding contour of the function).  */
                   2034: tree
                   2035: get_temp_regvar (type, init)
                   2036:      tree type, init;
                   2037: {
                   2038:   static char buf[sizeof (AUTO_TEMP_FORMAT) + 20] = { '_' };
                   2039:   tree decl;
                   2040: 
                   2041:   sprintf (buf+1, AUTO_TEMP_FORMAT, temp_name_counter++);
                   2042:   decl = build_decl (VAR_DECL, get_identifier (buf), type);
                   2043:   TREE_USED (decl) = 1;
                   2044:   DECL_REGISTER (decl) = 1;
                   2045: 
                   2046:   if (init)
                   2047:     store_init_value (decl, init);
                   2048: 
                   2049:   /* We can expand these without fear, since they cannot need
                   2050:      constructors or destructors.  */
                   2051:   expand_decl (decl);
                   2052:   expand_decl_init (decl);
                   2053: 
                   2054:   if (type_needs_gc_entry (type))
                   2055:     DECL_GC_OFFSET (decl) = size_int (++current_function_obstack_index);
                   2056: 
                   2057:   return decl;
                   2058: }
                   2059: 
                   2060: /* Make the macro TEMP_NAME_P available to units which do not
                   2061:    include c-tree.h.  */
                   2062: int
                   2063: temp_name_p (decl)
                   2064:      tree decl;
                   2065: {
                   2066:   return TEMP_NAME_P (decl);
                   2067: }
                   2068: 
                   2069: /* Finish off the processing of a UNION_TYPE structure.
                   2070:    If there are static members, then all members are
                   2071:    static, and must be laid out together.  If the
                   2072:    union is an anonymous union, we arrange for that
                   2073:    as well.  PUBLIC_P is nonzero if this union is
                   2074:    not declared static.  */
                   2075: void
                   2076: finish_anon_union (anon_union_decl)
                   2077:      tree anon_union_decl;
                   2078: {
                   2079:   tree type = TREE_TYPE (anon_union_decl);
                   2080:   tree field, main_decl = NULL_TREE;
                   2081:   tree elems = NULL_TREE;
                   2082:   int public_p = TREE_PUBLIC (anon_union_decl);
                   2083:   int static_p = TREE_STATIC (anon_union_decl);
                   2084:   int external_p = DECL_EXTERNAL (anon_union_decl);
                   2085: 
                   2086:   if ((field = TYPE_FIELDS (type)) == NULL_TREE)
                   2087:     return;
                   2088: 
                   2089:   if (public_p)
                   2090:     {
                   2091:       error ("global anonymous unions must be declared static");
                   2092:       return;
                   2093:     }
                   2094: 
                   2095:   for (; field; field = TREE_CHAIN (field))
                   2096:     {
                   2097:       tree decl;
                   2098:       if (TREE_CODE (field) != FIELD_DECL)
                   2099:        continue;
                   2100: 
                   2101:       decl = build_decl (VAR_DECL, DECL_NAME (field), TREE_TYPE (field));
                   2102:       /* tell `pushdecl' that this is not tentative.  */
                   2103:       DECL_INITIAL (decl) = error_mark_node;
                   2104:       TREE_PUBLIC (decl) = public_p;
                   2105:       TREE_STATIC (decl) = static_p;
                   2106:       DECL_EXTERNAL (decl) = external_p;
                   2107:       decl = pushdecl (decl);
                   2108: 
                   2109:       /* Only write out one anon union element--choose the one that
                   2110:         can hold them all.  */
                   2111:       if (main_decl == NULL_TREE
                   2112:          && simple_cst_equal (DECL_SIZE (decl), DECL_SIZE (anon_union_decl)))
                   2113:        {
                   2114:          main_decl = decl;
                   2115:        }
                   2116:       else
                   2117:        {
                   2118:          /* ??? This causes there to be no debug info written out
                   2119:             about this decl.  */
                   2120:          TREE_ASM_WRITTEN (decl) = 1;
                   2121:        }
                   2122: 
                   2123:       DECL_INITIAL (decl) = NULL_TREE;
                   2124:       /* If there's a cleanup to do, it belongs in the
                   2125:         TREE_PURPOSE of the following TREE_LIST.  */
                   2126:       elems = tree_cons (NULL_TREE, decl, elems);
                   2127:       TREE_TYPE (elems) = type;
                   2128:     }
                   2129:   if (static_p)
                   2130:     {
                   2131:       if (main_decl)
                   2132:        {
                   2133:          make_decl_rtl (main_decl, 0, global_bindings_p ());
                   2134:          DECL_RTL (anon_union_decl) = DECL_RTL (main_decl);
                   2135:        }
                   2136:       else
                   2137:        {
                   2138:          warning ("anonymous union with no members");
                   2139:          return;
                   2140:        }
                   2141:     }
                   2142: 
                   2143:   /* The following call assumes that there are never any cleanups
                   2144:      for anonymous unions--a reasonable assumption.  */
                   2145:   expand_anon_union_decl (anon_union_decl, NULL_TREE, elems);
                   2146: 
                   2147:   if (flag_cadillac)
                   2148:     cadillac_finish_anon_union (anon_union_decl);
                   2149: }
                   2150: 
                   2151: /* Finish and output a table which is generated by the compiler.
                   2152:    NAME is the name to give the table.
                   2153:    TYPE is the type of the table entry.
                   2154:    INIT is all the elements in the table.
                   2155:    PUBLICP is non-zero if this table should be given external access.  */
                   2156: tree
                   2157: finish_table (name, type, init, publicp)
                   2158:      tree name, type, init;
                   2159:      int publicp;
                   2160: {
                   2161:   tree itype, atype, decl;
                   2162:   static tree empty_table;
                   2163:   int is_empty = 0;
                   2164:   tree asmspec;
                   2165: 
                   2166:   itype = build_index_type (size_int (list_length (init) - 1));
                   2167:   atype = build_cplus_array_type (type, itype);
                   2168:   layout_type (atype);
                   2169: 
                   2170:   if (TREE_VALUE (init) == integer_zero_node
                   2171:       && TREE_CHAIN (init) == NULL_TREE)
                   2172:     {
                   2173:       if (empty_table == NULL_TREE)
                   2174:        {
                   2175:          empty_table = get_temp_name (atype, 1);
                   2176:          init = build (CONSTRUCTOR, atype, NULL_TREE, init);
                   2177:          TREE_CONSTANT (init) = 1;
                   2178:          TREE_STATIC (init) = 1;
                   2179:          DECL_INITIAL (empty_table) = init;
                   2180:          asmspec = build_string (IDENTIFIER_LENGTH (DECL_NAME (empty_table)),
                   2181:                                  IDENTIFIER_POINTER (DECL_NAME (empty_table)));
                   2182:          finish_decl (empty_table, init, asmspec, 0);
                   2183:        }
                   2184:       is_empty = 1;
                   2185:     }
                   2186: 
                   2187:   if (name == NULL_TREE)
                   2188:     {
                   2189:       if (is_empty)
                   2190:        return empty_table;
                   2191:       decl = get_temp_name (atype, 1);
                   2192:     }
                   2193:   else
                   2194:     {
                   2195:       decl = build_decl (VAR_DECL, name, atype);
                   2196:       decl = pushdecl (decl);
                   2197:       TREE_STATIC (decl) = 1;
                   2198:     }
                   2199: 
                   2200:   if (is_empty == 0)
                   2201:     {
                   2202:       TREE_PUBLIC (decl) = publicp;
                   2203:       init = build (CONSTRUCTOR, atype, NULL_TREE, init);
                   2204:       TREE_CONSTANT (init) = 1;
                   2205:       TREE_STATIC (init) = 1;
                   2206:       DECL_INITIAL (decl) = init;
                   2207:       asmspec = build_string (IDENTIFIER_LENGTH (DECL_NAME (decl)),
                   2208:                              IDENTIFIER_POINTER (DECL_NAME (decl)));
                   2209:     }
                   2210:   else
                   2211:     {
                   2212:       /* This will cause DECL to point to EMPTY_TABLE in rtl-land.  */
                   2213:       DECL_EXTERNAL (decl) = 1;
                   2214:       TREE_STATIC (decl) = 0;
                   2215:       init = 0;
                   2216:       asmspec = build_string (IDENTIFIER_LENGTH (DECL_NAME (empty_table)),
                   2217:                              IDENTIFIER_POINTER (DECL_NAME (empty_table)));
                   2218:     }
                   2219: 
                   2220:   finish_decl (decl, init, asmspec, 0);
                   2221:   return decl;
                   2222: }
                   2223: 
                   2224: /* Finish processing a builtin type TYPE.  It's name is NAME,
                   2225:    its fields are in the array FIELDS.  LEN is the number of elements
                   2226:    in FIELDS minus one, or put another way, it is the maximum subscript
                   2227:    used in FIELDS.
                   2228: 
                   2229:    It is given the same alignment as ALIGN_TYPE.  */
                   2230: void
                   2231: finish_builtin_type (type, name, fields, len, align_type)
                   2232:      tree type;
                   2233:      char *name;
                   2234:      tree fields[];
                   2235:      int len;
                   2236:      tree align_type;
                   2237: {
                   2238:   register int i;
                   2239: 
                   2240:   TYPE_FIELDS (type) = fields[0];
                   2241:   for (i = 0; i < len; i++)
                   2242:     {
                   2243:       layout_type (TREE_TYPE (fields[i]));
                   2244:       DECL_FIELD_CONTEXT (fields[i]) = type;
                   2245:       TREE_CHAIN (fields[i]) = fields[i+1];
                   2246:     }
                   2247:   DECL_FIELD_CONTEXT (fields[i]) = type;
                   2248:   DECL_CLASS_CONTEXT (fields[i]) = type;
                   2249:   TYPE_ALIGN (type) = TYPE_ALIGN (align_type);
                   2250:   layout_type (type);
                   2251: #if 0 /* not yet, should get fixed properly later */
                   2252:   TYPE_NAME (type) = make_type_decl (get_identifier (name), type);
                   2253: #else
                   2254:   TYPE_NAME (type) = build_decl (TYPE_DECL, get_identifier (name), type);
                   2255: #endif
                   2256:   layout_decl (TYPE_NAME (type), 0);
                   2257: }
                   2258: 
                   2259: /* Auxiliary functions to make type signatures for
                   2260:    `operator new' and `operator delete' correspond to
                   2261:    what compiler will be expecting.  */
                   2262: 
                   2263: extern tree sizetype;
                   2264: 
                   2265: tree
                   2266: coerce_new_type (type)
                   2267:      tree type;
                   2268: {
                   2269:   int e1 = 0, e2 = 0;
                   2270: 
                   2271:   if (TREE_CODE (type) == METHOD_TYPE)
                   2272:     type = build_function_type (TREE_TYPE (type), TREE_CHAIN (TYPE_ARG_TYPES (type)));
                   2273:   if (TREE_TYPE (type) != ptr_type_node)
                   2274:     e1 = 1, error ("`operator new' must return type `void *'");
                   2275: 
                   2276:   /* Technically the type must be `size_t', but we may not know
                   2277:      what that is.  */
                   2278:   if (TYPE_ARG_TYPES (type) == NULL_TREE)
                   2279:     e1 = 1, error ("`operator new' takes type `size_t' parameter");
                   2280:   else if (TREE_CODE (TREE_VALUE (TYPE_ARG_TYPES (type))) != INTEGER_TYPE
                   2281:           || TYPE_PRECISION (TREE_VALUE (TYPE_ARG_TYPES (type))) != TYPE_PRECISION (sizetype))
                   2282:     e2 = 1, error ("`operator new' takes type `size_t' as first parameter");
                   2283:   if (e2)
                   2284:     type = build_function_type (ptr_type_node, tree_cons (NULL_TREE, sizetype, TREE_CHAIN (TYPE_ARG_TYPES (type))));
                   2285:   else if (e1)
                   2286:     type = build_function_type (ptr_type_node, TYPE_ARG_TYPES (type));
                   2287:   return type;
                   2288: }
                   2289: 
                   2290: tree
                   2291: coerce_delete_type (type)
                   2292:      tree type;
                   2293: {
                   2294:   int e1 = 0, e2 = 0, e3 = 0;
                   2295:   tree arg_types = TYPE_ARG_TYPES (type);
                   2296: 
                   2297:   if (TREE_CODE (type) == METHOD_TYPE)
                   2298:     {
                   2299:       type = build_function_type (TREE_TYPE (type), TREE_CHAIN (arg_types));
                   2300:       arg_types = TREE_CHAIN (arg_types);
                   2301:     }
                   2302:   if (TREE_TYPE (type) != void_type_node)
                   2303:     e1 = 1, error ("`operator delete' must return type `void'");
                   2304:   if (arg_types == NULL_TREE
                   2305:       || TREE_VALUE (arg_types) != ptr_type_node)
                   2306:     e2 = 1, error ("`operator delete' takes type `void *' as first parameter");
                   2307: 
                   2308:   if (arg_types
                   2309:       && TREE_CHAIN (arg_types)
                   2310:       && TREE_CHAIN (arg_types) != void_list_node)
                   2311:     {
                   2312:       /* Again, technically this argument must be `size_t', but again
                   2313:         we may not know what that is.  */
                   2314:       tree t2 = TREE_VALUE (TREE_CHAIN (arg_types));
                   2315:       if (TREE_CODE (t2) != INTEGER_TYPE
                   2316:          || TYPE_PRECISION (t2) != TYPE_PRECISION (sizetype))
                   2317:        e3 = 1, error ("second argument to `operator delete' must be of type `size_t'");
                   2318:       else if (TREE_CHAIN (TREE_CHAIN (arg_types)) != void_list_node)
                   2319:        {
                   2320:          e3 = 1;
                   2321:          if (TREE_CHAIN (TREE_CHAIN (arg_types)))
                   2322:            error ("too many arguments in declaration of `operator delete'");
                   2323:          else
                   2324:            error ("`...' invalid in specification of `operator delete'");
                   2325:        }
                   2326:     }
                   2327:   if (e3)
                   2328:     arg_types = tree_cons (NULL_TREE, ptr_type_node, build_tree_list (NULL_TREE, sizetype));
                   2329:   else if (e3 |= e2)
                   2330:     {
                   2331:       if (arg_types == NULL_TREE)
                   2332:        arg_types = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
                   2333:       else
                   2334:        arg_types = tree_cons (NULL_TREE, ptr_type_node, TREE_CHAIN (arg_types));
                   2335:     }
                   2336:   else e3 |= e1;
                   2337: 
                   2338:   if (e3)
                   2339:     type = build_function_type (void_type_node, arg_types);
                   2340: 
                   2341:   return type;
                   2342: }
                   2343: 
                   2344: static void
                   2345: mark_vtable_entries (decl)
                   2346:      tree decl;
                   2347: {
                   2348:   tree entries = TREE_CHAIN (CONSTRUCTOR_ELTS (DECL_INITIAL (decl)));
                   2349: 
                   2350:   if (flag_dossier)
                   2351:     entries = TREE_CHAIN (entries);
                   2352: 
                   2353:   for (; entries; entries = TREE_CHAIN (entries))
                   2354:     {
                   2355:       tree fnaddr = FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (entries));
                   2356:       tree fn = TREE_OPERAND (fnaddr, 0);
                   2357:       TREE_ADDRESSABLE (fn) = 1;
                   2358:       if (DECL_ABSTRACT_VIRTUAL_P (fn))
                   2359:        {
                   2360:          extern tree abort_fndecl;
                   2361:          if (flag_vtable_thunks)
                   2362:            fnaddr = TREE_VALUE (entries);
                   2363:          TREE_OPERAND (fnaddr, 0) = abort_fndecl;
                   2364:        }
                   2365:     }
                   2366: }
                   2367: 
                   2368: /* Set TREE_PUBLIC and/or TREE_EXTERN on the vtable DECL,
                   2369:    based on TYPE and other static flags.
                   2370: 
                   2371:    Note that anything public is tagged TREE_PUBLIC, whether
                   2372:    it's public in this file or in another one.  */
                   2373: 
                   2374: void
                   2375: import_export_vtable (decl, type)
                   2376:   tree decl, type;
                   2377: {
                   2378:   if (write_virtuals >= 2
                   2379:       || CLASSTYPE_TEMPLATE_INSTANTIATION (type))
                   2380:     {
                   2381:       if (CLASSTYPE_INTERFACE_KNOWN (type))
                   2382:        {
                   2383:          TREE_PUBLIC (decl) = 1;
                   2384:          DECL_EXTERNAL (decl) = ! CLASSTYPE_VTABLE_NEEDS_WRITING (type);
                   2385:        }
                   2386:     }
                   2387:   else if (write_virtuals != 0)
                   2388:     {
                   2389:       TREE_PUBLIC (decl) = 1;
                   2390:       if (write_virtuals < 0)
                   2391:        DECL_EXTERNAL (decl) = 1;
                   2392:     }
                   2393: }
                   2394: 
                   2395: static void
                   2396: import_export_template (type)
                   2397:      tree type;
                   2398: {
                   2399:   if (CLASSTYPE_IMPLICIT_INSTANTIATION (type)
                   2400:       && ! flag_implicit_templates
                   2401:       && CLASSTYPE_INTERFACE_UNKNOWN (type))
                   2402:     {
                   2403:       SET_CLASSTYPE_INTERFACE_KNOWN (type);
                   2404:       CLASSTYPE_INTERFACE_ONLY (type) = 1;
                   2405:       CLASSTYPE_VTABLE_NEEDS_WRITING (type) = 0;
                   2406:     }
                   2407: }
                   2408:     
                   2409: static void
                   2410: finish_vtable_vardecl (prev, vars)
                   2411:      tree prev, vars;
                   2412: {
                   2413:   tree ctype = DECL_CONTEXT (vars);
                   2414:   import_export_template (ctype);
                   2415:   import_export_vtable (vars, ctype);
                   2416: 
                   2417:   if (flag_vtable_thunks && !CLASSTYPE_INTERFACE_KNOWN (ctype))
                   2418:     {
                   2419:       tree method;
                   2420:       for (method = CLASSTYPE_METHODS (ctype); method != NULL_TREE;
                   2421:           method = DECL_NEXT_METHOD (method))
                   2422:        {
                   2423:          if (DECL_VINDEX (method) != NULL_TREE && !DECL_SAVED_INSNS (method)
                   2424:              && !DECL_ABSTRACT_VIRTUAL_P (method))
                   2425:            {
                   2426:              SET_CLASSTYPE_INTERFACE_KNOWN (ctype);
                   2427:              CLASSTYPE_INTERFACE_ONLY (ctype) = DECL_EXTERNAL (method);
                   2428:              TREE_PUBLIC (vars) = 1;
                   2429:              DECL_EXTERNAL (vars) = DECL_EXTERNAL (method);
                   2430:              break;
                   2431:            }
                   2432:        }
                   2433:     }
                   2434: 
                   2435:   if (write_virtuals >= 0
                   2436:       && ! DECL_EXTERNAL (vars) && (TREE_PUBLIC (vars) || TREE_USED (vars)))
                   2437:     {
                   2438:       extern tree the_null_vtable_entry;
                   2439: 
                   2440:       /* Stuff this virtual function table's size into
                   2441:         `pfn' slot of `the_null_vtable_entry'.  */
                   2442:       tree nelts = array_type_nelts (TREE_TYPE (vars));
                   2443:       if (flag_vtable_thunks)
                   2444:        TREE_VALUE (CONSTRUCTOR_ELTS (DECL_INITIAL (vars))) = nelts;
                   2445:       else
                   2446:        SET_FNADDR_FROM_VTABLE_ENTRY (the_null_vtable_entry, nelts);
                   2447:       /* Kick out the dossier before writing out the vtable.  */
                   2448:       if (flag_dossier)
                   2449:        rest_of_decl_compilation (TREE_OPERAND (FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (TREE_CHAIN (CONSTRUCTOR_ELTS (DECL_INITIAL (vars))))), 0), 0, 1, 1);
                   2450: 
                   2451:       /* Write it out.  */
                   2452:       mark_vtable_entries (vars);
                   2453:       if (TREE_TYPE (DECL_INITIAL (vars)) == 0)
                   2454:          store_init_value (vars, DECL_INITIAL (vars));
                   2455: 
                   2456: #ifdef DWARF_DEBUGGING_INFO
                   2457:       if (write_symbols == DWARF_DEBUG)
                   2458:        {
                   2459:          /* Mark the VAR_DECL node representing the vtable itself as a
                   2460:             "gratuitous" one, thereby forcing dwarfout.c to ignore it.
                   2461:             It is rather important that such things be ignored because
                   2462:             any effort to actually generate DWARF for them will run
                   2463:             into trouble when/if we encounter code like:
                   2464: 
                   2465:                #pragma interface
                   2466:                struct S { virtual void member (); };
                   2467: 
                   2468:              because the artificial declaration of the vtable itself (as
                   2469:              manufactured by the g++ front end) will say that the vtable
                   2470:              is a static member of `S' but only *after* the debug output
                   2471:              for the definition of `S' has already been output.  This causes
                   2472:              grief because the DWARF entry for the definition of the vtable
                   2473:              will try to refer back to an earlier *declaration* of the
                   2474:              vtable as a static member of `S' and there won't be one.
                   2475:              We might be able to arrange to have the "vtable static member"
                   2476:              attached to the member list for `S' before the debug info for
                   2477:              `S' get written (which would solve the problem) but that would
                   2478:              require more intrusive changes to the g++ front end.  */
                   2479: 
                   2480:          DECL_IGNORED_P (vars) = 1;
                   2481:        }
                   2482: #endif /* DWARF_DEBUGGING_INFO */
                   2483: 
                   2484:       rest_of_decl_compilation (vars, NULL_PTR, 1, 1);
                   2485:     }
                   2486:   else if (TREE_USED (vars) && flag_vtable_thunks)
                   2487:     assemble_external (vars);
                   2488:   /* We know that PREV must be non-zero here.  */
                   2489:   TREE_CHAIN (prev) = TREE_CHAIN (vars);
                   2490: }
                   2491: 
                   2492: void
                   2493: walk_vtables (typedecl_fn, vardecl_fn)
                   2494:      register void (*typedecl_fn)();
                   2495:      register void (*vardecl_fn)();
                   2496: {
                   2497:   tree prev, vars;
                   2498: 
                   2499:   for (prev = 0, vars = getdecls (); vars; vars = TREE_CHAIN (vars))
                   2500:     {
                   2501:       register tree type = TREE_TYPE (vars);
                   2502: 
                   2503:       if (TREE_CODE (vars) == TYPE_DECL
                   2504:          && type != error_mark_node
                   2505:          && TYPE_LANG_SPECIFIC (type)
                   2506:          && CLASSTYPE_VSIZE (type))
                   2507:        {
                   2508:          if (typedecl_fn) (*typedecl_fn) (prev, vars);
                   2509:        }
                   2510:       else if (TREE_CODE (vars) == VAR_DECL && DECL_VIRTUAL_P (vars))
                   2511:        {
                   2512:          if (vardecl_fn) (*vardecl_fn) (prev, vars);
                   2513:        }
                   2514:       else
                   2515:        prev = vars;
                   2516:     }
                   2517: }
                   2518: 
                   2519: static void
                   2520: finish_sigtable_vardecl (prev, vars)
                   2521:      tree prev, vars;
                   2522: {
                   2523:   /* We don't need to mark sigtable entries as addressable here as is done
                   2524:      for vtables.  Since sigtables, unlike vtables, are always written out,
                   2525:      that was already done in build_signature_table_constructor.  */
                   2526: 
                   2527:   rest_of_decl_compilation (vars, NULL_PTR, 1, 1);
                   2528: 
                   2529:   /* We know that PREV must be non-zero here.  */
                   2530:   TREE_CHAIN (prev) = TREE_CHAIN (vars);
                   2531: }
                   2532: 
                   2533: void
                   2534: walk_sigtables (typedecl_fn, vardecl_fn)
                   2535:      register void (*typedecl_fn)();
                   2536:      register void (*vardecl_fn)();
                   2537: {
                   2538:   tree prev, vars;
                   2539: 
                   2540:   for (prev = 0, vars = getdecls (); vars; vars = TREE_CHAIN (vars))
                   2541:     {
                   2542:       register tree type = TREE_TYPE (vars);
                   2543: 
                   2544:       if (TREE_CODE (vars) == TYPE_DECL
                   2545:          && type != error_mark_node
                   2546:          && IS_SIGNATURE (type))
                   2547:        {
                   2548:          if (typedecl_fn) (*typedecl_fn) (prev, vars);
                   2549:        }
                   2550:       else if (TREE_CODE (vars) == VAR_DECL
                   2551:               && TREE_TYPE (vars) != error_mark_node
                   2552:               && IS_SIGNATURE (TREE_TYPE (vars)))
                   2553:        {
                   2554:          if (vardecl_fn) (*vardecl_fn) (prev, vars);
                   2555:        }
                   2556:       else
                   2557:        prev = vars;
                   2558:     }
                   2559: }
                   2560: 
                   2561: /* Determines the proper settings of TREE_PUBLIC and DECL_EXTERNAL for an
                   2562:    inline function at end-of-file.  */
                   2563: 
                   2564: void
                   2565: import_export_inline (decl)
                   2566:      tree decl;
                   2567: {
                   2568:   if (TREE_PUBLIC (decl))
                   2569:     return;
                   2570: 
                   2571:   /* If an explicit instantiation doesn't have TREE_PUBLIC set, it was with
                   2572:      'extern'.  */
                   2573:   if (DECL_EXPLICIT_INSTANTIATION (decl)
                   2574:       || (DECL_IMPLICIT_INSTANTIATION (decl) && ! flag_implicit_templates))
                   2575:     {
                   2576:       TREE_PUBLIC (decl) = 1;
                   2577:       DECL_EXTERNAL (decl) = 1;
                   2578:     }
                   2579:   else if (DECL_FUNCTION_MEMBER_P (decl))
                   2580:     {
                   2581:       tree ctype = DECL_CLASS_CONTEXT (decl);
                   2582:       if (CLASSTYPE_INTERFACE_KNOWN (ctype))
                   2583:        {
                   2584:          TREE_PUBLIC (decl) = 1;
                   2585:          DECL_EXTERNAL (decl)
                   2586:            = (CLASSTYPE_INTERFACE_ONLY (ctype)
                   2587:               || (DECL_INLINE (decl) && ! flag_implement_inlines));
                   2588:        }
                   2589:     }
                   2590: }
                   2591:   
                   2592: extern int parse_time, varconst_time;
                   2593: 
                   2594: #define TIMEVAR(VAR, BODY)    \
                   2595: do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
                   2596: 
                   2597: /* This routine is called from the last rule in yyparse ().
                   2598:    Its job is to create all the code needed to initialize and
                   2599:    destroy the global aggregates.  We do the destruction
                   2600:    first, since that way we only need to reverse the decls once.  */
                   2601: 
                   2602: void
                   2603: finish_file ()
                   2604: {
                   2605:   extern int lineno;
                   2606:   int start_time, this_time;
                   2607: 
                   2608:   tree fnname;
                   2609:   tree vars = static_aggregates;
                   2610:   int needs_cleaning = 0, needs_messing_up = 0;
                   2611:   int have_exception_handlers = build_exception_table ();
                   2612: 
                   2613:   if (flag_detailed_statistics)
                   2614:     dump_tree_statistics ();
                   2615: 
                   2616:   /* Bad parse errors.  Just forget about it.  */
                   2617:   if (! global_bindings_p () || current_class_type)
                   2618:     return;
                   2619: 
                   2620:   start_time = get_run_time ();
                   2621: 
                   2622:   /* Push into C language context, because that's all
                   2623:      we'll need here.  */
                   2624:   push_lang_context (lang_name_c);
                   2625: 
                   2626:   /* Set up the name of the file-level functions we may need.  */
                   2627:   /* Use a global object (which is already required to be unique over
                   2628:      the program) rather than the file name (which imposes extra
                   2629:      constraints).  -- [email protected], 10 Jan 1990.  */
                   2630: 
                   2631:   /* See if we really need the hassle.  */
                   2632:   while (vars && needs_cleaning == 0)
                   2633:     {
                   2634:       tree decl = TREE_VALUE (vars);
                   2635:       tree type = TREE_TYPE (decl);
                   2636:       if (TYPE_NEEDS_DESTRUCTOR (type))
                   2637:        {
                   2638:          needs_cleaning = 1;
                   2639:          needs_messing_up = 1;
                   2640:          break;
                   2641:        }
                   2642:       else
                   2643:        needs_messing_up |= TYPE_NEEDS_CONSTRUCTING (type);
                   2644:       vars = TREE_CHAIN (vars);
                   2645:     }
                   2646:   if (needs_cleaning == 0)
                   2647:     goto mess_up;
                   2648: 
                   2649:   /* Otherwise, GDB can get confused, because in only knows
                   2650:      about source for LINENO-1 lines.  */
                   2651:   lineno -= 1;
                   2652: 
                   2653:   fnname = get_file_function_name ('D');
                   2654:   start_function (void_list_node, build_parse_node (CALL_EXPR, fnname, void_list_node, NULL_TREE), 0, 0);
                   2655:   fnname = DECL_ASSEMBLER_NAME (current_function_decl);
                   2656:   store_parm_decls ();
                   2657: 
                   2658:   pushlevel (0);
                   2659:   clear_last_expr ();
                   2660:   push_momentary ();
                   2661:   expand_start_bindings (0);
                   2662: 
                   2663:   /* These must be done in backward order to destroy,
                   2664:      in which they happen to be!  */
                   2665:   while (vars)
                   2666:     {
                   2667:       tree decl = TREE_VALUE (vars);
                   2668:       tree type = TREE_TYPE (decl);
                   2669:       tree temp = TREE_PURPOSE (vars);
                   2670: 
                   2671:       if (TYPE_NEEDS_DESTRUCTOR (type))
                   2672:        {
                   2673:          if (TREE_STATIC (vars))
                   2674:            expand_start_cond (build_binary_op (NE_EXPR, temp, integer_zero_node, 1), 0);
                   2675:          if (TREE_CODE (type) == ARRAY_TYPE)
                   2676:            temp = decl;
                   2677:          else
                   2678:            {
                   2679:              mark_addressable (decl);
                   2680:              temp = build1 (ADDR_EXPR, TYPE_POINTER_TO (type), decl);
                   2681:            }
                   2682:          temp = build_delete (TREE_TYPE (temp), temp,
                   2683:                               integer_two_node, LOOKUP_NORMAL|LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR, 0);
                   2684:          expand_expr_stmt (temp);
                   2685: 
                   2686:          if (TREE_STATIC (vars))
                   2687:            expand_end_cond ();
                   2688:        }
                   2689:       vars = TREE_CHAIN (vars);
                   2690:     }
                   2691: 
                   2692:   expand_end_bindings (getdecls(), 1, 0);
                   2693:   poplevel (1, 0, 0);
                   2694:   pop_momentary ();
                   2695: 
                   2696:   finish_function (lineno, 0);
                   2697: 
                   2698:   assemble_destructor (IDENTIFIER_POINTER (fnname));
                   2699: 
                   2700:   /* if it needed cleaning, then it will need messing up: drop through  */
                   2701: 
                   2702:  mess_up:
                   2703:   /* Must do this while we think we are at the top level.  */
                   2704:   vars = nreverse (static_aggregates);
                   2705:   if (vars != NULL_TREE || have_exception_handlers)
                   2706:     {
                   2707:       fnname = get_file_function_name ('I');
                   2708:       start_function (void_list_node, build_parse_node (CALL_EXPR, fnname, void_list_node, NULL_TREE), 0, 0);
                   2709:       fnname = DECL_ASSEMBLER_NAME (current_function_decl);
                   2710:       store_parm_decls ();
                   2711: 
                   2712:       pushlevel (0);
                   2713:       clear_last_expr ();
                   2714:       push_momentary ();
                   2715:       expand_start_bindings (0);
                   2716: 
                   2717:       if (have_exception_handlers)
                   2718:        register_exception_table ();
                   2719: 
                   2720:       while (vars)
                   2721:        {
                   2722:          tree decl = TREE_VALUE (vars);
                   2723:          tree init = TREE_PURPOSE (vars);
                   2724:          tree old_cleanups = cleanups_this_call;
                   2725: 
                   2726:          /* If this was a static attribute within some function's scope,
                   2727:             then don't initialize it here.  Also, don't bother
                   2728:             with initializers that contain errors.  */
                   2729:          if (TREE_STATIC (vars)
                   2730:              || (init && TREE_CODE (init) == TREE_LIST
                   2731:                  && value_member (error_mark_node, init)))
                   2732:            {
                   2733:              vars = TREE_CHAIN (vars);
                   2734:              continue;
                   2735:            }
                   2736: 
                   2737:          if (TREE_CODE (decl) == VAR_DECL)
                   2738:            {
                   2739:              /* Set these global variables so that GDB at least puts
                   2740:                 us near the declaration which required the initialization.  */
                   2741:              input_filename = DECL_SOURCE_FILE (decl);
                   2742:              lineno = DECL_SOURCE_LINE (decl);
                   2743:              emit_note (input_filename, lineno);
                   2744: 
                   2745:              /* 9.5p5: The initializer of a static member of a class has
                   2746:                 the same acess rights as a member function.  */
                   2747:              DECL_CLASS_CONTEXT (current_function_decl) = DECL_CONTEXT (decl);
                   2748: 
                   2749:              if (init)
                   2750:                {
                   2751:                  if (TREE_CODE (init) == VAR_DECL)
                   2752:                    {
                   2753:                      /* This behavior results when there are
                   2754:                         multiple declarations of an aggregate,
                   2755:                         the last of which defines it.  */
                   2756:                      if (DECL_RTL (init) == DECL_RTL (decl))
                   2757:                        {
                   2758:                          my_friendly_assert (DECL_INITIAL (decl) == error_mark_node
                   2759:                                  || (TREE_CODE (DECL_INITIAL (decl)) == CONSTRUCTOR
                   2760:                                      && CONSTRUCTOR_ELTS (DECL_INITIAL (decl)) == NULL_TREE),
                   2761:                                              199);
                   2762:                          init = DECL_INITIAL (init);
                   2763:                          if (TREE_CODE (init) == CONSTRUCTOR
                   2764:                              && CONSTRUCTOR_ELTS (init) == NULL_TREE)
                   2765:                            init = NULL_TREE;
                   2766:                        }
                   2767: #if 0
                   2768:                      else if (TREE_TYPE (decl) == TREE_TYPE (init))
                   2769:                        {
                   2770: #if 1
                   2771:                          my_friendly_abort (200);
                   2772: #else
                   2773:                          /* point to real decl's rtl anyway.  */
                   2774:                          DECL_RTL (init) = DECL_RTL (decl);
                   2775:                          my_friendly_assert (DECL_INITIAL (decl) == error_mark_node,
                   2776:                                              201);
                   2777:                          init = DECL_INITIAL (init);
                   2778: #endif                         /* 1 */
                   2779:                        }
                   2780: #endif                         /* 0 */
                   2781:                    }
                   2782:                }
                   2783:              if (IS_AGGR_TYPE (TREE_TYPE (decl))
                   2784:                  || TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
                   2785:                expand_aggr_init (decl, init, 0);
                   2786:              else if (TREE_CODE (init) == TREE_VEC)
                   2787:                {
                   2788:                  expand_expr (expand_vec_init (decl, TREE_VEC_ELT (init, 0),
                   2789:                                                TREE_VEC_ELT (init, 1),
                   2790:                                                TREE_VEC_ELT (init, 2), 0),
                   2791:                               const0_rtx, VOIDmode, 0);
                   2792:                  free_temp_slots ();
                   2793:                }
                   2794:              else
                   2795:                expand_assignment (decl, init, 0, 0);
                   2796: 
                   2797:              DECL_CLASS_CONTEXT (current_function_decl) = NULL_TREE;
                   2798:            }
                   2799:          else if (TREE_CODE (decl) == SAVE_EXPR)
                   2800:            {
                   2801:              if (! PARM_DECL_EXPR (decl))
                   2802:                {
                   2803:                  /* a `new' expression at top level.  */
                   2804:                  expand_expr (decl, const0_rtx, VOIDmode, 0);
                   2805:                  free_temp_slots ();
                   2806:                  expand_aggr_init (build_indirect_ref (decl, NULL_PTR), init, 0);
                   2807:                }
                   2808:            }
                   2809:          else if (decl == error_mark_node)
                   2810:            ;
                   2811:          else my_friendly_abort (22);
                   2812:          vars = TREE_CHAIN (vars);
                   2813:          /* Cleanup any temporaries needed for the initial value.  */
                   2814:          expand_cleanups_to (old_cleanups);
                   2815:        }
                   2816: 
                   2817:       expand_end_bindings (getdecls(), 1, 0);
                   2818:       poplevel (1, 0, 0);
                   2819:       pop_momentary ();
                   2820: 
                   2821:       finish_function (lineno, 0);
                   2822:       assemble_constructor (IDENTIFIER_POINTER (fnname));
                   2823:     }
                   2824: 
                   2825:   /* Done with C language context needs.  */
                   2826:   pop_lang_context ();
                   2827: 
                   2828:   /* Now write out any static class variables (which may have since
                   2829:      learned how to be initialized).  */
                   2830:   while (pending_statics)
                   2831:     {
                   2832:       tree decl = TREE_VALUE (pending_statics);
                   2833:       if (TREE_USED (decl) == 1
                   2834:          || TREE_READONLY (decl) == 0
                   2835:          || DECL_INITIAL (decl) == 0)
                   2836:        rest_of_decl_compilation (decl, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), 1, 1);
                   2837:       pending_statics = TREE_CHAIN (pending_statics);
                   2838:     }
                   2839: 
                   2840:   this_time = get_run_time ();
                   2841:   parse_time -= this_time - start_time;
                   2842:   varconst_time += this_time - start_time;
                   2843: 
                   2844:   start_time = get_run_time ();
                   2845: 
                   2846:   /* Now delete from the chain of variables all virtual function tables.
                   2847:      We output them all ourselves, because each will be treated specially.  */
                   2848: 
                   2849: #if 1
                   2850:   /* The reason for pushing garbage onto the global_binding_level is to
                   2851:      ensure that we can slice out _DECLs which pertain to virtual function
                   2852:      tables.  If the last thing pushed onto the global_binding_level was a
                   2853:      virtual function table, then slicing it out would slice away all the
                   2854:      decls (i.e., we lose the head of the chain).
                   2855: 
                   2856:      There are several ways of getting the same effect, from changing the
                   2857:      way that iterators over the chain treat the elements that pertain to
                   2858:      virtual function tables, moving the implementation of this code to
                   2859:      decl.c (where we can manipulate global_binding_level directly),
                   2860:      popping the garbage after pushing it and slicing away the vtable
                   2861:      stuff, or just leaving it alone. */
                   2862: 
                   2863:   /* Make last thing in global scope not be a virtual function table.  */
                   2864: #if 0 /* not yet, should get fixed properly later */
                   2865:   vars = make_type_decl (get_identifier (" @%$#@!"), integer_type_node);
                   2866: #else
                   2867:   vars = build_decl (TYPE_DECL, get_identifier (" @%$#@!"), integer_type_node);
                   2868: #endif
                   2869:   DECL_IGNORED_P (vars) = 1;
                   2870:   SET_DECL_ARTIFICIAL (vars);
                   2871:   pushdecl (vars);
                   2872: #endif
                   2873: 
                   2874:   walk_vtables ((void (*)())0, finish_vtable_vardecl);
                   2875:   if (flag_handle_signatures)
                   2876:     walk_sigtables ((void (*)())0, finish_sigtable_vardecl);
                   2877: 
                   2878:   for (vars = getdecls (); vars; vars = TREE_CHAIN (vars))
                   2879:     {
                   2880:       if (TREE_CODE (vars) == THUNK_DECL)
                   2881:        emit_thunk (vars);
                   2882:     }
                   2883: 
                   2884:   {
                   2885:     int reconsider = 0;                /* More may be referenced; check again */
                   2886:     tree delayed = NULL_TREE;  /* These might be referenced later */
                   2887: 
                   2888:     /* Now write out inline functions which had their addresses taken and
                   2889:        which were not declared virtual and which were not declared `extern
                   2890:        inline'.  */
                   2891:     while (saved_inlines)
                   2892:       {
                   2893:        tree decl = TREE_VALUE (saved_inlines);
                   2894:        saved_inlines = TREE_CHAIN (saved_inlines);
                   2895:        /* Redefinition of a member function can cause DECL_SAVED_INSNS to be
                   2896:           0; don't crash.  */
                   2897:        if (TREE_ASM_WRITTEN (decl) || DECL_SAVED_INSNS (decl) == 0)
                   2898:          continue;
                   2899:        import_export_inline (decl);
                   2900:        if (TREE_PUBLIC (decl)
                   2901:            || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
                   2902:            || flag_keep_inline_functions)
                   2903:          {
                   2904:            if (DECL_EXTERNAL (decl))
                   2905:              assemble_external (decl);
                   2906:            else
                   2907:              {
                   2908:                reconsider = 1;
                   2909:                temporary_allocation ();
                   2910:                output_inline_function (decl);
                   2911:                permanent_allocation (1);
                   2912:              }
                   2913:          }
                   2914:        else if (TREE_USED (decl)
                   2915:                 || TREE_USED (DECL_ASSEMBLER_NAME (decl)))
                   2916:          delayed = tree_cons (NULL_TREE, decl, delayed);
                   2917:       }
                   2918: 
                   2919:     if (reconsider && delayed)
                   2920:       {
                   2921:        while (reconsider)
                   2922:          {
                   2923:            tree place;
                   2924:            reconsider = 0;
                   2925:            for (place = delayed; place; place = TREE_CHAIN (place))
                   2926:              {
                   2927:                tree decl = TREE_VALUE (place);
                   2928:                if (TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
                   2929:                    && ! TREE_ASM_WRITTEN (decl))
                   2930:                  {
                   2931:                    if (DECL_EXTERNAL (decl))
                   2932:                      assemble_external (decl);
                   2933:                    else
                   2934:                      {
                   2935:                        reconsider = 1;
                   2936:                        temporary_allocation ();
                   2937:                        output_inline_function (decl);
                   2938:                        permanent_allocation (1);
                   2939:                      }
                   2940:                  }
                   2941:              }
                   2942:          }
                   2943:       }
                   2944:   }
                   2945: 
                   2946:   if (write_virtuals == 2)
                   2947:     {
                   2948:       /* Now complain about an virtual function tables promised
                   2949:         but not delivered.  */
                   2950:       while (pending_vtables)
                   2951:        {
                   2952:          if (TREE_PURPOSE (pending_vtables) == NULL_TREE)
                   2953:            error ("virtual function table for `%s' not defined",
                   2954:                   IDENTIFIER_POINTER (TREE_VALUE (pending_vtables)));
                   2955:          pending_vtables = TREE_CHAIN (pending_vtables);
                   2956:        }
                   2957:     }
                   2958: 
                   2959:   permanent_allocation (1);
                   2960:   this_time = get_run_time ();
                   2961:   parse_time -= this_time - start_time;
                   2962:   varconst_time += this_time - start_time;
                   2963: 
                   2964:   if (flag_detailed_statistics)
                   2965:     dump_time_statistics ();
                   2966: }
                   2967: 
                   2968: /* This is something of the form 'A()()()()()+1' that has turned out to be an
                   2969:    expr.  Since it was parsed like a type, we need to wade through and fix
                   2970:    that.  Unfortunately, since operator() is left-associative, we can't use
                   2971:    tail recursion.  In the above example, TYPE is `A', and DECL is
                   2972:    `()()()()()'.
                   2973: 
                   2974:    Maybe this shouldn't be recursive, but how often will it actually be
                   2975:    used?  (jason) */
                   2976: tree
                   2977: reparse_absdcl_as_expr (type, decl)
                   2978:      tree type, decl;
                   2979: {
                   2980:   /* do build_functional_cast (type, NULL_TREE) at bottom */
                   2981:   if (TREE_OPERAND (decl, 0) == NULL_TREE)
                   2982:     return build_functional_cast (type, NULL_TREE);
                   2983: 
                   2984:   /* recurse */
                   2985:   decl = reparse_decl_as_expr (type, TREE_OPERAND (decl, 0));
                   2986: 
                   2987:   decl = build_x_function_call (decl, NULL_TREE, current_class_decl);
                   2988: 
                   2989:   if (TREE_CODE (decl) == CALL_EXPR && TREE_TYPE (decl) != void_type_node)
                   2990:     decl = require_complete_type (decl);
                   2991: 
                   2992:   return decl;
                   2993: }
                   2994: 
                   2995: /* This is something of the form `int ((int)(int)(int)1)' that has turned
                   2996:    out to be an expr.  Since it was parsed like a type, we need to wade
                   2997:    through and fix that.  Since casts are right-associative, we are
                   2998:    reversing the order, so we don't have to recurse.
                   2999: 
                   3000:    In the above example, DECL is the `(int)(int)(int)', and EXPR is the
                   3001:    `1'.  */
                   3002: tree
                   3003: reparse_absdcl_as_casts (decl, expr)
                   3004:      tree decl, expr;
                   3005: {
                   3006:   tree type;
                   3007:   
                   3008:   if (TREE_CODE (expr) == CONSTRUCTOR)
                   3009:     {
                   3010:       type = groktypename (TREE_VALUE (TREE_OPERAND (decl, 1)));
                   3011:       decl = TREE_OPERAND (decl, 0);
                   3012: 
                   3013:       if (IS_SIGNATURE (type))
                   3014:        {
                   3015:          error ("cast specifies signature type");
                   3016:          return error_mark_node;
                   3017:        }
                   3018: 
                   3019:       expr = digest_init (type, expr, (tree *) 0);
                   3020:       if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
                   3021:        {
                   3022:          int failure = complete_array_type (type, expr, 1);
                   3023:          if (failure)
                   3024:            my_friendly_abort (78);
                   3025:        }
                   3026:     }
                   3027: 
                   3028:   while (decl)
                   3029:     {
                   3030:       type = groktypename (TREE_VALUE (TREE_OPERAND (decl, 1)));
                   3031:       decl = TREE_OPERAND (decl, 0);
                   3032:       expr = build_c_cast (type, expr);
                   3033:     }
                   3034: 
                   3035:   return expr;
                   3036: }
                   3037: 
                   3038: /* Recursive helper function for reparse_decl_as_expr.  It may be a good
                   3039:    idea to reimplement this using an explicit stack, rather than recursion. */
                   3040: static tree
                   3041: reparse_decl_as_expr1 (decl)
                   3042:      tree decl;
                   3043: {
                   3044:   switch (TREE_CODE (decl))
                   3045:     {
                   3046:     case IDENTIFIER_NODE:
                   3047:       return do_identifier (decl);
                   3048:     case INDIRECT_REF:
                   3049:       return build_x_indirect_ref
                   3050:        (reparse_decl_as_expr1 (TREE_OPERAND (decl, 0)), "unary *");
                   3051:     case ADDR_EXPR:
                   3052:       return build_x_unary_op (ADDR_EXPR,
                   3053:                               reparse_decl_as_expr1 (TREE_OPERAND (decl, 0)));
                   3054:     case BIT_NOT_EXPR:
                   3055:       return build_x_unary_op (BIT_NOT_EXPR,
                   3056:                               reparse_decl_as_expr1 (TREE_OPERAND (decl, 0)));
                   3057:     case SCOPE_REF:
                   3058:       return build_offset_ref (TREE_OPERAND (decl, 0), TREE_OPERAND (decl, 1));
                   3059:     case ARRAY_REF:
                   3060:       return grok_array_decl (reparse_decl_as_expr1 (TREE_OPERAND (decl, 0)),
                   3061:                              TREE_OPERAND (decl, 1));
                   3062:     default:
                   3063:       my_friendly_abort (5);
                   3064:       return NULL_TREE;
                   3065:     }
                   3066: }
                   3067: 
                   3068: /* This is something of the form `int (*a)++' that has turned out to be an
                   3069:    expr.  It was only converted into parse nodes, so we need to go through
                   3070:    and build up the semantics.  Most of the work is done by
                   3071:    reparse_decl_as_expr1, above.
                   3072: 
                   3073:    In the above example, TYPE is `int' and DECL is `*a'.  */
                   3074: tree
                   3075: reparse_decl_as_expr (type, decl)
                   3076:      tree type, decl;
                   3077: {
                   3078:   decl = build_tree_list (NULL_TREE, reparse_decl_as_expr1 (decl));
                   3079:   return build_functional_cast (type, decl);
                   3080: }
                   3081: 
                   3082: /* This is something of the form `int (*a)' that has turned out to be a
                   3083:    decl.  It was only converted into parse nodes, so we need to do the
                   3084:    checking that make_{pointer,reference}_declarator do. */
                   3085: 
                   3086: tree
                   3087: finish_decl_parsing (decl)
                   3088:      tree decl;
                   3089: {
                   3090:   extern int current_class_depth;
                   3091:   
                   3092:   switch (TREE_CODE (decl))
                   3093:     {
                   3094:     case IDENTIFIER_NODE:
                   3095:       return decl;
                   3096:     case INDIRECT_REF:
                   3097:       return make_pointer_declarator
                   3098:        (NULL_TREE, finish_decl_parsing (TREE_OPERAND (decl, 0)));
                   3099:     case ADDR_EXPR:
                   3100:       return make_reference_declarator
                   3101:        (NULL_TREE, finish_decl_parsing (TREE_OPERAND (decl, 0)));
                   3102:     case BIT_NOT_EXPR:
                   3103:       TREE_OPERAND (decl, 0) = finish_decl_parsing (TREE_OPERAND (decl, 0));
                   3104:       return decl;
                   3105:     case SCOPE_REF:
                   3106:       push_nested_class (TREE_TYPE (TREE_OPERAND (decl, 0)), 3);
                   3107:       TREE_COMPLEXITY (decl) = current_class_depth;
                   3108:       return decl;
                   3109:     case ARRAY_REF:
                   3110:       TREE_OPERAND (decl, 0) = finish_decl_parsing (TREE_OPERAND (decl, 0));
                   3111:       return decl;
                   3112:     default:
                   3113:       my_friendly_abort (5);
                   3114:       return NULL_TREE;
                   3115:     }
                   3116: }
                   3117: 
                   3118: tree
                   3119: check_cp_case_value (value)
                   3120:      tree value;
                   3121: {
                   3122:   if (value == NULL_TREE)
                   3123:     return value;
                   3124: 
                   3125:   /* build_c_cast puts on a NOP_EXPR to make a non-lvalue.
                   3126:      Strip such NOP_EXPRs.  */
                   3127:   if (TREE_CODE (value) == NOP_EXPR
                   3128:       && TREE_TYPE (value) == TREE_TYPE (TREE_OPERAND (value, 0)))
                   3129:     value = TREE_OPERAND (value, 0);
                   3130: 
                   3131:   if (TREE_READONLY_DECL_P (value))
                   3132:     {
                   3133:       value = decl_constant_value (value);
                   3134:       /* build_c_cast puts on a NOP_EXPR to make a non-lvalue.
                   3135:         Strip such NOP_EXPRs.  */
                   3136:       if (TREE_CODE (value) == NOP_EXPR
                   3137:          && TREE_TYPE (value) == TREE_TYPE (TREE_OPERAND (value, 0)))
                   3138:        value = TREE_OPERAND (value, 0);
                   3139:     }
                   3140:   value = fold (value);
                   3141: 
                   3142:   if (TREE_CODE (value) != INTEGER_CST
                   3143:       && value != error_mark_node)
                   3144:     {
                   3145:       cp_error ("case label `%E' does not reduce to an integer constant",
                   3146:                value);
                   3147:       value = error_mark_node;
                   3148:     }
                   3149:   else
                   3150:     /* Promote char or short to int.  */
                   3151:     value = default_conversion (value);
                   3152: 
                   3153:   constant_expression_warning (value);
                   3154: 
                   3155:   return value;
                   3156: }

unix.superglobalmegacorp.com

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