Annotation of gcc/cp/decl2.c, revision 1.1.1.2

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

unix.superglobalmegacorp.com

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