home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Source / GNU / gcc / obcp / decl2.c < prev    next >
C/C++ Source or Header  |  1996-12-12  |  103KB  |  3,556 lines

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