summaryrefslogtreecommitdiffstats
path: root/contrib/gcc/cp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/gcc/cp')
-rw-r--r--contrib/gcc/cp/ChangeLog9459
-rw-r--r--contrib/gcc/cp/Make-lang.in197
-rw-r--r--contrib/gcc/cp/Makefile.in265
-rw-r--r--contrib/gcc/cp/call.c2993
-rw-r--r--contrib/gcc/cp/class.c5086
-rw-r--r--contrib/gcc/cp/class.h117
-rw-r--r--contrib/gcc/cp/config-lang.in35
-rw-r--r--contrib/gcc/cp/cp-tree.h2496
-rw-r--r--contrib/gcc/cp/cvt.c1820
-rw-r--r--contrib/gcc/cp/decl.c12878
-rw-r--r--contrib/gcc/cp/decl.h59
-rw-r--r--contrib/gcc/cp/decl2.c3511
-rw-r--r--contrib/gcc/cp/edsel.c928
-rw-r--r--contrib/gcc/cp/errfn.c230
-rw-r--r--contrib/gcc/cp/error.c1482
-rw-r--r--contrib/gcc/cp/except.c1690
-rw-r--r--contrib/gcc/cp/expr.c372
-rw-r--r--contrib/gcc/cp/g++.1674
-rw-r--r--contrib/gcc/cp/g++.c582
-rw-r--r--contrib/gcc/cp/gc.c1550
-rw-r--r--contrib/gcc/cp/gpcompare.texi236
-rw-r--r--contrib/gcc/cp/gxx.gperf102
-rw-r--r--contrib/gcc/cp/gxxint.texi1585
-rw-r--r--contrib/gcc/cp/init.c4180
-rw-r--r--contrib/gcc/cp/input.c202
-rw-r--r--contrib/gcc/cp/lang-options.h107
-rw-r--r--contrib/gcc/cp/lang-specs.h59
-rw-r--r--contrib/gcc/cp/lex.c4717
-rw-r--r--contrib/gcc/cp/lex.h135
-rw-r--r--contrib/gcc/cp/method.c2287
-rw-r--r--contrib/gcc/cp/parse.y3906
-rw-r--r--contrib/gcc/cp/pt.c2694
-rw-r--r--contrib/gcc/cp/ptree.c168
-rw-r--r--contrib/gcc/cp/reno.texi752
-rw-r--r--contrib/gcc/cp/repo.c409
-rw-r--r--contrib/gcc/cp/search.c3524
-rw-r--r--contrib/gcc/cp/sig.c1049
-rw-r--r--contrib/gcc/cp/spew.c455
-rw-r--r--contrib/gcc/cp/templates.texi235
-rw-r--r--contrib/gcc/cp/tree.c1995
-rw-r--r--contrib/gcc/cp/tree.def116
-rw-r--r--contrib/gcc/cp/typeck.c7615
-rw-r--r--contrib/gcc/cp/typeck2.c1681
-rw-r--r--contrib/gcc/cp/xref.c840
44 files changed, 85473 insertions, 0 deletions
diff --git a/contrib/gcc/cp/ChangeLog b/contrib/gcc/cp/ChangeLog
new file mode 100644
index 0000000..d2ef74f
--- /dev/null
+++ b/contrib/gcc/cp/ChangeLog
@@ -0,0 +1,9459 @@
+Mon Nov 20 14:06:28 1995 Mike Stump <mrs@cygnus.com>
+
+ * Version 2.7.2 released.
+
+Mon Nov 20 14:05:00 1995 Mike Stump <mrs@cygnus.com>
+
+ * g++.c (pfatal_with_name): Add missing third argument to concat.
+
+Thu Oct 26 13:59:54 1995 Mike Stump <mrs@cygnus.com>
+
+ * init.c (expand_aggr_init): Handle cv qualifiers on the object's
+ type.
+
+Sun Nov 12 18:09:35 1995 Mike Stump <mrs@cygnus.com>
+
+ * Version 2.7.1 released.
+
+Thu Nov 2 17:02:47 1995 Jason Merrill <jason@yorick.cygnus.com>
+
+ * call.c (convert_harshness): Handle references to arrays.
+
+Fri Oct 27 14:20:21 1995 Jason Merrill <jason@yorick.cygnus.com>
+
+ * typeck.c (comp_target_types): Check multi-level pointer
+ conversions in both directions.
+
+Tue Oct 17 21:39:05 1995 Jason Merrill <jason@yorick.cygnus.com>
+
+ * parse.y (explicit_instantiation): Fix 'extern template' with no
+ return type.
+
+Mon Oct 16 14:35:20 1995 Jason Merrill <jason@yorick.cygnus.com>
+
+ * parse.y (explicit_instantiation): Support automatic instantiation
+ of constructors.
+ (named_class_head_*): Support out-of-class definition of nested
+ types.
+
+Wed Oct 11 12:20:56 1995 Mike Stump <mrs@cygnus.com>
+
+ * search.c (envelope_add_decl): New routine. Fix so that
+ methods are hidden in the same way that other members are.
+ (dfs_pushdecls): Cleanup and move functionality out of line,
+ into envelope_add_decl.
+
+Tue Oct 10 15:46:01 1995 Mike Stump <mrs@cygnus.com>
+
+ * typeck.c (mark_addressable): Only call assemble_external if we
+ have started the output file.
+
+Tue Oct 10 11:27:18 1995 Jason Merrill <jason@yorick.cygnus.com>
+
+ * decl.c (start_function): Fix earlier cv-quals change.
+
+Mon Oct 9 23:53:05 1995 Mike Stump <mrs@cygnus.com>
+
+ * parse.y (complex_direct_notype_declarator): Only push the class if
+ we are not already in the class.
+
+Mon Oct 9 11:22:03 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * decl.c (duplicate_decls): Call merge_machine_decl_attributes.
+ Update olddecl's attributes too.
+ (grokdeclarator): #if 0 out call to build_decl_attribute_variant.
+ * typeck.c (common_type): Call merge_machine_type_attributes.
+
+Fri Oct 6 14:44:27 1995 Mike Stump <mrs@cygnus.com>
+
+ * typeck.c (mark_addressable): Add missing call to
+ assemble_external.
+
+Wed Oct 4 22:05:23 1995 Jeff Law (law@hurl.cygnus.com
+
+ * cp/decl.c (deplicate_decls): Merge in deferred output
+ status for variables.
+ * cp/tree.c (tree_copy_lang_decl_for_deferred_output): New
+ function to copy the g++ specific parts of a DECL node.
+ (tree_copy_lang_type_for_deferred_output): Similarly for
+ TYPE nodes.
+
+Wed Oct 4 15:06:39 1995 Mike Stump <mrs@cygnus.com>
+
+ * decl.c (store_parm_decls): Make sure the unwinder start comes
+ before the exception specification start.
+ * except.c (expand_exception_blocks): Make sure the unwinder end
+ comes after the terminate protected catch clause region and after
+ the end of the exception specification region.
+
+Wed Oct 4 12:47:02 1995 Jason Merrill <jason@yorick.cygnus.com>
+
+ * lex.c (real_yylex): Fix identifier case for linemode.
+ (handle_sysv_pragma): Don't abort when we see a pragma we don't
+ recognize.
+
+Tue Oct 3 14:09:46 1995 Mike Stump <mrs@cygnus.com>
+
+ * decl.c (store_parm_decls): Add a call to start_eh_unwinder.
+ * except.c (init_exception_processing): __throw doesn't take any
+ arguments.
+ (expand_builtin_throw): Ditto. Always use Pmode, instead of SImode
+ for all pointers. Use expand_builtin_return_addr to unwind the
+ first level off the stack.
+ (do_unwind): Always use Pmode, instead of SImode for all pointers.
+ (expand_exception_blocks): Add a call to end_eh_unwinder.
+ (start_eh_unwinder, end_eh_unwinder): New routines to build machine
+ independent stack unwinders for function/method calls.
+
+Mon Oct 2 17:20:42 1995 Mike Stump <mrs@cygnus.com>
+
+ * tree.c (unsave_expr_now): Make sure we process the argument list
+ of any called functions. Fixes incorrect code generation for
+ cleanups.
+
+Mon Oct 2 13:04:16 1995 Mike Stump <mrs@cygnus.com>
+
+ * typeck.c (get_member_function_from_ptrfunc): Save function if it
+ needs it. Cures core dump on things like (this->*(f()))().
+
+Sat Sep 23 22:51:25 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (start_function): Conform to gcc cv-quals convention (no
+ expression has a cv-qualified type) in RESULT_DECLs.
+ * method.c (make_thunk): Ditto.
+
+Fri Sep 22 10:21:13 1995 Mike Stump <mrs@cygnus.com>
+
+ * decl.c (pushtag): Add in the namespace name for the tag.
+
+Thu Sep 21 13:11:13 1995 Mike Stump <mrs@cygnus.com>
+
+ * parse.y (maybe_base_class_list, base_class_list, base_class,
+ base_class_access_list): Make sure we see the typenames for base
+ classes.
+ * lex.c (see_typename): Instead of failing to see a typename when
+ there is no next token, perfer a typename, and get the next token.
+
+Wed Sep 20 12:35:27 1995 Michael Meissner <meissner@cygnus.com>
+
+ * decl.c (init_decl_processing): Add __builtin_expect.
+
+Tue Sep 19 16:48:11 1995 Mike Stump <mrs@cygnus.com>
+
+ * cvt.c (cp_convert_to_pointer): Don't allow leftover conversions to
+ or from pointer to member functions, they must all be handled before
+ this point.
+
+Fri Sep 15 17:14:47 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * init.c (resolve_offset_ref): Fix wording of non-static member
+ being referenced as a static.
+
+Fri Sep 15 12:39:11 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (build_indirect_ref): Only bash pointer if we actually
+ call build_expr_type_conversion.
+
+Thu Sep 14 18:24:56 1995 Jason Merrill <jason@deneb.cygnus.com>
+
+ * cvt.c (build_expr_type_conversion): Handle conversion from
+ reference.
+ * typeck.c (build_indirect_ref): Avoid infinite recursion.
+
+Thu Sep 14 17:23:28 1995 Mike Stump <mrs@cygnus.com>
+
+ * decl.c (expand_start_early_try_stmts): New routine to start a try
+ block at the start of the function, for function-try-blocks.
+ * cp-tree.h (expand_start_early_try_stmts): Declare it.
+ * parse.y (function_try_block): Use it, instead of doing it here, as
+ we don't want to include rtl.h here, as that conflicts with RETURN
+ in the parser.
+
+Wed Sep 13 18:32:24 1995 Mike Stump <mrs@cygnus.com>
+
+ * lex.c (reinit_parse_for_block): Support saving inline
+ function-try-blocks, uses peekyylex.
+ * parse.y (eat_saved_input): New rule, permit the parser to see that
+ END_OF_SAVED_INPUT is ok, as it can see this when parsing the
+ handlers of a function-try-block.
+ (fndef): Use it.
+ (component_decl): Make sure TRY and RETURN can come after fn.def2.
+ * spew.c (peekyylex): New routine to peek at what will come next.
+
+Wed Sep 13 16:52:06 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (comptypes): Tighten up comparisons of template type
+ parms.
+
+ * decl.c (duplicate_decls): Turn off whining about virtual functions
+ redeclared inline for now.
+
+Wed Sep 13 11:13:40 1995 Mike Stump <mrs@cygnus.com>
+
+ * decl.c (store_in_parms): New routine to put things before we
+ put base inits.
+ * cp-tree.h (store_in_parms): Declare it.
+ * decl.c (store_parm_decls): Use it to makr sure the starting of the
+ eh spec comes before base inits.
+ (finish_function): Use sequences instead of the obsolete
+ reorder_insns.
+ * parse.y (fndef): Enhance readability and maintainability. Update
+ to include function_try_block syntax.
+ (function_try_block): Add.
+
+Tue Sep 12 17:43:07 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * call.c (convert_harshness): Use comptypes, not ==, to check if
+ TYPE and PARMTYPE are equivalent on a function type.
+
+Tue Sep 12 17:31:33 1995 Douglas Rupp (drupp@cs.washington.edu)
+
+ * Make-lang.in (cc1plus) : Removed unnecessary $(exeext).
+
+Mon Sep 11 23:24:07 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (expand_throw): Never allocate storage for thrown pointer
+ to objects.
+
+Mon Sep 11 19:36:45 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (expand_start_catch_block): Pointers to objects come
+ back from catch matching already dereferenced, don't dereference
+ again.
+
+Mon Sep 11 15:46:28 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (expand_throw): Only decay the throw expression, don't do
+ any default conversions. This is so that one can throw and catch
+ characters, and not have them match integers.
+
+Mon Sep 11 13:46:45 1995 Mike Stump <mrs@cygnus.com>
+
+ * error.c (dump_aggr_type): Deal with anonymous unions that don't
+ have a TYPE_NAME.
+
+Fri Sep 8 20:40:27 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * lex.c (handle_sysv_pragma): Deal with getting a comma from yylex.
+
+Fri Sep 8 15:51:41 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (expand_end_eh_spec): Handle empty EH specifications.
+
+Fri Sep 8 15:27:22 1995 Mike Stump <mrs@cygnus.com>
+
+ * cp-tree.h (expand_start_eh_spec): Declare new routine.
+ (expand_end_eh_spec): Ditto.
+ * decl.c (store_parm_decls): Call expand_start_eh_spec to process
+ exception specifications.
+ * except.c (expand_leftover_cleanups): Remove unused parameter.
+ (expand_end_catch_block): Ditto.
+ (expand_exception_blocks): Ditto.
+ (expand_start_eh_spec): New routine to mark the start of an
+ exception specification region.
+ (expand_end_eh_spec): New routine to mark the end of an exception
+ specification region.
+ (expand_exception_blocks): Call expand_end_eh_spec to process
+ exception specifications.
+
+Fri Sep 8 14:40:48 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * lex.c (do_identifier): Use global binding in preference of
+ dead for local variable.
+
+Wed Sep 6 19:32:59 1995 Mike Stump <mrs@cygnus.com>
+
+ * cp-tree.h (build_exception_variant): Remove used first argument.
+ * decl.c (duplicate_decls): Ditto.
+ (grokfndecl): Ditto.
+ (revert_static_member_fn): Ditto.
+ * decl2.c (grok_method_quals): Ditto.
+ * tree.c (build_exception_variant): Ditto.
+ * typeck.c (common_type): Ditto.
+ * decl2.c (grokclassfn): After changing the type, call
+ build_exception_variant, if necessary.
+
+Tue Sep 5 15:56:27 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (expand_throw): Run cleanups for the throw expression.
+
+Wed Aug 30 15:24:38 1995 Stephen L. Favor (sfavor@tigger.intecom.com)
+
+ * except.c (expand_builtin_throw): Moved gen_label_rtx calls beyond
+ the store_parm_decls call which does initialization in the emit_*
+ code concerning label numbering.
+
+Thu Aug 31 09:01:07 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (expand_internal_throw): Let the frontend be responsible
+ for managing all frontend EH parameters, the backend routine only
+ needs to deal with backend values. type and value are no longer
+ passed to __throw.
+ (init_exception_processing): Ditto.
+ (expand_start_all_catch): Ditto.
+ (expand_end_all_catch): Ditto.
+ (expand_leftover_cleanups): Ditto.
+ (expand_end_catch_block): Ditto.
+ (expand_builtin_throw): Ditto.
+ (expand_throw): Ditto.
+
+Tue Aug 29 15:04:36 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * cp-tree.h (DECL_REAL_CONTEXT): Give the real declaration context
+ for a decl.
+ * decl.c (cp_finish_decl): Use it.
+
+Tue Aug 29 10:30:27 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (expand_internal_throw): Oops, almost forgot type and
+ value are now trees.
+
+Mon Aug 28 17:57:45 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ Fix the attribute handling to make sure they get noted before we
+ create the function's RTL, in case they can affect that.
+ * decl.c (grokfndecl): New arg ATTRLIST. Run
+ cplus_decl_attributes before creating the decl's rtl.
+ (grokdeclarator): New arg ATTRLIST, passed down into grokfndecl.
+ (shadow_tag, groktypename, start_decl, start_method): Pass a
+ NULL_TREE to grokdeclarator's new last arg.
+ * decl2.c (grokfield): New arg ATTRLIST, passed into grokdeclarator.
+ (grokbitfield, grokoptypename): Pass a NULL_TREE to
+ grokdeclarator's new last arg.
+ * except.c (expand_start_catch_block): Likewise.
+ * pt.c (process_template_parm, end_template_decl,
+ do_function_instantiation): Likewise.
+ * cp-tree.h (grokfield): Add arg.
+ (grokdeclarator): Move the prototype from here...
+ * decl.h: ...to here.
+ * lex.c (cons_up_default_function): Pass NULL_TREE to grokfield
+ ATTRLIST argument.
+ * parse.y: Create a list for the grokfield arg where appropriate,
+ and pass it down instead of calling cplus_decl_attributes.
+
+Mon Aug 28 15:07:24 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c: Always allow turning on exception handling. Allow cross
+ compilations to use EH.
+
+Thu Aug 24 17:39:24 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (saved_pc, saved_throw_type, saved_throw_value): Use
+ trees, instead of rtxs, and don't depend on using special machine
+ dependent registers.
+ (expand_internal_throw): Ditto.
+ (init_exception_processing): Ditto.
+ (expand_start_all_catch): Ditto.
+ (expand_end_all_catch): Ditto.
+ (expand_start_catch_block): Ditto.
+ (expand_leftover_cleanups): Ditto.
+ (expand_end_catch_block): Ditto.
+ (expand_builtin_throw): Ditto.
+ (expand_throw): Ditto.
+
+Wed Aug 23 17:25:51 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * cvt.c (build_expr_type_conversion): Handle conversions to
+ reference types.
+
+Wed Aug 23 15:33:59 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (do_unwind): Work around backend bug with -fpic.
+
+Tue Aug 22 17:20:07 1995 Per Bothner <bothner@kalessin.cygnus.com>
+
+ * decl2.c (flag_new_for_scope): Add a new mode that follows ANSI
+ for-scoping, but supports (and warns about) old programs.
+ Make the new mode (with value 1) the default.
+ (lang_f_options): The on-value for flag_new_for_scope is now 2.
+ * cp-tree.h (DECL_DEAD_FOR_LOCAL, DECL_ERROR_REPORTED): New macros
+ (DECL_SHADOWED_FOR_VAR): Likewise.
+ * decl.c (struct binding_level): New fields dead_vars_from_for
+ and is_for_scope.
+ (note_level_for_for): New function.
+ (poplevel): Special processing if is_for_scope.
+ (pushdecl): Warn if for-scope variable shadows local.
+ * lex.c (do_identifier): Handle old (non-ANSI) for scoping,
+ and warn if conflicts.
+ * parse.y (FOR): Call note_level_for_for.
+
+Mon Aug 21 10:28:31 1995 Jason Merrill <jason@deneb.cygnus.com>
+
+ * decl2.c (import_export_inline): Class interface hackery does not
+ apply to synthesized methods.
+
+Sun Aug 20 16:29:00 1995 Mike Stump <mrs@cygnus.com>
+
+ * search.c (virtual_context): Find the right context more often.
+ Solves a `recoverable compiler error, fixups for virtual function'
+ problem.
+
+Sun Aug 20 13:53:24 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (expand_start_all_catch): Ensure that we always transfer
+ control to the right EH handler, by rethrowing the end label on the
+ region, instead of hoping we are nested and falling through.
+ (expand_leftover_cleanups): Ditto.
+ (end_protect): Since we now rethrow the end label, put a
+ nop after it, so that outer regions are recognized.
+ * init.c (build_vec_delete_1): New routine to handle most of vector
+ deleting, all code moved here from build_vec_delete.
+ (build_array_eh_cleanup): Use build_vec_delete_1 to do all the real
+ work.
+ (expand_vec_init): If the array needs partial destructing, setup an
+ EH region to handle it.
+ (build_vec_delete): Move lots of code to build_vec_delete_1, use
+ build_vec_delete_1 to do the grunt work.
+
+Sat Aug 19 14:25:33 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ Handle decl attributes properly for function definitions without
+ previous attribute-loaded declarations.
+ * decl.c (start_function): New arg ATTRS. Add a call to
+ cplus_decl_attributes with it before we create the RTL.
+ * cp-tree.h (start_function): Update prototype.
+ * parse.y (fn.def1): Pass ATTRS into start_function instead of
+ trying to call cplus_decl_attributes too late. Pass a NULL_TREE
+ for other use.
+ * decl2.c (finish_file): Pass NULL_TREE as fourth arg to
+ start_function.
+ * method.c (synthesize_method): Likewise.
+ * except.c (expand_builtin_throw): Likewise for start on __throw.
+
+Sat Aug 19 13:36:08 1995 Mike Stump <mrs@cygnus.com>
+
+ * class.c (set_rtti_entry): Turn on -fvtable-thunk -frtti support.
+ This changes -fvtable-thunks vtable layout, so a recompile will be
+ necessary, if you use -fvtable-thunks.
+ (get_vtable_entry): Use n, instead of i to be consistent with the
+ rest of the compiler.
+ (get_vtable_entry_n): Ditto.
+ (add_virtual_function): Add a slot for the tdesc, if -fvtable-thunks
+ are being used.
+ (finish_struct_1): Ditto.
+ (skip_rtti_stuff): New routine to collapse similar code from many
+ different parts of the compiler. I think I got them all.
+ (modify_one_vtable): Use it.
+ (fixup_vtable_deltas1): Ditto.
+ (override_one_vtable): Ditto.
+ * decl2.c (mark_vtable_entries): Ditto.
+ * tree.c (debug_binfo): Ditto.
+ * search.c (expand_upcast_fixups): Ditto.
+ (get_abstract_virtuals_1): Ditto. Use virtuals, instead of tmp to
+ consistent with the rest of the compiler.
+ (get_abstract_virtuals): Ditto.
+ * cp-tree.h (skip_rtti_stuff): New routine, declare it.
+ * gc.c (build_headof): Support -fvtable-thunk and -frtti together.
+ (build_typeid): Ditto.
+ (build_classof): Remove old style way of doing rtti. Remove support
+ for `classof' and `headof'.
+ * gxx.gperf: Ditto.
+ * hash.h: Ditto.
+ * parse.y: Ditto.
+
+Fri Aug 18 17:31:58 1995 Jason Merrill <jason@deneb.cygnus.com>
+
+ * decl.c (start_function): Clear ctor_label and dtor_label.
+
+ * class.c (finish_struct_1): Fix handling of access decls.
+
+Tue Aug 15 19:21:54 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * class.c (finish_struct): Only do minimal processing here, so it
+ can be used for class template definitions, as well.
+ (finish_struct_1): New function with the rest of the code.
+
+Tue Aug 15 09:46:16 1995 Mike Stump <mrs@cygnus.com>
+
+ * class.c (prepare_fresh_vtable): On second though, always build the
+ offset (see Aug 10 change), unless -fvtable-thunks is given. It
+ does this by calling the new routine set_rtti_entry.
+ (finish_struct): Ditto.
+ (set_rtti_entry): New routine to update the rtti information at the
+ start of the vtable.
+
+Mon Aug 14 12:21:22 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * error.c (dump_decl, case IDENTIFIER_NODE): Only work on a dtor
+ if it's declared in the C++ language spec.
+ (dump_function_decl): Likewise.
+ (dump_function_name): Likewise.
+ (ident_fndecl): Make sure we got something back from lookup_name.
+ * decl.c (start_function): Likewise.
+
+Fri Aug 11 16:52:15 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * call.c (build_method_call): Don't call build_new when calling a
+ constructor without an instance.
+
+Thu Aug 10 20:00:17 1995 Mike Stump <mrs@cygnus.com>
+
+ * class.c (prepare_fresh_vtable): Always build the offset to the
+ complete object, as it doesn't cost much. This allows dynamic_cast
+ to void * to work when -frtti isn't given.
+ (finish_struct): Ditto.
+
+Thu Aug 10 16:31:28 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (build_eh_type): Split out some functionality to new
+ routine named build_eh_type_type.
+ (build_eh_type_type): New routine.
+ (expand_start_catch_block): Use build_eh_type_type, as we never want
+ the dynamic type of the catch parameter, just the static type.
+ Fixes core dumps when -frtti is used and one catchs pointers to
+ classes.
+
+Thu Aug 10 14:55:29 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (expand_builtin_throw): Since we now use normal calling
+ conventions for __throw, we have to remove the first layer off the
+ stack, so that the next context we search for handlers is the outer
+ context instead of the context that had the call to __throw, if we
+ don't immediately find the desired context.
+
+Tue Aug 8 17:44:23 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * tree.c (cp_expand_decl_cleanup): Returns int, not tree.
+ * cp-tree.h: Update.
+
+ * parse.y (template_type_parm): Add support for `typename'.
+
+Tue Aug 8 12:06:31 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (expand_internal_throw): New internal routine to throw a
+ value.
+ (expand_end_all_catch, expand_leftover_cleanups): All throwers
+ changed to use `expand_internal_throw' instead of jumping to throw
+ label.
+ (expand_end_catch_block, expand_throw): Ditto.
+ (throw_label): Removed.
+ (expand_builtin_throw): Changed so that EH parameters are passed by
+ normal function call conventions. Completes Aug 4th work.
+
+Fri Aug 4 17:17:08 1995 Mike Stump <mrs@cygnus.com>
+
+ * cp-tree.h (expand_builtin_throw): Declare it.
+ * decl2.c (finish_file): Call expand_builtin_throw.
+ * except.c (make_first_label): Remove.
+ (init_exception_processing): Don't use a LABEL_REF for throw_label,
+ instead use a SYMBOL_REF, this is so that we don't use LABEL_REFs in
+ other functions that don't really appear in those functions. This
+ solves a problem where cc1plus consumed exponential amounts of
+ memory when -Wall was used.
+ (expand_end_all_catch, expand_leftover_cleanups,
+ expand_end_catch_block, expand_throw): Change all uses of
+ throw_label to match new style.
+ (do_unwind): Rename parameter to inner_throw_label, as it is now
+ different from throw_label. Also, assume that our caller will wrap
+ the passed label with a LABEL_REF, if needed.
+ (expand_builtin_throw): Make external, change so that the generated
+ throw is now a real function.
+ (expand_exception_blocks): Never generate throw code inside another
+ function.
+
+Fri Aug 4 12:20:02 1995 Mike Stump <mrs@cygnus.com>
+
+ * decl.c (grokdeclarator): Move checking of mutable const objects
+ and mutable static objects down, as we might decide during parsing
+ to unset staticp or constp (for example, when const is part of the
+ object being pointed to).
+
+Thu Aug 3 17:13:43 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (output_exception_table_entry): Enhance portability to
+ weird machines.
+ (emit_exception_table): Ditto.
+
+Thu Aug 3 16:41:38 1995 Mike Stump <mrs@cygnus.com>
+
+ * typeck.c (build_ptrmemfunc): Handle casting of pointer to
+ non-virtual member functions.
+
+Wed Aug 2 11:58:25 1995 Mike Stump <mrs@cygnus.com>
+
+ * gc.c (build_typeid): Strip cv qualifiers so that const T&, T&, T
+ and const T all match.
+
+Wed Aug 2 11:25:33 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (build_eh_type): Strip cv qualifiers so that const T&,
+ T&, T and const T all match.
+
+Tue Aug 1 14:20:16 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c: Fix up comments, cleanup code and eliminate exceptNode,
+ exceptStack, exceptstack, push_except_stmts, pop_except_stmts,
+ new_except_stack, push_last_insn, pop_last_insn, insn_save_node and
+ InsnSave. Also, numerous speed improvements, and correctness
+ improvements. Double faulting in all situations should now be
+ handled correctly.
+ (expand_start_all_catch): Instead of having many terminate protected
+ regions, just have one.
+ (expand_start_catch_block): No longer have to protect
+ false_label_rtx, as it isn't used for EH region marking.
+ (expand_end_catch_block): Expand out EH cleanups here by using
+ expand_leftover_cleanups.
+ (expand_end_all_catch): Use sequences instead of playing with insn
+ links directly.
+ (expand_exception_blocks): Ditto. Also protect all catch clauses
+ with one terminate region.
+
+Mon Jul 31 13:24:30 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * method.c (report_type_mismatch): Don't talk about an object
+ parameter for non-methods.
+
+Sun Jul 30 13:13:02 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * class.c (finish_struct): Catch private and protected members of
+ anonymous unions here.
+ * decl2.c (finish_anon_union): And here.
+ * parse.y: Instead of here.
+
+ * errfn.c (ARGSLIST): Support passing four args.
+ * error.c (cv_as_string): New function.
+ (cp_printers): Add it.
+ * call.c (build_method_call): Report 'const' at end of pseudo-decl.
+
+ * method.c (report_type_mismatch): Deal with a bad_arg of 0.
+
+ * init.c (expand_aggr_init): Handle volatile objects, too.
+
+Sat Jul 29 13:42:03 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (struct binding_level): Keep list of incomplete decls.
+ (print_binding_level): Use list_length to count them.
+ (pushdecl): Build up the list.
+ (hack_incomplete_structures): Walk it and prune completed decls.
+
+Fri Jul 28 15:26:44 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (comp_target_types): Don't check const and volatile for
+ function types.
+ (comp_ptr_ttypes_real): Ditto.
+
+Thu Jul 27 15:40:48 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (comp_target_types): Fix.
+
+Thu Jul 27 15:10:48 1995 Mike Stump <mrs@cygnus.com>
+
+ * cp-tree.h (unsave_expr_now, build_unsave_expr,
+ cp_expand_decl_cleanup): Declare new routines.
+ * decl.c (cp_finish_decl, store_parm_decls,
+ hack_incomplete_structures): Change all cals from
+ expand_decl_cleanup to cp_expand_decl_cleanup.
+ * gc.c (protect_value_from_gc): Ditto.
+ * expr.c (cplus_expand_expr): Handle UNSAVE_EXPRs.
+ * tree.c (unsave_expr): New routine to build an UNSAVE_EXPR.
+ (unsave_expr_now): Backend routine used by tree expander.
+ (cp_expand_decl_cleanup): Wrap second argument in an UNSAVE_EXPR to
+ work around a limitation in the backend. The backend uses the
+ cleanups multiple times, on disjoint control flows, so we cannot
+ pass unsaved SAVE_EXPRs to the backend.
+ * tree.def (UNSAVE_EXPR): New tree code.
+ * typeck.c (c_expand_return): Move goto/return code up inside
+ conditional, as we don't always want to do this, we only want to do
+ this when we don't otherwise finish with this control flow.
+
+Thu Jul 27 10:38:43 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * parse.y (typespec): Only complain about typeof if we're not
+ getting it from a system header.
+
+Thu Jul 27 10:26:23 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ Clean up prefix attribute handling.
+ * parse.y (reserved_declspecs): Link prefix attributes with declspecs.
+ (declmods): Likewise.
+ (all rules that reference typed_declspecs and declmods): Call
+ split_specs_attrs or strip_attrs to separate declspecs and attrs.
+ (lang_extdef): Delete resetting of prefix_attributes.
+ (template_def, notype_declarator rule): Use NULL_TREE for
+ prefix_attributes.
+ (condition): Use NULL_TREE for prefix_attributes.
+ (setattrs): Deleted.
+ (nomods_initdcl0): Set prefix_attributes to NULL_TREE.
+ (component_decl): Delete resetting of prefix_attributes.
+ (component_decl_1, notype_components rule): Use NULL_TREE for
+ prefix_attributes.
+ (simple_stmt): Delete resetting of prefix_attributes.
+
+Mon Jul 24 13:37:53 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * call.c (convert_harshness): Deal with reference conversions before
+ others. Actually do array->pointer decay. Call comp_target_types
+ with pointer types rather than their targets.
+
+ * typeck.c (comp_target_types): Avoid assigning D const * to B *.
+
+Mon Jul 24 08:54:46 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * pt.c (to_be_restored): Move decl to global scope.
+
+Sat Jul 22 12:22:11 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (start_decl): Put back clearing of DECL_IN_AGGR_P.
+
+Fri Jul 21 17:09:02 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (grokdeclarator): Downgrade error about 'extern int A::i'
+ to pedwarn.
+
+ * pt.c (instantiate_template): Also avoid instantiation if the
+ function has already been declared to be a specialization.
+
+ * decl2.c (check_classfn): Ignore cname argument, and return the
+ matching function.
+
+ * decl.c (start_decl): Handle declarations of member functions
+ outside of the class (i.e. specialization declarations).
+
+Thu Jul 20 10:34:48 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * class.c (finish_struct): Don't mess with the type of bitfields.
+
+ * various.c: s/TYPE_POINTER_TO/build_pointer_type/.
+
+Thu Jul 20 01:43:10 1995 Mike Stump <mrs@cygnus.com>
+
+ * init.c (expand_aggr_init): Assume LOOKUP_ONLYCONVERTING if init
+ is not a parameter list (TREE_LIST).
+ (expand_default_init): If LOOKUP_ONLYCONVERTING is set, then set
+ LOOKUP_NO_CONVERSION so that we don't allow two-level conversions,
+ but don't set it otherwise.
+
+Wed Jul 19 20:32:01 1995 Mike Stump <mrs@cygnus.com>
+
+ * init.c (expand_default_init): Don't allow two-level conversions
+ during construction.
+
+Wed Jul 19 18:06:37 1995 Mike Stump <mrs@cygnus.com>
+
+ * gc.c (build_headof): The type of dyncasting to a pointer to cv
+ void, should be pointer to cv void.
+
+Wed Jul 19 17:25:43 1995 Mike Stump <mrs@cygnus.com>
+
+ * gc.c (build_dynamic_cast): Allow casting in const.
+
+Wed Jul 19 16:34:27 1995 Mike Stump <mrs@cygnus.com>
+
+ * typeck.c (build_const_cast): If we are passed error_mark_node,
+ return it.
+
+Wed Jul 19 15:24:48 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * class.c (push_nested_class): Make sure TYPE is non-nil.
+
+ * cvt.c (type_promotes_to): Watch for error_mark_node on the
+ incoming TYPE.
+
+Wed Jul 19 13:23:12 1995 Gerald Baumgartner <gb@alexander.cs.purdue.edu>
+
+ * cp-tree.h (SIGTABLE_VT_OFF_NAME): Renamed from SIGTABLE_OFFSET_NAME.
+ (SIGTABLE_VB_OFF_NAME): New macro.
+ (vt_off_identifier): Renamed from offset_identifier.
+ (vb_off_identifier): Added extern declaration.
+
+ * decl.c (vt_off_identifier): Renamed from offset identifier.
+ (vb_off_identifier): New variable to hold the identifier for the
+ sigtable field vb_off.
+ (init_decl_processing): Initialize vb_off_identifier.
+ Renamed vt_off_identifier from offset_identifier.
+ * sig.c (build_signature_method_call): Renamed offset_identifier and
+ local variable offset to vt_off_identifer and vt_off, respecitively.
+ * sig.c (build_signature_table_constructor): Renamed offset to vt_off.
+
+ * decl.c (init_decl_processing): Add vb_off field to
+ sigtable_entry_type. Reorder fields so that pfn gets properly
+ aligned at a 64 bit boundary on the Alpha.
+ * sig.c (build_signature_table_constructor): Build the constructor
+ according to the new layout. Set the vb_off field to -1 for now.
+
+ * decl.c (init_decl_processing): Align sigtable_entry_type on word
+ boundaries instead of double word boundaries to save space.
+
+Tue Jul 18 16:58:37 1995 Mike Stump <mrs@cygnus.com>
+
+ * cvt.c (cp_convert): Always call build_cplus_new for a ctor.
+
+Tue Jul 18 14:24:53 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * parse.y (opt.component_decl_list): Only forbid private/protected
+ in anonymous unions. We need to make this know when the type is
+ defined for an object, to not give the error.
+
+Mon Jul 17 14:22:44 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * parse.y (opt.component_decl_list): Don't allow access control
+ as private or protected for union members.
+
+Sun Jul 16 14:01:00 1995 Jim Wilson <wilson@chestnut.cygnus.com>
+
+ * lex.c (check_newline): For 'p' case, move goto skipline line to
+ before end brace for 'pragma'.
+
+Fri Jul 7 13:55:58 1995 Mike Stump <mrs@cygnus.com>
+
+ * g++.1: Tiny updates.
+
+Fri Jul 7 13:05:20 1995 Mike Stump <mrs@cygnus.com>
+
+ * decl.c (cp_finish_decl): Only destruct local static variables if
+ they are constructed, and only construct the first time control
+ passes completely through its declaration (if not initialized with a
+ constant-expression).
+ (expand_static_init): Ditto.
+
+Wed Jul 5 14:05:04 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * typeck.c (comptypes, case OFFSET_REF): If either offset basetype
+ is a TEMPLATE_TYPE_PARM, give a match.
+
+Mon Jul 3 15:17:20 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * g++.c (sys/file.h): Remove change of Jun 28.
+
+Fri Jun 30 15:42:57 1995 Mike Stump <mrs@cygnus.com>
+
+ * method.c (build_overload_value): Handle encoding of null pointer
+ constants (or any pointer with a constant numeric value) for
+ templates.
+
+Fri Jun 30 13:45:51 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * call.c (convert_harshness): Add QUAL_CODE when we're faced with
+ const vs non-const for void conversions.
+
+Fri Jun 30 10:19:52 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (expand_start_all_catch): Fix problem with finding an
+ outer nested try block when there is no code to separate it from an
+ inner try block.
+
+Fri Jun 30 02:22:26 1995 Mike Stump <mrs@cygnus.com>
+
+ * search.c (dfs_pushdecls): Consume 2 or 3 orders of magnitude less
+ memory please when virtual bases are used.
+
+Thu Jun 29 19:03:47 1995 Mike Stump <mrs@cygnus.com>
+
+ * class.c (build_vbase_path): Avoid testing things that cannot be
+ null to see if they are null.
+ * cvt.c (convert_pointer_to_vbase): Remove code that doesn't work.
+ * decl.c (finish_function): Pass a type into the new
+ convert_pointer_to_vbase instead of a binfo.
+ * search.c (convert_pointer_to_vbase): Rewritten to use get_vbase
+ and convert_pointer_to_real.
+ (expand_indirect_vtbls_init): Use convert_pointer_to_vbase instead
+ of the more cryptic call to get_vbase.
+
+Thu Jun 29 09:35:05 1995 Mike Stump <mrs@cygnus.com>
+
+ * decl.c (BOOL_TYPE_SIZE): Fix broken SLOW_BYTE_ACCESS check.
+
+Thu Jun 29 03:43:55 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * pt.c (instantiate_template): Don't strip 'this' twice.
+
+ * pt.c (coerce_template_parms): Allow null pointer constants.
+
+ * decl.c (revert_static_member_fn): But only if DECL_ARGUMENTS is
+ set.
+
+Wed Jun 28 23:34:58 1995 Steve Chamberlain <sac@slash.cygnus.com>
+
+ * g++.c (pfatal_with_name): Use my_strerror to get error
+ string.
+ (sys/file.h): Include if HAVE_FILE_H defined.
+
+Wed Jun 28 18:39:03 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (revert_static_member_fn): Also remove 'this' from
+ DECL_ARGUMENTS.
+ * decl2.c (check_classfn): Don't revert this function until we get a
+ match.
+
+Wed Jun 28 14:07:27 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * parse.y (component_decl): Clear PREFIX_ATTRIBUTES here.
+
+Wed Jun 28 11:05:13 1995 Mike Stump <mrs@cygnus.com>
+
+ * decl2.c (finish_file): Handle global vector news.
+ * init.c (build_new): Encode vector news so that later we will know
+ how many elements there are.
+
+Mon Jun 26 13:38:06 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * expr.c (cplus_expand_expr): Don't mess with temp slots.
+
+ * decl2.c (warn_if_unknown_interface): Don't crash if tinst_for_decl
+ returns null.
+
+ * decl2.c (check_classfn): Use revert_static_member_fn.
+ * decl.c (revert_static_member_fn): Diagnose static member functions
+ declared const or volatile.
+
+ * decl2.c (grokfield): Check for missing default args here, too.
+ (check_default_args): Function to do the checking.
+ * decl.c (pushdecl): Use it.
+
+ * decl.c (pushdecl): Don't warn about shadowing a member of `this'
+ if there is no `this'.
+
+Sun Jun 25 11:34:25 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * call.c (build_method_call): Downgrade 'called before definition'
+ to a warning, as it ought to go away after Monterey.
+
+Sat Jun 24 14:18:42 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * pt.c (coerce_template_parms): Don't do extra checking on pointer
+ to member arguments.
+
+ * class.c (finish_struct): const and reference members don't prevent
+ a class from being an aggregate.
+
+ * class.c (finish_struct): Signatures are always aggregates.
+
+Fri Jun 23 17:20:29 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl2.c (check_classfn): Improve error message.
+
+ * pt.c (tsubst): Handle PROMOTE_PROTOTYPES.
+
+Thu Jun 22 01:50:42 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (comptypes): Don't ignore method quals.
+
+ * class.c (finish_struct): Non-abstract virtuals are always USED.
+
+ * decl.c (build_ptrmemfunc_type): The underlying union type isn't
+ IS_AGGR_TYPE, either.
+ * class.c (finish_struct): Use CLASSTYPE_NON_AGGREGATE instead.
+ * cp-tree.h: Ditto.
+
+ * cp-tree.h (lang_type): Add aggregate.
+ (CLASSTYPE_AGGREGATE): New macro.
+ (TYPE_NON_AGGREGATE_CLASS): Ditto.
+ * class.c (finish_struct): Determine whether a class is an
+ aggregate.
+ * decl.c (cp_finish_decl): Check TYPE_NON_AGGREGATE_CLASS instead of
+ TYPE_NEEDS_CONSTRUCTING.
+ * typeck2.c (digest_init): Check TYPE_NON_AGGREGATE_CLASS for
+ subobjects, too.
+
+ * pt.c (tsubst, PARM_TYPE): Propagate DECL_ARTIFICIAL.
+
+ * decl.c (start_function): For pre-parsed functions, layout all of
+ the parm decls again.
+ (grokvardecl): TREE_PUBLIC depends on DECL_THIS_EXTERN, not
+ DECL_EXTERNAL.
+
+ * pt.c (coerce_template_parms): Improve checking for invalid
+ template parms.
+
+Wed Jun 21 12:01:16 1995 Brendan Kehoe <brendan@lisa.cygnus.com>
+
+ * decl.c (grokdeclarator): Forbid declaration of a static member
+ with the same name as its enclosing class.
+
+Mon Jun 19 10:28:14 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (finish_function): Clear current_class_decl.
+
+ * typeck.c (build_conditional_expr): Use convert (boolean_type_node
+ instead of truthvalue_conversion.
+
+ * class.c (finish_struct): A data member with the same name as the
+ class doesn't suppress constructors.
+
+Fri Jun 16 18:11:39 1995 Gerald Baumgartner (gb@alexander.cs.purdue.edu)
+
+ * decl.c (start_function): If current_class_decl is a signature
+ pointer, don't dereference it but set C_C_D to current_class_decl.
+
+Fri Jun 16 17:06:28 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (duplicate_decls): Complain about virtual functions
+ redeclared to be inline.
+
+Fri Jun 16 13:20:38 1995 Mike Stump <mrs@cygnus.com>
+
+ * decl.c (get_unique_name): New routine to name unnamed namespaces.
+ (push_namespace): Use get_unique_name for naming unnamed namespaces.
+
+Fri Jun 16 15:07:29 1995 Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
+
+ * Make-lang.in (DEMANGLER_PROG): Add LIBS.
+
+Thu Jun 15 15:00:41 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (define_function): Don't set DECL_INTERFACE_KNOWN.
+
+ * parse.y: Call cplus_decl_attributes with prefix_attributes where
+ appropriate.
+
+Wed Jun 14 19:24:49 1995 Mike Stump <mrs@cygnus.com>
+
+ * search.c (get_vbase): New routine to switch hierarchies from the
+ CLASSTYPE_VBASECLASSES to the normal one.
+ (expand_indirect_vtbls_init): Use get_vbase to figure out how we
+ want to convert to a vbase pointer.
+
+Mon Jun 12 17:50:30 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * pt.c (instantiate_class_template): Add the new instantiation to
+ template_classes.
+ (do_pending_expansions): Call instantiate_member_templates on all of
+ the classes in template_classes.
+
+Mon Jun 12 12:36:59 1995 Mike Stump <mrs@cygnus.com>
+
+ * decl.c (complete_array_type): Fill in the TYPE_DOMAIN of our
+ TYPE_MAIN_VARIANT if it is not filled in.
+ * init.c (build_delete): If the TYPE_DOMAIN is not set, give an
+ error instead of core dumping.
+
+Mon Jun 12 10:41:40 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * call.c (can_convert): Also check for distance > 0.
+ (can_convert_arg): Ditto.
+ (user_harshness): Ditto.
+
+Fri Jun 9 19:17:21 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * g++.c (MATH_LIBRARY): Provide default.
+ (main): Always link with the math library if we link with libstdc++.
+
+ * decl.c (start_function): Complain about redefinition of a function
+ even when the pending_inline version is compiled after the other
+ version.
+
+Thu Jun 8 15:44:38 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * gc.c (build_dynamic_cast): Build up a reference to a parameter of
+ aggregate type.
+
+Wed Jun 7 20:00:31 1995 Mike Stump <mrs@cygnus.com>
+
+ * *.[chy]: Change all callers of finish_decl to cp_finish_decl.
+ * decl.c (finish_decl): New routine to handle call backs from the
+ mid end (declare_hidden_char_array).
+
+Wed Jun 7 19:02:50 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (start_function): Handle setting C_C_D here.
+ (set_C_C_D): Removed.
+ (struct saved_scope): Remove class_decl.
+ (push_to_top_level): Don't save current_class_decl.
+ (pop_from_top_level): Don't restore current_class_decl or C_C_D.
+ (struct cp_function): Add C_C_D.
+ (push_cp_function_context): Save C_C_D.
+ (pop_cp_function_context): Restore C_C_D.
+
+Wed Jun 7 15:31:57 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * init.c (build_vec_delete): Resolve an offset ref before we try to
+ use it.
+
+Wed Jun 7 14:19:32 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (build_modify_expr): If the class lacks a constructor or
+ assignment operator, return error_mark_node.
+ (common_type): Use build_cplus_array_type.
+
+Tue Jun 6 09:41:27 1995 Mike Stump <mrs@cygnus.com>
+
+ * class.c (dont_allow_type_definitions): New variable set when types
+ cannot be defined.
+ (finish_struct): Use it.
+ * cp-tree.h (dont_allow_type_definitions): Define it.
+ * parse.y (primary, handler_seq): Set it.
+
+Mon Jun 5 18:49:38 1995 Mike Stump <mrs@cygnus.com>
+
+ * method.c (build_opfncall): Use DECL_CHAIN, not TREE_CHAIN for
+ results from lookup_fnfields. Always give warning/error on bad
+ code.
+
+Mon Jun 5 11:39:37 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * init.c (member_init_ok_or_else): Don't allow initialization of
+ an ancestor's member from within a constructor.
+
+Mon Jun 5 11:20:34 1995 Gerald Baumgartner (gb@alexander.cs.purdue.edu)
+
+ * sig.c (build_signature_table_constructor): Use DECL_CONTEXT
+ instead of DECL_CLASS_CONTEXT for calculating the vfield offset so
+ abstract virtual functions are handled correctly.
+
+ * sig.c (build_signature_table_constructor): Store the correct
+ delta in signature table entries. It does not yet work for
+ classes with virtual base classes as implementations of signatures.
+ (build_signature_method_call): Add the delta to the object_ptr
+ before generating the function call.
+
+ * call.c (build_method_call): Make instance_ptr the signature
+ pointer itself instead of dereferencing the optr.
+ * sig.c (build_signature_method_call): Dereference the optr for the
+ direct and virtual calls.
+
+ * sig.c (build_signature_table_constructor): Make the tag for
+ default implementations -1 instead of 2.
+ (build_signature_method_call): Change the generated conditional
+ expression correspondingly.
+
+ * sig.c (build_signature_pointer_constructor): Deleted the sorry
+ message that said we can't handle multiple inheritance for
+ implementations of signatures
+ (build_signature_method_call): Use the offset from the sigtable
+ entry instead of the vptr field from the signature pointer for
+ building a virtual function call.
+
+ * class.c (build_vfn_ref): Deleted signature specific code, we don't
+ call this function anymore from build_signature_method_call.
+
+ * cp-tree.h (SIGNATURE_VPTR_NAME): Deleted. We use the right vptr
+ field in the object now instead of in the signature pointer/ref.
+ (build_vptr_ref): Deleted extern declaration.
+ * sig.c (build_vptr_ref): Deleted.
+ (build_signature_pointer_or_reference_type): Deleted construction of
+ the vptr field.
+ (build_signature_pointer_constructor): Deleted initialization of/
+ assignment to the vptr field.
+
+ * sig.c (build_signature_table_constructor): Convert the signature
+ table entry fields to their correct types.
+
+ * sig.c (build_signature_table_constructor): Don't call digest_init
+ for the fields of a sigtable entry, it's wasted time.
+
+ * sig.c (build_signature_table_constructor): Correctly set the
+ offset and index fields of a sigtable entry. Build the constructor
+ the way digest_init does, digest_init can't handle initializing an
+ anonymous union inside a struct.
+ (build_signature_method_call): Use the index field instead of the
+ delta field to get the vtable index.
+
+ * decl.c (init_decl_processing): Fix number of fields for building
+ sigtable_entry_type.
+
+ * cp-tree.h (tag_identifier, offset_identifier): Added extern decls.
+ (SIGTABLE_CODE_NAME): Renamed to SIGTABLE_TAG_NAME.
+ (SIGTABLE_PFN_NAME): Deleted, we'll use VTABLE_PFN_NAME instead.
+ * decl.c (tag_identifier, offset_identifier): New variables to
+ hold the identifiers for the sigtable fields tag and offset.
+ (init_decl_processing): Initialize these variables.
+ (init_decl_processing): Use these variables to build the
+ sigtable_entry_type structure. Rename the code and offset fields
+ to tag and delta, respectively; add offset and index fields. Changed
+ types of fields from short_integer_type_node to delta_type_node.
+ * sig.c (build_signature_table_constructor): Rename code and offset
+ to tag and delta, respectively.
+ (build_signature_method_call): Ditto. Use above variables.
+
+Fri Jun 2 11:05:58 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (set_C_C_D): New function. suspend_momentary before
+ building C_C_D.
+ (pop_from_top_level): Call it.
+ (start_function): Ditto.
+ (pop_cp_function_context): Ditto.
+
+ * class.c, cp-tree.h, decl.c, decl2.c, parse.y: Lose all references
+ to current_vtable_decl, CLASSTYPE_INST_VAR and CLASSTYPE_VTBL_PTR.
+
+ * decl.c (push_cp_function_context): Save current_class_decl.
+ (pop_cp_function_context): Restore current_class_decl and set C_C_D.
+ (pop_from_top_level): Don't use CLASSTYPE_INST_VAR to set C_C_D.
+ (start_function): Ditto.
+
+ * class.c (popclass): Don't mess with current_class_decl,
+ current_vtable_decl, or C_C_D.
+
+Mon May 29 12:45:10 1995 Paul Eggert <eggert@twinsun.com>
+
+ * Make-lang.in (c++.mostlyclean): Remove $(DEMANGLER_PROG).
+
+Thu Jun 1 17:03:51 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (lookup_name_real): Don't try to look anything up in an
+ erroneous object.
+
+Fri Jun 2 10:30:14 1995 Mike Stump <mrs@cygnus.com>
+
+ * method.c (build_overload_int): New routine. Break out
+ functionality from build_overload_value so we can reuse it.
+ (build_overload_value): Handle pointer to member functions as value
+ parameters for templates.
+ (build_overload_identifier): Since template parameters are shared
+ among all instantiations, we have to substitute in the real types
+ in TREE_TYPE (parm).
+ pt.c (coerce_template_parms): Ditto.
+ (push_template_decls): Ditto.
+ (grok_template_type): Deleted as template parameters are shared
+ among all instantiations.
+
+Wed May 31 19:10:32 1995 Mike Stump <mrs@cygnus.com>
+
+ * decl.c (grokdeclarator): Always give errors on constant overflow
+ for array indices.
+
+Wed May 31 11:39:43 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (commonparms): Don't abort if simple_cst_equal returns < 0.
+ (build_c_cast): Don't tack on a NON_LVALUE_EXPR when casting to
+ reference type.
+ (build_indirect_ref): Fix check for *&.
+
+Wed May 24 15:55:18 1995 Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
+
+ * decl.c (duplicate_decls): Check simple_cst_equal result against 0.
+ * decl2.c (finish_anon_union): Likewise.
+ * method.c (largest_union_member): Likewise.
+
+Wed May 24 14:41:11 1995 H.J. Lu (hjl@nynexst.com)
+
+ * Make-lang.in (cxxmain.o): Replace single quotes with backslashes.
+
+Mon May 22 17:38:48 1995 Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
+
+ * Make-lang.in (g++, g++-cross, cc1plus, DEMANGLER_PROG):
+ Use $@ instead of output name so works even if have .exe.
+ (cxxmain.o): Use cp if ln -s fails.
+ (c++.install-man): Use $(exeext) in executable names.
+ (c++.mostlyclean, stage[1-4]): Use $(objext) in object file names.
+ * Makefile.in (../cc1plus): Use $(exeext) in name of executable.
+
+Wed May 24 01:39:03 1995 Jason Merrill <jason@deneb.cygnus.com>
+
+ * call.c (build_method_call): parms can be null, duh.
+
+Tue May 23 01:32:09 1995 Jason Merrill <jason@deneb.cygnus.com>
+
+ * call.c (build_method_call): If convert_arguments failed, just bail.
+
+Fri May 19 10:31:11 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * cvt.c (convert_force): Pass LOOKUP_NORMAL to cp_convert.
+
+ * tree.c (copy_to_permanent): Oops.
+
+Fri May 19 10:01:07 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * cp-tree.h (break_out_target_exprs): Add decl.
+
+Thu May 18 13:02:30 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (start_function): Move *all* interface handling stuff after
+ the pushdecl.
+
+ * tree.c (mapcar): Renamed from make_deep_copy and generalized.
+ (perm_manip): Return t if permanent, otherwise 0.
+ (copy_to_permanent): Use them.
+ (bot_manip): Helper for break_out_target_exprs.
+ (break_out_target_exprs): New function. Uses mapcar.
+
+ * typeck.c (convert_arguments): Use it.
+
+ * method.c (hack_identifier): Use convert_from_reference to
+ dereference a reference.
+
+Wed May 17 17:54:54 1995 Mike Stump <mrs@cygnus.com>
+
+ * call.c (convert_harshness): Move reference bashing before pointer
+ to member bashing.
+
+Wed May 17 16:57:53 1995 Mike Stump <mrs@cygnus.com>
+
+ * cvt.c (convert_to_reference): Only complain, if complaints are
+ wanted.
+ * typeck.c (build_function_call_real): Ditto. If LOOKUP_SPECULATIVELY
+ is set and something won't work, return NULL_TREE.
+ * cvt.c (cp_convert): Ditto. Pass flags down to build_method_call.
+ (convert): Pass LOOKUP_NORMAL to cp_convert.
+ * typeck.c (convert_for_assignment): Ditto.
+ (convert_force): Pass LOOKUP_COMPLAIN to cp_convert.
+ (convert_arguments): Get out early if we get an error_mark_node.
+ (convert_for_initialization): Use cp_convert instead of convert so
+ that we can pass flags down.
+ * cp-tree.h (LOOKUP_SPECULATIVELY): Added documentation.
+
+Wed May 17 01:43:58 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck2.c (store_init_value): Don't take the MAIN_VARIANT of the
+ decl type.
+
+ * class.c (finish_struct): Don't complain about a class with no
+ user-defined constructors but with a member that has no default
+ constructor, as this is OK for aggregates.
+
+ * expr.c (cplus_expand_expr, NEW_EXPR): If this is an explicit
+ constructor call, mark slot addressable.
+
+Tue May 16 18:37:51 1995 Douglas Rupp (drupp@cs.washington.edu)
+
+ * g++.c: Changed WINNT to _WIN32.
+
+Tue May 16 12:40:16 1995 Jason Merrill <jason@lisa.cygnus.com>
+
+ * lex.c (handle_sysv_pragma): Don't use token_buffer.
+
+Tue May 16 12:05:26 1995 Mike Stump <mrs@cygnus.com>
+
+ * call.c (resolve_scope_to_name): Add initial semantic support for
+ namespaces.
+ * class.c (finish_struct): Ditto.
+ * cp-tree.h (NAMESPACE_LEVEL): Ditto.
+ * cvt.c (build_up_reference, convert_to_reference): Ditto.
+ * decl.c (binding_level::namespace_p, suspend_binding_level): Ditto.
+ (resume_binding_level, toplevel_bindings_p): Ditto
+ (namespace_bindings_p, declare_namespace_level): Ditto.
+ (resume_level, push_namespace, pop_namespace): Ditto.
+ (pop_everything, pushtag, duplicate_decls, pushdecl): Ditto.
+ (implicitly_declare, lookup_namespace_name, lookup_name_real): Ditto.
+ (start_decl, make_temporary_for_reference), Ditto.
+ (obscure_complex_init, finish_decl, expand_static_init): Ditto.
+ (grokvardecl, grokdeclarator, parmlist_is_exprlist): Ditto.
+ (store_parm_decls, hack_incomplete_structures): Ditto.
+ * decl2.c (get_temp_name, finish_anon_union, current_namespace): Ditto.
+ (push_namespace, pop_namespace, do_namespace_alias): Ditto.
+ (do_toplevel_using_decl, do_class_using_decl): Ditto.
+ * error.c (dump_decl): Ditto.
+ * init.c (build_member_call, build_offset_ref): Ditto.
+ * lex.c (identifier_type): Ditto.
+ * parse.y (lang_extdef, using_decl, extdef, component_decl_1): Ditto.
+ (nested_name_specifier_1): Ditto.
+ * spew.c (yylex): Ditto.
+ * tree.def (NAMESPACE_DECL): Ditto.
+
+Tue May 16 11:55:35 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (push_overloaded_decl): Return the new decl even if it
+ can't be pushed.
+
+Tue May 16 11:00:37 1995 Jason Merrill <jason@lisa.cygnus.com>
+
+ * typeck.c (decay_conversion): Split out from default_conversion.
+ (default_conversion): Call it.
+ (build_binary_op): Ditto.
+ (build_binary_op_nodefault): Use decay_conversion for truth ops.
+
+Mon May 15 12:47:56 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (warn_extern_redeclared_static): This is a pedwarn.
+ (duplicate_decls): Always use the old decl's linkage info. Don't
+ play with linkage of consts.
+ (pushdecl): Don't play with linkage of consts.
+ (redeclaration_error_message): Don't complain about an old public
+ decl and a new non-public decl here.
+ (grokvardecl): Handle linkage of consts here.
+ (grokdeclarator): An 'extern inline' is public. Pass constp to
+ grokvardecl.
+ (start_function): Wait until after the pushdecl to do some linkage
+ stuff.
+
+ * decl2.c (import_export_vtable): Make duplicates weak rather than
+ static if supported.
+ (import_export_inline): Ditto.
+ * pt.c (do_pending_expansions): Ditto.
+
+ * class.c (build_vbase_path): flag_assume_nonnull_objects only
+ affects reference conversion.
+
+ * init.c (emit_base_init): Build up an RTL_EXPR and add it to
+ rtl_expr_chain.
+ * decl.c, decl2.c: s/base_init_insns/base_init_expr/.
+
+Tue May 16 07:06:28 1995 Paul Eggert <eggert@twinsun.com>
+
+ * method.c (numeric_output_need_bar): Renamed from misspelling.
+
+ * typeck.c (build_ptrmemfunc): Fix misspellings in messages.
+
+Sun May 14 10:26:22 1995 Richard Kenner <kenner@vlsi1.ultra.nyu.edu>
+
+ * lang-options.h, lang-specs.h: New files.
+
+Thu May 11 00:31:48 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (default_conversion): Don't check for BLKmode before
+ pulling out the decl_constant_value.
+
+ * decl.c (start_function): Clear named_labels and shadowed_labels.
+
+ * typeck.c (build_function_call_real): Also synthesize methods here.
+
+Wed May 10 00:55:59 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl2.c (finish_file): Synthesize exported methods before the
+ reconsider loop.
+
+ * parse.y: Move declaration of flag_new_for_scope to file scope.
+
+Tue May 9 19:10:33 1995 Mike Stump <mrs@cygnus.com>
+
+ * decl2.c: Add flag_new_for_scope for new -ffor-scope flag.
+ * parse.y (FOR): Conditionalize the pushing and poping of scope for
+ the for-init-statement upon the new flag_new_for_scope.
+ * parse.y (try_block): Simplify and use compstmt.
+
+Mon May 8 12:41:52 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (define_function): Mark function decl artificial.
+
+Sun May 7 00:51:28 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * parse.y (simple_stmt, FOR): Put back push/pop for condition scope.
+
+ * decl2.c (grokclassfn): DECLs don't have cv-qualified types.
+ * tree.c (build_cplus_method_type): Ditto.
+
+ * cp-tree.h (SET_DECL_ARTIFICIAL): Just set DECL_ARTIFICIAL to 1.
+
+ * typeck.c (build_function_call_real): If convert_arguments failed,
+ just bail.
+ (convert_arguments): If one of the arguments is error_mark_node,
+ just bail.
+
+Sat May 6 02:39:41 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (duplicate_decls): Don't check DECL_NOT_REALLY_EXTERN for
+ decls that don't include it.
+
+Fri May 5 14:23:30 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (duplicate_decls): Decls that have DECL_INTERFACE_KNOWN or
+ DECL_NOT_REALLY_EXTERN set aren't extern decls.
+
+ * typeck.c (build_indirect_ref): Don't call default_conversion for a
+ parameter of reference_type.
+ * cvt.c (convert_from_reference): Just use build_indirect_ref.
+
+ * pt.c (do_type_instantiation): Only instantiate member functions
+ that actually come from templates.
+
+Fri May 5 09:46:05 1995 Mike Stump <mrs@cygnus.com>
+
+ * parse.y: Generalized cleanup of poplevels, and compound statements
+ and compound statements in try blocks. Rewritten `for' rule so that
+ the scope of variables declared in the for clause is shortened to
+ span just to the end of the statement, instead of the whole
+ containing block.
+
+Fri May 5 00:37:14 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * call.c (convert_harshness): Handle pointers to members better.
+
+Thu May 4 16:00:26 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl2.c (delete_sanity): Do access control here.
+ * init.c (build_delete): Instead of here.
+
+ * Make-lang.in: Build c++filt.
+
+Wed May 3 02:59:53 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl2.c (cplus_decl_attributes): If we just modified a TYPE_DECL,
+ update our IDENTIFIER_TYPE_VALUE.
+
+Fri Apr 28 07:58:41 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * lex.c (cons_up_default_function): Fix linkage of #pragma
+ implemented functions.
+
+Thu Apr 27 16:56:24 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * method.c (build_overload_name): Simplify and fix repeated type
+ folding.
+
+ * decl.c (grokdeclarator): Prohibit pointers to void or reference
+ members.
+
+Thu Apr 27 09:49:07 1995 Mike Stump <mrs@cygnus.com>
+
+ * typeck2.c (process_init_constructor): Make sure initializers are
+ fully digested.
+
+Thu Apr 27 01:11:55 1995 Jason Merrill <jason@python.cygnus.com>
+
+ * lex.c (cons_up_default_function): Always defer synthesis.
+
+Thu Apr 27 00:20:37 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl2.c (mark_inline_for_output): Don't play with pending_inline
+ stuff.
+
+Wed Apr 26 17:48:24 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * call.c (user_harshness): New function; like build_type_conversion,
+ but doesn't actually build anything.
+ (compute_conversion_costs): Use it instead of build_type_conversion.
+
+Wed Apr 26 17:11:25 1995 Jason Merrill <jason@deneb.cygnus.com>
+
+ * typeck.c (build_function_call_real): Improve error message for
+ calling a non-function.
+
+ * method.c (hack_identifier): Lose check for calling a data member.
+
+Wed Apr 26 16:59:13 1995 Mike Stump <mrs@cygnus.com>
+
+ * typeck2.c (build_functional_cast): Remove very old cruft.
+ Seems like good code is generated without it.
+
+Wed Apr 26 00:47:16 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * method.c (do_build_assign_ref): Fix handling of anonymous unions.
+ (do_build_copy_constructor): Ditto.
+
+ * parse.y (simple_stmt, SWITCH): Call {push,pop}_switch.
+
+ * decl.c (push_switch): New function.
+ (pop_switch): Ditto.
+ (define_case_label): Check for jumping over initialization.
+
+ * call.c (build_method_call): Check for an inline function being
+ called before its definition has been seen.
+ * typeck.c (build_function_call_real): Ditto.
+
+ * decl.c (duplicate_decls): Check for a function being redeclared
+ inline after its address has been taken.
+
+ * typeck.c (build_conditional_expr): Handle related class lvalues.
+
+Tue Apr 25 13:20:45 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * pt.c (do_pending_expansions): Don't expand unused templates.
+
+ * parse.y (component_decl): Accept a lone semicolon.
+
+Tue Apr 25 00:25:56 1995 Jason Merrill <jason@rtl.cygnus.com>
+
+ * call.c (build_method_call): Don't allow an RTL_EXPR to serve as the
+ object parameter anymore.
+
+ * expr.c (cplus_expand_expr): Don't create RTL_EXPRs with no insns.
+
+Mon Apr 24 12:35:48 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * parse.y (simple_stmt, decl case): Clear prefix_attributes.
+ (lang_extdef): Ditto.
+
+ * parse.y (maybe_parmlist): New rule for use in declarators where
+ this could either be a list of expressions or parameters. Calls
+ suspend_momentary before deciding which.
+ (direct_after_type_declarator): Use it.
+ (complex_direct_notype_declarator): Use it.
+
+ * pt.c (tsubst): Propagate attributes const and noreturn.
+
+ * typeck.c (build_modify_expr): If warn_synth, call build_opfncall
+ before doing the default thing.
+
+Thu Apr 27 21:49:36 1995 Doug Evans <dje@cygnus.com>
+
+ * typeck.c (common_type): Call lookup_attribute instead of
+ value_member.
+
+Tue Apr 25 18:07:43 1995 Richard Kenner (kenner@vlsi1.ultra.nyu.edu)
+
+ * Make-lang.in: Change "realclean" to "maintainer-clean".
+
+Sun Apr 23 12:32:38 1995 Mike Stump <mrs@cygnus.com>
+
+ * decl2.c (finish_file): Fix broken linked list handling.
+
+Fri Apr 21 18:08:43 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * class.c (finish_base_struct): Don't set TYPE_HAS_COMPLEX_*_REF
+ as often.
+ (finish_struct): Ditto.
+
+ * various: Use TYPE_HAS_TRIVIAL_* instead of TYPE_HAS_COMPLEX_*.
+
+ * cp-tree.h (TYPE_HAS_TRIVIAL_INIT_REF): New macro.
+ (TYPE_HAS_TRIVIAL_ASSIGN_REF): New macro.
+
+Fri Apr 21 15:52:22 1995 Jason Merrill <jason@python.cygnus.com>
+
+ * typeck.c (c_expand_return): Only expand a returned TARGET_EXPR if
+ it is of the same type as the return value.
+
+Fri Apr 21 03:01:46 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl2.c (finish_file): Reconsider if synthesizing a method wrote
+ out its assembly.
+
+ * typeck.c (convert_for_initialization): Don't call a trivial copy
+ constructor.
+
+ * typeck2.c (store_init_value): Only abort if the type has a
+ non-trivial copy constructor.
+
+ * typeck.c (c_expand_return): If we're returning in a register and
+ the return value is a TARGET_EXPR, expand it. Only do
+ expand_aggr_init if we're returning in memory.
+ (expand_target_expr): Function to expand a TARGET_EXPR.
+ (build_modify_expr): Use it.
+
+ * tree.c (build_cplus_new): Layout the slot.
+
+ * expr.c (cplus_expand_expr): Use expand_call to expand the call
+ under a NEW_EXPR, so the target is not discarded.
+
+Thu Apr 20 14:59:31 1995 Mike Stump <mrs@cygnus.com>
+
+ * gc.c (build_dynamic_cast): Tighten error checking.
+
+Thu Apr 20 11:23:54 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * expr.c (cplus_expand_expr): Only abort if the returned target is
+ different from what we expected if the type has a non-trivial copy
+ constructor.
+
+ * decl2.c (cplus_decl_attributes): Attributes applied to a template
+ really apply to the template's result.
+
+ * tree.c (lvalue_p): Check IS_AGGR_TYPE instead of TREE_ADDRESSABLE
+ to decide whether to consider a CALL_EXPR an lvalue.
+
+ * class.c (finish_struct_bits): Only set TREE_ADDRESSABLE if the
+ type has a non-trivial copy constructor.
+
+ * decl.c (start_function): If interface_known, unset
+ DECL_NOT_REALLY_EXTERN on the function.
+
+Wed Apr 19 16:53:13 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * pt.c (do_function_instantiation): Handle explicit instantiation of
+ member functions.
+ (do_type_instantiation): Handle 'inline template class foo<int>',
+ meaning just spit out the vtable.
+
+ * lex.c (cons_up_default_function): Set DECL_NOT_REALLY_EXTERN on
+ the consed functions.
+
+ * decl2.c (import_export_inline): Set DECL_INTERFACE_KNOWN.
+
+Wed Apr 19 16:28:17 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * call.c, class.c, decl2.c, gc.c, init.c, parse.y, pt.c, search.c,
+ typeck.c: Include output.h.
+
+Wed Apr 19 14:57:21 1995 Gerald Baumgartner (gb@alexander.cs.purdue.edu)
+
+ * call.c (build_method_call): Allow a signature member functions to
+ be called from a default implementation.
+
+Wed Apr 19 10:21:17 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * repo.c (finish_repo): Remember what directory we are in.
+
+ * search.c (expand_upcast_fixups): Don't mess with abort_fndecl.
+
+ * repo.c: Use obstacks instead of fixed-size buffers. Don't spit
+ out the second copy of the symbol name. Don't remember COLLECT_GCC.
+
+Wed Apr 19 02:32:40 1995 Mike Stump <mrs@cygnus.com>
+
+ * search.c (virtual_context): New function to get the virtual
+ context of a function.
+ (expand_upcast_fixups): New function to generate runtime vtables.
+ (fixup_virtual_upcast_offsets): Ditto.
+ (expand_indirect_vtbls_init): Use fixup_virtual_upcast_offsets to
+ ensure that the this offsets for upcasts from virtual bases into
+ other virtual bases or non-virtual bases are correct at construction
+ time and destruction time.
+ * class.c (fixup_vtable_deltas): Modify to fixup all offsets in all
+ vtables in all virtual bases, instead of just one vtable in each
+ virtual base.
+ (fixup_vtable_deltas1): Ditto.
+
+Tue Apr 18 03:57:35 1995 Michael Meissner (meissner@cygnus.com)
+
+ * Makefile.in (lex.o): Add dependency on c-pragma.h.
+
+ * lex.c (handle_sysv_pragma): Use NULL_PTR and NULL_TREE as
+ appropriate, instead of 0.
+
+Mon Apr 17 12:28:42 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (pushdecl): Use decls_match, not duplicate_decls, for
+ comparing local and global decls.
+
+Fri Apr 14 01:46:52 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (convert_arguments): Only prohibit passing to ... of
+ types with non-trivial copy constructors.
+
+ * repo.c (repo_template_used): Don't try to mess with no id.
+
+Fri Apr 14 23:32:50 1995 Per Bothner <bothner@rtl.cygnus.com>
+
+ * decl.c (duplicate_decls): Use cp_warning_at for redundant-decls.
+
+Thu Apr 13 15:37:42 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * cp-tree.h (current_tinst_level): Delete declaration, since it's
+ static inside pt.c.
+
+ * typeck.c (build_modify_expr): Catch incompatible array assignment.
+
+ * parse.y (attribute_list, attrib): Rewrite actions to feed the
+ right stuff to decl_attributes.
+
+Thu Apr 13 11:24:10 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * search.c (dfs_debug_mark): Check for magic virtual like
+ import_export_vtable.
+
+ * typeck.c (build_binary_op_nodefault): Don't call cp_pedwarn with
+ four args.
+
+Wed Apr 12 12:02:57 1995 Jason Merrill <jason@deneb.cygnus.com>
+
+ * decl2.c (finish_file): Move prevtable pass before needs_messing_up
+ decision.
+
+Tue Apr 11 11:20:27 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (finish_decl): If we're writing out a static data member of
+ a class, we want the debug info for that class.
+
+ * gc.c (build_t_desc): Check linkage of a class properly.
+
+ * class.c (finish_struct): Set the 'headof' offset for the main
+ vtable properly.
+ (prepare_fresh_vtable): Fix typeinfo pointer here.
+ (modify_one_vtable): Instead of here.
+
+Mon Apr 10 12:15:59 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * repo.c (repo_get_id): New function to return the interesting
+ identifier for a repo entity.
+ (repo_template_used): Use it.
+ (repo_template_instantiated): Mark the id as chosen.
+ (init_repo): Record whether or not the id was chosen.
+ (finish_repo): Note if an id was newly chosen.
+
+ * pt.c (do_function_instantiation): Call repo_template_instantiated.
+ (do_type_instantiation): Ditto. Don't diagnose multiple
+ instantiation.
+
+ * decl2.c (finish_file): Use DECL_NOT_REALLY_EXTERN when deciding
+ whether or not to synthesize a method.
+
+ Undo these changes:
+ * class.c (finish_vtbls): build more vtables if flag_rtti is on.
+ * class.c (modify_all_direct_vtables): ditto.
+ * init.c (expand_direct_vtbls_init): expand more vtables if
+ flag_rtti is on.
+
+Sat Apr 8 17:45:41 1995 Mike Stump <mrs@cygnus.com>
+
+ * gc.c (build_headof): Use ptrdiff_type_node instead of
+ integer_type_node on pointer arithmetic.
+
+Sat Apr 8 11:57:04 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (build_modify_expr): Undo previous change.
+
+Thu Apr 6 01:23:50 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * Makefile.in (compiler): Remove ../cc1plus before rebuilding it.
+
+ * repo.c (get_base_filename): Put the .rpo file in the directory
+ with the object file, not the source.
+
+ * typeck.c (build_conditional_expr): Handle pmf's better.
+
+ * repo.c (finish_repo): Also use ASM_OUTPUT_LABELREF to print out
+ the name of the symbol.
+
+Wed Apr 5 15:24:12 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * repo.c (open_repo_file): Make repo filename DOS-compliant.
+ (*): Also write a new repo file if some previously-used
+ templates are no longer used. Only remember the identifier.
+
+ * lex.c (cons_up_default_function): If this function belongs to a
+ template class, call repo_template_used for it.
+
+ * repo.c (repo_template_used): Using a class means using its vtable,
+ if any.
+ (finish_repo): Ditto.
+
+ * typeck.c (build_modify_expr): Only wrap TARGET_EXPRs in RTL_EXPRs
+ if the type has a complex copy constructor.
+
+ * decl2.c (lang_decode_option): -frepo implies
+ -fno-implicit-templates.
+
+ * decl.c (start_function): Clear current_{base,member}_init_list.
+
+ * lex.c (init_lex): Also unset *_eq if ! flag_operator_names.
+
+Tue Apr 4 16:11:08 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (struct cp_function): Add {base,member}_init_list.
+ (push_cp_function_context): Save current_{base,member}_init_list.
+ (pop_cp_function_context): Restore them.
+
+Mon Apr 3 16:55:08 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * repo.c (get_base_filename): Take filename parm, fix logic bug.
+
+ * typeck.c (build_compound_expr): Do not warn about a compound expr
+ in which the first expression has no side effects.
+ (build_x_compound_expr): Warn here instead.
+ (build_conditional_expr): Don't warn about a conditional expression
+ between an enum and the type it promotes to.
+
+ * init.c (build_new): Handle initialization of arrays of builtins
+ properly.
+
+Mon Apr 3 15:08:04 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * repo.c: Include config.h to get definitions of bcopy and rindex
+ on systems that don't have them (e.g., SVR4).
+
+Mon Apr 3 14:41:55 1995 Mike Stump <mrs@cygnus.com>
+
+ * decl2.c (finish_table): Pass NULL_TREE instead of init to
+ finish_decl so that it won't try and do error checking on the
+ initializer.
+
+Mon Apr 3 10:45:50 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * repo.c (get_base_filename): Analyze COLLECT_GCC_OPTIONS to
+ determine whether this compile used -c -o.
+ (open_repo_file): Use get_base_filename. Remove the extension.
+ (finish_repo): Spit out the values of main_input_filename,
+ COLLECT_GCC and COLLECT_GCC_OPTIONS.
+
+ * parse.y (structsp): Add TYPENAME_KEYWORD complex_type_name.
+
+Sun Apr 2 23:43:51 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * search.c (compute_access): Don't try to do access control on
+ nested types.
+
+Fri Mar 31 10:14:23 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * repo.c: New file to handle things repo.
+
+ * pt.c (instantiate_template): Call repo_template_used if the
+ definition is accessible.
+ (mark_function_instantiated): Split out from
+ do_function_instantiation.
+ (mark_class_instantiated): Split out from do_type_instantiation.
+
+ * parse.y (template_instantiate_once): Call repo_template_used.
+
+ * lex.c (lang_init): Call init_repo.
+
+ * decl2.c: Handle flag_use_repository.
+ (finish_file): Call finish_repo.
+
+ * decl.c (start_method): Call repo_template_used if this is a
+ template method.
+
+ * Makefile.in (CXX_OBJS): Add repo.o.
+ (repo.o): Add dependencies.
+
+ * Make-lang.in (CXX_SRCS): Add repo.c.
+
+ * decl.c (start_function): If DECL_INTERFACE_KNOWN and
+ DECL_NOT_REALLY_EXTERN are both set, unset DECL_EXTERNAL.
+
+ * typeck.c (build_binary_op_nodefault): Identify the invalid operand
+ types used.
+
+ * decl.c (duplicate_decls): Propagate DECL_NOT_REALLY_EXTERN.
+
+Thu Mar 30 17:54:42 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (build_binary_op_nodefault): Tidy up use of build_type
+ and result_type. When checking for comparison between signed
+ and unsigned, use result_type rather than the (possibly shortened)
+ type of op0. Also, don't warn about equality comparison of a
+ signed operand to an unsigned constant that fits in the signed
+ type.
+
+ * method.c (do_build_copy_constructor): Reverse
+ current_base_init_list after we've built it up.
+
+Thu Mar 30 14:35:18 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (build_throw): Never warn about the value of throw not
+ being used.
+
+Thu Mar 30 13:16:54 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (expand_start_catch_block): Check for bad catch parameter
+ declarations.
+
+Thu Mar 30 13:06:11 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (finish_function): Only set DECL_NOT_REALLY_EXTERN if
+ DECL_EXTERNAL is not already set.
+
+Thu Mar 30 11:26:24 1995 Mike Stump <mrs@cygnus.com>
+
+ * method.c (emit_thunk): Let poplevel know that the last level is
+ for a function so it can create a BLOCK_NODE and set DECL_INITIAL.
+
+Thu Mar 30 11:15:06 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl2.c (import_export_inline): Don't set DECL_NOT_REALLY_EXTERN
+ here.
+
+ * decl.c (grokdeclarator): OK, don't abort if we see a decl with
+ METHOD_TYPE.
+ (finish_function): Set DECL_EXTERNAL and DECL_NOT_REALLY_EXTERN on
+ all deferred inlines.
+
+Wed Mar 29 19:35:02 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * cp-tree.h (DECL_THIS_INLINE): New macro.
+ (DECL_NOT_REALLY_EXTERN): New macro.
+ (DECL_THIS_STATIC): New macro.
+
+ * decl.c: Lose all references to current_extern_inline. Break
+ inline semantics into DECL_INLINE for actual inlining and
+ DECL_THIS_INLINE for the linkage wierdness. Use DECL_THIS_STATIC.
+ * decl2.c: Use DECL_NOT_REALLY_EXTERN to indicate that we want to
+ emit an inline here. Associated changes.
+ * lex.c: Ditto.
+ * pt.c: Ditto.
+ * typeck.c: Ditto.
+
+ * call.c (build_method_call): Don't bother trying to handle inlines
+ specially.
+ * cvt.c (convert_to_aggr): Ditto.
+
+ * pt.c (do_function_instantiation): Handle instantiation of
+ public inlines, too.
+
+Wed Mar 29 16:04:25 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (init_exception_processing): Change the interface for
+ __throw_type_match and add decl for new rtti matching routine
+ __throw_type_match_rtti.
+ (build_eh_type): New routine to build a run time descriptor for the
+ expression given.
+ (expand_start_catch_block): Update to use new calling convention for
+ the matcher.
+ (expand_throw): Update to use build_eh_type.
+
+Mon Mar 27 07:14:33 1995 Warner Losh <imp@village.org>
+
+ * g++.c: Removed __NetBSD__ from conditional.
+ Declare strerror if HAVE_STRERROR is defined; otherwise
+ declare sys_errlist and sys_nerr.
+ (my_strerror): New function.
+
+Tue Mar 28 14:16:35 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * search.c (get_binfo): Don't try to be so clever.
+
+ * tree.c (copy_to_permanent): Also suspend_momentary().
+
+ * cvt.c (cp_convert_to_pointer): Hand off to convert_fn_pointer even
+ if the types are the same.
+
+ * decl.c (start_function): Handle extern inlines more like C++ says
+ we should.
+
+ * init.c (build_member_call): Hand constructor calls off to
+ build_functional_cast.
+
+ * typeck2.c (build_functional_cast): Use DECL_NESTED_TYPENAME to get
+ the name of the type.
+
+Tue Mar 28 13:13:56 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * decl.c (grokdeclarator): Check for the decl returned by
+ grokfndecl to be null before using build_decl_attribute_variant.
+
+Mon Mar 27 18:04:41 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * init.c (build_new): Use build_pointer_type instead of
+ TYPE_POINTER_TO.
+
+Fri Mar 24 12:11:24 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (build_conditional_expr): Handle pmfs.
+ (convert_for_assignment): Fix pmf support.
+
+ * cvt.c (convert_fn_ptr): Support !flag_vtable_thunks.
+ (cp_convert_to_pointer): Handle pmfs.
+ (cp_convert): Pass pmfs to cp_convert_to_pointer.
+
+ * typeck.c (common_type): Handle inheritance for pmfs.
+
+ * typeck2.c (build_m_component_ref): Do access control.
+
+ * typeck.c (comp_target_types): Check for conversion to void *
+ before checking trickier conversions.
+
+ * decl.c (duplicate_decls): Propagate DECL_ABSTRACT_VIRTUAL_P.
+
+ * pt.c (push_tinst_level): Complain if template instantiation depth
+ is greater than max_tinst_depth.
+
+ * typeck.c (common_type): Assume that we can call common_type to
+ unify the target type of a pointer.
+
+Thu Mar 23 00:48:44 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl2.c (finish_file): Don't synthesize methods at
+ finish_vtable_prevardecl time. Do synthesize methods that are not
+ used, but are public and not external.
+
+ * cvt.c (build_type_conversion): Only give an error if for_sure.
+
+ * typeck.c (comp_target_types): Only support pointer conversions if
+ nptrs > 0.
+
+Wed Mar 22 19:30:15 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * init.c (build_new): Catch use of an initializer list where it
+ shouldn't be.
+
+Wed Mar 22 16:21:07 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * init.c (build_new): Wrap alloc_expr in an RTL_EXPR if nelts is
+ non-constant.
+
+ * decl2.c: temp_name_counter is now public.
+
+ * decl.c (struct cp_function): Add temp_name_counter field.
+ (push_cp_function_context): Save it.
+ (pop_cp_function_context): Restore it.
+
+ * typeck.c (common_type): Handle unifying function types, and unify
+ unmatched things to void* with a compiler_error, rather than
+ silently like before.
+
+Wed Mar 22 15:10:34 1995 Mike Stump <mrs@cygnus.com>
+
+ * decl2.c (finish_prevtable_vardecl, finish_vtable_vardecl): Revert
+ Brendan's last change and fix latent problem that causes TD entries
+ to not come out when the things that need them has yet to be
+ expanded.
+
+Wed Mar 22 15:12:00 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (build_binary_op_nodefault, comparison ops): Update type0
+ and type1, since we might have changed op0 or op1.
+
+Wed Mar 22 13:33:45 1995 Jason Merrill <jason@python.cygnus.com>
+
+ * typeck.c (common_type): Don't mess up templates.
+
+Wed Mar 22 04:56:00 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (common_type): Handle ptms properly. Also handle
+ T* -> void*.
+ (build_binary_op_nodefault): New variable build_type controls what
+ type is given to the expression when it is created. Set this to
+ boolean_type_node for comparison ops instead of using result_type.
+ (comp_target_types): Allow T * -> void *.
+
+ * cvt.c (cp_convert_to_pointer): Do access control when converting
+ ptms, too.
+
+Tue Mar 21 17:25:06 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * parse.y (extern_lang_string): Catch use of linkage specs that
+ aren't all naming the same language.
+
+ * class.c (finish_struct): Delete accidental duplicate code.
+
+Tue Mar 21 14:00:57 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (build_binary_op_nodefault): Disable pedwarns about
+ comparing functions and incomplete types.
+
+ * decl.c (finish_function): Only unset current_function_decl if
+ !nested.
+ (duplicate_decls): Last change went too far; we only want to stop
+ checking for value/reference ambiguity.
+
+Tue Mar 21 01:26:39 1995 Mike Stump <mrs@cygnus.com>
+
+ * gc.c (build_generic_desc): Zap the DECL_SIZE so that we can lay it
+ out fresh, as the new type may be larger.
+
+Mon Mar 20 19:01:10 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * expr.c (extract_init): Try to expand the RTL for the
+ initialization and figure out what it will look like so we can avoid
+ run-time initialization. Disabled for now.
+ (extract_scalar_init): Helper for scalar initialization.
+ (extract_aggr_init): Helper for aggregate initialization.
+
+ * decl.c (duplicate_decls): Don't complain about ambiguous
+ declarations.
+ (obscure_complex_init): Now returns a tree. Call extract_init if
+ we're optimizing and this is a toplevel decl.
+ (finish_decl): Update accordingly.
+
+ * lex.c (check_newline): If we're just changing files (not pushing
+ or popping), update input_file_stack->name.
+
+Mon Mar 20 17:55:04 1995 Mike Stump <mrs@cygnus.com>
+
+ * pt.c (type_unification): Only TEMPLATE_DECLs are handled right now
+ in the transitive unification code.
+
+Mon Mar 20 16:07:50 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * decl.c (shadow_tag): Don't allow inline, virtual, or explicit on
+ non-functions.
+ (grokdeclarator): Don't allow friends to be defined in local classes.
+
+Sat Mar 18 04:03:33 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl2.c (finish_prevtable_vardecl): Use DECL_DECLARED_STATIC
+ rather than DECL_SAVED_INSNS to decide whether or not this method
+ was declared inline.
+
+ * method.c (synthesize_method): Turn off DECL_INLINE if
+ function_cannot_inline_p thinks we're too large.
+
+ * typeck.c (build_indirect_ref): Use build_expr_type_conversion.
+
+Fri Mar 17 17:47:36 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * class.c (instantiate_type): Handle pmfs.
+
+ * typeck.c (convert_for_assignment): Check types when assigning one
+ pmf to another.
+
+ * decl.c (define_label): Fix logic for printing out the name of the
+ label in an error message.
+
+ * error.c (dump_expr): Support ARRAY_REF.
+
+Fri Mar 17 17:43:02 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * decl2.c (finish_vtable_vardecl): Call build_t_desc here.
+ (finish_prevtable_vardecl): Instead of here.
+
+Fri Mar 17 14:40:45 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (expand_static_init): Also use expand_aggr_init if the
+ initializer is a TREE_LIST.
+ (grokdeclarator): Only pedwarn about extra qualification if -pedantic.
+
+ * pt.c (unify): Fix unification of return type.
+
+ * expr.c (fixup_result_decl): Use store_expr, rather than
+ emit_move_insn, to move the return value into the place where
+ callers will expect it.
+
+Thu Mar 16 22:05:25 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * init.c (build_offset_ref): Call assmble_external on functions.
+ * typeck.c (build_component_ref): Ditto.
+
+Thu Mar 16 20:28:16 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * decl.c (struct saved_scope): Add members base_init_list and
+ member_init_list.
+ (push_to_top_level): Save current_base_init_list and
+ current_member_init_list to them.
+ (pop_from_top_level): Put it back.
+
+Thu Mar 16 19:21:14 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * pt.c (instantiate_template): Call assemble_external.
+
+Thu Mar 16 18:07:54 1995 Brendan Kehoe (brendan@phydeaux.cygnus.com)
+
+ * class.c: Include rtl.h, to get NULL_RTX.
+ (finish_struct): Also zero out DECL_SAVED_INSNS, to avoid problems
+ on hosts with different sizes for each part of the union.
+ * tree.c: Also include rtl.h.
+ (layout_basetypes): Same change for DECL_SAVED_INSNS.
+
+Thu Mar 16 13:57:36 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * pt.c (unify): Fix array domain unification for 64-bit targets.
+
+ * decl2.c (finish_file): Push bizarre type decl before walking the
+ vtables the first time.
+ (walk_vtables): OK, don't set prev to vars if the vardecl_fn messed
+ with TREE_CHAIN (prev).
+
+ * init.c (emit_base_init): Use convert_pointer_to_real instead of
+ convert_pointer_to when converting to a direct base.
+
+Wed Mar 15 20:26:29 1995 Mike Stump <mrs@cygnus.com>
+
+ * pt.c (type_unification): Handle transitive unification better.
+
+Wed Mar 15 13:56:16 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl2.c (walk_vtables): Always set prev to vars.
+ (mark_vtable_entries): Call assemble_external on the vtable entries.
+
+ * class.c (finish_struct): Set the vtable's size to NULL_TREE before
+ calling layout_decl, so that it gets updated properly.
+
+ Finally re-enable dynamic synthesis. This time it works.
+ * method.c (synthesize_method): Pass decl_function_context (fndecl)
+ to {push,pop}_cp_function_context.
+ * decl.c (push_cp_function_context): Now takes a tree argument.
+ (pop_cp_function_context): Ditto.
+ * call.c (build_method_call): Enable synthesis.
+ * lex.c (cons_up_default_function): Ditto.
+
+Tue Mar 14 19:14:19 1995 Doug Evans <dje@chestnut.cygnus.com>
+
+ * parse.y (setattrs): Chain onto prefix_attributes rather than
+ setting it.
+
+Wed Mar 15 13:00:00 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * decl.c (pushdecl): Check if the type of the VAR_DECL is an
+ error_mark_node before trying to read TYPE_LANG_SPECIFIC.
+
+Mon Mar 13 21:00:28 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * decl.c (grokdeclarator, case ARRAY_REF): Wrap the exp with fold,
+ and convert the size and integer_one_node to the index type.
+
+Mon Mar 13 08:01:02 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (get_member_function_from_ptrfunc): Save the instance
+ argument, and tack it onto the front of the COND_EXPR to make the
+ semantics come out right. Grab the instance argument from
+ '*instance_ptrptr', rather than having it passed in separately.
+
+ * various: Change various consed-up comparison operations to have
+ boolean type. Remove the instance argument in calls to
+ get_member_function_from_ptrfunc.
+
+ * error.c (dump_expr): Dump true and false as "true" and "false".
+
+ * decl2.c (finish_file): Also set DECL_STATIC_FUNCTION_P on the
+ global init function.
+
+ * decl.c (finish_function): Only set DECL_EXTERNAL here if the
+ inline function is public.
+
+Sat Mar 11 00:58:03 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * init.c (is_friend): Be more careful about checking
+ DECL_CLASS_CONTEXT on non-member functions.
+
+ * decl2.c (finish_vtable_vardecl): Don't bother calling
+ assemble_external here.
+ (prune_vtable_vardecl): New function that just splices out the
+ vtable decl from the top-level decls.
+ (import_export_inline): Unset DECL_EXTERNAL at first.
+ (finish_file): Don't bother calling assemble_external here. Do
+ splice out all of the vtables.
+
+Fri Mar 10 14:42:29 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (finish_function): If we're not emitting the function yet,
+ call assemble_external for it.
+
+ * decl2.c (finish_prevtable_vardecl): Don't call mark_vtable_entries
+ here.
+ (finish_vtable_vardecl): Don't do the linkage deduction thing here.
+ Also don't splice out the current vtable if it is unused.
+ (finish_file): Move the second walk_vtables and the synthesis check
+ inside the 'reconsider' loop. Move thunk emission after the
+ 'reconsider' loop.
+
+Thu Mar 9 16:28:16 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * pt.c (tsubst): Don't bother calling cp_build_type_variant, since it
+ was passing bogus values for readonly and volatile from the original
+ template decl, not the resultant type of the tsubst call.
+
+ * class.c (duplicate_tag_error): Use cp_error_at to point out the
+ previous definition of the tag.
+
+Thu Mar 9 10:46:17 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (start_function): Clear base_init_insns and protect_list.
+ (struct cp_function): Add base_init_insns field.
+ (push_cp_function_context): Also save base_init_insns.
+ (pop_cp_function_context): Also restore base_init_insns.
+
+Wed Mar 8 13:31:44 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * init.c (member_init_ok_or_else): Check for initializing a static
+ member here.
+ (emit_base_init): Instead of here.
+
+Tue Mar 7 16:03:26 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * call.c (build_method_call): Disable synthesis as needed.
+ * lex.c (cons_up_default_function): Ditto.
+
+Tue Mar 7 10:14:29 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * parse.y: New rules to allow attributes in a prefix position.
+ (prefix_attributes): New variable. Pass it into cplus_decl_attributes.
+ (setattr): New rule.
+ (reserved_declspecs, declmods): Catch attributes here.
+ * decl2.c (cplus_decl_attributes): Add PREFIX_ATTRIBUTES argument.
+ * decl.c (duplicate_decls): Pass DECL_MACHINE_ATTRIBUTES to
+ descendent typedef.
+ (grokdeclarator): Added code to support machine attributes.
+ * Makefile.in (stamp-parse): Expect 5 shift/reduce failures.
+
+Mon Mar 6 15:07:02 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * call.c (build_method_call): Don't synthesize methods outside of a
+ function.
+
+ Make base initialization more re-entrant so that synthesis on the
+ fly will work (and, eventually, template instantation on the fly).
+ * init.c (sort_member_init): Don't bother with members that can't be
+ initialized. Reorganize a bit. Don't initialize base members here.
+ (sort_base_init): New function, like sort_member_init, but for base
+ classes. Steals some code from emit_base_init.
+ (emit_base_init): Simplify. Call sort_{member,base}_init before
+ doing any initialization, so we don't have to save
+ current_{member,base}_init_list in push_cp_function_context.
+ (expand_aggr_vbase_init_1): Adjust for sort_base_init.
+ (expand_aggr_vbase_init): Simplify.
+ * decl.c (struct cp_function): Add protect_list field.
+ (push_cp_function_context): Also save protect_list.
+ (pop_cp_function_context): Also restore protect_list.
+ * call.c (build_method_call): Enable synthesis at point of call.
+ * lex.c (cons_up_default_function): Ditto.
+
+ * parse.y: Turn -ansi checks back into -pedantic checks.
+
+ * init.c (build_new): Fix -fcheck-new for array new.
+
+Sat Mar 4 15:55:42 1995 Fergus Henderson <fjh@cs.mu.oz.au>
+
+ * typeck.c (build_compound_expr): warn if left-hand operand of
+ comma expression has no side-effects.
+
+Fri Mar 3 15:16:45 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * parse.y (primary): Change 'object qualified_id *' rules to 'object
+ overqualified_id *'.
+
+Fri Mar 3 12:48:17 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * parse.y (unary_expr): Catch doing sizeof an overloaded function.
+ Make the error look the same as the one we issue in c_sizeof.
+
+ * typeck.c (build_binary_op_nodefault): Give an error for trying
+ to compare a pointer-to-member to `void *'.
+
+Fri Mar 3 11:28:50 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (build_unary_op): Handle bool increment with smoke and
+ mirrors here, rather than in expand_increment where it belongs,
+ because Kenner doesn't agree with me.
+
+Fri Mar 3 00:08:10 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * decl.c (grokparms): Catch a PARM_DECL being used for a default
+ argument as well.
+
+Thu Mar 2 20:05:54 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * init.c (build_new): Don't allow new on a function type.
+
+ * parse.y (primary): Avoid a crash when seeing if the arg is of
+ the same type as that given for the typespec in an explicit dtor call.
+
+Thu Mar 2 00:49:38 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (finish_function): Change test for calling
+ mark_inline_for_output.
+
+Wed Mar 1 11:23:46 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (build_modify_expr): Complain if
+ build_default_binary_type_conversion fails.
+
+ * init.c (expand_default_init): Handle arguments of unknown type
+ properly.
+
+ * cvt.c (build_expr_type_conversion): Only complain about ambiguity
+ if 'complain'.
+ * various: Pass 'complain'.
+
+ * typeck.c (comptypes): Be more picky about comparing UPTs.
+
+Wed Mar 1 11:03:41 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * decl.c (grokdeclarator): If declarator is null, say that the
+ type used has an incomplete type.
+
+Wed Mar 1 10:06:20 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * pt.c (instantiate_template): Copy the template arguments to the
+ permanent_obstack. Also use simple_cst_equal to compare them when
+ looking for a previous instantiation.
+
+ * tree.c (make_deep_copy): Support copying INTEGER_TYPEs (assuming
+ they are array domain types).
+
+Tue Feb 28 23:24:55 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * cp-tree.h: Define WANT_* constants for passing to
+ build_expr_type_conversion.
+ * cvt.c (build_expr_type_conversion): New function to build
+ conversion to one of a group of suitable types.
+ (build_default_binary_type_conversion): Use it.
+ * decl2.c (grok_array_decl): Ditto.
+ * typeck.c (build_unary_op): Ditto.
+ (build_array_ref): Tidy up a bit.
+ (build_binary_op): Ditto.
+
+Tue Feb 28 19:57:31 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * decl.c (grokdeclarator): Don't allow decl of an argument as `void'.
+
+Tue Feb 28 17:23:36 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * parse.y (typed_declspecs1): Add 'typespec reserved_typespecquals
+ reserved_declspecs' rule.
+
+ * parse.y (expr_or_declarator): Remove notype_qualified_id rule.
+ (direct_notype_declarator): Ditto.
+ (complex_direct_notype_declarator): Add notype_qualified_id rule.
+
+ * lex.c (real_yylex): Handle :> digraph properly.
+
+Tue Feb 28 12:26:29 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * decl.c (grokdeclarator): Check if it's a friend, not if it's
+ non-virtual, that's being initialized. Move the check up to
+ before FRIENDP would get cleared. Catch an unnamed var/field
+ being declared void. Say just `field' instead of `structure field'
+ in the error message. Only go for the operator name if DECLARATOR
+ is non-null.
+
+Tue Feb 28 00:08:01 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (start_function): Complain about abstract return type.
+ (grokdeclarator): Complain about declaring constructors and
+ destructors to be const or volatile. Complain about declaring
+ destructors to be static.
+
+ * pt.c (uses_template_parms): Handle pmfs.
+
+ * decl.c (grokdeclarator): Don't call variable_size for array bounds
+ that only depend on template constant parameters.
+
+Mon Feb 27 15:38:16 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * error.c (dump_decl): Only look to see if it's a vtable if we
+ actually have a name to check out.
+
+Mon Feb 27 13:37:53 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * cvt.c (convert_to_aggr): Lose misleading shortcut.
+
+Sun Feb 26 17:27:32 1995 Doug Evans <dje@canuck.cygnus.com>
+
+ * decl.c (set_nested_typename): Always set DECL_IGNORED_P,
+ not just for dwarf.
+
+Sun Feb 26 00:10:18 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * decl.c (grokdeclarator): Don't allow a static member to be
+ declared `register'.
+
+ * init.c (make_friend_class): Move up to a pedwarn for the warning
+ about a class declaring friends with itself.
+
+ * decl.c (grokdeclarator): You can't do `volatile friend class foo'
+ or `inline friend class foo'. Only try to make a friend out of
+ TYPE if we didn't already reset it to integer_type_node.
+
+Sat Feb 25 22:32:03 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * decl.c (grokdeclarator): Don't allow initialization of a
+ non-virtual function.
+
+ * decl.c (start_function): Do a pedwarn if we're changing `main'
+ to have an int return type.
+
+Sat Feb 25 00:02:05 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (build_modify_expr): Handle simple assignment from
+ TARGET_EXPRs by building up an RTL_EXPR to force expansion. Whew.
+
+Fri Feb 24 18:27:14 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * decl.c (grokdeclarator): Also don't allow virtual outside of a
+ class decl for a scope method definition performed at global binding.
+
+ * init.c (build_offset_ref): Don't allow creation of an OFFSET_REF
+ of a bitfield.
+
+ * decl.c (grokdeclarator): Don't allow a const to be declared mutable.
+
+ * typeck.c (build_binary_op): Return an error_mark_node if either
+ one of the args turned into an error_mark_node when we tried to
+ use default_conversion.
+
+ * typeck.c (build_unary_op): Forbid using postfix -- on a bool.
+
+ * decl.c (grokdeclarator): Allow `signed' and `unsigned' to be
+ used on `__wchar_t'.
+
+Fri Feb 24 13:59:53 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (end_protect_partials): Do it the right way.
+
+Wed Feb 22 15:42:56 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (build_binary_op_nodefault): Upgrade warning about
+ comparing distinct pointer types to pedwarn.
+
+ * typeck2.c (digest_init): Cope with extra braces.
+
+ * typeck.c (build_binary_op_nodefault): Use tree_int_cst_sgn instead
+ of INT_CST_LT (..., interger_zero_node).
+
+Wed Feb 22 14:45:52 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * except.c [!TRY_NEW_EH] (end_protect_partials): Define dummy
+ function for systems that don't have EH.
+
+Tue Feb 21 19:18:31 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * call.c (can_convert_arg): Like can_convert, but takes an arg as
+ well.
+
+ * pt.c (type_unification): Allow implicit conversions for parameters
+ that do not depend on template parameters.
+
+Tue Feb 21 18:43:48 1995 Douglas Rupp (drupp@cs.washington.edu)
+
+ * Make-lang.in, config-lang.in: ($exeext): New macro.
+ * Make-lang.in: Try a "cp" if "ln" fails.
+ * cp-tree.h (decl_attributes): Added argument.
+ * decl2.c (cplus_decl_attribute): Add arg to decl_attributes.
+ * cp/g++.c: Added #ifdefs for sys/file.h and process.h for NT.
+ Modified spawnvp to have to correct number of arguments for OS/2, NT.
+
+Tue Feb 21 18:36:55 1995 Mike Stump <mrs@cygnus.com>
+
+ * decl.c (finish_function): Add calls to end_protect_partials to end
+ the exception region that protects constructors so that partially
+ constructed objects can be partially destructed when the constructor
+ throws an exception.
+ * init.c (perform_member_init, sort_member_init, emit_base_init):
+ Added support for partially constructed objects.
+ * init.c (build_partial_cleanup_for): New routine to do partial
+ cleanups of a base class.
+ * decl2.c (finish_file): Move the emitting of the exception table
+ down, after we emit all code that might have exception regions in
+ them.
+ * except.c (end_protect_partials, might_have_exceptions_p): New
+ routines.
+ (emit_exception_table): Always output table if called.
+ * cp-tree.h (protect_list, end_protect_partials,
+ might_have_exceptions_p, emit_exception_table): Added.
+
+Tue Feb 21 16:05:59 1995 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * gc.c (build_typeid): Pass a NULL_TREE, not the bogus, unused
+ address of a local variable.
+ * class.c (build_vfn_ref): Only try to build the PLUS_EXPR if we
+ were given a non-null PTR_TO_INSTPTR.
+
+Tue Feb 21 01:53:18 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (duplicate_decls): Always lay out the merged decl.
+
+ * decl2.c (finish_vtable_vardecl): Don't do vtable hack on templates.
+ (finish_prevtable_vardecl): Ditto.
+
+ * method.c (synthesize_method): Set interface_{unknown,only}
+ according to the settings for our class, not the file where it comes
+ from.
+
+Sat Feb 18 12:26:48 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c: Handle systems that define __i386__ but not __i386.
+
+Fri Feb 17 15:31:31 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl2.c (reparse_decl_as_expr): Support being called without a
+ type argument.
+
+ * parse.y (primary): Add '(' expr_or_declarator ')'. Adds 4 r/r
+ conflicts. Sigh.
+
+Fri Feb 17 12:02:06 1995 Mike Stump <mrs@cygnus.com>
+
+ * parse.y (template_def, fndef, fn.def1, return_init, condition,
+ initdcl0, initdcl, notype_initdcl0, nomods_initdcl0,
+ component_decl_1, after_type_component_declarator0,
+ notype_component_declarator0, after_type_component_declarator,
+ notype_component_declarator, after_type_component_declarator,
+ full_parm, maybe_raises, exception_specification_opt): Fix up,
+ include exception_specification_opt maybeasm maybe_attribute and
+ maybe_init if missing. Rename maybe_raises to
+ exception_specification_opt to match draft wording. Use maybe_init
+ to simplify rules.
+
+Fri Feb 17 01:54:46 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * init.c (build_new): Set TREE_NO_UNUSED_WARNING on COMPOUND_EXPRs
+ built for news of scalar types.
+
+Thu Feb 16 17:48:28 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (build_binary_op_nodefault): Update code for warning
+ about signed/unsigned comparisons from C frontend. Realize that the
+ code in the C frontend is, if anything, even more bogus. Fix it.
+ (build_binary_op): Undo default_conversion if it wasn't useful.
+
+ * typeck.c (build_unary_op, ADDR_EXPR): Lose bogus special case for
+ PRE*CREMENT_EXPR.
+
+ * decl2.c (import_export_vtable): Don't try the vtable hack
+ if the class doesn't have any real non-inline virtual functions.
+ (finish_vtable_vardecl): Don't bother trying to find a non-inline
+ virtual function in a non-polymorphic class.
+ (finish_prevtable_vardecl): Ditto.
+
+ * decl2.c (import_export_vtable): Use and set DECL_INTERFACE_KNOWN.
+
+ * cp-tree.h (DECL_INTERFACE_KNOWN): Use DECL_LANG_FLAG_5.
+
+ * init.c (expand_virtual_init): Always call assemble_external.
+
+ * class.c (build_vfn_ref): Always call assemble_external.
+ (build_vtable): Always call import_export_vtable.
+ (prepare_fresh_vtable): Ditto.
+ (add_virtual_function): Don't bother setting TREE_ADDRESSABLE.
+
+Thu Feb 16 03:28:49 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * class.c (finish_struct): Use TYPE_{MIN,MAX}_VALUE to determine
+ whether an enumerated type fits in a bitfield.
+
+Wed Feb 15 15:38:12 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * class.c (grow_method): Update method_vec after growing the class
+ obstack.
+
+Wed Feb 15 13:42:59 1995 Mike Stump <mrs@cygnus.com>
+
+ * parse.y (handler_seq): Push a level for the catch parameters.
+
+Wed Feb 15 12:42:57 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * init.c (emit_base_init): Update BINFO_INHERITANCE_CHAIN on my
+ bases, in case they've been clobbered.
+
+Wed Feb 15 12:07:29 1995 Mike Stump <mrs@cygnus.com>
+
+ * class.c (finish_base_struct): Set up BINFO_INHERITANCE_CHAIN here,
+ so that one day it will always be valid.
+ * tree.c (propagate_binfo_offsets, layout_vbasetypes): Ditto.
+
+ * cp-tree.h (copy_binfo): Removed, unused.
+ * tree.c (copy_binfo): Ditto.
+
+Wed Feb 15 00:05:30 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * init.c (build_new): Save the allocation before calling
+ expand_vec_init on it.
+
+ * decl.c (finish_enum): The TYPE_PRECISION of the enum type mush
+ match the TYPE_PRECISION of the underlying type for constant folding
+ to work.
+
+Tue Feb 14 15:31:25 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (push_eh_entry, expand_start_all_catch,
+ expand_leftover_cleanups, expand_end_catch_block): Keep track of
+ the context in which the exception region occurs.
+ (build_exception_table): If the region was not output, don't output
+ the entry in the eh table for it.
+
+Tue Feb 14 02:15:43 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * init.c (expand_default_init): Only use a previous constructor call
+ if it's a call to our constructor. Does the word "Duh" mean
+ anything to you?
+
+ * decl.c (grokparms): Fine, just don't call
+ convert_for_initialization at all. OK? Happy now?
+
+Mon Feb 13 02:23:44 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * cp-tree.h (CLASSTYPE_FIRST_CONVERSION): Make sure that the class
+ method vector has a second element before returning it.
+
+ * decl.c (grokparms): Don't strip REFERENCE_TYPE before calling
+ convert_for_initialization.
+
+Sun Feb 12 03:57:06 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (build_modify_expr): Compare function name to
+ constructor_name (current_class_type) instead of current_class_name.
+
+ * decl.c (grokparms): Don't do anything with the return value of
+ convert_for_initialization.
+
+ * error.c (dump_decl): Also dump_readonly_or_volatile on the decl.
+
+ * decl.c (duplicate_decls): Tweak error message.
+
+ * typeck.c (build_const_cast): Implement checking.
+ (build_reinterpret_cast): Implement some checking.
+
+ * cp-tree.h (CONV_FORCE_TEMP): Require a new temporary when
+ converting to the same aggregate type.
+ (CONV_STATIC_CAST): Include it.
+ (CONV_C_CAST): Ditto.
+ * cvt.c (convert_force): Use CONV_C_CAST instead of CONV_OLD_CONVERT.
+ (cp_convert): Only force a new temporary if CONV_FORCE_TEMP.
+
+Fri Feb 10 16:18:52 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (build_c_cast): Use non_lvalue to tack something on
+ where necessary.
+
+ * decl.c (auto_function): Now a function.
+ * except.c (init_exception_processing): terminate, unexpected,
+ set_terminate, and set_unexpected have C++ linkage.
+
+ * typeck.c (build_unary_op, TRUTH_NOT_EXPR): Use convert instead of
+ truthvalue_conversion for converting to bool, as it handles
+ user-defined conversions properly.
+ (condition_conversion): Ditto.
+
+ * except.c (expand_throw): Don't call convert_to_reference.
+ Pass the correct parameters to build_new.
+
+ * method.c (do_build_assign_ref): Don't use access control when
+ converting to a base reference here.
+ (do_build_copy_constructor): Or here.
+
+ * init.c (build_new): Unset TREE_READONLY on the dereferenced
+ pointer before assigning to it.
+
+ * decl.c (maybe_build_cleanup): Don't bother stripping const here.
+
+ * decl2.c (delete_sanity): You can now delete pointer to const.
+
+Fri Feb 10 13:28:38 1995 Jason Merrill <jason@python.cygnus.com>
+
+ * decl.c (finish_function): Don't rely on actual parameters being
+ evaluated left-to-right.
+ * except.c (expand_end_catch_block): Ditto.
+
+Fri Feb 10 00:52:04 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * tree.c (real_lvalue_p): Like lvalue_p, but class temps aren't
+ considered lvalues.
+ * cvt.c (convert_to_reference): Use real_lvalue_p instead of
+ lvalue_p.
+
+ * cvt.c (build_type_conversion_1): Don't call convert on aggregate
+ types.
+ (convert_to_reference): Fix erroneous text substitution.
+
+ * typeck2.c (initializer_constant_valid_p): Update from C frontend.
+ Add new argument to all callers.
+
+ * typeck.c (convert_arguments): Check for error_mark_node before
+ trying to do anything with the actual parameter.
+
+ * typeck.c (condition_conversion): Build up a CLEANUP_POINT_EXPR and
+ fold it.
+ (bool_truthvalue_conversion): Remove. Fix all callers to call
+ truthvalue_conversion instead.
+ (various): Fold CLEANUP_POINT_EXPRs.
+
+ * parse.y (conditions): Call condition_conversion rather than
+ building up a CLEANUP_POINT_EXPR.
+
+ * pt.c (end_template_decl): Don't warn_if_unknown_interface here
+ under -falt-external-templates.
+
+Thu Feb 9 05:24:10 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * init.c (build_new): Complain about new of const type without
+ initializer. Other cleanup.
+
+ * call.c (compute_conversion_costs): Don't call
+ build_type_conversion with a reference type; convert to the target
+ type and check its lvaluetude.
+ * cvt.c (convert_to_reference): Ditto.
+
+ * cvt.c (build_type_conversion_1): There will never be any need to
+ dereference references here now.
+
+Thu Feb 9 00:37:47 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (expand_builtin_throw): Make sure we only `use' the
+ value of return_val_rtx.
+
+Wed Feb 8 15:45:55 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * parse.y (structsp): Don't complain about declaring a type being
+ defined to be a friend.
+
+ * decl2.c (warn_if_unknown_interface): Note the template in question
+ and the point of instantiation, for -falt-external-templates.
+ * lex.c (reinit_parse_for_method): Pass the decl to
+ warn_if_unknown_interface.
+ * pt.c (instantiate_template): Ditto.
+ (end_template_decl): Ditto.
+
+ * decl.c (set_nested_typename): Set IDENTIFIER_TYPE_VALUE on the
+ nested name again, to make local classes work a bit better.
+
+ * typeck.c (build_function_call_real): Dereference reference after
+ checking for incomplete type.
+
+ * init.c (build_new): Accept new of const and volatile types.
+
+Wed Feb 8 14:04:16 1995 Jason Merrill <jason@deneb.cygnus.com>
+
+ * decl.c (grokdeclarator): Fix error message.
+
+Wed Feb 8 03:16:15 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (convert_for_initialization): Do bash arrays when
+ converting to a reference to non-array.
+
+Tue Feb 7 15:50:33 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * cvt.c (cp_convert): Don't call convert_to_reference, or
+ automatically dereference references. Do pass reference conversions
+ to cp_convert_to_pointer.
+ (cp_convert_to_pointer): Support references.
+
+ * call.c (build_method_call): Don't build up a reference to the
+ parameter here; let build_overload_call handle that.
+
+ * typeck.c (build_c_cast): Call convert_to_reference directly if
+ converting to a reference type.
+ * method.c (do_build_copy_constructor): Ditto.
+ * method.c (do_build_copy_constructor): Ditto.
+ (do_build_assign_ref): Ditto.
+
+ * call.c (build_method_call): Dereference a returned reference.
+ * typeck.c (build_function_call_real): Ditto.
+
+ * decl.c (xref_basetypes): Check for unions with basetypes here.
+ (xref_tag): Instead of here.
+
+ * pt.c (process_template_parm): Template type parm decls are
+ artificial.
+
+Mon Feb 6 04:32:09 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * parse.y (typed_declspecs): Add missing semicolon.
+ (do_xref_defn): Resurrect.
+ (named_class_head_sans_basetype): Move template specialization
+ definition cases to named_class_head_sans_basetype_defn.
+
+ * decl2.c (grokfield): Call pushdecl_class_level after setting the
+ TYPE_NAME, not before.
+
+Sun Feb 5 02:50:45 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * call.c (convert_harshness): Don't call sorry here. Don't allow
+ conversions between function pointer types if pedantic.
+
+ * pt.c (overload_template_name): Pass globalize=1 to xref_tag.
+
+ * lex.c (cons_up_default_function): Use the full name for the return
+ type of op=.
+
+ * decl.c (set_nested_typename): Don't worry about anonymous types,
+ as they already have a unique name.
+ (pushdecl): Remove redundant set_nested_typename
+ (xref_tag): Split out base handling into xref_basetypes.
+
+ * cp-tree.h (TYPE_INCOMPLETE): New macro; TEMPLATE_TYPE_PARMs are
+ not considered incomplete even though their definition is unknown.
+
+ * decl.c (xref_defn_tag): Lose.
+ (xref_tag): xref_next_defn = ! globalize.
+ (pushdecl): Don't set DECL_NESTED_TYPENAME on artificial decls. The
+ ones that should have it set will have it set by pushtag.
+ (pushdecl_class_level): Ditto.
+ (pushtag): Tidy up a bit.
+ (set_nested_typename): Push a decl for the nested typename from
+ here, rather than from xref_defn_tag.
+
+ * parse.y (do_xref): Lose.
+ (named_class_head): If we see 'class foo:' we know it's a
+ definition, so don't worry about base lists for non-definitions.
+
+ * pt.c (push_template_decls): Template parm decls are artificial.
+
+ * decl.c (duplicate_decls): Restore check for qualifier
+ disagreement for non-functions.
+ (decls_match): Remove check for qualifier disagreement.
+
+Fri Feb 3 14:58:58 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (grok_reference_init): Convert initializer from
+ reference.
+ * typeck.c (convert_for_initialization): Ditto.
+
+ * decl.c (duplicate_decls): Propagate DECL_NESTED_TYPENAME.
+
+ * cvt.c (cp_convert): Don't convert to the same class type by just
+ tacking on a NOP_EXPR.
+ (convert_to_reference): Use comp_target_types instead of comptypes
+ so that we don't allow conversions two levels down.
+
+Thu Feb 2 15:07:58 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * class.c (build_vbase_path): Bash types to make the backend happy.
+ * cvt.c (build_up_reference): Bash the types bashed by
+ build_vbase_path to be reference types instead of pointer types.
+ (convert_to_reference): Ditto.
+
+ * typeck.c (build_c_cast): Don't strip NOPs if we're converting to a
+ reference type.
+
+ * parse.y (structsp): Put back error for 'struct B: public A;'.
+
+Wed Feb 1 23:02:06 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c: Add support for mips systems that don't define __mips
+ but do define mips, like Ultrix.
+
+Wed Feb 1 22:39:07 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c: Add support for exception handling on the Alpha.
+
+Wed Feb 1 10:12:14 1995 Mike Stump <mrs@cygnus.com>
+
+ * decl2.c (finish_file): Fix bug in Jan 31st change.
+
+Tue Jan 31 16:59:15 1995 Gerald Baumgartner (gb@lorenzo.cs.purdue.edu)
+
+ * sig.c (build_signature_pointer_or_reference_type): Don't set
+ IS_AGGR_TYPE for signature pointers/reference so expand_default_init
+ doesn't expect to find a copy constructor.
+ * call.c (build_method_call): Treat signature pointers/reference
+ as if IS_AGGR_TYPE were set.
+
+Tue Jan 31 13:28:56 1995 Mike Stump <mrs@cygnus.com>
+
+ * gc.c (get_typeid): Pawn off error messages to build_t_desc.
+ (build_t_desc): Inform the user here if they try and build
+ with -frtti and don't include <typeinfo.h>.
+
+ * decl2.c (finish_prevtable_vardecl): Support rescanning.
+ (finish_file): Move finish_prevtable_vardecl up to before the global
+ initializers are done as tdecls are initialized in the global
+ initializer. Also Pick up any new tdecls or vtables needed by
+ synthesized methods.
+
+ * class.c (finish_struct): Simplify. We have to do rtti scanning at
+ end, so we might as well do all of it there.
+
+Tue Jan 31 05:35:02 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * call.c (build_method_call): Fix -fthis-is-variable for 32-bit
+ targets, too.
+
+Tue Jan 31 00:11:04 1995 Mike Stump <mrs@cygnus.com>
+
+ * decl2.c (finish_prevtable_vardecl): New routine, mostly split from
+ finish_vtable_vardecl. It has the first half functionality from
+ that routine.
+ * decl2.c (finish_vtable_vardecl): Update to not include stuff not
+ in finish_prevtable_vardecl.
+ * decl2.c (finish_file): Call finish_prevtable_vardecl.
+ * gc.c (build_generic_desc): Allow it to be called when not at the
+ global binding layer, but behave as if we were.
+ (build_t_desc): Rearrange a bit so that it really works and is
+ easier to follow.
+ * class.c (finish_struct): Don't decide on tdecls here, as we have
+ to wait until the end of the file in general to decide whether or
+ not they come out.
+
+Mon Jan 30 01:00:40 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * init.c (build_delete): Check access to operator delete before
+ calling the destructor.
+ * method.c (build_opfncall, DELETE_EXPR): build_method is allowed to
+ return error_mark_node.
+ * call.c (build_method_call): Use the one-argument op delete even if
+ it's an error.
+
+ * init.c (build_new): Fix -fthis-is-variable support.
+ * call.c (build_method_call): Ditto.
+
+ * call.c (convert_harshness): Make conversion from a pointer to bool
+ worse than conversion to another pointer.
+
+Sat Jan 28 16:46:10 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * init.c (build_new): Check new return value if -fcheck-new.
+
+ * lex.c (check_newline): Clear end_of_file when we're done, too.
+
+Sat Jan 28 10:38:39 1995 Mike Stump <mrs@cygnus.com>
+
+ * decl2.c (finish_vtable_vardecl): Make rtti TD tables follow
+ vtables whereever they go.
+
+ * gc.c (build_t_desc): Remove old way of setting it up, as it wasn't
+ right.
+
+Sat Jan 28 09:10:44 1995 Mike Stump <mrs@cygnus.com>
+
+ * decl2.c (finish_vtable_vardecl): Now set the
+ interface/implementation of vtables on the first virtual function,
+ if one exists, otherwise we use the old method. This is a major win
+ in terms of cutting down the size of objects and executables in
+ terms of text space and data space. Now most of the savings that
+ #pragma interface/implementation gives is automatic in a fair number
+ of cases.
+
+Sat Jan 28 04:57:33 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (grokdeclarator): Discard the template parameters in a
+ template constructor declaration so that the function is always
+ named constructor_name (ctype).
+
+ * lex.c (check_newline): Use ungetc to put back the character before
+ calling HANDLE_PRAGMA.
+
+Fri Jan 27 17:23:47 1995 Mike Stump <mrs@cygnus.com>
+
+ * decl2.c (check_classfn): If the cname is T<int> and fn_name is T,
+ make sure we still match them.
+
+Fri Jan 27 16:32:10 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * parse.y: Add END_OF_LINE token.
+
+ * lex.c (check_newline): Set linemode when we see a # directive, and
+ unset it when we're done. Turn all 'return's into 'goto skipline'.
+ Fix all uses of '\n', since we won't see it anymore. Put back the
+ character we read before checking for a sysv or target pragma.
+ (real_yylex): If we see an EOF in linemode, return END_OF_LINE.
+ (handle_sysv_pragma): Don't look at the input stream; quit when we
+ see an END_OF_LINE token.
+
+ * input.c (getch): Return EOF if we're in line mode and at the end
+ of a line.
+ (put_back): Don't put back an EOF.
+
+Thu Jan 26 19:26:34 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (expand_throw): Do the newing of the exception object
+ before we load the type descriptor or the address so that we don't
+ wipe any of the values out.
+
+Thu Jan 26 19:20:00 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (init_exception_processing): Don't use r12 on the rs6000.
+
+Tue Jan 24 16:36:31 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (grokparms): Don't try to build up a reference at this point.
+
+ * typeck2.c (build_functional_cast): Don't assume that a NOP_EXPR
+ will suffice to convert from integer_zero_node.
+
+Wed Jan 25 15:02:09 1995 David S. Miller (davem@nadzieja.rutgers.edu)
+
+ * class.c (instantiate_type): Change error message text.
+ * typeck2.c (store_init_value): Likewise.
+
+Mon Jan 23 21:57:14 1995 Mike Stump <mrs@cygnus.com>
+
+ * pt.c (tsubst): When we copy a node, don't forget to copy
+ TREE_CHAIN, we use it later.
+
+Mon Jan 23 03:33:47 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (convert_for_assignment): Initialize variable before use.
+
+Fri Jan 20 01:17:59 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * g++.c (main): Link with both libstdc++ and libg++ if called as
+ something ending with "g++", otherwise only libstdc++. Move -lm to
+ the end of the line.
+
+Thu Jan 19 15:43:11 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * call.c (build_method_call): Don't mess with 'this' before calling
+ compute_conversion_costs.
+
+Wed Jan 18 15:40:55 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * search.c (get_matching_virtual): Give line number for previous
+ declaration.
+
+ * call.c (convert_harshness): Handle conversions to references
+ better.
+
+ * cvt.c (build_up_reference): OK, handle {MIN,MAX}_EXPR *properly*.
+
+Wed Jan 18 15:21:38 1995 Mike Stump <mrs@cygnus.com>
+
+ * class.c (instantiate_type): Use DECL_CHAIN to walk lists instead,
+ as the TREE_CHAIN for methods will take us to the next differently
+ named function, DECL_CHAIN won't.
+
+Wed Jan 18 14:26:59 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * tree.c (lvalue_p): Handle {MIN,MAX}_EXPR.
+
+ * decl2.c (lang_decode_option): -Wall implies -Wparentheses.
+ warn_parentheses defaults to 0.
+
+ * decl.c (grokparms): Put back call to require_instantiated_type.
+
+Tue Jan 17 19:56:15 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c (exception_section): Use the data section on the rs6000.
+ Change calling convention for named_section.
+
+Wed Jan 17 18:20:57 1994 Fergus Henderson <fjh@munta.cs.mu.oz.au>
+
+ * cp-tree.h : Make if (x=0) warn with wall
+ * parse.y : Make if (x=0) warn with wall
+
+Tue Jan 17 14:12:00 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (BOOL_TYPE_SIZE): BITS_PER_WORD if SLOW_BYTE_ACCESS,
+ BITS_PER_UNIT otherwise.
+
+ * search.c (get_matching_virtual): Don't check the binfo if the
+ types are the same.
+
+ * cvt.c (cp_convert): Just call truthvalue_conversion to convert to
+ bool.
+
+Mon Jan 16 13:28:48 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * various: Use boolean_type_node, boolean_true_node,
+ boolean_false_node.
+
+ * search.c (get_matching_virtual): Allow covariant returns that
+ don't require pointer adjustment.
+
+ * typeck.c (build_conditional_expr): Don't call default_conversion
+ on ifexp.
+
+ * cvt.c (build_up_reference): Handle MIN_EXPR and MAX_EXPR.
+
+ * decl.c (grokdeclarator): Upgrade warning about &const to pedwarn.
+
+Sun Jan 15 22:17:32 1995 dcb@lovat.fmrco.COM (David Binderman)
+
+ * pt.c (do_function_instantiation): Free targs once we're done.
+
+Sun Jan 15 22:17:32 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (BOOL_TYPE_SIZE): Defaults to BITS_PER_WORD.
+ (init_decl_processing): Use BOOL_TYPE_SIZE instead of CHAR_TYPE_SIZE
+ for bool.
+
+Sat Jan 14 05:33:55 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl2.c (finish_file): We need to mess up if there are any
+ variables in the list, not just if there is one with a constructor.
+
+Fri Jan 13 14:42:55 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (duplicate_decls): Propagate DECL_STATIC_{CON,DE}STRUCTOR.
+ (finish_function): Handle DECL_STATIC_{CON,DE}STRUCTOR.
+ (finish_function): Trust rest_of_compilation.
+
+ * decl2.c (finish_file): Also call functions designated as static
+ constructors/destructors.
+
+ * decl.c (grokdeclarator): Allow access decls of operator functions.
+ (grokparms): Only do convert_for_initialization if the initializer
+ has a type.
+ (duplicate_decls): Put back push_obstacks_nochange call.
+
+ * lex.c (real_yylex): Downgrade complaint about the escape sequence
+ being too large from pedwarn to warning.
+
+ * decl.c (grokdeclarator): Don't complain about long long in system
+ headers.
+
+ * lex.c (real_yylex): Handle digraphs.
+
+Thu Jan 12 12:17:24 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (init_decl_processing): -f{no-,}strict-prototype only
+ affects C linkage declarations now.
+
+ * typeck.c (comp_target_types): Grok simple contravariant conversions.
+ (common_type): t1 and t2 are interchangeable.
+
+ * various: Test return value of comp_target_types differently in
+ different places; it now returns -1 for a contravariant conversion
+ (which is fine in symmetric cases).
+
+ (common_type): Prefer long double to double even when
+ they have the same precision.
+
+ * decl.c (grokparms): Call convert_for_initialization to check
+ default arguments.
+
+ * init.c (build_new): void_type_node has a size (of 0).
+
+ * decl.c (decls_match): Also check for agreement of TREE_READONLY
+ and TREE_THIS_VOLATILE.
+ (push_class_level_binding): Properly handle shadowing of
+ nested tags by fields.
+
+ * search.c (dfs_pushdecls): Ditto.
+
+ * decl2.c (finish_file): Don't second-guess self-initialization.
+
+ * cvt.c (convert_to_reference): Work with expr directly, rather than
+ a copy.
+
+ * decl.c (push_overloaded_decl): Only shadow artificial TYPE_DECLs.
+
+ * init.c (add_friend): Downgrade duplicate friend message from
+ pedwarn to warning.
+
+ * decl.c (duplicate_decls): Push obstacks before calling common_type.
+
+Thu Jan 12 17:15:21 1995 Michael Ben-Gershon <mybg@cs.huji.ac.il>
+
+ * except.c (push_eh_entry): set LABEL_PRESERVE_P flag for
+ exception table labels.
+ (expand_start_all_catch): Ditto.
+ (expand_leftover_cleanups): Ditto.
+ (expand_end_catch_block): Ditto.
+ * except.c (make_first_label): new function.
+ (expand_start_all_catch): add a call to make_first_label() before
+ using a label as a jump destination.
+ (expand_end_all_catch): Ditto.
+ (expand_leftover_cleanups): Ditto.
+ (expand_end_catch_block): Ditto.
+ (expand_builtin_throw): Ditto.
+ (expand_throw): Ditto.
+ * except.c: Add ARM processor support for exception handling.
+
+Thu Jan 12 12:17:24 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ (complete_array_type): Copy code from C frontend.
+
+ * lex.c (real_yylex): Don't multiply the length of a wide string
+ literal by WCHAR_BYTES.
+
+ * decl.c (pushdecl): Check for redeclaration of wchar_t here.
+ (duplicate_decls): Instead of here.
+ (define_label): Complain about a label named wchar_t.
+ (grokdeclarator): Complain about declarations of
+ operator-function-ids as non-functions.
+
+ * typeck.c (unary_complex_lvalue): Also wrap prefix -- and ++ in
+ COMPOUND_EXPRs.
+ (build_unary_op): Wrap unary plus in a NON_LVALUE_EXPR.
+
+ * lex.c (real_yylex): Don't skip whitespace when reading the next
+ character after ->.
+
+Wed Jan 11 16:32:49 1995 Mike Stump <mrs@cygnus.com>
+
+ * except.c: Allow cc1plus to be built with native compiler on rs6000.
+ (expand_start_all_catch): Add assemble_external calls for various
+ routines we call.
+ (expand_leftover_cleanups): Ditto.
+ (expand_start_catch_block): Ditto.
+ (do_unwind): Ditto.
+ (expand_builtin_throw): Ditto.
+
+Wed Jan 11 01:05:42 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (pushtag): Only look for a previous decl in the current
+ binding level. Use explicit global scope in DECL_NESTED_TYPENAME.
+
+ * gxx.gperf: Add __signature__ and __sigof__ keywords.
+
+ * decl2.c (lang_decode_option): -ansi does not set flag_no_asm. It
+ does set flag_no_gnu_keywords and flag_operator_names.
+
+ * lex.c (init_lex): 'overload' is not a keyword unless -traditional.
+ Unset extension keywords if -fno-gnu-keywords.
+ Allow operator names ('bitand') if -foperator-names.
+ Never unset 'asm'; -fno-asm only affects 'typeof'.
+
+ * decl.c (lookup_name_real): The got_object special lookup only
+ applies to types.
+
+Tue Jan 10 18:07:51 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * spew.c (yylex): Also use DECL_NESTED_TYPENAME if got_object is set.
+
+ * parse.y (primary): Unset got_object after all rules that use the
+ 'object' nonterminal.
+ (object): Set got_object.
+
+ * lex.h: Declare got_object.
+
+ * decl.c (lookup_name_real): Also lookup names in the context of an
+ object specified.
+
+Tue Jan 10 14:30:30 1995 Mike Stump <mrs@cygnus.com>
+
+ * typeck.c (get_member_function_from_ptrfunc): Use ptrdiff_type_node
+ for things that have to be added to pointers, not size_type. Cures
+ problems with pointer to members on Alphas.
+ (build_binary_op_nodefault): Ditto.
+ (get_delta_difference_: Ditto.
+ (build_ptrmemfunc): Ditto.
+
+Tue Jan 10 01:49:25 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (pushtag): Stick the new decl in TYPE_NAME before pushing
+ it.
+
+ * typeck.c (build_component_ref): Don't build up a COMPONENT_REF
+ when dealing with overloaded member functions; just act like
+ build_offset_ref.
+ (commonparms): Remove misleading comment.
+
+ * decl.c (duplicate_decls): Complain about repeated default
+ arguments here.
+ (redeclaration_error_message): Instead of here.
+ (pushdecl): Complain about missing default arguments here.
+ (grokparms): Instead of here.
+ (lookup_name_current_level): Also match on DECL_ASSEMBLER_NAME.
+ (grok_reference_init): Do not complain about missing initializer if
+ declared 'extern'.
+
+ * search.c (lookup_field): Don't return a TYPE_DECL if there is a
+ function alternative and want_type is not set.
+
+Mon Jan 9 18:16:23 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (pushtag): Don't set TYPE_NAME to an identifier. Do push
+ the decl when the type has no TYPE_NAME.
+ (lookup_nested_type): Don't assume that type has TYPE_NAME set.
+ (lookup_name_real): Call lookup_field with want_type =
+ prefer_type.
+
+ * search.c (lookup_field): Handle want_type properly in the presence
+ of fields with the same name.
+
+ * decl.c (set_nested_typename): Set nested name for file-scope types
+ to include leading ::.
+ (pushdecl): Set the nested typename if the decl doesn't have one,
+ rather than if the type's canonical decl doesn't have one.
+
+Mon Jan 9 16:48:16 1995 Steve Chamberlain (sac@jonny.cygnus.com)
+
+ * typeck.c (pointer_int_sum): Use offset size when calculating
+ index expression.
+
+Mon Jan 9 03:44:33 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (convert_for_assignment): Complain about contravariance
+ violation here.
+ (comp_target_types): Instead of here.
+ (build_unary_op): resolve_offset_ref before checking for a valid
+ type.
+
+ * spew.c (yylex): Decrement looking_for_typename after we see a
+ _DEFN.
+
+ * decl.c (pushdecl): Don't install an artificial TYPE_DECL in
+ IDENTIFIER_LOCAL_VALUE if we already have a decl with that name.
+
+ * typeck.c (convert_for_assignment): Converting pointers to bool
+ does not need a cast.
+
+Sun Jan 8 18:16:45 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * class.c (instantiate_type): Initialize nsubsts parm.
+
+ * pt.c (do_function_instantiation): Ditto.
+
+Sat Jan 7 14:37:05 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * pt.c (tsubst): Use TREE_STATIC instead of DECL_INLINE &&
+ DECL_SAVED_INSNS to determine whether or not we've seen a definition
+ of this function.
+ (instantiate_template): Ditto.
+
+ * call.c (convert_harshness): Allow const reference binding when
+ called from the overloading code, but not when called from
+ can_convert (since it isn't a conversion).
+ (convert_harshness): Put back some disabled code.
+
+Fri Jan 6 14:10:57 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * call.c (convert_harshness): There is no implicit conversion from
+ void* to other pointer types (unless the parameter is (void*)0).
+ (convert_harshness): Non-lvalues do not convert to reference types.
+
+ * class.c (finish_struct_methods): Still set
+ TYPE_HAS_{INT,REAL}_CONVERSION.
+
+ * call.c (can_convert): Don't use aggregate initialization.
+
+ * cp-tree.h: Declare lookup_conversions.
+
+Thu Jan 5 21:08:00 1995 Mike Stump <mrs@cygnus.com>
+
+ * parse.y (simple_stmt): Fix duplicate case value error messages to
+ be more readable.
+
+Wed Jan 4 16:44:19 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * cvt.c (build_type_conversion): Total rewrite to use
+ convert_harshness instead of reproducing conversion logic here. Now
+ much shorter.
+
+ * call.c (convert_harshness): Support conversions to bool.
+ (can_convert): Checks whether a conversion is less harsh
+ than USER_CODE, for build_type_conversion.
+
+ * search.c (add_conversions): Function for passing to dfs_walk which
+ adds all the type conversion operators in the current type to a list.
+ (lookup_conversions): Calls dfs_walk with add_conversions and return
+ the list.
+ (dfs_walk): Don't require a qfn.
+
+ * cp-tree.h: Lose CLASSTYPE_CONVERSIONS hackery.
+ (CLASSTYPE_FIRST_CONVERSION): Points to elt 1 of CLASSTYPE_METHOD_VEC.
+
+ * class.c (finish_struct_bits): Lose CLASSTYPE_CONVERSIONS hackery.
+ (grow_method): A separate function for building onto the growing
+ method vector.
+ (finish_struct_methods): Use it. Put all type conversion operators
+ right after the constructors. Perhaps we should sort the methods
+ alphabetically?
+
+Mon Jan 2 14:42:58 1995 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * call.c (build_method_call): Lose another misleading shortcut.
+
+Fri Dec 30 17:57:30 1994 Mike Stump <mrs@cygnus.com>
+
+ * gc.c (build_bltn_desc): Handle bool as a built-in type.
+
+Fri Dec 30 14:20:21 1994 Mike Stump <mrs@cygnus.com>
+
+ * tree.c (layout_vbasetypes): Ensure that we don't loose alignment
+ on the complete type because of small virtual bases.
+
+Fri Dec 30 12:22:29 1994 Mike Stump <mrs@cygnus.com>
+
+ * decl.c (n_incomplete): Bump n_incomplete up to int to match C
+ front end.
+ (pushdecl): Also count decls pushed that are of a type being defined
+ as incomplete things.
+ * class.c (finish_struct): Move hack_incomplete_structures up to
+ just after we set it as not being defined, so that the decls we
+ build for RTTI don't count as incomplete.
+
+Thu Dec 29 18:20:57 1994 Mike Stump <mrs@cygnus.com>
+
+ * pt.c (tsubst): Fix problem with defining constructors in templated
+ classes with virtual bases.
+
+Wed Dec 28 08:31:00 1994 Mike Stump <mrs@cygnus.com>
+
+ * parse.y (TYPEID): Strip top-level cv-qualifiers on typeid
+ expressions.
+ * gc.c (build_typeid): Ditto.
+
+Thu Dec 22 17:26:33 1994 Mike Stump <mrs@cygnus.com>
+
+ * cvt.c (build_up_reference): Fix breakage introduced on Nov 29,
+ don't assert on complex AGGR inits.
+
+Thu Dec 22 14:32:31 1994 Mike Stump <mrs@cygnus.com>
+
+ * method.c (build_overload_value): Handle pointer to members as
+ template arguments.
+
+Thu Dec 22 13:09:07 1994 Mike Stump <mrs@cygnus.com>
+
+ * typeck.c (unary_complex_lvalue): Don't call sorry if we know how
+ to do take the address of a data member for a pointer to data
+ member.
+
+Thu Dec 22 10:04:19 1994 Mike Stump <mrs@cygnus.com>
+
+ * decl.c (grokdeclarator): Use the typedef name for linkage if the
+ type doesn't otherwise have a name.
+
+ * decl2.c (grokfield): Ditto.
+
+ * class.c (finish_struct): Since we reuse the TYPE_DECL for the
+ DECL_NAME of enums, structs and classes, we have to avoid trying to
+ put it in the TYPE_FIELDS again.
+
+Wed Dec 21 11:07:05 1994 Mike Stump <mrs@cygnus.com>
+
+ * decl2.c (check_classfn): Ignore this parameter on static functions
+ when checking to see if we match.
+
+Tue Dec 20 17:47:02 1994 Mike Stump <mrs@cygnus.com>
+
+ * typeck.c (unary_complex_lvalue): Handle address of non-left most
+ pointers to members by calling get_delta_difference.
+
+Mon Dec 19 22:40:53 1994 Mike Stump <mrs@cygnus.com>
+
+ * decl2.c (check_classfn): Don't use decls_match yet, as it modifies
+ static functions to early.
+
+Thu Dec 19 22:37:48 1994 Mike Stump <mrs@cygnus.com>
+
+ * method.c (make_thunk): Handle encoding of positive thunk offsets.
+
+Sat Dec 17 13:29:50 1994 Doug Evans <dje@canuck.cygnus.com>
+
+ * Make-lang.in (.PHONY): Tell GNU make C++ and c++ are phony targets.
+
+Thu Dec 15 16:32:12 1994 Mike Stump <mrs@cygnus.com>
+
+ * decl2.c (check_classfn): Use decls_match to check if this has
+ already been declared, as the DECL_ASSEMBLER_NAME may have been
+ changed via asm("new_name").
+ * decl.c (decls_match): Make public.
+
+Thu Dec 15 15:17:55 1994 Mike Stump <mrs@cygnus.com>
+
+ * *.[chy] (expand_aggr_init) Add fourth argument to handle
+ distinction between = init and (init) style of initializations.
+ * *.[chy] (finish_decl): Add fifth argument to to handle
+ distinction between = init and (init) style of initializations.
+
+Tue Dec 13 19:16:05 1994 Mike Stump <mrs@cygnus.com>
+
+ Fix some random `explicit' bugs.
+
+ * cvt.c (convert_to_reference): Add third parameter to
+ convert_force.
+ (convert_force): Ditto.
+ * call.c (build_method_call): Ditto.
+ * decl2.c (setup_vtbl_ptr): Ditto.
+ * init.c (expand_virtual_init): Ditto.
+ (build_member_call): Ditto.
+ (build_delete): Ditto.
+ (build_vbase_delete): Ditto.
+ * typeck.c (build_component_addr): Ditto.
+ (build_c_cast): Ditto.
+ (build_modify_expr): Ditto.
+ * cp-tree.h (CONV_NONCONVERTING): Ditto. Add so that we can
+ distinguish the context in which the conversion appears. Add thrid
+ argument to build_c_cast.
+ * cvt.c (cp_convert): Pass whether or not we want to consider
+ non-converting constructors down to build_method_call.
+ * decl2.c (reparse_absdcl_as_casts): Add third argument to
+ build_c_cast.
+ * gc.c (build_m_desc): Ditto.
+ * init.c (build_new): Ditto.
+ * parse.y (expr_no_commas): Ditto.
+ (primary): Ditto.
+ * typeck.c (build_x_function_call): Ditto.
+ (build_static_cast): Ditto.
+ (build_reinterpret_cast): Ditto.
+ (build_const_cast): Ditto.
+ (build_c_cast): Ditto.
+ (build_ptrmemfunc): Ditto.
+ * typeck2.c (build_functional_cast): Ditto.
+ * init.c (expand_aggr_init): Added LOOKUP_ONLYCONVERTING to
+ expand_aggr_init_1 as inits are converted to the destination type.
+
+Tue Dec 13 16:18:57 1994 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * Make-lang.in (cc1plus): Depends on c-pragma.o.
+
+ * Makefile.in (OBJ{DEP,}S): Add ../c-pragma.o.
+
+ * lex.c (check_newline): If the #pragma is not recognized by g++,
+ try machine-specific ones too.
+ (handle_sysv_pragma): Copied from c-lex.c.
+
+Mon Dec 12 23:53:06 1994 Mike Stump <mrs@cygnus.com>
+
+ * except.c (expand_throw): Fix Dec 6th change, build_new likes a
+ reference better.
+
+Mon Dec 12 18:01:00 1994 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck.c (build_binary_op): Lose checks on TYPE_PTRMEMFUNC_P with
+ IS_AGGR_TYPE, since now they will not both be set on the same type.
+
+ * pt.c (do_pending_expansions): Don't clear TREE_PUBLIC on
+ instantiations controlled by -fexternal-templates.
+
+ * decl.c (duplicate_decls): Don't complain about different values of
+ __attribute__ ((const)) and ((noreturn)).
+
+Fri Dec 9 18:17:37 1994 Doug Evans <dje@cygnus.com>
+
+ * Makefile.in (BISONFLAGS): Delete --yacc.
+ (PARSE_H): Depend on $(PARSE_C), for parallel makes.
+ (PARSE_C): Undo last patch.
+
+Fri Dec 2 10:44:36 1994 Mike Stump (mrs@wombat.gnu.ai.mit.edu)
+
+ * Makefile.in (BISONFLAGS): Add --yacc so that output winds up in
+ y.tab.c.
+
+Thu Dec 8 17:39:46 1994 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (finish_decl): Don't call obscure_complex_init for decls
+ of indeterminate size.
+
+Wed Dec 7 16:49:22 1994 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (obscure_complex_init): Function to tweak the decl to
+ prevent expand_decl from tring to initialize it.
+ (finish_decl): Use it rather than writing the same code in three
+ different places.
+
+ * parse.y (bad_parm): Stop trying to support parms without types.
+
+Wed Dec 7 12:06:56 1994 Mike Stump <mrs@cygnus.com>
+
+ * decl2.c (grokfield): Make asm specs on static member functions
+ work.
+
+Tue Dec 6 15:43:20 1994 Mike Stump <mrs@cygnus.com>
+
+ * except.c (expand_throw): Make a copy of the thrown object.
+
+Tue Dec 6 14:16:34 1994 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * parse.y: : has lower precedence than =.
+
+Tue Dec 6 12:46:17 1994 Mike Stump <mrs@cygnus.com>
+
+ * decl.c (pushdecl): Use DECL_NAME of VAR_DECLs to avoid namespace
+ manglings.
+ (grokvardecl): Add namespace into variable name.
+
+Tue Dec 6 11:26:55 1994 Mike Stump <mrs@cygnus.com>
+
+ * decl2.c (current_namespace_id): New routine to transform a simple
+ name into a name in a namespace.
+ * decl.c (grokdeclarator): Use it.
+ * decl2.c (get_namespace_id): Find the name of the current
+ namespace.
+ (push_namespace, pop_namespace): Complete out missing
+ functionality.
+
+Mon Dec 5 17:11:51 1994 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * class.c (finish_struct): Don't use LONG_LONG_TYPE_SIZE, as it may
+ not be defined. Fix warning message for enums and restore warning
+ for non-enums.
+
+ * decl2.c (push_namespace): Dummy function.
+ (pop_namespace): Ditto.
+ (do_namespace_alias): Ditto.
+ (do_using_decl): Ditto.
+ (do_using_directive): Ditto.
+
+ * parse.y: New token NSNAME for namespace names.
+ (extdef): Add namespace, using definitions.
+ (using_decl): New rule for using declarations.
+ (any_id): New rule for identifiers with any degree of scoping.
+ (identifier): Add NSNAME.
+ (notype_identifier): Ditto.
+ (component_decl): Add using_decl.
+ (nested_name_specifier): Add NSNAME SCOPE.
+
+ * typeck.c (convert_for_assignment): Handle conversions between
+ enums and bool.
+
+ * decl.c (duplicate_decls): Only propagate DECL_MAIN_VARIANT on
+ FUNCTION_DECLs.
+
+Mon Dec 5 13:03:16 1994 Mike Stump <mrs@cygnus.com>
+
+ * class.c (finish_struct): Give an error if one tries to declare a
+ bit-field's size greater than a long long, as the backend will dump.
+ It is not an error to declare an enum bit-field greater than its
+ precision. Warn if an enum bit-field is too small to hold all
+ its values.
+
+Mon Dec 5 11:41:50 1994 Mike Stump <mrs@cygnus.com>
+
+ * typeck.c (convert_for_assignment): Use cp_convert instead of
+ convert so that we don't get static casts.
+
+Sun Dec 4 11:59:01 1994 Mike Stump <mrs@cygnus.com>
+
+ * cvt.c (cp_convert): Don't complain about int->enum conversion if
+ we are doing static casts.
+
+Fri Dec 2 18:32:41 1994 Mike Stump <mrs@cygnus.com>
+
+ * error.c (dump_expr): Do something more intelligent with SAVE_EXPRs
+ when dumping expressions in error messages.
+
+Fri Dec 2 17:04:27 1994 Mike Stump <mrs@cygnus.com>
+
+ * gc.c (build_dynamic_cast): Change interface to libg++, ensure that
+ the return type is the right type, and make references work.
+
+Fri Dec 2 16:36:43 1994 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * decl.c (poplevel): Don't be confused by function-scope
+ declarations of non-nested functions.
+ (duplicate_decls): Propagate DECL_MAIN_VARIANT.
+ (pushdecl): Use duplicate_decls to copy info from old decl into new
+ function-scope one rather than doing it here.
+
+ * decl2.c (mark_inline_for_output): Deal with the DECL_MAIN_VARIANT
+ of this decl, in case this is a function-scope declaration.
+
+ * decl.c (finish_enum): Make sure that the type has the right
+ precision when we call fixup_*_type.
+
+Tue Nov 29 19:12:07 1994 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * cvt.c (build_up_reference): Strip superfluous NOP_EXPRs; we do
+ want to build up references to rvalues if possible.
+ (cp_convert): Stick on a NOP_EXPR when converting to the same type.
+
+Tue Nov 29 11:28:59 1994 Mike Stump <mrs@cygnus.com>
+
+ * parse.y (maybe_raises): Handle throw ().
+ * parse.y (ansi_raise_identifier): grok type-ids in exception
+ specifications.
+ * tree.c (build_exception_variant): Use list compare to check if
+ two exception specifications match.
+ * decl.c (duplicate_decls, bad_specifiers): Enhance wording on error
+ messages.
+ * call.c (build_method_call): Remove TREE_RAISES.
+ * cvt.c (convert_to_aggr): Ditto.
+ * typeck.c (build_function_call_real, convert_arguments): Ditto.
+ * init.c (expand_aggr_init_1): Ditto.
+
+Tue Nov 29 09:50:39 1994 Mike Stump <mrs@cygnus.com>
+
+ * except.c: Add support for m68k and mips exception handling
+ support.
+
+Tue Nov 29 08:48:33 1994 Mike Stump <mrs@cygnus.com>
+
+ * except.c (expand_end_all_catch): Throw into outer context, if we
+ fall off end of catch handlers.
+
+Mon Nov 28 16:44:41 1994 Mike Stump <mrs@cygnus.com>
+
+ * Makefile.in: Make is easier to decide where parse.[ch] will be
+ built.
+
+Thu Nov 17 20:11:24 1994 Doug Evans <dje@cygnus.com>
+
+ * cp/Make-lang.in (CXX_INSTALL_NAME) Use program_transform_name.
+ (GXX_INSTALL_NAME) Likewise.
+ (CXX_CROSS_NAME) Use program_transform_cross_name.
+ (GXX_CROSS_NAME) Likewise.
+ (c++.install-man): Use program_transform_name on g++.1.
+ (c++.uninstall): Likewise.
+
+Thu Nov 3 18:48:19 1994 Paul Eggert <eggert@twinsun.com>
+
+ * Makefile.in (spew.o, lex.o, pt.o):
+ Depend on $(srcdir)/parse.h, not parse.h.
+
+Mon Nov 28 13:53:03 1994 Mike Stump <mrs@cygnus.com>
+
+ * parse.y (THROW): Fix precedence of throw expressions.
+
+Mon Nov 28 13:15:16 1994 Mike Stump <mrs@cygnus.com>
+
+ * typeck.c (build_unary_op): Allow promotions from bool to int on
+ unary ~.
+
+Sun Nov 27 00:16:21 1994 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * method.c (build_overload_name): Use DECL_ASSEMBLER_NAME for
+ classes when appropriate.
+ (build_overload_nested_name): When dealing with a function context,
+ use ASM_FORMAT_PRIVATE_NAME to tweak the name of the function to
+ avoid conflicts between local classes of the same name.
+
+Wed Nov 23 17:59:42 1994 Mike Stump <mrs@cygnus.com>
+
+ * gxx.gperf, parse.y, lex.h, hash.h, lex.c (init_lex), delc.c
+ (duplicate_decls, grokdeclarator), cp-tree.h: Add support for
+ `explicit'.
+ * cvt.c (convert_to_reference, cp_convert, build_type_conversion_1,
+ build_type_conversion): Use LOOKUP_ONLYCONVERTING in
+ build_method_calls so that non-converting constructors are not used.
+ * call.c (build_method_call): If we shouldn't use a non-converting
+ constructor, then don't.
+
+Wed Nov 23 14:46:56 1994 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * call.c (build_method_call): Don't try to synthesize methods yet.
+
+Tue Nov 22 12:45:21 1994 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * pt.c (push_template_decls): Create CONST_DECLs for template
+ constant parameters, not VAR_DECLs.
+
+Sat Nov 19 15:28:31 1994 Jim Wilson (wilson@chestnut.cygnus.com)
+
+ * typeck.c (build_binary_op_nodefault): Can shorten shift only if
+ shift count is less than size in bits of arg0.
+
+Thu Nov 17 15:30:50 1994 Mike Stump <mrs@cygnus.com>
+
+ * gxx.gperf, hash.h, lex.c (init_lex, real_yylex), parse.y: Add new
+ ANSI keywords and, and_eq, bitand, bitor, explicit, namespace, not,
+ not_eq, or, or_eq, typename, using, xor, xor_eq to g++. Still need
+ to add support for explicit, namespace, typename, and using, support
+ for the rest is already in.
+
+Thu Nov 17 10:56:50 1994 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * typeck2.c (build_m_component_ref): Check the basetype of the
+ member pointer against the main variant of the object type.
+
+Mon Nov 14 14:21:52 1994 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * cvt.c (convert_to_reference): Make sure that the original expr
+ gets its type back when converting a reference.
+
+ * method.c (build_overload_name): Clear numeric_outputed_need_bar here.
+ (build_decl_overload): Instead of here.
+
+Tue Nov 8 17:11:24 1994 Jason Merrill <jason@phydeaux.cygnus.com>
+
+ * cvt.c (cp_convert): Don't build a TARGET_EXPR if we're not in a
+ function.
+
+ * typeck.c (convert_for_initialization): Handle initialization from
+ a TARGET_EXPR.
+
+Sun Nov 6 01:34:24 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * pt.c (lookup_nested_type_by_name): Fix list-walking logic.
+ (tsubst): When replacing a TEMPLATE_TYPE_PARM, propagate
+ TYPE_READONLY and TYPE_VOLATILE from the argument.
+ (unify): When unifying with a TEMPLATE_TYPE_PARM, remove cv-quals
+ present in parm from arg.
+ (type_unification): Strip REFERENCE_TYPE from the argument type.
+ (unify): Don't strip REFERENCE_TYPE from the argument type.
+
+Sat Nov 5 22:42:15 1994 Greg McGary (gkm@magilla.cichlid.com)
+
+ * pt.c (do_type_instantiation): Check to see if there's a
+ IDENTIFIER_TEMPLATE on a class before calling
+ instantiate_member_templates().
+
+Fri Nov 4 19:04:18 1994 Mike Stump <mrs@cygnus.com>
+
+ * gc.c (get_bad_cast_node): New routine to support compile time
+ throws of bad_cast.
+ * gc.c (build_dynamic_cast): Support throwing of bad_cast at compile
+ time.
+
+Fri Nov 4 11:12:00 1994 Mike Stump <mrs@cygnus.com>
+
+ * except.c: Add hppa support.
+
+Fri Nov 4 10:50:50 1994 Mike Stump <mrs@cygnus.com>
+
+ * except.c: Add rs6000 support.
+
+Thu Nov 3 14:24:23 1994 Mike Stump <mrs@cygnus.com>
+
+ * except.c (do_unwind): Add i[34]86 support.
+
+Thu Nov 3 00:10:46 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * pt.c (do_pending_expansions): Unset TREE_PUBLIC on implicit
+ instantiations.
+
+Wed Nov 2 15:08:24 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * decl.c (finish_function): emit types used in method parameters
+ into symbol table.
+
+Wed Nov 2 15:05:47 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * pt.c (process_template_parm): Allow pointer to member function
+ template parameter types.
+ (uses_template_parms): Handle pointer to member function
+ CONSTRUCTORs.
+
+ * g++.c (main): Cast first argument of bzero to (char *).
+ Pass -lstdc++ instead of -lg++ unless we are invoked as 'g++'.
+
+Mon Oct 31 14:50:48 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * gc.c (build_dynamic_cast): rewrite to make it work.
+ * class.c (finish_vtbls): build more vtables if flag_rtti is on.
+ * class.c (modify_all_direct_vtables): ditto.
+ * init.c (expand_direct_vtbls_init): expand more vtables if
+ flag_rtti is on.
+ * decl.c (init_type_desc): add default return.
+
+Tue Oct 25 17:13:09 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * tree.c (debug_binfo): get rid of the initial size entry of
+ vtable.
+ * cp-tree.h: change flag_dossier to flag rtti, define type
+ descriptor type nodes.
+ * decl.c (init_type_desc): new function to initialize type
+ descriptor type nodes.
+ * decl.c (record_builtin_type): change flag_dossier to flag_rtti.
+ * lex.c (init_lex): ditto.
+ * decl.c : change variable flag_dossier to flag_rtti.
+ * decl.c (duplicate_decls): get rid initial size entry of vtable.
+ * decl.c (hack_incomplete_structures): take out assert 164.
+ * search.c (get_abstract_virtuals_1): ditto.
+ * search.c (dfs_init_vbase_pointers): change CLASSTYPE_DOSSIER to
+ CLASSTYPE_RTTI.
+ * parse.y: ditto.
+ * class.c (prepare_fresh_vtable): for virtual bases, get right
+ offset.
+ * class.c (add_virtual_function): change flag_dossier to
+ flag_rtti.
+ * class.c (modify_one_vtable): modify the right rtti entry.
+ * class.c (override_one_vtable): get rid of size entry.
+ * class.c (finish_struct): change flag_dossier to flag_rtti, and
+ build extra vtables, build type descriptors for polymorphic
+ classes.
+ * gc.c (build_headof): make headof() works correctly with new
+ rtti.
+ * gc.c (build_typeid): make this function work with new rtti.
+ * gc.c (get_typeid): make this function work with new rtti.
+ * gc.c (build_bltn_desc): new function for new rtti.
+ * gc.c (build_user_desc): ditto.
+ * gc.c (build_class_desc): ditto.
+ * gc.c (build_ptr_desc): ditto.
+ * gc.c (build_attr_desc): ditto.
+ * gc.c (build_func_desc): ditto.
+ * gc.c (build_ptmf_desc): ditto.
+ * gc.c (build_ptmd_desc): ditto.
+ * gc.c (build_t_desc): ditto.
+ * gc.c : comment out old build_t_desc, build_i_desc, build_m_desc.
+
+Tue Oct 25 13:37:41 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * call.c (convert_harshness): Check for TREE_UNSIGNED differences
+ after checking for integral conversions.
+
+Sun Oct 23 13:19:55 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * decl2.c: Declare flag_access_control.
+ (struct lang_f_options): Add access-control.
+ * expr.c (cplus_expand_expr, NEW_EXPR): Unset flag_access_control
+ for the call to expand_aggr_init to copy the object out of the
+ pcc_struct_return slot.
+ * search.c (compute_access): if (!flag_access_control) return
+ access_public.
+
+Fri Oct 21 00:32:54 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * lex.c (cons_up_default_function): Don't try to defer method
+ synthesis now.
+
+ * decl.c (init_decl_processing): Use __pure_virtual for abort_fndecl
+ instead of abort, since the OSF/1 dynamic linker doesn't like to see
+ relocation entries for abort.
+
+ * tree.c (array_type_nelts_total): Use sizetype, not
+ integer_type_node.
+ (array_type_nelts_top): Ditto.
+
+Thu Oct 20 15:48:27 1994 Mike Stump <mrs@cygnus.com>
+
+ * decl.c (grokdeclarator): Added handling for catch parameters
+ (CATCHPARM).
+ * except.c (expand_start_catch_block): Use the new CATCHPARM context
+ instead of NORMAL.
+ * except.c (expand_throw): Don't let convert_to_reference complain
+ about what we are doing.
+
+Thu Oct 20 12:55:24 1994 Jim Wilson (wilson@cygnus.com)
+
+ * method.c (emit_thunk): Call instantiate_virtual_regs.
+
+Wed Oct 19 14:15:33 1994 Mike Stump <mrs@cygnus.com>
+
+ * except.c (expand_exception_blocks): Make sure throw code doesn't
+ get put in function that won't be output.
+
+Mon Oct 17 18:03:15 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * decl.c (init_decl_processing): Make alloca a builtin.
+
+Thu Oct 27 21:10:25 1994 Craig Burley (craig@burley)
+
+ * g++.c (main): Only decrement "added" and set "library" to
+ NULL when "library" != NULL (just like 940829 fix).
+
+Mon Oct 17 15:56:11 1994 Mike Stump <mrs@cygnus.com>
+
+ * except.c (expand_start_catch_block): Make sure the false label
+ gets onto the permanent obstack, as it is used for the exception
+ table.
+
+Fri Oct 14 18:54:48 1994 Mike Stump <mrs@cygnus.com>
+
+ * class.c (modify_one_vtable): Since the DECL_CONTEXT of fndecl can
+ be set just below, use current_fndecl instead.
+
+Fri Oct 14 15:12:22 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * init.c (expand_aggr_vbase_init_1): Don't call expand_aggr_init_1
+ with LOOKUP_SPECULATIVELY.
+ (expand_default_init): Abort if build_method_call returns NULL_TREE.
+
+ * typeck.c (build_modify_expr): Don't just build a MODIFY_EXPR if
+ the rhs is a TARGET_EXPR.
+
+ * parse.y (left_curly): Anonymous types are not affected by #pragma
+ interface/implementation.
+
+ * method.c (synthesize_method): Don't call setup_vtbl_ptr for the
+ default constructor if it isn't needed.
+
+ * lex.c (cons_up_default_function): Do synthesize methods for
+ anonymous types if necessary.
+
+Thu Oct 13 17:44:55 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * method.c (build_decl_overload): Set numeric_outputed_need_bar to 0.
+
+Wed Oct 12 13:27:57 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * typeck.c (build_modify_expr): Understand how to copy an aggregate.
+
+ * init.c (expand_default_init): Ditto. Also remove some of the
+ crufty code that assumes methods will not be synthesized properly.
+
+ * lex.c (cons_up_default_function): If the containing type has no
+ name, these functions should never need to be called, so just
+ declare them.
+
+ * lex.c (real_yylex): Use HOST_BITS_PER_WIDE_INT to determine the
+ bitmask for lexing character constants.
+
+ * call.c (build_method_call): Disable code that tries to do tricky
+ stuff with a default parameter that is a constructor call, but
+ actually does other tricky stuff that breaks things.
+
+Wed Oct 12 16:14:01 1994 Benoit Belley <belley@cae.ca>
+
+ * decl.c (finish_enum): Disable code which forces enums to be signed,
+ since this conflicts with their use as bitfields. type_promotes_to
+ handles promotion of enums of underlying unsigned types to signed
+ integer types.
+
+Wed Oct 12 13:24:03 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * cvt.c (type_promotes_to): Also promote enums to long if
+ appropriate.
+
+ * typeck.c (default_conversion): Don't expect type_promotes_to to
+ return a main variant.
+
+Wed Oct 12 12:19:45 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * call.c (build_scoped_method_call): Don't lose side effects in the
+ object expression when calling a non-existent destructor.
+
+Fri Sep 2 19:05:21 1994 Rohan Lenard (rjl@iassf.easams.com.au)
+
+ * call.c (build_scoped_method_call): Remove erroneous error message
+ when destructor call is written as a scoped call.
+
+Tue Oct 11 23:48:31 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * various: Cast pointer arguments to bzero and bcopy to char *.
+
+Tue Oct 11 19:34:32 1994 Mike Stump <mrs@cygnus.com>
+
+ * class.c (get_derived_offset): Added a type parameter to limit how
+ far up the CLASSTYPE_VFIELD_PARENT chain we search.
+ * class.c (modify_one_vtable, fixup_vtable_deltas): When forming the
+ offset to put into the vtable for the this parameter, make sure we
+ don't offset from a parent of the DECL_CONTEXT of the function.
+
+Tue Oct 11 16:10:52 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * pt.c (do_function_instantiation): Set DECL_EXTERNAL and
+ TREE_STATIC when setting DECL_INTERFACE_KNOWN.
+ (do_type_instantiation): Ditto.
+
+ * lex.c (cons_up_default_function): Set DECL_INTERFACE_KNOWN,
+ DECL_EXTERNAL and TREE_STATIC as appropriate.
+
+ * decl2.c (finish_file): Also synthesize methods that don't have
+ DECL_EXTERNAL set. Set interface_unknown before doing so.
+
+ * decl.c (start_function): If DECL_INTERFACE_KNOWN is set on the
+ function decl, don't muck with TREE_PUBLIC and DECL_EXTERNAL.
+
+Mon Oct 10 00:56:53 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * lex.c (cons_up_default_function): Mark methods in a template class
+ as template instances. Store the values of interface_unknown and
+ interface_only for do_pending_inlines.
+ (do_pending_inlines): Use them.
+
+ * decl2.c (finish_file): If we haven't seen a definition of a
+ function declared static, make the decl non-PUBLIC so compile_file
+ can give an error.
+
+Sun Oct 9 02:42:29 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * method.c (do_build_copy_constructor): Handle anonymous unions.
+ (do_build_assign_ref): Ditto.
+ (largest_union_member): Move from lex.c.
+
+Sat Oct 8 14:59:43 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ Re-implement g++'s vague linkage independent of TREE_PUBLIC.
+ * pt.c (instantiate_member_templates): Lose redundant
+ -fexternal-templates handling.
+ (tsubst): Set TREE_PUBLIC and DECL_EXTERNAL on new decls. Don't set
+ TREE_STATIC or DECL_INTERFACE_KNOWN.
+ (do_pending_expansions): Predicate on DECL_INTERFACE_KNOWN instead
+ of DECL_EXTERNAL for explicit instantiations.
+ (do_function_instantiation): Do the new thing.
+ (do_type_instantiation): Ditto.
+ (instantiate_template): Deal with member templates defined in a .cc
+ file with -fexternal-templates.
+ * except.c (expand_exception_blocks): Use DECL_LINKAGE_KNOWN to
+ decide whether to stick builtin_throw here.
+ * decl2.c (import_export_inline): Predicate on DECL_INTERFACE_KNOWN
+ rather than TREE_PUBLIC. Generally fix rules.
+ (finish_file): Use DECL_INITIAL to determine whether or not a method
+ has been synthesized, rather than TREE_ASM_WRITTEN.
+ * decl.c (warn_extern_redeclared_static): Use DECL_PUBLIC instead of
+ TREE_PUBLIC.
+ (pushdecl): Ditto.
+ (duplicate_decls): Ditto. Deal with DECL_DECLARED_STATIC and
+ DECL_INTERFACE_KNOWN.
+ (redeclaration_error_message): Fix checking for conflicting linkage.
+ (define_function): Set DECL_INTERFACE_KNOWN.
+ (grokfndecl): Function decls are PUBLIC until we are sure about
+ their linkage. Set DECL_DECLARED_STATIC as needed.
+ (start_function): Deal with linkage. Move pushdecl after linkage
+ magic.
+ (finish_function): Don't set TREE_ASM_WRITTEN on discarded inlines.
+ * cp-tree.h (lang_decl_flags): Add interface_known and
+ declared_static.
+ (DECL_INTERFACE_KNOWN): New macro.
+ (DECL_DECLARED_STATIC): New macro.
+ (DECL_PUBLIC): New macro.
+
+ Clean up bogus use of TREE_PUBLIC.
+ * class.c (alter_access): Fix mistaken use of TREE_PUBLIC (it
+ doesn't correspond to TREE_PROTECTED and TREE_PRIVATE).
+ * init.c (do_friend): Don't arbitrarily set TREE_PUBLIC.
+
+Wed Oct 5 13:44:41 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * call.c (build_overload_call_real): Don't immediately do
+ array->pointer conversion.
+
+ * pt.c (type_unification): If not passing to a reference, strip
+ cv-quals. Also handle array->pointer conversion.
+
+Tue Oct 4 17:45:37 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * decl.c (grokdeclarator): Don't warn about applying const to a
+ const typedef or template type parameter.
+
+ * decl2.c (finish_file): Also synthesize methods after walking the
+ vtables. Ugly ugly ugly.
+
+Mon Oct 3 15:02:41 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * various: Remove lingering remnants of old exception handling code.
+
+ * decl2.c (finish_file): Synthesize methods before walking the
+ vtables, so that the vtables get emitted as needed.
+
+ * decl.c (shadow_tag): Remove obsolete code for pushing tags and
+ dealing with exceptions.
+
+Mon Oct 3 13:05:27 1994 Ian Lance Taylor <ian@sanguine.cygnus.com>
+
+ * Make-lang.in (g++-cross): Depend upon version.o and $(LIBDEPS).
+
+Mon Oct 3 02:59:28 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * decl2.c (finish_file): Fix inline handling.
+
+Sun Oct 2 00:21:56 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ * decl.c (grokdeclarator): Handle redundant scope even better.
+ ({push,pop}_cp_function_context): Take toplev parameter.
+
+ * method.c (synthesize_method): Pass toplev parameter to
+ {push,pop}_cp_function_context depending on decl_function_context
+ (fndecl).
+
+ * typeck.c (build_x_unary_op): Unary & on OFFSET_REFs is always the
+ built-in version.
+
+ * method.c (synthesize_method): Don't be confused by __in_chrg
+ parameter.
+
+ * class.c (popclass): Set C_C_D like start_function does.
+
+ * decl.c (grokdeclarator): Handle redundant scope better.
+
+ * parse.y (expr_or_declarator): Add '(' expr_or_declarator ')' rule.
+ (direct_notype_declarator): Ditto.
+ (complex_direct_notype_declarator): Remove it here.
+
+Sat Oct 1 21:42:18 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * init.c (resolve_offset_ref): Fix types used in resolving .*
+ expressions.
+
+Sat Oct 1 15:18:49 1994 Jason Merrill (jason@phydeaux.cygnus.com)
+
+ Beginnings of work to synthesize methods only when needed.
+ * call.c (build_method_call): Synthesize methods as necessary
+ (currently never necessary).
+ * class.c (popclass): Don't try to set C_C_D here, as it'll end up
+ on the wrong obstack.
+ * decl.c (push_cp_function_context): Mostly copied from
+ push_c_function_context.
+ (pop_cp_function_context): Similarly.
+ (finish_function): Reverse order of poplevel and pop_nested_class so
+ that current_class_decl is restored properly.
+ (start_function): Ditto.
+ (finish_function): Add parameter 'nested'. Don't call
+ permanent_allocation if (nested).
+ * various: Pass extra parameter to finish_function.
+ * decl2.c (finish_file): Reorganize end-of-file inline handling,
+ synthesizing methods as necessary.
+ * lex.c (cons_up_default_function): Call mark_inline_for_output.
+ Only synthesize methods immediately if #pragma implementation
+ (currently disabled).
+ (do_pending_inlines): Call synthesize_method.
+ * method.c (synthesize_method): New function; all method synthesis
+ goes through here. Calls do_build_assign_ref and
+ do_build_copy_constructor.
+ (build_default_constructor): Remove.
+ (build_dtor): Ditto.
+ (build_assign_ref): Rename to do_build_assign_ref and remove stuff
+ done by synthesize_method.
+ (build_copy_constructor): Similarly.
+
+Thu Sep 29 16:58:52 1994 Mike Stump <mrs@cygnus.com>
+
+ * typeck.c (c_expand_return): Use magic so the backend can fixup the
+ assignment into the return register, so cleanups won't clobber it.
+
+Thu Sep 29 13:08:50 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * method.c (hack_identifier): Don't call assemble_external for
+ template decls.
+
+ * decl.c (finish_decl): Also end temporary allocation if the decl in
+ question has a type of error_mark_node.
+
+Wed Sep 28 21:45:00 1994 Mike Stump <mrs@cygnus.com>
+
+ * typeck.c (build_modify_expr): When optimizing ?: on lhs, make sure
+ that if the ?: was a reference type, that the subparts will be also.
+
+Wed Sep 28 16:14:04 1994 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * except.c (register_exception_table): Use Pmode, not PTRmode.
+
+Fri Sep 23 13:54:27 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * lex.c (do_pending_inlines): Do method synthesis after the
+ pending_inlines have been reversed.
+
+Thu Sep 22 12:53:03 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * decl2.c (finish_file): Fix Brendan's fix: Only call
+ register_exception_table if there is a non-empty exception table.
+
+Thu Sep 22 12:03:46 1994 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * decl2.c (finish_file): Only do register_exception_table if
+ -fhandle-exceptions is being used.
+
+Wed Sep 21 19:01:51 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * except.c (output_exception_table_entry): Simplify
+ by using assemble_integer.
+ (build_exception_table): Change to return a count.
+ Cleanup to use standard macros, instead of hard-wired
+ sparc asm format. Don't make __EXCEPTION_TABLE__ global.
+ (register_exception_table): New function. Generate call to builtin.
+ * decl2.c (finish_file): Call register_exception_table.
+ * cp-tree.h (build_exception_table): Fix prototype.
+
+Wed Sep 21 13:20:42 1994 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * tree.c (break_out_calls): Don't try to duplicate the DECL_INITIAL.
+
+ * decl2.c (delete_sanity): Give an error at trying to delete a
+ function.
+
+Wed Sep 21 11:47:10 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * lex.c (cons_up_default_function): Mark synthesized destructors
+ inline.
+
+ * decl.c (duplicate_decls): Ignore redeclarations of wchar_t as
+ something other than __wchar_t, complaining if -pedantic and not in
+ a system header.
+
+Tue Sep 20 09:43:28 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (xref_tag): Set up BINFO_INHERITANCE_CHAIN on base binfos
+ here.
+
+ * typeck.c (build_modify_expr): Require complete type after checking
+ for error_mark_node.
+
+ * call.c (build_method_call): Print parmtypes when complaining of
+ ambiguous call.
+
+ * typeck.c (build_modify_expr): Handle assignment to array from
+ non-array.
+
+ * decl.c (lookup_name_real): Deal with got_scope == error_mark_node.
+
+ * call.c (build_method_call): Don't bother with the exact match.
+
+Mon Sep 19 00:51:39 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * init.c (expand_aggr_init): If we munge the type of the variable,
+ also munge the type of the initializer.
+
+ * decl.c (grokdeclarator): Use <= when comparing to RID_LAST_MODIFIER.
+ (init_decl_processing): Push artificial declaration of wchar_t so
+ people don't have to declare it before they can use it.
+
+ * error.c (cp_line_of): return lineno in lieu of 0.
+
+ * typeck.c (convert_for_assignment): Handle conversion of pmfs to
+ int and bool.
+ (build_component_ref): Fold the COMPONENT_REF in case it can be
+ reduced.
+
+ * typeck2.c (store_init_value): Don't pedwarn about non-constant
+ bracketed initializers for automatic variables.
+
+Sun Sep 18 10:12:12 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * error.c (dump_decl): Don't say `typedef enum foo foo'.
+
+ * decl.c (start_decl): Don't set TREE_PUBLIC on template decls just
+ because they're affected by #pragma i/i. We'll deal with that when
+ they get instantiated.
+
+ * typeck.c (build_unary_op): Clean up cruft in ADDR_EXPR case.
+
+ * class.c (instantiate_type): Set TREE_CONSTANT on instantiated
+ ADDR_EXPRs if appropriate.
+
+ * decl.c (build_ptrmemfunc_type): Unset IS_AGGR_TYPE on pmf types.
+
+ * typeck.c (build_ptrmemfunc): Handle &overloaded_method as an
+ initializer properly.
+ * typeck2.c (digest_init): Ditto.
+
+ * tree.c (cp_build_type_variant): Like c_build_type_variant, except
+ it uses build_cplus_array_type.
+ * *.c: Use cp_build_type_variant instead of c_build_type_variant.
+
+ * pt.c (do_type_instantiation): Don't try to instantiate nested
+ enums.
+
+Tue Sep 13 10:56:58 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cvt.c (build_up_reference): Handle preincrement and predecrement
+ properly.
+
+Tue Sep 13 09:51:59 1994 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * decl.c (finish_decl): Only lay out the rtl for DECL if it is, in
+ fact, static.
+
+Mon Sep 12 14:40:30 1994 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * decl.c (finish_decl): Lay out the rtl for DECL before doing
+ grok_reference_init, in case it's static.
+
+Mon Sep 12 12:45:38 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * class.c (finish_struct): Don't synthesize constructors if the
+ class has a field with the same name as the class. Don't die on
+ classes with no constructors or destructors. Don't die if the head
+ and tail of the class are in different files.
+
+ * decl.c (grokdeclarator): Don't treat a function pointer field
+ with the same name as the class as a constructor.
+
+Fri Sep 9 13:17:00 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (build_c_cast): Pull constant values out of their
+ variables here.
+
+ * decl.c (duplicate_decls): Only propagate DECL_CHAIN in
+ FUNCTION_DECLs and TEMPLATE_DECLs.
+
+Thu Sep 8 10:07:48 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (duplicate_decls): Propagate DECL_CHAIN in all DECLs that
+ have it.
+
+ * pt.c (unify): REALs and INTEGERs only unify with their own genus.
+ (instantiate_member_templates): Don't muck with DECL_EXTERNAL and
+ TREE_PUBLIC unless -fexternal-templates.
+
+Wed Sep 7 13:17:10 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * pt.c (do_type_instantiation): Call instantiate_member_templates.
+ Deal with specializations.
+ (tsubst): Don't stick the mangled name in DECL_NAME for function
+ instantiations. Don't push them, either.
+
+ * decl2.c (grokfield): Move code for generating the
+ DECL_ASSEMBLER_NAME for static members from here.
+ * method.c (build_static_name): To here.
+ * decl.c (grokvardecl): Call build_static_name.
+ (duplicate_decls): Keep old DECL_ASSEMBLER_NAME.
+
+Mon Sep 5 12:49:18 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * call.c (build_method_call): if -Wsynth, warn when selecting
+ synthesized op= over user-supplied one cfront would select.
+ * decl2.c (lang_decode_option): Handle -Wsynth.
+
+Fri Sep 2 15:11:59 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (finish_enum): Overhaul to fix several bugs.
+ (start_enum): Disable useless code.
+
+Thu Sep 1 16:04:54 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (c_expand_return): Warn about returning a reference to a
+ temporary.
+ (convert_arguments): Increment argument counter when using default
+ arguments, too.
+
+Wed Aug 31 14:29:22 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (finish_decl): If the type of decl is error_mark_node,
+ don't bother trying to do anything.
+
+ * typeck.c (convert_for_initialization): If the rhs contains a
+ constructor call, pretend the lhs type needs to be constructed.
+
+ * init.c (expand_default_init): If we stick the object inside the
+ initializer, mark the initializer used.
+
+Tue Aug 30 13:50:18 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * method.c (build_assign_ref): return *this;
+ (build_assign_ref): Fix base assignment order.
+ (build_copy_constructor): Fix member init order.
+
+Mon Aug 29 13:54:39 1994 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * g++.c (main): Remember to clear out SAW_SPECLANG after we see
+ its argument.
+
+Sat Aug 27 09:36:03 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * method.c (build_copy_constructor): Also copy virtual bases.
+
+Fri Aug 26 17:05:15 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * lex.c (do_pending_inlines): Clear out pending_inlines before doing
+ any synthesis. Also first set deja_vu on all pending_inlines.
+
+ * method.c (build_assign_ref): Use build_member_call to invoke base
+ operator=, rather than build_modify_expr. And use
+ build_reference_type instead of TYPE_REFERENCE_TO.
+ (build_copy_constructor): Use TYPE_NESTED_NAME to identify the
+ basetype.
+
+ * decl2.c (grokfield): Don't complain about undefined local class
+ methods.
+
+ * class.c (finish_struct): Don't try to synthesize methods here.
+ * lex.c (do_pending_inlines): Instead, synthesize them here.
+ (init_lex): Initialize synth_obstack.
+ (cons_up_default_function): Stick synthesis request on
+ pending_inlines.
+
+Fri Aug 26 12:24:14 1994 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * call.c (build_method_call) [PCC_STATIC_STRUCT_RETURN]: Also
+ accept an RTL_EXPR in what we're about to use for the instance,
+ since anything which would end up with pcc_struct_return set
+ inside cplus_expand_expr.
+
+ * cp-tree.h (cons_up_default_function): Note change of prototype.
+
+Thu Aug 25 23:05:30 1994 Gerald Baumgartner (gb@cs.purdue.edu)
+
+ * class.c (finish_struct): Undid change from Aug 21 testing
+ CLASSTYPE_INTERFACE and CLASSTYPE_VTABLE_NEEDS_WRITING.
+ * parse.y (left_curly): Ditto, undid change from Aug 21.
+ * decl.c (xref_tag): Undid change from Aug 21, set
+ CLASSTYPE_INTERFACE correctly, and added comments.
+
+Thu Aug 25 00:36:31 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ Rework approach to synthesized methods; don't go through the parser
+ anymore.
+ * class.c (finish_struct): Use new synthesis approach.
+ * lex.c (cons_up_default_function): Now just creates declaration,
+ not code.
+ (largest_union_member): #if 0 out.
+ (default_assign_ref_body): Ditto.
+ (default_copy_constructor_body): Ditto.
+ * method.c (build_default_constructor): New function to synthesize X().
+ (build_copy_constructor): Synthesize X(X&).
+ (build_assign_ref): Synthesize X::operator=(X&).
+ (build_dtor): Synthesize ~X().
+
+ * error.c (cp_line_of): If we're dealing with an artificial
+ TYPE_DECL, look at the type instead.
+
+Wed Aug 24 11:11:50 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * init.c (sort_member_init): Check warn_reorder.
+ * decl2.c (lang_decode_option): Handle -W{no-,}reorder.
+
+ * cp-tree.h (CLASSTYPE_SOURCE_LINE): New macro.
+ * error.c (cp_line_of): Use CLASSTYPE_SOURCE_LINE for aggregates.
+ * class.c (finish_struct): Set CLASSTYPE_SOURCE_LINE.
+
+Tue Aug 23 09:28:35 1994 Mike Stump <mrs@cygnus.com>
+
+ * error.c (dump_decl): Improve wording, so that error messages
+ dont't read template<, class foo>...
+
+Mon Aug 22 15:30:51 1994 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * parse.y (label_colon): Also match a TYPENAME as a label name,
+ since they may have declared a class by that name but have also
+ tried to have a local label under the same name.
+
+ * pt.c (coerce_template_parms): Call cp_error, not cp_error_at,
+ for the message so they know at what point it was instantiated.
+
+Sun Aug 21 23:07:35 1994 Gerald Baumgartner (gb@cs.purdue.edu)
+
+ * class.c (finish_struct): Move setting of CLASSTYPE_INTERFACE and
+ CLASSTYPE_VTABLE_NEEDS_WRITING for signatures up to left_curly time.
+ * decl.c (xref_tag): Move setting of CLASSTYPE_INTERFACE and
+ CLASSTYPE_VTABLE_NEEDS_WRITING for signatures down to left_curly time.
+ * parse.y (left_curly): New final resting place for setting
+ CLASSTYPE_INTERFACE and CLASSTYPE_VTABLE_NEEDS_WRITING for signatures.
+
+ * class.c (finish_struct): Don't test for function/field name
+ conflicts in signatures, since all the fields are compiler-constructed.
+
+Fri Aug 19 14:04:47 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * method.c (build_overload_nested_name): in qualified name
+ mangling, the template with value instantiation will have numeric
+ at end and may mixed with the name length of next nested level.
+ Add a '_' in between.
+ * method.c (build_overload_name): ditto.
+ * method.c (build_overload_identifier): ditto.
+
+Thu Aug 18 16:24:43 1994 Mike Stump <mrs@cygnus.com>
+
+ * error.c (dump_decl): Handle NULL args.
+
+Thu Sep 29 16:15:36 1994 Michael I Bushnell <mib@churchy.gnu.ai.mit.edu>
+
+ * g++.c: Rework last change so it's done like collect.c (and
+ gcc.c).
+
+Wed Sep 14 10:17:27 1994 Michael I Bushnell <mib@churchy.gnu.ai.mit.edu>
+
+ * g++.c: Include <sys/errno.h> in case `errno' is a macro
+ as permitted by ANSI C.
+
+Thu Aug 18 12:48:09 1994 Mike Stump <mrs@cygnus.com>
+
+ * class.c (finish_struct): Move setting of CLASSTYPE_INTERFACE and
+ CLASSTYPE_VTABLE_NEEDS_WRITING up to left_curly time.
+ * decl.c (xref_tag): Move setting of CLASSTYPE_INTERFACE and
+ CLASSTYPE_VTABLE_NEEDS_WRITING down to left_curly time.
+ * parse.y (left_curly): New final resting place for setting
+ CLASSTYPE_INTERFACE and CLASSTYPE_VTABLE_NEEDS_WRITING.
+
+Thu Aug 11 11:32:42 1994 H.J. Lu (hjl@nynexst.com)
+
+ * g++.c (main): Only decrement "added" and set "library" to
+ NULL when "library" != NULL.
+
+Sat Aug 13 00:14:52 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (grokdeclarator): Don't set TREE_PUBLIC on a function decl
+ just because its class has a known interface.
+ (decls_match): Deal with new format of template parms.
+
+ * lex.c (cons_up_default_function): Don't play with TREE_PUBLIC and
+ DECL_EXTERNAL here.
+
+Fri Aug 12 01:55:15 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (pushtag): SET_DECL_ARTIFICIAL on gratuitous typedefs.
+ (xref_defn_tag): Ditto.
+ (pushdecl): Only allow artificial typedefs to be shadowed.
+
+ * init.c (emit_base_init): Pass the right binfos to
+ expand_aggr_init_1.
+
+ * class.c (delete_duplicate_fields_1): Make it work right.
+ (finish_struct): Catch function/field name conflict.
+
+ * decl2.c (check_classfn): Pass the function to cp_error, not just
+ the name.
+
+ * init.c (sort_member_init): Warn when order of member initializers
+ does not match order of member declarations.
+ (emit_base_init): Call expand_aggr_init_1 with LOOKUP_PROTECT.
+
+ * error.c (dump_expr): Handle lists of functions.
+
+ * decl.c (start_function): #pragma interface only affects functions
+ that would otherwise be static.
+ (finish_decl): Don't warn about an unused variable if it has both
+ constructor and destructor, since the 'resource allocation is
+ initialization' idiom is relatively common.
+
+ * typeck.c (comp_target_types): Don't handle TEMPLATE_TYPE_PARMs.
+ (comp_target_parms): Ditto.
+ (compparms): Never consider default parms.
+ (common_base_type): Don't choose a virtual baseclass if there is a
+ more derived class in common.
+ (build_conditional_expr): If pedantic, pedwarn about conversion to
+ common base in conditional expr.
+
+ * class.c (instantiate_type): Handle template instantiation better.
+
+ * typeck.c (convert_arguments): Don't try to get tricky and convert
+ to int directly when PROMOTE_PROTOTYPES is set, as it breaks
+ user-defined conversions.
+
+ * lex.c (check_for_missing_semicolon): Also give error at end of
+ file.
+
+ * call.c (build_method_call): Don't promote arrays to pointers here.
+
+ * typeck.c (convert_arguments): Don't require the actual parameter
+ to be of a complete type if the formal parameter is a reference.
+
+Thu Aug 11 15:21:40 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (grokdeclarator): Soften 'static' on member function error
+ to pedwarn.
+
+ * init.c (build_new): Don't automatically save rval.
+ (build_offset_ref): Do field lookup with proper basetype_path.
+
+Thu Aug 11 12:46:54 1994 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * errfn.c (cp_silent): Declare to mark when we should avoid
+ emitting warnings and errors.
+ (cp_error): Check it.
+ (cp_warning): Likewise.
+ (cp_pedwarn): Likewise.
+ (cp_compiler_error): Likewise.
+ (cp_error_at): Likewise.
+ (cp_warning_at): Likewise.
+ (cp_pedwarn_at): Likewise.
+ * call.c (compute_conversion_costs): Set CP_SILENT when we start
+ out, and make sure we turn it off before we leave.
+
+Thu Aug 11 00:02:54 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl2.c (grok_array_decl): Try computing *(A+B) if neither
+ argument is obviously an array.
+
+Wed Aug 10 15:32:04 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (c_expand_start_case): Do cleanups here.
+
+ * parse.y (xcond): Do bool conversion here, too.
+ (simple_stmt, SWITCH case): Don't do cleanups here.
+
+ * decl.c (duplicate_decls): Don't treat builtins that have been
+ explicitly declared specially.
+
+Tue Aug 9 01:16:09 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * tree.c (make_deep_copy): Support copying pointer, reference,
+ function, array, offset and method types.
+
+ * decl.c (init_decl_processing): Mark exit and abort as
+ BUILT_IN_NONANSI so that duplicate_decls is kinder about
+ redeclaration.
+ (duplicate_decls): Don't give two errors for redeclaring a C
+ function with the same parms but a different return type.
+
+ * parse.y (paren_cond_or_null): Do cleanup and bool conversion here.
+ (condition): Instead of here.
+ (simple_stmt, SWITCH case): Also do cleanup here.
+
+ * decl2.c (finish_anon_union): Only break out FIELD_DECLs.
+
+ * call.c (build_method_call): Don't throw away the side effects of
+ the object in a call to a non-existent constructor.
+ * parse.y (primary): Ditto.
+
+ * method.c (build_decl_overload): Oop.
+
+ * decl2.c (lang_decode_option): Deal with flag_no_nonansi_builtin,
+ warn about uselessness of specifying -fansi-overloading.
+
+ * method.c (build_decl_overload): Treat any non-member new with one
+ parameter as __builtin_new.
+
+ * decl.c (init_decl_processing): Setup built-in meanings of exit,
+ _exit and abort.
+
+Mon Aug 8 15:03:30 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * error.c (dump_readonly_or_volatile): Put a space between const and
+ volatile if both apply.
+
+ * init.c (perform_member_init): Clean up after this initialization.
+ (emit_base_init): Clean up after each base init, not after all have
+ been done.
+ (expand_aggr_vbase_init_1): Clean up after this init.
+
+Sun Aug 7 14:55:05 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * call.c (build_method_call): Deal with destroying references.
+
+ * parse.y (condition): Do bool_truthvalue_conversion here.
+ (paren_expr_or_null): And here.
+ (simple_if): Not here.
+ (simple_stmt): Or here.
+
+Sat Aug 6 22:29:45 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y (paren_expr_or_null): Wrap the expression in a
+ CLEANUP_POINT_EXPR.
+ (condition): Ditto.
+
+Sat Aug 6 19:46:37 1994 Rohan Lenard (rjl@easams.com.au)
+
+ * call.c (build_scoped_method_call): Fix error message when
+ destructor call refers to a nonexistent type.
+
+Sat Apr 16 22:43:30 1993 Gerald Baumgartner (gb@cs.purdue.edu)
+
+ * lex.h (rid): Deleted RID_RAISES, it's never used.
+ Moved RID_PUBLIC, RID_PRIVATE, RID_PROTECTED, RID_EXCEPTION,
+ RID_TEMPLATE and RID_SIGNATURE to the end of the enumeration,
+ they don't need to be touched in `grokdeclarator.'
+ (RID_LAST_MODIFIER): Defined macro to be RID_MUTABLE.
+
+ * decl.c (grokdeclarator): Use RID_LAST_MODIFIER instead of
+ RID_MAX as loop limit for finding declaration specifiers.
+
+Sat Apr 3 21:59:07 1993 Gerald Baumgartner (gb@cs.purdue.edu)
+
+ * lex.c (debug_yytranslate): Moved to parse.y since it needs to
+ access `yytname,' which is static in parse.c.
+
+Fri Apr 2 23:36:57 1993 Gerald Baumgarnter (gb@cs.purdue.edu)
+
+ * cp-tree.h (GNU_xref_ref): Fixed typo in extern declaration, it
+ was `GNU_xref_def' instead of `GNU_xref_ref.'
+
+Fri Aug 5 14:20:16 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * pt.c (do_function_instantiation): Don't set TREE_PUBLIC and
+ DECL_EXTERNAL on 'extern' instantiations; wait until EOF to do that.
+ (do_type_instantiation): Ditto.
+
+ * decl2.c (import_export_inline): Decides at EOF what an inline's
+ linkage should be.
+ (finish_file): Call it.
+
+ * decl.c (start_function): Don't rely on the settings of TREE_PUBLIC
+ and DECL_EXTERNAL from do_*_instantiation. Only set
+ DECL_DEFER_OUTPUT on inlines whose linkage might actually change.
+ (finish_function): Use DECL_DEFER_OUTPUT to decide which inlines to
+ mark for later consideration, rather than DECL_FUNCTION_MEMBER_P.
+
+Fri Aug 5 01:12:20 1994 Mike Stump <mrs@cygnus.com>
+
+ * class.c (get_class_offset_1, get_class_offset): New routine to
+ find the offset of the class where a virtual function is defined,
+ from the complete type.
+ * class.c (modify_one_vtable, fixup_vtable_deltas): Use
+ get_class_offset instead of virtual_offset as get_class_offset will
+ always provide the right answer.
+ * tree.c (virtual_offset): Remove. It only ever worked some of the
+ time.
+
+Tue Aug 2 12:44:21 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * call.c (build_method_call): Put back unary_complex_lvalue call
+ that I thought was redundant.
+
+ * typeck.c (c_expand_return): Fix a case I missed before.
+
+Sun Jul 31 17:54:02 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * pt.c (unify): Strip cv-quals from template type arguments (when
+ 'const T*' is matched to 'const char*', that does not mean that T is
+ 'const char').
+
+Fri Jul 29 01:03:06 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * pt.c (do_type_instantiation): Instantiate nested TAGS, not
+ typedefs. Third time's the charm?
+
+ * parse.y (template_parm): Support default template parms.
+ * pt.c (process_template_parm): Ditto.
+ (end_template_parm_list): Ditto.
+ (coerce_template_parms): Ditto.
+ (mangle_class_name_for_template): Ditto.
+ (push_template_decls): Ditto.
+ (unify): Ditto.
+ * method.c (build_overload_identifier): Ditto.
+ * error.c (dump_decl): Ditto.
+
+Wed Jul 27 17:47:00 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * pt.c (do_type_instantiation): Only instantiate nested *classes*.
+
+Tue Jul 26 13:22:40 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * search.c (note_debug_info_needed): Also emit debugging information
+ for the types of fields.
+
+Mon Jul 25 00:34:44 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * pt.c (lookup_template_class): Pass 'template' to
+ coerce_template_parms instead of 'in_decl', since it's a more
+ meaningful context.
+
+ * typeck.c (c_expand_return): Make sure any cleanups for the return
+ expression get run.
+ (build_c_cast): Use CONVERT_EXPR for conversion to void.
+
+ * pt.c (do_type_instantiation): Also instantiate nested types.
+
+ * typeck.c (convert_for_assignment): Don't die when comparing
+ pointers with different levels of indirection.
+
+ * decl.c (grokdeclarator): The sub-call to grokdeclarator for
+ class-local typedefs sets DECL_ARGUMENTS, so we need to clear it
+ out.
+
+ * decl2.c (finish_anon_union): Don't die if the union has no
+ members.
+
+ * decl.c (grokdeclarator): Undo changes to declspecs when we're done
+ so that 'typedef int foo, bar;' will work.
+
+ * decl2.c (finish_file): Don't call expand_aggr_init for
+ non-aggregates.
+
+Mon Jul 25 00:03:10 1994 Teemu Torma (tot@trema.fi)
+
+ * decl.c (finish_function): We can't inline constructors and
+ destructors under some conditions with -fpic, but don't unset
+ DECL_INLINE.
+
+Mon Jul 25 00:03:10 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (build_object_ref): Make sure 'datum' is a valid object.
+
+Sun Jul 24 14:19:31 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * class.c (finish_struct): Don't set DECL_FIELD_BITPOS on
+ non-fields.
+ (finish_struct_methods): Use copy_assignment_arg_p.
+
+ * cvt.c (cp_convert): If expr is an OFFSET_REF, resolve it instead
+ of giving an error.
+
+ * typeck.c (build_binary_op_nodefault): Don't set result_type if we
+ don't know how to compare the operands.
+
+ * decl.c (grokdeclarator): Avoid seg fault when someone uses '__op'
+ as a declarator-id in their program. Like the Linux headers do.
+ Arrgh.
+
+ * tree.c (lvalue_p): Treat calls to functions returning objects by
+ value as lvalues again.
+
+ * typeck.c (build_component_addr): Use convert_force to convert the
+ pointer in case the component type is also a private base class.
+
+ * search.c (get_matching_virtual): Fix bogus warning of overloaded
+ virtual.
+
+ * pt.c (overload_template_name): Set DECL_ARTIFICIAL on the created
+ TYPE_DECL to fix bogus shadowing warnings.
+
+Fri Jul 22 01:15:32 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * init.c (expand_aggr_init_1): const and volatile mismatches do not
+ prevent a TARGET_EXPR from initializing an object directly.
+
+Tue Jul 19 17:55:37 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cvt.c (build_up_reference): Allow building up references to
+ `this', don't warn about making references to artificial variables
+ (like `this').
+
+ * tree.c (lvalue_p): `this' is not an lvalue.
+
+ * call.c (build_method_call): Accept using a typedef name (or
+ template type parameter) for explicit destructor calls.
+
+Wed Jul 13 03:57:54 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * method.c (hack_identifier): Put back old code so lists of
+ non-functions will be handled properly.
+
+ * cp-tree.h (TYPE_NEEDS_CONSTRUCTING): #if 0 out; this macro is now
+ defined in the language-independent tree.h.
+
+ * tree.c (count_functions): Avoid bogus warning when compiling this
+ function.
+
+Mon Jul 11 18:37:20 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (grok_reference_init): Always save the initializer of a
+ reference.
+
+Fri Jul 8 17:41:46 1994 Mike Stump <mrs@cygnus.com>
+
+ * decl.c (cplus_expand_expr_stmt): Wrap statement expressions inside
+ CLEANUP_POINT_EXPRs so that the stack slots can be reused.
+ (disabled for now)
+
+Fri Jul 8 12:59:38 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * method.c (hack_identifier): Fix for new overloading.
+
+ * typeck.c (build_binary_op_nodefault): Don't mess with division by
+ zero.
+
+Fri Jul 8 13:20:28 1994 Gerald Baumgartner (gb@cs.purdue.edu)
+
+ * decl2.c (finish_file): Only call walk_sigtables, if
+ flag_handle_signatures is turned on, don't waste time otherwise.
+
+Fri Jul 8 02:27:41 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (push_overloaded_decl): Don't create overloads of one when
+ shadowing a class type.
+ * typeck.c (build_x_function_call): Complain about overloads of one.
+
+ * decl.c (grokdeclarator): Don't try to treat a char* as a tree.
+ (grokdeclarator): Fix setting of TREE_STATIC.
+ (start_decl): Clear DECL_IN_AGGR_P after calling duplicate_decls.
+
+Thu Jul 7 22:20:46 1994 Gerald Baumgartner (gb@andros.cygnus.com)
+
+ * cp-tree.h (walk_sigtables): Created extern declaration.
+ * decl2.c (walk_sigtables): Created function, patterned after
+ walk_vtables, even though we only need it to write out sigtables.
+ (finish_sigtable_vardecl): Created function.
+ (finish_vtable_vardecl): Changed 0 to NULL_PTR.
+ (finish_file): Call walk_sigtables.
+
+ * sig.c (build_signature_table_constructor): Mark class member
+ function pointed to from signature table entry as addressable.
+
+Thu Jul 7 13:39:37 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (start_decl): Check new decl of static member variable
+ against the declaration in the class here.
+ (grokvardecl): Instead of here.
+
+ * class.c (prepare_fresh_vtable): Call import_export_vtable if not
+ -fvtable-thunks.
+ (build_vtable): Ditto.
+
+ * decl2.c (import_export_vtable): Move logic for deciding the
+ interface of a template class from here.
+ (import_export_template): To here.
+ (finish_vtable_vardecl): Call import_export_template before
+ import_export_vtable.
+
+Wed Jul 6 20:25:48 1994 Mike Stump <mrs@cygnus.com>
+
+ * except.c (init_exception_processing): Setup interim_eh_hook to
+ call lang_interim_eh.
+ * except.c (do_unwind): Propagate throw object value across
+ stack unwinding.
+ * except.c (saved_throw_value): Used to hold the value of the object
+ being thrown. It is always a reference to the real value.
+ * except.c (expand_start_catch_block): Add handling for the
+ value of the exception object.
+ * except.c (expand_start_catch_block): Add handler for the handler,
+ so that throws inside the handler go to the outer block.
+ * except.c (expand_end_catch_block): Ditto.
+ * parse.y (handler_args): Use parm instead, as the other doesn't yet
+ handle references correctly.
+
+Wed Jul 6 17:55:32 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * decl2.c (mark_vtable_entries): If -ftable-thunks, set the
+ vtable entry properly to abort.
+
+Tue Jul 5 14:07:54 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (build_binary_op_nodefault): Downgrade division by zero
+ errors to warnings.
+
+ * call.c (build_overload_call_real): Handle fnname being a list of
+ functions.
+ * typeck.c (build_x_function_call): Pass list of functions to
+ build_overload_call, not just the name.
+ * tree.c (count_functions): Complain when called for invalid
+ argument.
+
+ * decl.c (grokdeclarator): Fix settings of TREE_STATIC, TREE_PUBLIC
+ and DECL_EXTERNAL on static members and initialized const members.
+ * decl2.c (grokfield): Reflect this change.
+
+Fri Jul 1 09:35:51 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y (init): ANSI C++ does not forbid { }.
+
+Thu Jun 30 00:35:22 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl2.c (lang_decode_option): Set warn_nonvdtor along with -Wall.
+ warn_nonvdtor defaults to off.
+
+ * class.c (instantiate_type): Use comptypes rather than relying on
+ types to satisfy ==.
+
+ * decl.c (start_function): Set DECL_DEFER_OUTPUT on all inlines that
+ might be static.
+
+ * tree.c (build_cplus_new): Never build WITH_CLEANUP_EXPRs.
+
+ * decl.c (grok_reference_init): Deal with ADDR_EXPRs of TARGET_EXPRs.
+
+ * cvt.c (cp_convert): Pass 0 to with_cleanup_p arg of
+ build_cplus_new.
+
+Wed Jun 29 22:31:09 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl2.c (finish_file): Maybe consider static inlines multiple
+ times, in case they reference each other.
+
+Tue Jun 28 11:58:38 1994 Gerald Baumgartner (gb@cs.purdue.edu)
+
+ * class.c (finish_struct): Don't `cons_up_default_function's
+ for signatures.
+ (finish_struct): Handle an empty method_vec correctly.
+
+ * decl.c (grokdeclarator): Don't warn about a signature being
+ empty in a signature pointer declaration if we only saw a
+ forward declaration of the signature. Changed `warning's into
+ `cp_warning's.
+
+ * sig.c (build_sigtable): Don't die if a null signature table
+ constructor is returned.
+ (build_signature_pointer_constructor): If the signature table
+ constructor is null, the _sptr field is set to a null pointer
+ and cast to the appropriate type. Make copies of all null
+ pointers so that the type null_pointer_node doesn't get changed.
+ (build_signature_table_constructor): Added comments.
+
+ * sig.c (build_signature_pointer_constructor): Complain if we
+ try to assign to/initialize a signature pointer/reference of
+ an undefined signature.
+
+Mon Jun 27 14:05:16 1994 Gerald Baumgartner (gb@cs.purdue.edu)
+
+ * typeck2.c (store_init_value): Don't be pedantic about
+ non-constant initializers of signature tables/pointers/references.
+
+Fri Jun 24 16:49:41 1994 Gerald Baumgartner (gb@cs.purdue.edu)
+
+ * decl.c (grokdeclarator): If we are grokking an opaque typedef
+ in a signature, don't complain about it begin static.
+
+Wed Jun 29 16:44:45 1994 Mike Stump <mrs@cygnus.com>
+
+ Fixes a problem of the this pointer being wrong in virtual calls to
+ methods that are not overridden in more derived classes.
+
+ * class.c (fixup_vtable_delta): New routine. It will fixup the
+ delta entries in vtables, wheever they need updating.
+ * class.c (finish_struct): Call the new routine for all virtual
+ bases, as they can have different offsets, than those used in base
+ classes that we derive our vtable from.
+
+Tue Jun 28 23:49:28 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (build_binary_op): Use the types before default
+ conversions in the error message.
+
+ * *.c: Use c_build_type_variant instead of build_type_variant where
+ the type might be an array.
+
+ * call.c (build_method_call): Call build_type_variant and
+ build_reference_type in the right order.
+ * decl.c (record_builtin_type): Ditto.
+
+Wed Jun 29 16:58:53 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * call.c (build_method_call): Call build_type_variant and
+ build_reference_type in the right order.
+ * decl.c (record_builtin_type): Ditto.
+
+Tue Jun 28 23:49:28 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (build_binary_op): Use the types before default
+ conversions in the error message.
+
+ * *.c: Use c_build_type_variant instead of build_type_variant where
+ the type might be an array.
+
+Sat Jun 25 11:50:54 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cvt.c (convert_to_reference): Try UDC's before doing the
+ reinterpret_cast thang, though.
+
+Fri Jun 24 01:24:01 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (c_expand_return): Don't USE the return value location
+ after we've expanded the jump.
+
+ * decl2.c (finish_file): Make sure DECL_SAVED_INSNS is not 0 before
+ trying to write out an inline.
+
+ * cvt.c (build_up_reference): Also do address adjustment when the
+ target type uses MI.
+ (convert_to_reference): Try UDCs only after built-in conversions.
+ (build_type_conversion_1): Don't play games with the argument to the
+ method.
+ (build_type_conversion): #if 0 out code for binding to reference.
+
+Thu Jun 23 00:22:28 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl2.c (finish_file): Use TREE_SYMBOL_REFERENCED to decide
+ whether to emit inlines.
+
+ * decl.c (grokdeclarator): Set explicit_int for decls that just
+ specify, say, 'long'.
+
+ * init.c (do_friend): Do overload C functions (or call pushdecl,
+ anyaway).
+
+Wed Jun 22 13:40:49 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cvt.c (build_up_reference): Don't call readonly_error.
+ (convert_to_reference): Propagate const and volatile from expr to
+ its type.
+
+ * tree.c (lvalue_p): Random CALL_EXPRs are not lvalues.
+
+ * cvt.c (build_up_reference): Break out WITH_CLEANUP_EXPR when
+ creating a temporary.
+ (convert_to_reference): Lose excessive and incorrect trickiness.
+ (cp_convert): Call build_cplus_new with with_cleanup_p set.
+
+ * typeck2.c (build_functional_cast): Ditto.
+
+Tue Jun 21 17:38:38 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (grokdeclarator): signed, unsigned, long and short all
+ imply 'int'.
+
+ * decl.c (grokdeclarator): Allow "this is a type" syntax.
+ (grok_reference_init): Simplify and fix.
+
+Sun Jun 19 17:08:48 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (grokdeclarator): pedwarn about a typedef that specifies no
+ type.
+
+Sat Jun 18 04:16:50 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (start_function): Move TREE_PUBLIC and DECL_EXTERNAL
+ tinkering to after call to pushdecl.
+
+Fri Jun 17 14:48:28 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * call.c (build_method_call): Handle destructors for non-aggregate
+ types properly.
+
+Thu Jun 16 16:48:05 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * call.c (build_method_call): Make sure that the name given for the
+ destructor matches the constructor_name of the instance.
+
+ * pt.c (do_function_instantiation): A non-extern instantiation
+ overrides a later extern one.
+ (do_type_instantiation): Ditto.
+
+Wed Jun 15 19:34:54 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * init.c (expand_aggr_init): Use TYPE_MAIN_VARIANT to get the
+ unqualified array type.
+
+ * cp-tree.h (EMPTY_CONSTRUCTOR_P): Tests whether NODE is a
+ CONSTRUCTOR with no elements.
+
+ * decl.c (various): Lose empty_init_node.
+ (finish_decl): Use EMPTY_CONSTRUCTOR_P, do the empty CONSTRUCTOR
+ thing depending on the value of DECL_COMMON instead of
+ flag_conserve_space, do the empty CONSTRUCTOR thing for types that
+ don't have constructors, don't treat a real empty CONSTRUCTOR
+ specially.
+
+ * typeck2.c (process_init_constructor): Don't treat empty_init_node
+ specially.
+
+Wed Jun 15 19:05:25 1994 Mike Stump <mrs@cygnus.com>
+
+ * class.c (override_one_vtable): Don't forget to merge in an old
+ overrider when we wanted to reuse a vtable, but couldn't.
+
+Wed Jun 15 15:03:16 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (start_decl): Put statics in common again.
+
+ * decl.c (grokdeclarator): Return NULL_TREE for an error rather than
+ setting the type to error_mark_node.
+
+ * typeck.c (build_modify_expr): Build up a COMPOUND_EXPR for enum
+ bitfield assignments.
+
+Tue Jun 14 12:23:38 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (grok_op_properties): Const objects can be passed by value.
+
+Mon Jun 13 03:10:59 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl2.c (import_export_vtable): Force implicit instantiations to
+ be interface_only when -fno-implicit-templates.
+
+ * decl.c (duplicate_decls): Redeclaring a class template name is an
+ error.
+
+ * pt.c (end_template_decl): Call GNU_xref_decl for class templates.
+ * xref.c (GNU_xref_decl): Support templates.
+
+Sat Jun 11 17:09:05 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (grok_op_properties): Split out checking for whether this
+ function should suppress the default assignment operator.
+ * decl2.c (grok_function_init): Ditto.
+ (copy_assignment_arg_p): New function do do just that.
+ Now considers virtual assignment operators that take a base as an
+ argument to count as copy assignment operators.
+
+ * search.c (dfs_debug_mark): Lose checks for DWARF_DEBUG and
+ TREE_ASM_WRITTEN, as they are redundant.
+
+ * pt.c (end_template_decl): Don't try to set DECL_CLASS_CONTEXT on a
+ decl that has no LANG_SPECIFIC part.
+ (do_type_instantiation): Force the debugging information for this
+ type to be emitted.
+
+ * decl.c (start_decl): Clear up uses of various types of templates
+ (say sorry for static data members, rather than "invalid template").
+ (expand_static_init): Fix initialization of static data members of
+ template classes.
+
+Fri Jun 10 00:41:19 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (grokdeclarator): Set DECL_CONTEXT on static data members.
+
+ * g++.c (main): Use -xc++-cpp-output for .i files.
+
+ * pt.c (tsubst): Give meaningful error about declaring template for
+ a copy constructor which was not declared in the class template.
+ (do_type_instantiation): Explicit instantiation before the class
+ template is an error.
+ (instantiate_template): Don't die if tsubst returns error_mark_node.
+
+Thu Jun 9 19:04:59 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ Don't synthesize the copy assignment operator if the one in a base
+ class is pure virtual.
+ * cp-tree.h (TYPE_HAS_ABSTRACT_ASSIGN_REF): New macro to indicate
+ whether the type has a pure virtual copy assignment operator.
+ * class.c (finish_base_struct): Don't generate the copy assignment
+ operator if a base class has a pure virtual one.
+ * decl.c (grok_op_properties): Add disabled code to set
+ TYPE_HAS_ABSTRACT_ASSIGN_REF with comment pointing to where it is
+ actually set.
+ * decl2.c (grok_function_init): Set TYPE_HAS_ABSTRACT_ASSIGN_REF.
+
+ * decl2.c (import_export_vtable): Always treat template
+ instantiations as if write_virtuals >= 2, and treat implicit
+ instantiations as external if -fno-implicit-templates.
+ (finish_file): Output all pending inlines if
+ flag_keep_inline_functions.
+
+Wed Jun 8 20:48:02 1994 Mike Stump <mrs@cygnus.com>
+
+ * tree.c (layout_vbasetypes): Align virtual base classes inside
+ complete objects, so that we don't core dump on machines such as
+ SPARCs when we access members that require larger than normal
+ alignments, such as a double. Also, we bump up the total alignment
+ on the complete type, as necessary.
+
+Wed Jun 8 16:18:14 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * gxxint.texi (Free Store): New section with code for examining
+ cookie.
+ (Limitations of g++): Remove operator delete entry, since it is no
+ longer accurate. Fix access control entry.
+
+ * typeck.c (build_unary_op): Pedwarn about taking the address of or
+ incrementing a cast to non-reference type.
+ (build_modify_expr): Use convert instead of convert_force again.
+
+ * search.c (get_base_distance): Use IS_AGGR_TYPE_CODE to check for
+ class type, not == RECORD_TYPE.
+
+ * decl.c (grokdeclarator): Cope with grokfndecl returning NULL_TREE.
+
+ * typeck2.c (report_case_error): #if 0 out.
+ * lex.c (real_yylex): Lose RANGE.
+ * parse.y: Ditto.
+
+Tue Jun 7 18:17:35 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y (simple_stmt, case ranges): Use ELLIPSIS instead of RANGE.
+
+Mon Jun 6 19:39:57 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (build_c_cast): Don't shortcut conversions to the same
+ type. Don't replace consts with their values here, since that's now
+ done in cp_convert.
+
+ * cvt.c (cp_convert): When converting to bool, take
+ integer_zero_node to false_node and all other INTEGER_CSTs to
+ true_node.
+ (build_type_conversion): Don't complain about multiple conversions
+ to float if we're not really converting.
+
+Fri Jun 3 02:10:56 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ Implement 'extern template class A<int>;' syntax for suppressing
+ specific implicit instantiations.
+ * cp-tree.h: Update prototypes for do_*_instantiation.
+ * pt.c (do_pending_expansions): Don't compile 'extern' explicit
+ instantiations.
+ (do_function_instantiation): Set DECL_EXTERNAL on 'extern' explicit
+ instantiations.
+ (do_type_instantiation): Ditto.
+ * parse.y (explicit_instantiation): Support 'extern template class
+ A<int>;' syntax.
+ * decl.c (start_function): Don't modify the settings of TREE_PUBLIC
+ and DECL_EXTERNAL on explicit instantiations.
+
+ * cvt.c (cp_convert): Replace constants with their values before
+ converting.
+ (cp_convert): Consistently use 'e' instead of 'expr'.
+
+Thu Jun 2 03:53:30 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck2.c (build_x_arrow): Resolve OFFSET_REFs first.
+
+Wed Jun 1 18:57:35 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck2.c (digest_init): Handle initializing a pmf with an
+ overloaded method.
+ * typeck.c (build_ptrmemfunc): Handle overloaded methods.
+
+ * decl.c (pushtag): Use build_decl to make TYPE_DECLs.
+ (xref_defn_tag): Ditto.
+ * pt.c (process_template_parm): Ditto.
+ (lookup_template_class): Ditto.
+ (push_template_decls): Ditto.
+ (instantiate_class_template): Ditto.
+ (create_nested_upt): Ditto.
+ * class.c (finish_struct): Don't try to set DECL_CLASS_CONTEXT on
+ TYPE_DECLs.
+
+ * typeck.c (convert_arguments): Make sure type is not NULL before
+ checking its TREE_CODE.
+
+Wed Jun 1 17:40:39 1994 Mike Stump <mrs@cygnus.com>
+
+ * class.c (get_derived_offset): New routine.
+ * class.c (finish_base_struct): Make sure we set BINFO_VTABLE and
+ BINFO_VIRTUALS when we choose a new base class to inherit from.
+ * class.c (modify_one_vtable): Use get_derived_offset to get the
+ offset to the most base class subobject that we derived this binfo
+ from.
+ * class.c (finish_struct): Move code to calculate the
+ DECL_FIELD_BITPOS of the vfield up, as we need might need it for
+ new calls to get_derived_offset in modify_one_vtable.
+
+Wed Jun 1 16:50:59 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * init.c (build_member_call): Use build_pointer_type instead of
+ TYPE_POINTER_TO.
+
+Wed Jun 1 11:11:15 1994 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * decl.c (grokdeclarator): Make sure we have a DNAME set before we
+ try to use it in an error.
+
+Wed Jun 1 09:48:49 1994 Mike Stump <mrs@cygnus.com>
+
+ * typeck.c (convert_arguments, convert_for_initialization): Don't
+ strip NOP_EXPRs, when we are converting to a reference.
+
+Wed Jun 1 01:11:38 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (build_modify_expr): Don't dereference references when
+ initializing them.
+
+ * decl2.c (grokfield): Don't check for grokdeclarator returning
+ error_mark_node any more.
+
+ * decl.c (grokfndecl): Return NULL_TREE instead of error_mark_node.
+ (start_method): Return void_type_node instead of error_mark_node.
+
+ * typeck.c (build_modify_expr): Resolve offset refs earlier.
+
+Tue May 31 16:06:58 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * call.c (build_method_call): Resolve OFFSET_REFs in the object.
+
+ * typeck.c (build_modify_expr): Dereference references before trying
+ to assign to them.
+
+ * call.c (build_method_call): Don't confuse type conversion
+ operators with constructors.
+ * typeck2.c (build_functional_cast): Just call build_c_cast if there
+ was only one parameter.
+ * method.c (build_typename_overload): Don't set
+ IDENTIFIER_GLOBAL_VALUE on these identifiers.
+ * decl.c (grok_op_properties): Warn about defining a type conversion
+ operator that converts to a base class (or reference to it).
+ * cvt.c (cp_convert): Don't try to use a type conversion operator
+ when converting to a base class.
+ (build_type_conversion_1): Don't call constructor_name_full on an
+ identifier.
+ * cp-tree.h (DERIVED_FROM_P): Should be self-explanatory.
+
+ * decl.c (start_decl): Don't complain that error_mark_node is an
+ incomplete type.
+ (finish_decl): Check for type == error_mark_node.
+
+Mon May 30 23:38:55 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (start_function): Set DECL_DEFER_OUTPUT on implicit
+ instantiations and inline members.
+
+ * spew.c (yylex): Set looking_for_template if the next token is a '<'.
+
+ * lex.h: Declare looking_for_template.
+
+ * decl.c (lookup_name_real): Use looking_for_template to arbitrate
+ between type and template interpretations of an identifier.
+
+Sat May 28 04:07:40 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * pt.c (instantiate_template): Zero out p if we found a
+ specialization.
+
+ * decl.c (grokdeclarator): Elucidate warning.
+ (grokdeclarator): If pedantic AND -ansi, complain about long long.
+
+ Make explicit instantiation work reasonably. It is now appropriate
+ to deprecate the use of -fexternal-templates.
+ * pt.c (instantiate_template): Set DECL_TEMPLATE_SPECIALIZATION or
+ DECL_IMPLICIT_INSTANTIATION on fndecl as appropriate.
+ (end_template_instantiation): Reflect changes in USE_TEMPLATE
+ semantics.
+ (do_pending_expansions): if (!flag_implicit_templates) DECIDE(0);
+ (do_function_instantiation): Don't set EXPLICIT_INST if
+ flag_external_templates is set. Do set TREE_PUBLIC and DECL_EXTERN
+ appropriately otherwise.
+ (do_type_instantiation): Set interface info for class. Set
+ TREE_PUBLIC and DECL_EXTERN for methods. Do none of this if
+ flag_external_templates is set.
+ * parse.y: Reflect changes in USE_TEMPLATE semantics.
+ * decl2.c: New flag flag_implicit_templates determines whether or
+ not implicit instantiations get emitted. This flag currently
+ defaults to true, and must be true for -fexternal-templates to work.
+ (finish_file): Consider flag_implement_inlines when
+ setting DECL_EXTERNAL. Consider flag_implicit_templates when
+ deciding whether or not to emit a static copy.
+ * decl.c (start_function): Set TREE_PUBLIC and DECL_EXTERNAL
+ properly for template instantiations.
+ (start_method): Set DECL_IMPLICIT_INSTANTIATION on methods of a
+ template class.
+ * cp-tree.h (CLASSTYPE_USE_TEMPLATE): Change semantics.
+ (DECL_USE_TEMPLATE): Parallel macro for FUNCTION and VAR_DECLs.
+ (various others): Accessor macros for the above.
+
+Fri May 27 13:57:40 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (build_binary_op_nodefault): Division by constant zero is
+ an error.
+
+Fri May 27 13:50:15 1994 Mike Stump <mrs@cygnus.com>
+
+ * class.c (override_one_vtable): Don't modify things we don't own.
+
+Fri May 27 01:42:58 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (finish_decl): Don't postpone processing the initializer of
+ a decl with DECL_EXTERNAL set, and do call rest_of_compilation for a
+ PUBLIC const at toplevel.
+ (grokdeclarator): pedwarn about initializing non-const or
+ non-integral statics in the class body.
+
+ * decl.c (pushtag): Don't try to set DECL_CLASS_CONTEXT on a
+ TYPE_DECL.
+
+ * call.c (convert_harshness): Dereference reference on rhs before
+ proceeding, properly grok passing const things to non-const
+ references.
+
+ * typeck.c (build_unary_op): Soften error about taking the address
+ of main() to a pedwarn.
+
+ * lex.c (default_copy_constructor_body): Unambiguously specify base
+ classes (i.e. A((const class ::A&)_ctor_arg) ).
+ (default_assign_ref_body): Ditto.
+
+Thu May 26 13:13:55 1994 Gerald Baumgartner (gb@mexican.cygnus.com)
+
+ * decl2.c (grokfield): Don't complain about local signature
+ method declaration without definition.
+
+ * call.c (convert_harshness): If `type' is a signature pointer
+ and `parmtype' is a pointer to a signature, just return 0. We
+ don't really convert in this case; it's a result of making the
+ `this' parameter of a signature method a signature pointer.
+
+ * call.c (build_method_call): Distinguish calling the default copy
+ constructor of a signature pointer/reference from a signature
+ member function call.
+
+Thu May 26 12:56:25 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl2.c (grokfield): Don't set TREE_PUBLIC on member function
+ declarations.
+
+ * decl.c (duplicate_decls): A previous function declaration as
+ static overrides a subsequent non-static definition.
+ (grokdeclarator): Don't set TREE_PUBLIC on inline method
+ declarations.
+
+Wed May 25 14:36:38 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (grokdeclarator): Handle initialization of static const
+ members.
+ (finish_decl): Ditto.
+
+ * decl2.c (grokfield): Allow initialization of static const members
+ even when pedantic.
+
+ * decl2.c (grokfield): Deal with grokdeclarator returning
+ error_mark_node.
+
+ * decl.c (grok_ctor_properties): Return 0 for A(A) constructor.
+ (grokfndecl): Check the return value of grok_ctor_properties.
+ (start_method): Ditto.
+
+ * parse.y (absdcl): Expand type_quals inline.
+
+Tue May 24 19:10:32 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (pushtag): Use IS_AGGR_TYPE rather than checking for a
+ RECORD_TYPE.
+
+Tue May 24 18:09:16 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * cp-tree.h (VTABLE_NAME_FORMAT): If flag_vtable_thunks,
+ always use "__vt_%s".
+ * decl2.c (finish_vtable_vardecl): Don't consider abstract virtuals
+ when looking for a "sentinal" method (to decide on emitting vtables).
+ * decl2.c (finish_file): Scan all decls for thunks that need
+ to be emitted.
+ * decl2.c (finish_vtable_vardecl): Don't bother calling emit_thunk.
+ * method.c (make_thunk): Use a more meaningful label. If there
+ exists a matching top-level THUNK_DECL re-use it; otherwise
+ create a new THUNK_DECL (and declare it).
+ * method.c (emit_thunk): Make thunk external/public depending
+ on the underlying method.
+
+Tue May 24 00:22:04 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * pt.c (tsubst): Use lookup_name_nonclass to find guiding decls, not
+ lookup_name.
+
+ * call.c (build_overload_call_real): Don't immediately pick a
+ function which matches perfectly.
+
+ * decl.c (grokdeclarator): Use c_build_type_variant for arrays.
+ (grokdeclarator): Warn about, and throw away, cv-quals attached to a
+ reference (like 'int &const j').
+
+ * typeck.c (convert_arguments): Don't mess with i for methods.
+ * call.c (build_method_call): Pass the function decl to
+ convert_arguments.
+
+ * typeck.c (comp_ptr_ttypes_real): New function. Implements the
+ checking for which multi-level pointer conversions are allowed.
+ (comp_target_types): Call it.
+ (convert_for_assignment): Check const parity on the ultimate target
+ type, too. And make those warnings pedwarns.
+
+Mon May 23 14:11:24 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * error.c (dump_char): Use TARGET_* for character constants.
+
+Mon May 23 13:03:03 1994 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * tree.c (debug_no_list_hash): Make static.
+
+ * decl.c (decls_match): Say the types don't match if newdecl ends up
+ with a null type, after we've checked if olddecl does.
+ (pushdecl): Check if the decls themselves match before looking for
+ an extern redeclared as static, to avoid inappropriate and incorrect
+ warnings.
+
+Fri May 20 14:04:34 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (grokdeclarator): Make warning about duplicate short, etc.
+ a pedwarn.
+
+ * typeck.c (build_c_cast): Casting to function or method type is an
+ error.
+
+ * class.c (finish_struct): Make warning for anonymous class with no
+ instances a pedwarn.
+
+ * Makefile.in (stamp-parse): Expect a s/r conflict.
+
+ * typeck.c (build_modify_expr): pedwarn about using a non-lvalue
+ cast as an lvalue.
+
+Thu May 19 12:08:48 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cvt.c (type_promotes_to): Make sure bool promotes to int rather
+ than unsigned on platforms where sizeof(char)==sizeof(int).
+
+Wed May 18 14:27:06 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (build_c_cast): Tack on a NOP_EXPR when casting to
+ another variant.
+ (build_modify_expr): Don't strip NOP_EXPRs, and don't get tricky
+ and treat them as lvalues.
+
+ * decl.c (shadow_tag): Do complain about forward declarations of
+ enums and empty declarations.
+ * parse.y: Don't complain about forward declarations of enums and
+ empty declarations.
+
+ * typeck.c (convert_for_assignment): Complain about changing
+ the signedness of a pointer's target type.
+
+ * parse.y (stmt): Move duplicated code for checking case values from
+ here.
+ * decl2.c (check_cp_case_value): To here. And add a call to
+ constant_expression_warning.
+
+ * typeck.c (convert_for_assignment): Don't complain about assigning
+ a negative value to bool.
+
+ * decl.c (init_decl_processing): Make bool unsigned.
+
+ * class.c (finish_struct): Allow bool bitfields.
+
+Wed May 18 12:35:27 1994 Ian Lance Taylor (ian@tweedledumb.cygnus.com)
+
+ * Make-lang.in (c++.install-man): Get g++.1 from $(srcdir)/cp.
+
+Wed May 18 03:28:35 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cvt.c (build_type_conversion): Lose special handling of
+ truthvalues.
+
+ * search.c (dfs_pushdecls): Improve shadowing warning.
+
+Tue May 17 13:34:46 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * init.c (build_delete): Throw away const and volatile on `this'.
+
+ * decl.c (finish_enum): Put the constants in TYPE_VALUES again,
+ rather than the enumerators.
+ (pushtag): s/cdecl/c_decl/g
+
+Mon May 16 23:04:01 1994 Stephen R. van den Berg (berg@pool.informatik.rwth-aachen.de)
+
+ * cp/typeck.c (common_type): Attribute merging.
+ (comp_types): Utilise COMP_TYPE_ATTRIBUTES macro.
+
+ * cp/parse.y: Revamp attribute parsing.
+
+Mon May 16 01:40:34 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (shadow_tag): Also check for inappropriate use of auto and
+ register.
+
+ * method.c (build_overload_name): Clarify that the illegal case is a
+ pointer or reference to array of unknown bound.
+
+ * error.c (dump_type_prefix): Print references to arrays properly.
+
+ * typeck.c (various): Be more helpful in pointer
+ comparison diagnostics.
+
+ * tree.c (lvalue_p): MODIFY_EXPRs are lvalues again. Isn't this
+ fun?
+
+ * parse.y: Also catch an error after valid stmts.
+
+ * search.c (dfs_init_vbase_pointers): Don't abort because `this' is
+ const.
+
+ * typeck.c (convert_for_initialization): If call to
+ convert_to_reference generated a diagnostic, print out the parm
+ number and function decl if any.
+
+ * errfn.c (cp_thing): Check atarg1 to determine whether or not we're
+ specifying a line, not atarg.
+
+ * tree.c (build_cplus_method_type): Always make `this' const.
+
+ * decl2.c (grokclassfn): If -fthis-is-variable and this function is
+ a constructor or destructor, make `this' non-const.
+
+ * typeck.c (build_modify_expr): Don't warn specially about
+ assignment to `this' here anymore, since it will be caught by the
+ usual machinery.
+
+ * various: Disallow specific GNU extensions (variable-size arrays,
+ etc.) when flag_ansi is set, not necessarily when pedantic is set,
+ so that people can compile with -pedantic-errors for tighter const
+ checking and such without losing desirable extensions.
+
+ * typeck2.c (build_functional_cast): Call build_method_call with
+ LOOKUP_PROTECT.
+ (process_init_constructor): Only process FIELD_DECLs.
+
+ * decl.c (finish_decl): Also force static consts with no explicit
+ initializer that need constructing into the data segment.
+
+ * init.c (build_delete): Undo last patch, as it interferes with
+ automatic cleanups.
+
+Sat May 14 01:59:31 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * call.c, class.h, cp-tree.h, cvt.c, decl2.c: Lose old overloading
+ code.
+
+ * init.c (build_delete): pedwarn about using plain delete to delete
+ an array.
+
+Fri May 13 16:45:07 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (comp_target_types): Be more helpful in contravariance
+ warnings, and make them pedwarns.
+
+ * decl.c (grokdeclarator): Use decl_context to decide whether or not
+ this is an access declaration.
+
+ * class.c (finish_struct_bits): Set TYPE_HAS_INT_CONVERSION if it
+ has a conversion to enum or bool, too.
+
+Fri May 13 16:31:27 1994 Mike Stump <mrs@cygnus.com>
+
+ * method.c (emit_thunk): Make declaration for
+ current_call_is_indirect local (needed for hppa).
+
+Fri May 13 16:16:37 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * pt.c (uses_template_parms): Grok BOOLEAN_TYPE.
+ (tsubst): Ditto.
+
+Fri May 13 16:23:32 1994 Mike Stump <mrs@cygnus.com>
+
+ * pt.c (tsubst): If there is already a function for this expansion,
+ use it.
+ * pt.c (instantiate_template): Ditto.
+
+Fri May 13 10:30:42 1994 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * parse.y (implicitly_scoped_stmt, simple_stmt case): Use
+ kept_level_p for MARK_ENDS argument to expand_end_bindings, to avoid
+ generating debug info for unemitted symbols on some systems.
+
+ * cp-tree.h (build_static_cast, build_reinterpret_cast,
+ build_const_cast): Add declarations.
+
+Fri May 13 09:50:31 1994 Mike Stump <mrs@cygnus.com>
+
+ * search.c (expand_indirect_vtbls_init): Fix breakage from Apr 27
+ fix. We now try get_binfo, and if that doesn't find what we want,
+ we go back to the old method, which still sometimes fails.
+
+Fri May 13 01:43:18 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y (initdcl): Call cplus_decl_attributes on the right
+ variable.
+ * decl2.c (cplus_decl_attributes): Don't call decl_attributes for
+ void_type_node.
+
+ * typeck.c (build_binary_op_nodefault): Change result_type for
+ comparison ops to bool.
+ (build_binary_op): Convert args of && and || to bool.
+ * cvt.c (build_default_binary_type_conversion): Convert args of &&
+ and || to bool.
+ (build_default_unary_type_conversion): Convert arg of ! to bool.
+ (type_promotes_to): bool promotes to int.
+
+Fri May 13 01:43:18 1994 Mike Stump <mrs@cygnus.com>
+
+ Implement the new builtin `bool' type.
+ * typeck.c (build_binary_op_nodefault): Convert args of && and || to
+ bool.
+ (build_unary_op): Convert arg of ! to bool.
+ * parse.y: Know true and false. Use bool_truthvalue_conversion.
+ * method.c (build_overload_value): Know bool.
+ (build_overload_name): Ditto.
+ * lex.c (init_lex): Set up RID_BOOL.
+ * gxx.gperf: Add bool, true, false.
+ * error.c (*): Know bool.
+ * decl.c (init_decl_processing): Set up bool, true, false.
+ * cvt.c (cp_convert): Handle conversion to bool.
+ (build_type_conversion): Ditto.
+ * *.c: Accept bool where integers and enums are accepted (use
+ INTEGRAL_CODE_P macro).
+
+Thu May 12 19:13:54 1994 Richard Earnshaw (rwe11@cl.cam.ac.uk)
+
+ * g++.c: Use #ifdef for __MSDOS__, not #if.
+
+Thu May 12 18:05:18 1994 Mike Stump <mrs@cygnus.com>
+
+ * decl2.c (lang_f_options): Handle -fshort-temps. -fshort-temps
+ gives old behavior , and destroys temporaries earlier. Default
+ behavior now conforms to the ANSI working paper.
+
+Thu May 12 14:45:35 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (build_modify_expr): Understand MODIFY_EXPR as an lvalue.
+ Use convert_force to convert the result of a recursive call when we
+ are dealing with a NOP_EXPR. Don't automatically wrap MODIFY_EXPRs
+ in COMPOUND_EXPRs any more.
+ (various): Lose pedantic_lvalue_warning.
+ (unary_complex_lvalue): Understand MODIFY_EXPR.
+
+ * cvt.c (convert_to_reference): Allow DECL to be error_mark_node if
+ we don't know what we're initializing.
+
+Wed May 11 01:59:36 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cvt.c (convert_to_reference): Modify to use convtype parameter.
+ Only create temporaries when initializing a reference, not when
+ casting.
+ (cp_convert): New main function.
+ (convert): Call cp_convert.
+ * cvt.c, decl.c, typeck.c: Fix calls to convert_to_reference.
+ * cp-tree.h (CONV_*): New constants used by conversion code for
+ selecting conversions to perform.
+
+ * tree.c (lvalue_p): MODIFY_EXPRs are no longer lvalues.
+
+ * typeck.c (build_{static,reinterpret,const_cast): Stubs that just
+ call build_c_cast.
+ * parse.y: Add {static,reinterpret,const}_cast.
+ * gxx.gperf: Ditto.
+
+ * typeck.c (common_type): Allow methods with basetypes of different
+ UPTs.
+ (comptypes): Deal with UPTs.
+ (build_modify_expr): Wrap all MODIFY_EXPRs in a COMPOUND_EXPR.
+
+ * pt.c (end_template_decl): Check for multiple definitions of member
+ templates.
+
+ * call.c (build_method_call): Complain about calling an abstract
+ virtual from a constructor.
+
+ * typeck.c (pointer_int_sum): Check for the integer operand being 0
+ after checking the validity of the pointer operand.
+
+ * typeck2.c (digest_init): Pedwarn about string initializer being
+ too long.
+
+Tue May 10 12:10:28 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (push_overloaded_decl): Only throw away a builtin if the
+ decl in question is the artificial one.
+
+ * parse.y (simple_stmt, switch): Use implicitly_scoped_stmt because
+ expand_{start,end}_case cannot happen in the middle of a block.
+
+ * cvt.c (build_type_conversion_1): Use convert again.
+
+Tue May 10 11:52:04 1994 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * typeck2.c (digest_init): Make sure we check for signed and
+ unsigned chars as well when warning about string initializers.
+
+ * init.c (emit_base_init): Check if there's a DECL_NAME on the
+ member before trying to do an initialization for it.
+
+Tue May 10 11:34:37 1994 Mike Stump <mrs@cygnus.com>
+
+ * except.c: Don't do anything useful when cross compiling.
+
+Tue May 10 03:04:13 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (duplicate_decls): Fix up handling of builtins yet again.
+ (push_overloaded_decl): Ditto.
+
+ * cvt.c (convert): Don't look for void type conversion.
+
+Mon May 9 18:05:41 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * init.c (do_friend): Only do a pushdecl for friends, not
+ pushdecl_top_level.
+
+Mon May 9 13:36:34 1994 Jim Wilson (wilson@sphagnum.cygnus.com)
+
+ * decl.c (lookup_name_current_level): Put empty statement after
+ the label OUT to make the code valid C.
+
+Mon May 9 12:20:57 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (build_binary_op_nodefault): Only complain about
+ comparing void * and a function pointer if void * is smaller.
+
+Sun May 8 01:29:13 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (lookup_name_current_level): Move through temporary binding
+ levels.
+
+ * parse.y (already_scoped_stmt): Revive.
+ (simple_stmt): Use it again.
+
+ * decl.c (poplevel): Always call poplevel recursively if we're
+ dealing with a temporary binding level.
+
+Sat May 7 10:52:28 1994 Mike Stump <mrs@cygnus.com>
+
+ * decl.c (finish_decl): Make sure we run cleanups for initial values
+ of decls. Cures memory leak.
+ * decl.c (expand_static_init): Ditto for static variables.
+ * decl2.c (finish_file): Ditto for globals.
+
+Sat May 7 03:57:44 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (commonparms): Don't complain about redefining default
+ args.
+
+ * decl.c (duplicate_decls): Don't complain twice about conflicting
+ function decls.
+ (decls_match): Don't look at default args.
+ (redeclaration_error_message): Complain about redefining default
+ args.
+
+ * call.c (build_overload_call_real): Also deal with guiding
+ declarations coming BEFORE the template decl.
+
+ * pt.c (unify): Allow different parms to have different
+ cv-qualifiers.
+ (unify): Allow trivial conversions on non-template parms.
+
+Fri May 6 03:53:23 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * pt.c (tsubst): Support OFFSET_TYPEs.
+ (unify): Ditto.
+
+ * decl2.c (finish_decl_parsing): Call push_nested_class with a type.
+
+ * init.c (build_offset_ref): Fix error message.
+ * search.c (lookup_field): Ditto.
+
+ * call.c (build_scoped_method_call): Pass binfo to
+ build_method_call.
+ * typeck.c (build_object_ref): Ditto.
+
+ * typeck2.c (binfo_or_else): Don't return a _TYPE.
+
+ * class.c (finish_struct): Don't complain about re-use of inherited
+ names or shadowing of type decls.
+ * decl.c (pushdecl_class_level): Ditto.
+
+ * decl.c (finish_enum): Set the type of all the enums.
+
+ * class.c (finish_struct): Don't get confused by access decls.
+
+ * cp-tree.h (TYPE_MAIN_DECL): New macro to get the _DECL for a
+ _TYPE. You can stop using TYPE_NAME for that now.
+
+ * parse.y: Lose doing_explicit (check $0 instead).
+ * gxx.gperf: 'template' now has a RID.
+ * lex.h (rid): Ditto.
+ * lex.c (init_lex): Set up the RID for 'template'.
+
+ * parse.y (type_specifier_seq): typed_typespecs or
+ nonempty_type_quals. Use it.
+ (handler_args): Fix bogus syntax.
+ (raise_identifier{,s}, optional_identifier): Lose.
+ * except.c (expand_start_catch_block): Use grokdeclarator to parse
+ the catch variable.
+ (init_exception_processing): The second argument to
+ __throw_type_match is ptr_type_node.
+
+ Fri May 6 07:18:54 1994 Chip Salzenberg (chip@fin)
+
+ [ change propagated from c-decl.c of snapshot 940429 ]
+ * cp/decl.c (finish_decl): Setting asmspec_tree should not
+ zero out the old RTL.
+
+Fri May 6 01:25:38 1994 Mike Stump <mrs@cygnus.com>
+
+ Add alpha exception handling support to the compiler.
+ Quick and dirty backend in except.c.
+
+ * cp/*: Remove most remnants of old exception handling support.
+ * decl.c (finish_function): Call expand_exception_blocks to put
+ the exception hanlding blocks at the end of the function.
+ * dec.c (hack_incomplete_structures): Make sure expand_decl_cleanup
+ comes after expand_decl_init.
+ * except.c: Reimplementation.
+ * expr.c (cplus_expand_expr): Handle THROW_EXPRs.
+ * lex.c (init_lex): Always have catch, try and throw be reserved
+ words, so that we may always parse exception handling.
+ * parse.y: Cleanup to support new interface into exception handling.
+ * tree.def (THROW_EXPR): Add.
+
+Thu May 5 17:35:37 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y (simple_stmt, for loops): Use implicitly_scoped_stmt.
+ (various): Lose .kindof_pushlevel and partially_scoped_stmt.
+
+Thu May 5 16:17:27 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * parse.y (already_scoped_stmt): move expand_end_binding() to
+ fix the unmatched LBB/LBE in stabs.
+
+Thu May 5 14:36:17 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (set_nested_typename): Set TREE_MANGLED on the new
+ identifiers.
+ (pushdecl): Check TREE_MANGLED.
+ (xref_tag): Ditto.
+ * cp-tree.h (TREE_MANGLED): This identifier is a
+ DECL_NESTED_TYPENAME (named to allow for future use to denote
+ mangled function names as well).
+
+ Implement inconsistency checking specified in [class.scope0].
+ * decl.c (lookup_name_real): Don't set ICV here after all.
+ (finish_enum): Also set the type of the enumerators themselves.
+ (build_enumerator): Put the CONST_DECL in the list instead of its
+ initial value.
+ (pushdecl_class_level): Check inconsistent use of a name in the
+ class body.
+ * class.c (finish_struct): Check inconsistent use of a name in the
+ class body. Don't set DECL_CONTEXT on types here anymore.
+ * parse.y (qualified_type_name): Note that the identifier has now
+ been used (as a type) in the class body.
+ * lex.c (do_identifier): Note that the identifier has now been used
+ (as a constant) in the class body.
+ * error.c (dump_decl): Print type and enum decls better.
+
+Thu May 5 09:35:35 1994 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * typeck.c (build_modify_expr): Warn about assignment to `this'.
+
+Wed May 4 15:55:49 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * init.c (build_delete): Use the global operator delete when
+ requested.
+
+ * decl.c (lookup_name_real): If we find the type we're looking in a
+ base class while defining a class, set IDENTIFIER_CLASS_VALUE for
+ the type.
+
+ * class.c (finish_struct): Remove a couple of dependencies on
+ language linkage.
+
+ * decl.c (pushtag): Classes do nest in extern "C" blocks.
+ (pushdecl): Only set DECL_NESTED_TYPENAME on the canonical one for
+ the type.
+ (pushtag): Remove another dependency on the language linkage.
+
+ * lex.c (cons_up_default_function): Don't set DECL_CLASS_CONTEXT to
+ a const-qualified type.
+
+ * decl.c (push_overloaded_decl): Throw away built-in decls here.
+ (duplicate_decls): Instead of here.
+
+Wed May 4 15:27:40 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * typeck.c (get_member_function_from_ptrfunc): Do The Right
+ Thing (I hope) if we're using thunks.
+
+Wed May 4 13:52:38 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y (specialization): aggr template_type_name ';'.
+ (named_class_head_sans_basetype): Use it.
+ (explicit_instantiation): Ditto.
+ (tmpl.2): Revert.
+
+ * cvt.c (build_type_conversion_1): Use convert_for_initialization,
+ rather than convert, to do conversions after the UDC.
+
+ * cp-tree.h (SHARED_MEMBER_P): This member is shared between all
+ instances of the class.
+
+ * search.c (lookup_field): If the entity found by two routes is the
+ same, it's not ambiguous.
+
+Wed May 4 12:10:00 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * decl.c (lookup_name_real): Check for a NULL TREE_VALUE,
+ to prevent the compiler from crashing ...
+
+Wed May 4 11:19:45 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * call.c (build_method_call): If we don't have an object, check
+ basetype_path to figure out where to look up the function.
+
+ * typeck.c (convert_for_initialization): Pass TYPE_BINFO (type) to
+ build_method_call in case exp is NULL_TREE.
+
+Tue May 3 16:02:53 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ Give a vtable entries a unique named type, for the sake of gdb.
+ * class.c (build_vtable_entry): The addres of a thunk now has
+ type vtable_entry_type, not ptr_type_node.
+ * method.c (make_thunk): Fix type of THUNK_DECL.
+ * class.c (add_virtual_function, override_one_vtable): Use
+ vfunc_ptr_type_node, instead of ptr_type_node.
+ * cp-tree.h (vfunc_ptr_type_node): New macro.
+ * decl.c (init_decl_processing): Make vtable_entry_type
+ be a unique type of pointer to a unique function type.
+
+Tue May 3 09:20:44 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y (do_explicit): Sets doing_explicit to 1.
+ (explicit_instantiation): Use do_explicit rather than TEMPLATE
+ directly, add "do_explicit error" rule.
+ (datadef): Set doing_explicit to 0 after an explicit instantiation.
+ (tmpl.2): Don't instantiate if we see a ';' unless we're doing an
+ explicit instantiation.
+ (named_class_head_sans_basetype): Remove aggr template_type_name
+ ';' again.
+
+Mon May 2 23:17:21 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * search.c (lookup_nested_tag): Lose.
+
+ * decl2.c (grokfield): Set DECL_CONTEXT on TYPE_DECLs.
+ (lookup_name_nonclass): Lose.
+
+ * decl.c (poplevel_class): Add force parameter.
+ (lookup_name_real): Fix handling of explicit scoping which specifies
+ a class currently being defined. Add 'nonclass' argument.
+ (lookup_name, lookup_name_nonclass): Shells for lookup_name_real.
+
+ * class.c (finish_struct): Don't unset IDENTIFIER_CLASS_VALUEs here.
+ (popclass): Force clearing of IDENTIFIER_CLASS_VALUEs if we're being
+ called from finish_struct.
+
+Mon May 2 19:06:21 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * decl.c (init_decl_processing), cp-tree.h: Removed memptr_type.
+ (It seeems redundant, given build_ptrmemfunc_type.)
+ * typeck.c (get_member_function_from_ptrfunc), gc.c (build_headof,
+ build_classof): Use vtable_entry_type instead of memptr_type.
+ * method.c (emit_thunk): Call poplevel with functionbody==0
+ to prevent DECL_INITIAL being set to a BLOCK.
+
+Mon May 2 15:02:11 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y (named_class_head_sans_basetype): Add "aggr
+ template_type_name ';'" rule for forward declaration of
+ specializations.
+
+Mon May 2 15:02:11 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * class.c (instantiate_type): Deal with pmf's.
+
+ * Make-lang.in (cc1plus): Don't depend on OBJS or BC_OBJS, since
+ stamp-objlist does.
+
+ * Makefile.in (../cc1plus): Depend on OBJDEPS.
+ (OBJDEPS): Dependency version of OBJS.
+
+Mon May 2 12:51:31 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * search.c (dfs_debug_mark): unmark TYPE_DECL_SUPPRESS_DEBUG, not
+ DECL_IGNORED_P.
+
+Fri Apr 29 12:29:56 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * class.c (finish_struct): Clear out memory of local tags. And
+ typedefs.
+
+ * decl2.c (grokclassfn): Don't set DECL_CONTEXT to a cv-qualified
+ type.
+ * search.c (get_matching_virtual): Be more helpful in error message.
+
+ * *: Use DECL_ARTIFICIAL (renamed from DECL_SYNTHESIZED).
+
+ * lex.c (default_assign_ref_body): Expect TYPE_NESTED_NAME to work.
+ (default_copy_constructor_body): Ditto.
+
+ * class.c (finish_struct): Don't gratuitously create multiple decls
+ for nested classes.
+
+Thu Apr 28 23:39:38 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ Avoid clobbering the arg types of other functions when reverting
+ static member functions.
+ * decl.c (revert_static_member_fn): Rearrange arguments, don't
+ require values for 'fn' and 'argtypes', add warning to comment
+ above.
+ (decls_match): Rearrange arguments in call to rsmf.
+ (grok_op_properties): Don't pass values for fn and argtypes.
+ * pt.c (instantiate_template): Don't pass values for fn and argtypes.
+
+Thu Apr 28 16:29:11 1994 Doug Evans (dje@canuck.cygnus.com)
+
+ * Make-lang.in (cc1plus): Depend on stamp-objlist.
+ * Makefile.in (BC_OBJS): Delete.
+ (OBJS): Cat ../stamp-objlist to get language independent files.
+ Include ../c-common.o.
+ (../cc1plus): Delete reference to BC_OBJS.
+
+Thu Apr 28 02:12:08 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * search.c (compute_access): No really, deal with static members
+ properly. Would I lie to you?
+
+ Implement lexical hiding of function declarations.
+ * pt.c (tsubst): Use lookup_name to look for function decls to guide
+ instantiation.
+ * method.c (build_opfncall): Use lookup_name_nonclass to look for
+ non-member functions.
+ * init.c (do_friend): Use lookup_name_nonclass to look for
+ functions.
+ * error.c (ident_fndecl): Use lookup_name to look for functions.
+ * decl2.c (lookup_name_nonclass): New function, skips over
+ CLASS_VALUE.
+ * decl.c (struct binding_level): Lose overloads_shadowed field.
+ (poplevel): Don't deal with overloads_shadowed.
+ (push_overloaded_decl): Do lexical hiding for functions.
+ * class.c (instantiate_type): Don't check non-members if we have
+ members with the same name.
+ * call.c (build_method_call): Use lookup_name_nonclass instead of
+ IDENTIFIER_GLOBAL_VALUE to check for non-member functions.
+ (build_overload_call_real): Ditto.
+
+ * decl.c (duplicate_decls): Check for ambiguous overloads here.
+ (push_overloaded_decl): Instead of here.
+
+ * decl.c (pushdecl): Back out Chip's last change.
+
+ * decl.c (grok_op_properties): operators cannot be static members.
+
+ * cp-tree.h (DECL_SYNTHESIZED): DECL_SOURCE_LINE == 0
+ (SET_DECL_SYNTHESIZED): DECL_SOURCE_LINE = 0
+ * lex.c (cons_up_default_function): Use SET_DECL_SYNTHESIZED.
+
+ * method.c (do_inline_function_hair): Don't put friends of local
+ classes into global scope, either.
+
+ * typeck2.c (build_functional_cast): Don't look for a function call
+ interpretation.
+
+Thu Apr 28 15:19:46 1994 Mike Stump <mrs@cygnus.com>
+
+ * cp-tree.h: disable use of backend EH.
+
+Wed Apr 27 21:01:24 1994 Doug Evans (dje@canuck.cygnus.com)
+
+ * Make-lang.in (c++.distdir): mkdir tmp/cp first.
+ * Makefile.in (INCLUDES): Move definition to same place as
+ parent makefile.
+ (ALLOCA): Define.
+ (OLDAR_FLAGS): Delete.
+ (OLDCC): Define.
+ (DIR): Delete.
+ (CLIB): Define.
+ (####site): Delete.
+ (SUBDIR_USE_ALLOCA): Don't use ALLOCA if compiling with gcc.
+
+Wed Apr 27 19:10:04 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * decl.c (xref_tag): not to use strstr(), it's not available on
+ all platforms.
+
+Wed Apr 27 18:10:12 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * class.c (finish_struct): Resolve yet another class/pmf confusion.
+
+ * call.c (build_overload_call_real): Don't take the single-function
+ shortcut if we're dealing with an overloaded operator.
+
+Wed Apr 27 17:35:37 1994 Mike Stump <mrs@cygnus.com>
+
+ * search.c (get_base_distance): Search the virtual base class
+ binfos, incase someone wants to convert to a real virtual base
+ class.
+ * search.c (expand_indirect_vtbls_init): Use convert_pointer_to_real
+ instead of convert_pointer_to, as it now will work.
+
+Wed Apr 27 15:36:49 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cvt.c (convert_to_reference): Don't complain about casting away
+ const and volatile.
+
+ * typeck.c (build_unary_op): References are too lvalues.
+
+Wed Apr 27 13:58:05 1994 Mike Stump <mrs@cygnus.com>
+
+ * class.c (override_one_vtable): We have to prepare_fresh_vtable
+ before we modify it, not after, also, we cannot reuse an old vtable,
+ once we commit to a new vtable. Implement ambiguous overrides in
+ virtual bases as abstract. Hack until we make the class
+ ill-formed.
+
+Wed Apr 27 01:17:08 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y (unary_expr): Expand new_placement[opt] and
+ new_initializer[opt] inline.
+
+ * search.c (lookup_fnfields): Don't throw away the inheritance
+ information here, either.
+ (compute_access): Handle static members properly.
+
+ * init.c (build_member_call): Always set basetype_path, and pass it
+ to lookup_fnfields.
+
+ * search.c (lookup_field): Deal properly with the case where
+ xbasetype is a chain of binfos; don't throw away the inheritance
+ information.
+ (compute_access): protected_ok always starts out at 0.
+
+ * init.c (resolve_offset_ref): Don't cast `this' to the base type
+ until we've got our basetype_path.
+
+ * cp-tree.h (IS_OVERLOAD_TYPE): aggregate or enum.
+
+ * cvt.c (build_up_reference): Use build_pointer_type rather than
+ TYPE_POINTER_TO.
+
+ * call.c (convert_harshness_ansi): Call type_promotes_to for reals
+ as well.
+
+ * cvt.c (type_promotes_to): Retain const and volatile, add
+ float->double promotion.
+
+ * decl.c (grokdeclarator): Don't bash references to arrays into
+ references to pointers in function parms. Use type_promotes_to.
+
+Tue Apr 26 23:44:36 1994 Mike Stump <mrs@cygnus.com>
+
+ Finish off Apr 19th work.
+
+ * class.c (finish_struct_bits): Rename has_abstract_virtuals to
+ might_have_abstract_virtuals.
+ * class.c (strictly_overrides, override_one_vtable,
+ merge_overrides): New routines to handle virtual base overrides.
+ * class.c (finish_struct): Call merge_overrides to handle overrides
+ in virtual bases.
+
+Tue Apr 26 12:45:53 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (build_function_call): Call build_function_call_real with
+ LOOKUP_NORMAL.
+
+ * *: Don't deal with TYPE_EXPRs.
+
+ * tree.c (lvalue_p): If the type of the expression is a reference,
+ it's an lvalue.
+
+ * cvt.c (convert_to_reference): Complain about passing const
+ lvalues to non-const references.
+ (convert_from_reference): Don't arbitrarily throw away const and
+ volatile on the target type.
+
+ * parse.y: Simplify and fix rules for `new'.
+
+ * decl.c (grok_op_properties): operator void is illegal.
+
+Mon Apr 25 02:36:28 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y (components): Anonymous bitfields can still have declspecs.
+
+ * decl.c (pushdecl): Postpone handling of function templates like we
+ do C functions.
+
+ * search.c (expand_indirect_vtbls_init): Fix infinite loop when
+ convert_pointer_to fails.
+
+ * call.c (compute_conversion_costs_ansi): A user-defined conversion
+ by itself is better than that UDC followed by standard conversions.
+ Don't treat integers and reals specially.
+
+ * cp-tree.h: Declare flag_ansi.
+
+ * typeck.c (c_expand_return): pedwarn on return in void function
+ even if the expression is of type void.
+ (build_c_cast): Don't do as much checking for casts to void.
+ (build_modify_expr): pedwarn about array assignment if this code
+ wasn't generated by the compiler.
+
+ * tree.c (lvalue_p): A comma expression is an lvalue if its second
+ operand is.
+
+ * typeck.c (default_conversion): Move code for promoting enums and
+ ints from here.
+ * cvt.c (type_promotes_to): To here.
+ * call.c (convert_harshness_ansi): Use type_promotes_to. Also fix
+ promotion semantics for reals.
+
+Sun Apr 24 16:52:51 1994 Doug Evans (dje@canuck.cygnus.com)
+
+ * Make-lang.in (c++.install-common): Check for g++-cross.
+ * Makefile.in: Remove Cygnus cruft.
+ (config.status): Delete.
+ (RTL_H): Define.
+ (TREE_H): Use complete pathname, some native makes have minimal
+ VPATH support.
+ (*.o): Use complete pathname to headers in parent dir.
+ (doc, info, dvi): Delete.
+
+Sun Apr 24 16:52:51 1994 Doug Evans (dje@canuck.cygnus.com)
+
+ * Make-lang.in (c++.install-common): Check for g++-cross.
+ * Makefile.in: Remove Cygnus cruft.
+ (config.status): Delete.
+ (RTL_H): Define.
+ (TREE_H): Use complete pathname, some native makes have minimal
+ VPATH support.
+ (*.o): Use complete pathname to headers in parent dir.
+ (doc, info, dvi): Delete.
+
+Sun Apr 24 00:47:49 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (pushdecl): Avoid redundant warning on redeclaring function
+ with different return type.
+ (decls_match): Compare return types strictly.
+
+Fri Apr 22 12:55:42 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cvt.c (build_type_conversion): Do try to convert through other
+ pointers. This will fail if the class defines multiple pointer
+ conversions.
+
+ * error.c (dump_type_prefix): Print out pointers to arrays properly.
+ (dump_type_suffix): Ditto. (was 'int *[]', now 'int (*)[]')
+
+ * typeck.c (build_unary_op): Disallow ++/-- on pointers to
+ incomplete type.
+
+ * decl.c (duplicate_decls): Check mismatched TREE_CODES after
+ checking for shadowing a builtin. If we're redeclaring a builtin
+ function, bash the old decl to avoid an ambiguous overload.
+
+ * cvt.c (convert_to_reference): Don't force arrays to decay here.
+
+ * tree.c (lvalue_p): A MODIFY_EXPR is an lvalue.
+
+ * decl.c (duplicate_decls): Don't assume that the decls will have
+ types.
+
+ Mon Apr 18 11:35:32 1994 Chip Salzenberg (chip@fin.uucp)
+
+ [ cp/* changes propagated from c-* changes in 940318 snapshot ]
+ * c-decl.c (pushdecl): Warn if type mismatch with another external decl
+ in a global scope.
+
+ Fri Apr 22 06:38:56 1994 Chip Salzenberg (chip@fin.uucp)
+
+ * cp/typeck2.c (signature_error): Use cp_error for "%T".
+
+ Mon Apr 18 11:59:59 1994 Chip Salzenberg (chip@fin.uucp)
+
+ [ cp/* changes propagated from c-* changes in 940415 snapshot ]
+ * cp/decl.c (duplicate_decls, pushdecl, builtin_function):
+ Use DECL_FUNCTION_CODE instead of DECL_SET_FUNCTION_CODE.
+
+ Mon Apr 18 11:55:18 1994 Chip Salzenberg (chip@fin.uucp)
+
+ [ cp/* changes propagated from c-* changes in 940409 snapshot ]
+ * cp/decl.c (duplicate_decls): Put new type in same obstack as
+ old ones, or permanent if old ones in different obstacks.
+
+ Mon Apr 18 11:48:49 1994 Chip Salzenberg (chip@fin.uucp)
+
+ [ cp/* changes propagated from c-* changes in 940401 snapshot ]
+ * cp/parse.y (attrib): Handle string args as expressions,
+ merging the two rules. `mode' attribute now takes a string arg.
+ Delete the rule for an identifier as arg.
+
+ Mon Apr 18 11:24:00 1994 Chip Salzenberg (chip@fin.uucp)
+
+ [ cp/* changes propagated from c-* changes in 940312 snapshot ]
+ * cp/typeck.c (pointer_int_sum): Multiplication should be done signed.
+ (pointer_diff): Likewise the division.
+
+ Sun Mar 6 19:43:39 1994 Chip Salzenberg (chip@fin.uucp)
+
+ [ cp/* changes propagated from c-* changes in 940304 snapshot ]
+ * cp/decl.c (finish_decl): Issue warning for large objects,
+ if requested.
+
+ Sat Feb 19 22:20:32 1994 Chip Salzenberg (chip@fin.uucp)
+
+ [ cp/* changes propagated from c-* changes in 940218 snapshot ]
+ * cp/parse.y (attrib): Handle attribute ((section ("string"))).
+ * cp/decl.c (duplicate_decls): Merge section name into new decl.
+
+ Tue Feb 8 09:49:17 1994 Chip Salzenberg (chip@fin.uucp)
+
+ [ cp/* changes propagated from c-* changes in 940206 snapshot ]
+ * cp/typeck.c (signed_or_unsigned_type): Check for any
+ INTEGRAL_TYPE_P not just INTEGER_TYPE.
+
+ Mon Dec 6 13:35:31 1993 Norbert Kiesel (norbert@i3.INformatik.rwth-aachen.DE)
+
+ * cp/decl.c (finish_enum): Start from 0 when determining precision
+ for short enums.
+
+ Fri Dec 3 17:07:58 1993 Ralph Campbell (ralphc@pyramid.COM)
+
+ * cp/parse.y (unary_expr): Look at $1 for tree_code rather than
+ casting $$.
+
+ Wed Nov 17 19:22:09 1993 Chip Salzenberg (chip@fin.uucp)
+
+ * cp/typeck.c (build_binary_op_nodefault): Propagate code
+ from C front-end to optimize unsigned short division.
+ (build_conditional_expr): Fix bug in "1 ? 42 : (void *) 8".
+
+ Wed Nov 17 19:17:18 1993 Chip Salzenberg (chip@fin.uucp)
+
+ * cp/call.c (convert_harshness_ansi): Given an (e.g.) char
+ constant, prefer 'const char &' to 'int'.
+
+ Wed Feb 3 13:11:48 1993 Chip Salzenberg (chip@fin.uucp)
+
+ * cp/class.c (finish_struct_methods): Handle multiple
+ constructors in fn_fields list.
+
+Fri Apr 22 12:48:10 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * class.c (finish_struct): use TYPE_DECL_SUPPRESS_DEBUG to flag
+ types not to be dumped in stabs, like types in #pragma interface.
+ * decl.c (init_decl_processing): use TYPE_DECL_SUPPRESS_DEBUG to
+ mark unknown type.
+
+Fri Apr 22 03:27:26 1994 Doug Evans (dje@cygnus.com)
+
+ * Language directory reorganization.
+ See parent makefile.
+
+Thu Apr 21 18:27:57 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * cp-tree.h (THUNK_DELTA): It is normally negative, so
+ use signed .i variant of frame_size rather than unsigned .u.
+ * cp-tree.h (VTABLE_NAME_FORMAT): If flag_vtable_thunks,
+ use "VT" rather than "vt" due to binary incompatibility.
+ * class.c (get_vtable_name): Use strlen of VTABLE_NAME_FORMAT,
+ rather than sizeof, since it is now an expression.
+ * class.c (modify_one_vtable): Modify to skip initial element
+ containing a count of the vtable.
+
+Thu Apr 21 00:09:02 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * lex.c (check_newline): Force interface_unknown on main input file.
+
+ * pt.c (do_pending_expansions): Always emit functions that have been
+ explicitly instantiated.
+ (do_function_instantiation): Set DECL_EXPLICITLY_INSTANTIATED.
+ (do_type_instantiation): Set CLASSTYPE_VTABLE_NEEDS_WRITING and
+ DECL_EXPLICITLY_INSTANTIATED on all my methods.
+ * parse.y (explicit_instantiation): Call do_type_instantiation for
+ types.
+ * decl2.c (finish_vtable_vardecl): Call import_export_vtable.
+ * decl.c (start_function): Don't set DECL_EXTERNAL on a function
+ that has been explicitly instantiated.
+ * cp-tree.h (DECL_EXPLICITLY_INSTANTIATED): Alias for
+ DECL_LANG_FLAG_4.
+ * class.c: Move import_export_vtable to decl2.c, and comment out all
+ uses.
+
+Wed Apr 20 16:51:06 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * lex.c (process_next_inline): Don't muck with DECL_INLINE.
+ (do_pending_inlines): Ditto.
+
+Tue Apr 19 22:25:41 1994 Mike Stump <mrs@cygnus.com>
+
+ Reimplement vtable building, and most vtable pointer setting.
+ Allows for earier maintenance, easier understandability, and most
+ importantly, correct semantics.
+
+ * class.c (build_vtable): Removed unneeded
+ SET_BINFO_VTABLE_PATH_MARKED.
+ * class.c (prepare_fresh_vtable): Ditto. Added argument.
+ * class.c (modify_vtable_entry): General cleanup.
+ * class.c (related_vslot, is_normal, modify_other_vtable_entries,
+ modify_vtable_entries): Removed.
+ * class.c (add_virtual_function): General cleanup.
+ * class.c (finish_base_struct): Setup BINFO_VTABLE and
+ BINFO_VIRTUALS as early as we can, so that modify_all_vtables can
+ work.
+ * class.c (finish_vtbls): New routine, mostly from
+ unmark_finished_struct.
+ * class.c (overrides): New routine.
+ * class.c (modify_one_vtable): New routine, mostly from
+ modify_other_vtable_entries and modify_vtable_entries.
+ * class.c (modify_all_direct_vtables, modify_all_indirect_vtables,
+ modify_all_vtables): New routines.
+ * class.c (finish_struct): Added arguemnt to prepare_fresh_vtable
+ call. General cleanup on how pending_hard_virtuals are handled.
+ General cleanup on modifying vtables. Use finish_vtbls, instead of
+ unmark_finished_struct.
+ * cp-tree.h (init_vtbl_ptrs, expand_direct_vtbls_init,
+ get_first_matching_virtual, get_matching_virtual,
+ expand_vbase_vtables_init, expand_indirect_vtbls_init): Update.
+ * cvt.c (convert_pointer_to_real): cleanup error message.
+ * decl.c (grokfndecl): General cleanup.
+ * decl.c (finish_function): Change init_vtbl_ptrs call to
+ expand_direct_vtbls_init. Change expand_vbase_vtables_init call to
+ expand_indirect_vtbls_init.
+ * init.c (expand_virtual_init): Remove unneeded argument.
+ * init.c (init_vtbl_ptrs): Rename to expand_direct_vtbls_init, added
+ two arguments to make more general. Made more general. Now can be
+ used for vtable pointer initialization from virtual bases.
+ * init.c (emit_base_init): Change expand_vbase_vtables_init call to
+ expand_indirect_vtbls_init. Change init_vtbl_ptrs call to
+ expand_direct_vtbls_init.
+ * init.c (expand_virtual_init): General cleanup.
+ * init.c (expand_default_init): Change expand_vbase_vtables_init
+ call to expand_indirect_vtbls_init.
+ * init.c (expand_recursive_init_1): Change expand_vbase_vtables_init
+ call to expand_indirect_vtbls_init.
+ * init.c (expand_recursive_init): Change expand_vbase_vtables_init
+ call to expand_indirect_vtbls_init.
+ * search.c (get_first_matching_virtual): Rename to
+ get_matching_virtual. General cleanup and remove setting of
+ DECL_CONTEXT. That is now done in a cleaner way in
+ modify_vtable_entry and add_virtual_function.
+ * search.c (expand_vbase_vtables_init): Rename to
+ expand_indirect_vtbls_init. General cleanup. Use
+ expand_direct_vtbls_init to do hard work. Ensures that _all_ vtable
+ pointers from virtual bases are set up.
+ * search.c (bfs_unmark_finished_struct, unmark_finished_struct):
+ Removed.
+
+ * *.[chy]: Remove support for VTABLE_USES_MASK.
+
+Tue Apr 19 12:51:59 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cvt.c (convert_to_reference): Use NOP_EXPRs to switch between
+ reference and pointer types instead of bashing the types directly.
+
+ * call.c (build_overload_call_real): Use the TREE_CODE to determine
+ whether the function is overloaded or not, rather than
+ TREE_OVERLOADED.
+ * *: Remove all uses of TREE_OVERLOADED.
+
+ * decl.c (grokdeclarator): Only complain about initializing const
+ fields when -ansi or -pedantic.
+
+Tue Apr 19 12:42:42 1994 Doug Evans (dje@canuck.cygnus.com)
+
+ * cp-tree.h (THUNK_DELTA): frame_size is now a union.
+
+Mon Apr 18 00:17:13 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ Do overloading on a block-by-block basis, not function-by-function.
+ * decl.c: Lose overloads_to_forget.
+ (struct binding_level): Add overloads_shadowed field.
+ (poplevel): Restore overloads_shadowed.
+ (push_overloaded_decl): Use overloads_shadowed instead of
+ overloads_to_forget.
+ (finish_function): Don't look at overloads_to_forget.
+
+ Copy enum_overflow logic from c-decl.c.
+ * decl.c (start_enum): Initialize enum_overflow.
+ (build_enumerator): Use enum_overflow. Also use current_scope().
+
+ * search.c (current_scope): Move Brendan's comment from
+ build_enumerator here.
+
+ * typeck.c (convert_for_assignment): Change warnings to pedwarns for
+ discarding const/volatile.
+
+Sat Apr 16 01:18:21 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (comp_target_parms): Accept TEMPLATE_TYPE_PARMs on the rhs.
+ (comp_target_types): Ditto.
+
+ * decl.c (lookup_name): Don't unset got_scope here.
+
+ * spew.c (yylex): Only replace yylval with the TYPE_NESTED_NAME if
+ got_scope != NULL_TREE.
+
+Fri Apr 15 16:36:33 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ Horrible kludge to prevent templates from being instantiated by
+ their base classes.
+ * parse.y (template_instantiate_once): Unset TYPE_BEING_DEFINED
+ before we get to left_curly.
+ * pt.c (instantiate_class_template): Set TYPE_BEING_DEFINED.
+
+ * error.c (dump_decl): If it's a typedef, print out the name of the
+ decl, not just the underlying type.
+
+ * decl.c (pushdecl): If the old duplicate decl was a TYPE_DECL,
+ update the IDENTIFIER_TYPE_VALUE of its name.
+
+ * decl2.c (finish_file): When processing the initializer for a
+ static member, pretend that the dummy function is a member of the
+ same class.
+
+Fri Apr 15 15:56:35 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * class.c (build_vtable_entry): revert Apr 4 change.
+ * decl2.c (mark_vtable_entries): replace pure virtual function
+ decl with abort's.
+
+Fri Apr 15 13:49:33 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (build_conditional_expr): Pedwarn on pointer/integer
+ mismatch, and don't pedwarn on 0/function pointer mismatch.
+
+ * typeck2.c (digest_init): Lose code for special handling of unions.
+ (process_init_constructor): Since they're handled just fine here.
+ Pedwarn on excess elements.
+
+ * decl2.c (grokfield): Complain about local class method declaration
+ without definition.
+
+Fri Apr 15 13:19:40 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * method.c (emit_thunk): Add extern declaration for
+ current_call_is_indirect (needed for hppa).
+
+Thu Apr 14 16:12:31 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ Improve local class support; allow classes in different blocks to
+ have the same name.
+ * decl.c (pushtag): Support local classes better.
+ (pushdecl_nonclass_level): New function for pushing mangled decls of
+ nested types into the appropriate scope.
+ (xref_defn_tag): Use pushdecl_nonclass_level instead of
+ pushdecl_top_level.
+ (grokfndecl): Don't mess with IDENTIFIER_GLOBAL_VALUE for local
+ class methods.
+ * method.c (do_inline_function_hair): Ditto.
+
+ * class.c (finish_struct): It is legal for a class with no
+ constructors to have nonstatic const and reference members.
+
+Thu Apr 14 07:15:11 1994 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * decl.c (push_overloaded_decl): Avoid giving errors about
+ built-ins, since duplicate_decls will have given warnings/errors
+ for them.
+
+Thu Apr 14 03:45:12 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cvt.c (convert_to_reference): Warn about casting pointer type to
+ reference type when this is probably not what they wanted.
+
+Wed Apr 13 13:12:35 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * decl.c (finish_decl): Don't mindlessly set TREE_USED for
+ static consts any more (toplev.c has now been modified to
+ not emit warnings if they are unused).
+
+Wed Apr 13 00:22:35 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (grok_op_properties): If op new/delete get here with
+ METHOD_TYPEs, do a revert_static_member_fn.
+
+ * cp-tree.h (IDENTIFIER_CLASS_TYPE_VALUE): Lose.
+ * init.c (is_aggr_typedef): Don't look at
+ IDENTIFIER_CLASS_TYPE_VALUE.
+ (get_aggr_from_typedef): Ditto.
+ (get_type_value): Ditto.
+ * call.c (build_scoped_method_call): Don't rely on overloaded
+ template names having IDENTIFIER_CLASS_VALUE set.
+
+ * parse.y (component_decl_1, fn.def2): Revert rules for
+ constructors.
+ (component_decl_1, fn.def2): Use $1 instead of $$, since $$ is being
+ clobbered.
+
+ * decl.c (start_function): Only warn about `void main()' if pedantic
+ || warn_return_type.
+
+Tue Apr 12 02:14:17 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ Clean up overloading of the template name.
+ * class.c (pushclass): overload the template name whenever pushing
+ into the scope of a template class, not just if it is
+ uninstantiated.
+ (popclass): Correspondingly.
+ * search.c (push_class_decls): Don't overload_template_name.
+ * pt.c (overload_template_name): Don't set IDENTIFIER_LOCAL_VALUE or
+ DECL_CONTEXT on things.
+ * parse.y (left_curly): Don't overload_template_name.
+ * class.c (finish_struct): Don't undo_template_name_overload.
+
+ * method.c (build_opfncall): Only pass one argument to global op
+ delete.
+
+ * call.c (build_method_call): Use TYPE_VEC_DELETE_TAKES_SIZE to
+ decide how many arguments to use for vec delete.
+
+ * decl.c (grok_op_properties): Be consistent in modifying
+ current_class_type.
+ (grokdeclarator): Only complain about function decls with no return
+ type if we're being pedantic.
+
+Mon Apr 11 00:10:53 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ Add support for operator new [] and operator delete [].
+
+ * tree.def: Add VEC_NEW_EXPR and VEC_DELETE_EXPR.
+ * ptree.c (print_lang_type): Indicate vec new/delete.
+ * parse.y: Support vec new/delete.
+ * method.c (build_decl_overload): Deal with vec new/delete.
+ (build_opfncall): Ditto.
+ * lex.c (init_lex): Set up values of ansi_opname and opname_tab for
+ vec new/delete. vec new uses "__vn", and vec delete uses "__vd".
+ * init.c (init_init_processing): Set up BIVN and BIVD.
+ (do_friend): Don't clean up after mistaken setting of TREE_GETS_NEW,
+ since it doesn't happen any more.
+ (build_new): Support vec new. Always call something.
+ (build_x_delete): Support vec delete.
+ (build_vec_delete): Lose dtor_dummy argument, add use_global_delete,
+ and pass it to build_x_delete.
+ * decl2.c (delete_sanity): Don't change behavior by whether or not
+ the type has a destructor. Pass use_global_delete to
+ build_vec_delete.
+ (coerce_delete_type): Make sure that the type returned has a first
+ argument of ptr_type_node.
+ * decl.c (init_decl_processing): Also declare the global vec
+ new/delete.
+ (grokdeclarator): Also force vec new/delete to be static.
+ (grok_op_properties): Note presence of vec new/delete, and play with
+ their args. If vec delete takes the optional size_t argument, set
+ TYPE_VEC_DELETE_TAKES_SIZE.
+ * cp-tree.h (TYPE_GETS_{REG,VEC}_DELETE): New macros to simplify
+ checking for one delete or the other.
+ (lang_type): gets_new and gets_delete are now two bits long. The
+ low bit is for the non-array version. Lose gets_placed_new.
+ (TYPE_VEC_DELETE_TAKES_SIZE): New macro indicating that the vec
+ delete defined by this class wants to know how much space it is
+ deleting.
+ (TYPE_VEC_NEW_USES_COOKIE): New macro to indicate when vec new must
+ add a header containing the number of elements in the vector; i.e.
+ when the elements need to be destroyed or vec delete wants to know
+ the size.
+ * class.c (finish_struct_methods): Also check for overloading vec
+ delete.
+ * call.c (build_method_call): Also delete second argument for vec
+ delete.
+
+ * decl.c (grokdeclarator): Correct complaints again.
+ (grokdeclarator): Fix segfault on null declarator.
+ (decls_match): Also accept redeclaration with no arguments if both
+ declarations were in C context. Bash TREE_TYPE (newdecl) here.
+ (duplicate_decls): Instead of here.
+
+ * parse.y (nested_name_specifier_1): Lose rules for dealing with
+ syntax errors nicely, since they break parsing of 'const i;'.
+
+ * decl.c (lookup_name): if (got_scope == current_class_type)
+ val = IDENTIFIER_CLASS_VALUE (name).
+
+ * search.c (lookup_nested_tag): Look in enclosing classes, too.
+
+ * spew.c (yylex): Only look one character ahead when checking for a
+ SCOPE.
+
+ * lex.c (check_newline): Read first nonwhite char before
+ incrementing lineno.
+
+ * decl.c (grokdeclarator): Don't claim that typedefs are variables
+ in warning.
+
+ * parse.y: Divide up uses of unqualified_id into
+ notype_unqualified_id and unqualified_id, so that TYPENAME can be
+ used as an identifier after an object.
+
+ * class.c (push_nested_class): Don't push into non-class scope.
+
+ * decl.c (grokdeclarator): If an identifier could be a type
+ conversion operator, but has no associated type, it's not a type
+ conversion operator.
+
+ * pt.c (unify): Check for equality of constants better.
+
+ * decl.c (grokdeclarator): Don't complain about access decls.
+
+Sun Apr 10 02:39:55 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (grokdeclarator): pedwarn about data definitions without
+ types here.
+
+ * parse.y (datadef): Don't pedwarn about decls without types here,
+ since that is valid for functions.
+ (fn.def2, component_decl): Support constructors with declmods again.
+ (nomods_initdecls): For decls without any mods, so that we don't try
+ to get declspecs from some arbitrary $0.
+
+ * search.c (lookup_field): Use cp_error.
+
+ * parse.y (nested_name_specifier_1): Don't check aggr/non-aggr type
+ here; it breaks destructors for non-aggr types.
+
+ * decl.c (lookup_name): Only look for TYPE_DECLs in base classes of
+ a type being defined, like the comment says.
+ If got_scope is not an aggregate, just return NULL_TREE.
+
+ * pt.c (create_nested_upt): Kung's code for creating types nested
+ within uninstantiated templates now lives here (it used to live in
+ hack_more_ids). It needs to be expanded.
+
+ * parse.y: Stop calling see_typename so much.
+
+ * decl.c (lookup_name): Deal with TTPs and UPTs.
+
+ * lex.c (real_yylex): Don't set looking_for_typename just because we
+ saw a 'new'.
+ (dont_see_typename): #if 0 out.
+
+ * spew.c (yylex): Increment looking_for_typename if the next
+ character is SCOPE, rather than setting it to 1; this way, the value
+ from seeing an aggr specifier will not be lost. This kinda relies
+ on looking_for_typename never being < 0, which is now true.
+
+ * parse.y (nested_name_specifier_1): Accept TEMPLATE_TYPE_PARMs,
+ too.
+ (named_class_head_sans_basetype): Accept template types, too. Oops.
+
+Fri Apr 8 16:39:35 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl2.c (reparse_decl_as_expr1): Handle SCOPE_REFs.
+
+ * parse.y: Lose START_DECLARATOR.
+
+ * search.c (lookup_nested_tag): New function to scan CLASSTYPE_TAGS
+ for a class.
+
+ * parse.y: Simplify fn.def2 and component_decl. Support 'enum
+ A::foo' syntax. Catch invalid scopes better.
+
+ * parse.y, lex.c: lose TYPENAME_COLON.
+
+ * decl2.c (groktypefield): #if 0 out.
+
+ * decl.c (lookup_name): If the type denoted by got_scope is
+ currently being defined, look in CLASSTYPE_TAGS rather than FIELDS.
+
+ * class.c (push_nested_class): Don't try to push into
+ error_mark_node.
+
+Fri Apr 8 07:26:36 1994 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * Makefile.in (stamp-parse): Update count of conflicts to 33.
+
+Thu Apr 7 17:47:53 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ A saner implementation of nested types that treats template types
+ no differently from non-template types. There are still some
+ shortcomings of our system; most notably, it is difficult to look
+ for a nested type that is hidden by another name, because of the way
+ we keep track of hidden types. But this shouldn't be a problem for
+ just about anyone. Perhaps lookup_field should be fixed up a bit.
+
+ * spew.c: Moved handling of nested types/scoping from the lexer
+ into the parser. Removed variable template_type_seen_before_scope.
+ Removed functions frob_identifier, hack_more_ids, and various cruft
+ that was #if 0'd out in the past, reducing the size of the file from
+ 1146 lines to 450 lines. We can't quite do away with spew.c yet,
+ though; we still need it for do_aggr () and checking for SCOPE after
+ the current identifier. And setting lastiddecl.
+
+ * parse.y: Moved handling of nested types/scoping from the lexer
+ into the parser, using a new global variable `got_scope'. Reduced
+ the number of states by 53. Implemented all uses of explicit global
+ scope. Removed terminals SCOPED_TYPENAME and SCOPED_NAME. Removed
+ nonterminals tmpl.1, scoped_base_class, id_scope, typename_scope,
+ scoped_typename. Added nonterminals nested_type,
+ qualified_type_name, complete_type_name, qualified_id, ptr_to_mem,
+ nested_name_specifier, global_scope, overqualified_id, type_name.
+ Changed many others. Added 9 new reduce/reduce conflicts, which are
+ nested type parallels of 9 that were already in the grammar for
+ non-nested types. Eight of the now 33 conflicts should be removed
+ in the process of resolving the late binding between variable and
+ function decls.
+
+ * gxxint.texi (Parser): Update.
+
+ * cp-tree.h (IS_AGGR_TYPE_CODE): Add UNINSTANTIATED_P_TYPE.
+
+ * lex.h: Add decl for got_scope.
+
+ * lex.c (see_typename): Claim to be the lexer when calling
+ lookup_name.
+
+ * decl.c (lookup_name): When called from the lexer, look at
+ got_scope and looking_at_typename; otherwise don't.
+
+Thu Apr 7 22:05:47 1994 Mike Stump <mrs@cygnus.com>
+
+ 31th Cygnus<->FSF merge.
+
+Thu Apr 7 17:47:53 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl2.c (mark_vtable_entries): Call this to mark all the
+ entries in the vtable addressable.
+ (finish_decl_parsing): Handle SCOPE_REFs.
+
+ * decl.c (decls_match): Always call compparms with strict == 1.
+ Handle the special case of C function redecl here.
+ (duplicate_decls): Only keep the old type if the new decl takes no
+ arguments.
+
+ * typeck.c (compparms): Also allow t1 to be ... if strict == 0.
+
+Thu Apr 7 16:17:50 1994 Mike Stump <mrs@cygnus.com>
+
+ * class.c (build_vtable_entry): Fix breakage introduced Apr 5
+ 17:48:41.
+
+Wed Apr 6 16:05:10 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * init.c (build_virtual_init), search.c (build_vbase_vtables_init),
+ ch-tree.h: Every place these functions were called, the result was
+ immediately passed to expand_expr_stmt. Reduce redundancy by
+ calling expand_expr_init *inside* these functions. These
+ makes for a simpler interface, and we don't have to build
+ compound expressions. Hence, rename these function to:
+ expand_virtual_init and expand_vbase_vtables_init respectively.
+ * init.c, decl.c: Change callers of these functions.
+ * init.c, cp-tree.h (expand_virtual_init): Make static.
+
+ * decl2.c (finish_file): Check TREE_PUBLIC||TREE_ADDRESSABLE
+ rather than DECL_SAVED_INSNS before emitting inlines.
+
+Wed Apr 6 13:06:39 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * spew.c (init_spew): #if 0 out stuff used by arbitrate_lookup.
+
+ * decl.c (duplicate_decls): If this is a new declaration of an
+ extern "C" function, keep the type (for the argtypes).
+ (redeclaration_error_message): Don't check DECL_LANGUAGE here.
+ (decls_match): Call compparms with a value of strict dependent on
+ the value of strict_prototypes for DECL_LANGUAGE (oldecl).
+
+ * typeck.c (compparms): ... is only equivalent to non-promoting
+ parms if we're not being strict.
+
+ * parse.y (empty_parms): Don't check flag_ansi || pedantic here.
+
+ * decl.c (init_decl_processing): if (flag_ansi || pedantic)
+ strict_prototypes_lang_c = strict_prototypes_lang_cplusplus;
+
+ * decl2.c (grok_function_init): Don't set DECL_INITIAL on pure
+ virtuals.
+
+Tue Apr 5 17:48:41 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ Support for implementing vtables with thunks.
+ * tree.def (THUNK_DECL): New TREE_CODE.
+ * cp-tree.h (FNADDR_FROM_VTABLE_ENTRY), tree.c
+ (fnaddr_from_vtable_entry): Handle flag_vtable_thunks case.
+ * cp-tree.h (memptr_type): New variable.
+ * class.c (build_vtable_entry): Build thunk if necessary.
+ * class.c (build_vfn_ref): If using thunks, don't need
+ to add delta field from vtable (there is none!).
+ * decl.c: Add memptr_type as well as vtable_entry_type.
+ If using thunks, the latter is just ptr_type_node.
+ * gc.c, typeck.c: Use memptr_typeChange, not vtable_entry_type.
+ * decl2.c (finish_vtable_vardecl): Handle thunks.
+ * expr.c (cplus_expand_expr): Support THUNK_DECL.
+
+ * decl.c (grokdeclarator): Set DECL_THIS_EXTERN if "extern".
+ * decl.c (start_function): Set current_extern_inline based on
+ DECL_THIS_EXTERN, not TREE_PUBLIC.
+ * decl.c (finish_function): Call mark_inline_for_output if needed,
+
+ Improve intelligence about when to emit inlines.
+ * cp-tree.h (lang_decl_flags): New field saved_inline.
+ * cp-tree.h (DECL_SAVED_INLINE): New macro.
+ * class.c (add_virtual_function): Don't set TREE_ADDRESSABLE.
+ * decl.h, decl.c (pending_addressable_inlines): Removed.
+ * decl2.c (pending_addressable_inlines): Renamed to saved_inlines.
+ * decl2.c (mark_inline_for_output): Do nothing if
+ DECL_SAVED_INLINE; otherwise set it (and add to saved_inlines list).
+ * decl2.c (finish_vtable_vardecl): SET_CLASSTYPE_INTERFACE_KNOWN
+ and set CLASSTYPE_INTERFACE_ONLY if there is a non-inline virtual.
+ * decl2.c (finish_file): Writing out inlines later, so we can
+ also handle the ones needed for vtbales.
+ * decl2.c (write_vtable_entries, finish_vtable_typedecl): Removed.
+
+ * cp-tree.h, class.c, decl2.c, search.c: Remove -fvtable-hack
+ and flag_vtable_hack. Use -fvtable-thunks and flag_vtable_thunks
+ instead. (The rationale is that these optimizations both break binary
+ compatibility, but should become the default in a future release.)
+
+Wed Apr 6 10:53:56 1994 Mike Stump <mrs@cygnus.com>
+
+ * class.c (modify_vtable_entries): Never reset the DECL_CONTEXT
+ of a fndecl, as we might not be from that vfield.
+
+Tue Apr 5 17:43:35 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * class.c (add_virtual_function): fix bug for pure virtual, so
+ that DECL_VINDEX of the dummy decl copied won't be error.
+ (see also Apr 4 change)
+
+Tue Apr 5 17:23:45 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * typeck.c (c_expand_return): Before checking that we're not
+ returning the address of a local, make sure it's a VAR_DECL.
+ (And don't worry about it being a TREE_LIST.)
+
+Tue Apr 5 13:26:42 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y (YYDEBUG): Always define.
+ * lex.c (YYDEBUG): Ditto.
+
+Mon Apr 4 11:28:17 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * class.c (finish_struct): backup out the change below, put the
+ new change for the same purpose. The change below breaks code.
+
+ * class.c (finish_struct): if pure virtual, copy node and make
+ RTL point to abort, then put in virtual table.
+ * decl2.c (grok_function_iit): reinstate Mar 31 change.
+
+Sat Apr 2 03:12:58 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * init.c (build_new): pedwarn about newing const and volatile
+ types.
+
+ * tree.c (get_identifier_list): Only do the special handling
+ thing if we're dealing with the main variant of the record type.
+
+ * cvt.c (convert_to_reference): When converting between
+ compatible reference types, use the pointer conversion machinery.
+ Don't just blindly overwrite the old type.
+
+Fri Apr 1 17:14:42 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * call.c (build_method_call): When looking at global functions,
+ be sure to use instance_ptr for the first argument, not some version
+ of it that has been cast to a base class. Also do this before
+ comparing candidates.
+
+Thu Mar 31 19:50:35 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * call.c (build_method_call): Constructors can be called for
+ const objects.
+
+Thu Mar 31 16:20:16 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * decl2.c (grok_func_init): do not abort as rtl for pur virtual
+ fucntions. They can be defined somewhere else.
+
+Sat Jan 23 23:23:26 1994 Stephen R. van den Berg (berg@pool.informatik.rwth-aachen.de)
+
+ * decl.c (init_decl_processing): Declare __builtin_return_address
+ and __builtin_frame_address for C++ as well.
+
+Thu Mar 31 12:35:49 1994 Mike Stump <mrs@cygnus.com>
+
+ * typeck2.c (store_init_value): Integral constant variables are
+ always constant, even when doing -fpic.
+
+Sat Jan 23 23:23:26 1994 Stephen R. van den Berg (berg@pool.informatik.rwth-aachen.de)
+
+ * decl.c (redeclaration_error_message): Pass the types to
+ comptypes.
+
+Wed Mar 30 21:29:25 1994 Mike Stump <mrs@cygnus.com>
+
+ Cures incorrect errors about pure virtuals in a class, when they
+ have been overridden in a derived class.
+
+ * search.c (get_abstract_virtuals): Reimplement.
+ * search.c (get_abstract_virtuals_1): New routine.
+
+Wed Mar 30 14:10:04 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * pt.c (push_template_decls): Make the pushed level pseudo
+ global.
+
+ * parse.y (extdefs): Don't pop everything if the current binding
+ level is pseudo_global.
+
+ * decl.c (pop_everything): Stop on reaching a pseudo-global
+ binding level.
+
+ * cp-tree.h (DECL_FUNCTION_MEMBER_P): Change to more reliable test.
+
+ * decl.c (duplicate_decls): Only copy DECL_SOURCE_{FILE_LINE} if
+ the old decl actually had an initializer.
+
+ * {various}: Clean up gcc -W complaints.
+
+ * cp-tree.h (DECL_FUNCTION_MEMBER_P): Currently defined to be
+ (DECL_CONTEXT (NODE) != NULL_TREE).
+
+ * parse.y (lang_extdef): Call pop_everything if necessary.
+
+ * decl.c (pop_everything): New function for popping binding
+ levels left over after a syntax error.
+ (pushdecl): Use DECL_FUNCTION_MEMBER_P to decide whether or not
+ a function is a member.
+
+Wed Mar 30 14:20:50 1994 Mike Stump <mrs@cygnus.com>
+
+ Cures calling a more base base class function, when a more derived
+ base class member should be called in some MI situations.
+
+ * search.c (make_binfo): Use more the more specialized base
+ binfos from the binfo given as the second argument to make_binfo,
+ instead of the unspecialized ones from the TYPE_BINFO.
+ * class.c (finish_base_struct): Ditto, update callers.
+ * search.c (dfs_get_vbase_types): Ditto.
+ * tree.c (propagate_binfo_offsets, layout_vbasetypes): Ditto.
+ * decl.c (xref_tag): Use NULL_TREE instead of 0.
+ * lex.c (make_lang_type): Ditto.
+
+Wed Mar 30 14:10:04 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (pushdecl): If pushing a C-linkage function, only do a
+ push_overloaded_decl.
+ (duplicate_decls): Standard overloading does not shadow built-ins.
+
+Tue Mar 29 00:54:18 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * pt.c (end_template_decl): Don't call push_overloaded_decl.
+
+ * init.c (do_friend): Don't call push_overloaded_decl.
+
+ * decl.c (pushdecl): Call push_overloaded_decl for functions and
+ function templates.
+ (duplicate_decls): functions and function templates are not
+ duplicates, but don't complain about calling this function to
+ compare them.
+ (push_overloaded_decl): Don't deal with linkage. Call
+ duplicate_decls.
+ (redeclaration_error_message): Deal with linkage.
+
+ * decl.c (start_function): If push_overloaded_decl returns an
+ older version of the function, deal with it.
+
+ * decl.c (start_function): Be sure only to push_overloaded_decl
+ for non-members.
+
+ * decl.c (grokfndecl): Put back clearing of DECL_CHAIN for
+ methods.
+ (start_function): Lose broken and redundant code for checking old
+ decl.
+
+ * init.c (add_friend): Give line numbers of both friend decls
+ when warning about re-friending.
+
+ * pt.c (tsubst): Use comptypes rather than == to compare the
+ types of the method as declared and as defined, since default
+ parameters may be different.
+
+ * call.c (build_method_call): Use brendan's candidate printing
+ routine.
+
+ * decl.c (start_method): Methods defined in the class body are
+ inline whether or not it's a template class.
+
+Mon Mar 28 16:39:26 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y (initdcl0): Add "extern" to current_declspecs if
+ have_extern_spec && ! used_extern_spcec.
+
+ * tree.c (really_overloaded_fn): A fn with more than one
+ overload.
+
+ * pt.c (end_template_decl): Use really_overloaded_fn.
+
+ * decl.c (duplicate_decls): When smashing a decl into a previous
+ definition, keep the old file and line.
+ Don't deal with overloaded functions.
+ Lose old code for checking arg types of functions.
+ Check for overloaded C functions.
+ (pushdecl): Deal with overloaded functions.
+ (start_decl): Expect pushdecl to return an appropriate function decl.
+ (start_function): Ditto.
+ (push_overloaded_decl): Don't check for overloaded C functions.
+
+ * *.c: Stop using DECL_OVERLOADED, it being archaic.
+ TREE_OVERLOADED should probably go, too.
+
+Mon Mar 28 14:00:45 1994 Ron Guilmette (rfg@netcom.com)
+
+ * typeck.c (comp_target_types): Call comp_target_parms with
+ strict == 1.
+
+Sun Mar 27 00:07:45 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y (empty_parms): Don't parse () as (...) in extern "C"
+ sections if we're compiling with -ansi or -pedantic.
+
+ * decl.c (decls_match): Don't treat (int) and (int&) as matching.
+
+ * decl2.c (grokfield): Don't pedwarn twice about initializing
+ field.
+
+ * decl.c (push_overloaded_decl): Warn about shadowing
+ constructor.
+ (redeclaration_error_message): Don't allow 'int a; int a;'
+
+ * cvt.c (build_up_reference): Only check for valid upcast if
+ LOOKUP_PROTECT is set, not just any flag.
+
+Fri Mar 25 01:22:31 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * lex.c (check_newline): When we see a #pragma implementation,
+ also set it for the main input file.
+
+ * init.c (build_new): Convert array size argument to size_t.
+
+ * parse.y (primary): If we're doing a parenthesized type-id, call
+ groktypename before passing it to build_new.
+
+ * call.c (build_method_call): Deal properly with const and
+ volatile for instances of reference type.
+
+ * decl.c (store_return_init): Change 'if (pedantic) error' to 'if
+ (pedantic) pedwarn'.
+
+ * decl.c (grokdeclarator): Don't complain about putting `static'
+ and `inline' on template function decls.
+
+Thu Mar 24 23:18:19 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * call.c (build_method_call): Preserve const & volatile on
+ `this'.
+
+Thu Mar 24 16:21:52 1994 Mike Stump <mrs@cygnus.com>
+
+ * init.c (build_new, build_vec_delete): Use global new and delete
+ for arrays.
+ * decl2.c (delete_sanity): Ditto.
+
+Thu Mar 24 02:10:46 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cvt.c (convert_to_reference): If i is an lvalue,
+ (int &)i -> *(int*)&i, as per 5.2.8p9 of the latest WP.
+ (convert_force): Call convert_to_reference with LOOKUP_COMPLAIN.
+
+Wed Mar 23 17:45:37 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (duplicate_decls): Also propagate DECL_TEMPLATE_MEMBERS
+ and DECL_TEMPLATE_INSTANTIATIONS.
+
+ * init.c (build_new): Handle array typedefs properly.
+
+Wed Mar 23 18:23:33 1994 Mike Stump <mrs@cygnus.com>
+
+ 30th Cygnus<->FSF merge.
+
+Wed Mar 23 00:46:24 1994 Mike Stump <mrs@cygnus.com>
+
+ * class.c (modify_vtable_entries): Avoid running off the end of the
+ virtuals list when processing a virtual destructor.
+ * class.c (get_vtable_entry): Ditto.
+
+Wed Mar 23 00:23:59 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (duplicate_decls): If two template decls don't match,
+ just return 0.
+
+Tue Mar 22 23:49:41 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (convert_for_assignment): Don't pedwarn about
+ converting function pointer to void *.
+
+Tue Mar 22 22:23:19 1994 Mike Stump <mrs@cygnus.com>
+
+ Major revamp of pointer to member functions. Cures major
+ nonfunctionality when used in casts, and MI situations.
+
+ * cvt.c (convert_force): Update call site of build_ptrmemfunc.
+ * typeck.c (convert_for_assignment): Ditto.
+ * typeck2.c (digest_init): Ditto.
+ * typeck2.c (process_init_constructor): Simplify by moving code into
+ digest_init.
+ * typeck2.c (digest_init): Do default_conversions on init value, if
+ we are processing pointer to member functions.
+ * class.c (get_vfield_offset): Now non-static. Convert bit offset
+ into byte offset.
+ * cp-tree.h (get_vfield_offset): Ditto.
+ * typeck.c (get_member_function_from_ptrfunc): Convert down to right
+ instance, before fetching vtable pointer.
+ * typeck.c (get_delta_difference): New routine.
+ * typeck.c (build_ptrmemfunc): Revamp to handle casting better, also
+ get vtable pointer out of right subobject.
+
+Tue Mar 22 17:56:48 1994 Mike Stump <mrs@cygnus.com>
+
+ * search.c (get_binfo): Return NULL instead of aborting, when
+ passed a UNION_TYPE.
+
+Tue Mar 22 12:44:54 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ These patches implement handling of redefinition/redeclaration of
+ templates.
+
+ * typeck.c (comptypes): Simplify. All TEMPLATE_TYPE_PARMs are
+ considered compatible.
+
+ * parse.y (template_def): Pass defn argument to end_template_decl.
+
+ * pt.c (end_template_decl): Add defn argument. Check for
+ redefinition. Simplify.
+
+ * error.c (OB_UNPUT): New macro, to remove mistakes.
+ (aggr_variety): Subroutine of dump_aggr_type.
+
+ * decl.c (decls_match): Support templates.
+ (duplicate_decls): No longer static. Don't try to lay out template
+ decls.
+ (pushdecl): Simplify.
+
+ * cp-tree.h (DECL_TEMPLATE_MEMBERS): Use DECL_SIZE instead of
+ DECL_INITIAL.
+
+Mon Mar 21 11:46:55 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * error.c (dump_decl): Support class template decls.
+ (dump_type): Don't adorn template type parms.
+
+ * decl.c (duplicate_decls): Save DECL_TEMPLATE_INFO from old decl
+ if it was a definition.
+ (redeclaration_error_message): Do the cp_error thang, and reject
+ redefinition of templates.
+
+Mon Mar 21 19:36:06 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * decl.c (grokdeclarator): Set TREE_PUBLIC for METHOD_TYPE
+ in FIELD context, when appropriate. Also,
+ CLASSTYPE_INTERFACE_ONLY is irrelevant to setting TREE_PUBLIC.
+ Also, simplify check for bogus return specifiers.
+
+Mon Mar 21 11:46:55 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y (after_type_declarator1): Expand type_quals.
+ (notype_declarator1): Ditto.
+ (absdcl1): Ditto.
+
+Sat Mar 19 01:05:17 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (grokdeclarator): Treat class-local typedefs like static
+ members; i.e. 'typedef int f();' means that f is a function type,
+ not a method type.
+
+ * parse.y (decl): Change direct_* back to *.
+ (type_id): Change direct_abstract_declarator to absdcl.
+ (direct_declarator, direct_initdecls, direct_initdcl0): Remove again.
+
+Fri Mar 18 12:47:59 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ These two patches fix crashes on instantiating a template inside a
+ function with C linkage or containing labels.
+
+ * class.c (current_lang_stacksize): No longer static.
+
+ * decl.c (struct saved_scope): Add lang_base, lang_stack,
+ lang_name, lang_stacksize, and named_labels.
+ (push_to_top_level): Save them.
+ (pop_from_top_level): Restore them.
+
+ * gxxint.texi (Parser): Update.
+
+ These two patches finish moving the task of expr/declarator
+ ambiguity resolution from the lexer to the parser, and add one more
+ r/r conflict. START_DECLARATOR can now be nuked.
+
+ * parse.y (decl): Add "direct_" in typespec X rules.
+ (direct_declarator): New nonterminal for
+ direct_after_type_declarator and direct_notype_declarator.
+ (direct_initdecls): Like initdecls, but uses direct_initdcl0.
+ (direct_initdcl0): Like initdcl0, but uses direct_declarator.
+ (named_parm): Add typespec direct_declarator rule.
+
+ * spew.c (yylex): #if 0 out START_DECLARATOR insertion.
+
+ These two patches disable some excessive cleverness on the part of
+ g++; a non-class declaration always hides a class declaration in the
+ same scope, and g++ was trying to unhide it depending on the
+ enclosing expression.
+
+ * spew.c (arbitrate_lookup): #if 0 out.
+
+ * decl.c (lookup_name): Never call arbitrate_lookup.
+
+ * parse.y (complex_notype_declarator1): Add '*'
+ complex_notype_declarator1 and '&' complex_notype_declarator1 rules.
+
+ * parse.y (complex_direct_notype_declarator): Restore id_scope
+ see_typename TYPENAME rule, remove all other rules beginning with
+ those tokens.
+ (notype_unqualified_id): Add '~' see_typename IDENTIFIER rule.
+
+Thu Mar 17 17:30:01 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ These changes fix the compiler's handling of the functional cast/
+ object declaration ambiguities in section 6.8 of the ARM. They also
+ add 11 reduce/reduce conflicts. Sigh.
+
+ * parse.y: Add precedence decls for OPERATOR and '~'.
+ (notype_unqualified_id): New nonterminal, encompasses all of the
+ ANSI unqualified-id nonterminal except TYPENAMEs.
+ (expr_or_declarator): New nonterminal to delay parsing of code like
+ `int (*a)'.
+ (primary): Use notype_unqualified_id.
+ (decl): Add typespec initdecls ';' and typespec declarator ';'
+ rules.
+ (initdcl0): Deal with the above.
+ (complex_notype_declarator1): A notype_declarator that is not also
+ an expr_or_declarator.
+ (complex_direct_notype_declarator): A direct_notype_declarator that
+ doesn't conflict with expr_or_declarator. Use
+ notype_unqualified_id. Remove id_scope see_typename TYPENAME rule.
+ (functional_cast): New nonterminal, for the three functional cast
+ rules. So that they can be moved after
+ complex_direct_notype_declarator.
+ (see_typename): Don't accept type_quals any more.
+
+ * decl2.c (reparse_decl_as_expr): New function to deal with parse
+ nodes for code like `int (*a)++;'.
+ (reparse_decl_as_expr1): Recursive subroutine of the above.
+ (finish_decl_parsing): New function to deal with parse nodes for
+ code like `int (*a);'. See the difference?
+
+Thu Mar 17 12:16:10 1994 Mike Stump <mrs@cygnus.com>
+
+ These changes break binary compatibility in code with classes
+ that use virtual bases.
+
+ * search.c (dfs_get_vbase_types): Simplify and correct to make
+ sure virtual bases are initialized in dfs ordering.
+ * search.c (get_vbase_types): Simplify and make readable.
+
+Thu Mar 17 12:01:10 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y: s/ typename / type_id /g
+
+Wed Mar 16 17:42:52 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * parse.y (typespec): add SCOPE TYPENAME for global scoped
+ type. e.g. ::B x.
+
+ * decl.c (complete_array_type): fix a bug that in -pendantic
+ mode even there's no initializer, it will continue to build
+ default index.
+
+Wed Mar 16 17:43:07 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y (direct_notype_declarator): Add PTYPENAME rule, remove
+ all of the scoped PTYPENAME rules.
+
+Wed Mar 16 16:39:02 1994 Mike Stump <mrs@cygnus.com>
+
+ * init.c (build_offset_ref): The value of A::typedef_name is
+ always the TYPE_DECL, and never an error.
+
+Tue Mar 15 20:02:35 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * search.c (get_base_distance_recursive): Two binfos can only
+ represent the same object if they are both via_virtual.
+
+ * class.c (finish_base_struct): Check vbases for ambiguity, too.
+
+ * search.c (get_vbase_types): Accept binfo argument, too.
+
+Tue Mar 15 19:22:05 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * decl.c (complete_array_type): complete TYPE_DOMAIN of the
+ initializer also, because back-end requires it.
+
+Tue Mar 15 15:33:31 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * error.c (dump_expr): Support member functions (which show up as
+ OFFSET_REFs).
+
+Mon Mar 14 16:24:36 1994 Mike Stump <mrs@cygnus.com>
+
+ * init.c (build_new): Set the return type of multidimensional
+ news correctly.
+
+Fri Mar 11 15:35:39 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * call.c (build_method_call): if basetype not equal to type
+ of the instance, use the type of the instance in building
+ destructor.
+
+Thu Mar 10 17:07:10 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * parse.y (direct_notype_declarator): add push_nested_type for
+ 'template_type SCOPED_NAME' rule.
+
+Tue Mar 8 00:19:58 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y (parm): Add typed_declspec1 {absdcl, epsilon} rules.
+
+Sat Mar 5 04:47:48 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y (regcast_or_absdcl): New nonterminal to implement late
+ reduction of constructs like `int ((int)(int)(int))'.
+ (cast_expr): Use it.
+ (sub_cast_expr): Everything that can come after a cast.
+ (typed_declspecs1): typed_declspecs that are not typed_typespecs.
+ (direct_after_type_declarator): Lose PAREN_STAR_PAREN rule.
+ (direct_abstract_declarator): Replace '(' parmlist ')' rule with
+ '(' complex_parmlist ')' and regcast_or_absdcl.
+ (parmlist): Split
+ (complex_parmlist): Parmlists that are not also typenames.
+ (parms_comma): Enabler.
+ (named_parm): A parm that is not also a typename. Use declarator
+ rather than dont_see_typename abs_or_notype_decl. Expand
+ typed_declspecs inline.
+ (abs_or_notype_decl): Lose.
+ (dont_see_typename): Comment out.
+ (bad_parm): Break out abs_or_notype_decl into two rules.
+
+Fri Mar 4 18:22:39 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl2.c (reparse_decl_as_casts): New function to change parse
+ nodes for `(int)(int)(int)' from "function taking int and returning
+ function taking int and returning function taking int" to "... cast
+ to int, cast to int, cast to int".
+
+ * decl2.c (reparse_decl_as_expr): Recursive function to change
+ parse nodes for `A()()' from "function returning function returning
+ A" to "A().operator()".
+
+ * parse.y (primary): Replace `typespec LEFT_RIGHT' rule with
+ `typespec fcast_or_absdcl' rule.
+ (fcast_or_absdcl): New nonterminal to implement late reduction of
+ constructs like `A()()()()'.
+ (typename): Replace `typespec absdcl1' rule with
+ `typespec direct_abstract_declarator' rule.
+ (direct_abstract_declarator): Replace `LEFT_RIGHT type_quals' rule
+ with `fcast_or_absdcl type_quals' rule.
+
+Fri Mar 4 16:18:03 1994 Mike Stump <mrs@cygnus.com>
+
+ * tree.c (lvalue_p): Improve OFFSET_REF handling, so that it
+ matches Section 5.5.
+
+Fri Mar 4 14:01:59 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * error.c (dump_type_prefix): Don't print basetype twice for
+ pmfs.
+
+Fri Mar 4 13:24:33 1994 Mike Stump <mrs@cygnus.com>
+
+ * typeck.c (convert_arguments): Handle setHandler(A::handlerFn)
+ so that it is like setHandler(&A::handlerFn). Cures an `invalid
+ lvalue in unary `&''.
+
+Fri Mar 4 11:15:59 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * gxxint.texi (Copying Objects): New section discussing default
+ op= problems with virtual inheritance.
+
+ * decl2.c (grokoptypename): Just does grokdeclarator and
+ build_typename_overload, since the parser can't call grokdeclarator
+ directly.
+
+ * method.c (build_typename_overload): Set IDENTIFIER_GLOBAL_VALUE
+ and TREE_TYPE on generated identifiers.
+
+ * decl.c (grokdeclarator): Don't deal with TYPE_EXPRs anymore.
+
+ * parse.y (parm): Convert `const char *' to `__opPCc' here.
+
+ * error.c (dump_decl): Say sorry rather than my_friendly_aborting
+ if we can't figure out what to do.
+ (dump_type*): Ditto.
+
+ * typeck2.c (build_m_component_ref): 'component' is an expr, not
+ a decl. Also move the IS_AGGR_TYPE check after the stripping of
+ REFERENCE_TYPE.
+
+Fri Mar 4 04:46:05 1994 Mike Stump <mrs@cygnus.com>
+
+ * call.c (build_method_call): Handle b->setHandler(A::handlerFn)
+ so that it is like b->setHandler(&A::handlerFn). Cures an `invalid
+ lvalue in unary `&''.
+
+Thu Mar 3 12:38:15 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y: Add precedence specification for START_DECLARATOR.
+ (type_quals): Move before primary.
+ (typename): Move before typed_declspecs, add 'typespec absdcl1' rule.
+
+ * decl2.c (grokoptypename): Lose.
+
+ * decl.c (grokdeclarator): Parse TYPE_EXPRs in the initial scan,
+ rather than waiting until later.
+
+Wed Mar 2 14:12:23 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y (unary_expr): Use 'typename' in 'new' rules, rather
+ than expanding it inline.
+ (typename): Expand empty option of (former) absdcl inline.
+ (abs_or_notype_decl): Ditto.
+ (absdcl): Lose empty rule.
+ (conversion_declarator): New nonterminal for 'typename' of 'operator
+ typename'.
+ (operator_name): Use it instead of absdcl.
+
+ * parse.y: Add precedence declarations for SCOPED_TYPENAME,
+ TYPEOF, and SIGOF.
+ (typed_declspecs): Accept typed_typespecs, rather than typespec
+ directly. Add rules with reserved_typespecquals.
+ (reserved_declspecs): Don't accept typespecqual_reserved at the
+ beginning of the list. The typed_declspecs rule will deal with this
+ omission.
+ (declmods): Accept nonempty_type_quals, rather than TYPE_QUAL
+ directly.
+
+ * parse.y (direct_notype_declarator,
+ direct_after_type_declarator, direct_abstract_declarator): Split up
+ the declarator1 nonterminals to match the draft standard and avoid
+ ambiguities.
+ (new_type_id, new_declarator, direct_new_declarator,
+ new_member_declarator): New nonterminals to implement the subset of
+ 'typename' allowed in new expressions.
+ (unary_expr): Use new_type_id instead of typename.
+ (after_type_declarator1, absdcl1): Fix semantics of member pointers.
+ (abs_member_declarator, after_type_member_declarator): Lose.
+
+ * parse.y (absdcl1): Don't require parens around
+ abs_member_declarator.
+ (abs_member_declarator): Lose see_typename from rules.
+ (after_type_member_declarator): Ditto.
+
+ * tree.c (get_identifier_list): New function, containing code
+ previously duplicated in get_decl_list and list_hash_lookup_or_cons.
+ (get_decl_list): Use it.
+ (list_hash_lookup_or_cons): Ditto.
+
+ * parse.y (typed_declspecs, declmods): It's not necessary to hash
+ the declspecs on class_obstack, so don't. This way typed_typespecs
+ can reduce to typed_declspecs.
+
+Wed Mar 2 14:29:18 1994 Jason Merrill (jason@cygnus.com)
+
+ * cvt.c (build_up_reference): If we aren't checking visibility,
+ also allow base->derived conversions.
+
+Mon Feb 28 15:14:29 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * typeck.c (build_c_cast): Remove bogus hack when converting
+ to a reference type.
+
+ * cp-tree.h (lang_decl::vbase_init_list, DECL_VBASE_INIT_LIST):
+ Removed, not used.
+ (lang_stype::methods, lang_decl::next_method): New fields.
+ (CLASSTYPE_METHODS, DECL_NEXT_METHOD): New macros.
+ * decl.c (duplicate_decls): Preserve DECL_NEXT_METHOD.
+
+ * cp-tree.h, decl2.c (flag_vtable_hack): New flag.
+ * decl2.c (finish_vtable_vardecl): If flag_vtable_hack,
+ and !CLASSTYPE_INTERFACE_KNOWN, try to use the presence of
+ a non-inline virtual function to control emitting of vtables.
+ * class.c (finish_struct): Build CLASSTYPE_METHODS list.
+ * search.c (build_vbase_vtables_init): Don't assemble_external
+ (yet) if flag_vtable_hack.
+ * class.c (build_vfn_ref): Ditto.
+
+Mon Feb 28 14:54:13 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y (component_decl): Don't include "typed_declspecs
+ declarator ';'" speedup, since it breaks enums.
+
+Fri Feb 25 15:43:44 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * class.c (finish_struct): Minor optimization for building
+ fn_fields list.
+
+Fri Feb 25 15:23:42 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (start_function): Fix detection of function overloading.
+
+Thu Feb 24 22:26:19 1994 Mike Stump <mrs@cygnus.com>
+
+ * lex.c (check_newline): #pragma interface can take a string
+ argument, just like #pragma implementation. #pragma implementation
+ checks for garbage on the line, line #pragma interface does. Main
+ input files do not auto implement like named files, #pragma
+ implementation must be used explicitly.
+
+Thu Feb 24 17:09:01 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y (components): Handle list of one again.
+ (notype_components): Ditto.
+ (after_type_declarator1): Take maybe_raises out again.
+
+ * gxxint.texi (Parser): Document additional r/r conflict.
+
+Wed Feb 23 14:42:55 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * gxxint.texi (Parser): Add node.
+
+ * Makefile.in (stamp-parse): Update expected conflict count.
+
+ * parse.y (various): Replace "declmods declarator" with "declmods
+ notype_declarator". The comment saying that "declmods declarator ';'"
+ corresponds to "int i;" was wrong; it corresponds to "const i;".
+ (component_decl): Add "typed_declspecs declarator ';'" rule; this
+ *does* correspond to "int i;". Change "declmods components" to
+ "declmods notype_components".
+ (components): Don't deal with a list of one anymore.
+ (notype_components): New nonterminal, corresponds to notype_declarator.
+ ({after_,no}type_component_decl{,0}): More new nonterminals.
+ ({after_,no}type_declarator): Fold in START_DECLARATOR token.
+ Eliminates four reduce/reduce conflicts.
+
+ (expr): Depend on nontrivial_exprlist instead of nonnull_exprlist.
+ (nontrivial_exprlist): New nonterminal: A list of at least two
+ expr_no_commas's.
+ (nonnull_exprlist): Depend on nontrival_exprlist.
+ Eliminates four reduce/reduce conflicts.
+
+ (named_class_head): Move intermediate code block into separate
+ nonterminal so that we can stick %prec EMPTY on it.
+
+ Add more %prec EMPTY's to eliminate remaining shift/reduce
+ conflicts.
+
+ (after_type_declarator): Add maybe_raises to fndecl rules.
+ (after_type_declarator_no_typename): Remove.
+ For correctness.
+
+ Document remaining reduce/reduce conflicts.
+
+Tue Feb 22 12:10:32 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * search.c (get_base_distance): Only bash BINFO_INHERITANCE_CHAIN
+ (TYPE_BINFO (type)) if we care about the path.
+
+ * tree.c (lvalue_p): A COND_EXPR is an lvalue if both of the
+ options are.
+
+Mon Feb 21 19:59:40 1994 Mike Stump <mrs@cygnus.com>
+
+ * Makefile.in (mostlyclean): lex.c is a source file, don't
+ remove.
+
+Sat Feb 19 01:27:14 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * parse.y: Eliminate 20 shift/reduce conflicts.
+
+Fri Feb 18 11:49:42 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * pt.c (type_unification): Add subr argument; if set, it means
+ that we are calling ourselves recursively, so a partial match is OK.
+ (unify): Support pointers to methods and functions.
+ (tsubst): Support method pointers.
+ * decl.c (build_ptrmemfunc_type): No longer static, so that
+ tsubst can get at it.
+
+ * init.c (is_aggr_typedef): Pretend template type parms are
+ aggregates.
+ * decl2.c (build_push_scope): If cname refers to a template type
+ parm, just grin and nod.
+
+ * call.c (build_overload_call_real): Pass subr argument to
+ type_unification.
+ * pt.c (do_function_instantiation): Ditto.
+ * class.c (instantiate_type): Ditto.
+
+ * search.c (get_base_distance): If BINFO is a binfo, use it and
+ don't mess with its BINFO_INHERITANCE_CHAIN.
+
+ * cvt.c (convert_to_reference): Fix temporary generation.
+ If ambiguous, return error_mark_node.
+
+ * init.c (build_new): Put back some necessary code.
+
+Thu Feb 17 15:39:47 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * init.c (build_new): Deal with array types properly.
+
+ * search.c (get_binfo): Become a shell for get_base_distance.
+ (get_binfo_recursive): Lose.
+ (get_base_distance_recursive): Find the path to the via_virtual base
+ that provides the most access.
+ (get_base_distance): Ditto.
+
+ * parse.y (explicit_instantiation): Syntax is 'template class
+ A<int>', not 'template A<int>'.
+
+ * typeck.c (convert_for_initialization): Remove bogus warning.
+
+ * parse.y (datadef): Revert patch of Oct 27.
+
+Thu Feb 17 15:12:29 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * class.c (build_vfn_ref): Cast delta field to ptrdiff_type_node,
+ rather than integer_type_node. Does wonders for the Alpha.
+
+Thu Feb 17 13:36:21 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (build_ptrmemfunc_type): Make sure that the pmf type
+ goes onto the same obstack as its target type.
+
+Wed Feb 16 00:34:46 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cvt.c (convert_to_reference): If converting via constructor
+ on local level, go back to build_cplus_new approach.
+
+ * tree.c (build_cplus_new): If with_cleanup_p, set cleanup slot
+ to error_mark_node to prevent expand_expr from building a cleanup
+ for this variable.
+
+ * lex.c (default_assign_ref_body): Return *this from the memcpy
+ version, too.
+
+ * decl.c (grok_reference_init): Just return if called with
+ error_mark_node, don't worry about initializing non-const reference
+ with temporary.
+
+ * cvt.c (convert_to_reference): Do the right thing for
+ non-aggregate reference conversions, pedwarn when generating a
+ non-const reference to a temporary.
+
+ * class.c (finish_struct): TYPE_HAS_COMPLEX_{INIT,ASSIGN}_REF and
+ TYPE_NEEDS_CONSTRUCTING all depend on TYPE_USES_VIRTUAL_BASECLASSES
+ again.
+
+Tue Feb 15 19:47:19 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (grok_reference_init): Pawn off a lot of the work on
+ convert_to_reference. Generally do the right thing.
+
+ * cvt.c (convert_to_reference): Conform to the initial comment;
+ i.e. don't create temps if decl != error_mark_node. Handle
+ cleanups better for temps that do get created. Don't pretend
+ that we can use an 'A' to initialize a 'const double &' just by
+ tacking on a NOP_EXPR. Support LOOKUP_SPECULATIVELY.
+
+ * call.c (build_method_call): Set TREE_HAS_CONSTRUCTOR on
+ constructor calls.
+
+Mon Feb 14 14:50:17 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (grok_reference_init): Make a temporary for initializing
+ const reference from constant expression.
+
+Mon Feb 14 11:31:31 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * cp-tree.h, decl.c (set_identifier_local_value): Deleted function.
+ * decl.c (pushdecl): Define decl in correct binding_level
+ (which isn't always the inner_binding_level).
+
+ * cvt.c (build_up_reference): Don't ever call expand_aggr_init.
+ It's ugly, and I don't think it's the right thing to do.
+
+ * cp-tree.h, class.c, decl.c, decl2.c, sp/search.c:
+ Remove NEW_CLASS_SCOPING, assuming it is always 1.
+ * decl.c (pop_decl_level): Removed; manually inlined.
+
+Sun Feb 13 19:04:56 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * class.h (candidate): Add basetypes field.
+
+ * call.c (build_method_call): Do access checking after choosing a
+ function, not before.
+
+ * Makefile.in (cvt.o, call.o, method.o): Depend on class.h.
+ (mostlyclean): Remove ../cc1plus.
+
+Fri Feb 11 11:52:26 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * class.c (finish_struct): Don't allow adjusting access to a field
+ of a base class if a local field has the same name.
+
+ * error.c (dump_type_prefix): Output basetype for METHOD_TYPEs.
+
+hu Jan 13 17:55:51 EST 1994 Gnanasekaran Swaminathan (gs4t@virginia.edu)
+
+ * cp-tree.h (DESTRUCTOR_NAME_P): do not confuse AUTO_TEMP names
+ with destructor names when either NO_DOLLAR_IN_LABEL or
+ NO_DOT_IN_LABEL are not defined.
+
+ Now `template <class T, T f(T&), const T*> class A {...}' works.
+
+ * pt.c (grok_template_type): substitute template parm types
+ with actual types in complex type as well.
+ (coerce_template_parms): update the grok_template_type ()
+ function call.
+
+ * pt.c (tsubst): Traverse method list using DECL_CHAIN.
+
+ * decl.c (grok_op_properties): Allow operator++/-- to have
+ default arguments.
+
+ * typeck2.c (store_init_value): Don't abort when called to
+ initialize a type that needs constructing with a CONSTRUCTOR.
+
+ * init.c (expand_aggr_init_1, CONSTRUCTOR case): If
+ store_init_value fails, build and expand an INIT_EXPR. If
+ store_init_value succeeds, call expand_decl_init.
+
+Fri Feb 11 02:49:23 1994 Mike Stump <mrs@cygnus.com>
+
+ * class.c (build_vbase_path): Use complete_type_p instead of
+ resolves_to_fixed_type_p to determine if the virtual bases are in
+ their right place for the type of expr. Cures problem of thinking a
+ virtual base class is one place, when it is in fact someplace else.
+
+Fri Feb 11 00:26:46 1994 Mike Stump <mrs@cygnus.com>
+
+ * init.c (resolve_offset_ref): Make sure we first convert to
+ intermediate type, if given, when dealing with members off `this'.
+ Solves an incorrrect `type `foo' is not a base type for type
+ `multiple'' when it is infact, a base type.
+
+Thu Feb 10 21:49:35 1994 Mike Stump <mrs@cygnus.com>
+
+ * class.c (modify_other_vtable_entries): Use get_binfo, instead
+ of binfo_value. Solves problem with compiler giving a `base class
+ `B' ambiguous in binfo_value (compiler error)' on complex MI
+ herarchies, when a virtual function is first defied in a virtual
+ base class.
+
+Thu Feb 10 17:19:32 1994 Mike Stump <mrs@cygnus.com>
+
+ * class.c (build_vbase_path): Don't complain about ambiguous
+ intermediate conversion when converting down to a virtual base
+ class, even if they might seem to be ambiguous.
+
+Thu Feb 10 12:18:26 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck2.c (build_functional_cast): #if 0 out constructor
+ inheritance code, improve error messages.
+
+ * class.c (finish_base_struct): Complain about base with only
+ non-default constructors in derived class with no constructors.
+
+ * decl.c (grokdeclarator): Fix detection of virtual new/delete.
+
+Wed Feb 9 22:02:32 1994 Mike Stump <mrs@cygnus.com>
+
+ * search.c (build_mi_virtuals, add_mi_virtuals,
+ report_ambiguous_mi_virtuals): Removed unneeded code.
+ * class.c (finish_struct_bits): Ditto.
+
+Wed Feb 9 11:27:17 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * pt.c (end_template_instantiation): Push decl before
+ pop_from_top_level.
+
+ * typeck2.c (build_m_component_ref): Make sure datum is of
+ aggregate type.
+
+ * init.c (get_type_value): New function, returns
+ IDENTIFIER_TYPE_VALUE or IDENTIFIER_CLASS_TYPE_VALUE or NULL_TREE.
+
+ * call.c (build_method_call): Don't die on call to destructor for
+ non-type.
+
+ * decl.c (grokdeclarator): Complain about virtual op new and op
+ delete, make static virtuals unvirtual instead of unstatic.
+
+ * typeck.c (build_c_cast): Also call default_conversion on
+ methods.
+
+ * decl.c (grokdeclarator): Don't complain about anonymous
+ bitfields.
+
+ * parse.y (simple_stmt, for loops): Move the continue point after
+ the cleanups.
+
+ * class.c (finish_struct): Fix setting of
+ TYPE_HAS_COMPLEX_INIT_REF.
+
+Tue Feb 8 13:21:40 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * init.c (build_new): Deal with `new double (1)'.
+
+ * class.c (finish_struct): TYPE_HAS_COMPLEX_*_REF are supersets of
+ TYPE_HAS_REAL_*_REF, but TYPE_HAS_COMPLEX_INIT_REF is independent of
+ TYPE_NEEDS_CONSTRUCTING.
+
+ * decl.c (duplicate_decls): Propagate access decls.
+
+ * typeck2.c (process_init_constructor): Accept empty_init_node
+ for initializing unions.
+
+ * class.c, lex.c, cp-tree.h: Use
+ TYPE_HAS_COMPLEX_ASSIGN_REF where TYPE_HAS_REAL_ASSIGN_REF was used
+ before, use TYPE_HAS_COMPLEX_INIT_REF for TYPE_NEEDS_CONSTRUCTING in
+ some places.
+
+ * decl.c (finish_decl): Don't complain about uninitialized const
+ if it was initialized before.
+
+Mon Feb 7 18:12:34 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * lex.c (default_assign_ref_body): Don't deal with vbases for
+ now.
+
+ * decl.c (finish_decl): Fix reversed logic for objects and other
+ things that need to be constructed but have no initializer.
+
+ * class.c (finish_struct): Don't set TYPE_HAS_* flags that are
+ set by grok_op_properties or finish_decl.
+
+ * decl.c: Don't warn about extern redeclared inline unless
+ -Wextern-inline is given.
+ * decl2.c (lang_decode_option): Ditto.
+ * cp-tree.h: Ditto.
+
+Mon Feb 7 17:29:24 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * decl.c (pushdecl_with_scope): Fix thinko. Add forward
+ declaration.
+
+ * decl.c (pushdecl_with_scope): New function.
+ * decl.c (pushdecl_top_level): Use new function.
+ * decl.c (pushtag): Initialize newdecl.
+ * decl.c (pushtag): Push new type decl into correct scope.
+
+Mon Feb 7 14:42:03 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * call.c, cvt.c, init.c, search.c, cp-tree.h:
+ Eradicate LOOKUP_PROTECTED_OK.
+
+Mon Feb 7 13:57:19 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * decl.c (pushtag, xref_tag), cp-tree.h: Add extra parameter
+ 'globalize' to signify implicit declarations.
+ * decl.c (globalize_nested_type, maybe_globalize_type): Removed.
+ * decl.c (set_identifier_type_value_with_scope): New function.
+ * decl.c (set_identifier_local_value): Simplify.
+ * spew.c (yylex, do_addr): Modify to return a _DEFN if a
+ forward declaration (followed by ';' and not preceded by 'friend').
+ * class.c, decl.c, except.c, init.c, parse.y,
+ pt.c, search.c: Add new argument to calls to xref_tag and
+ pushtag.
+
+Mon Feb 7 00:22:59 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-tree.h (ACCESSIBLY_UNIQUELY_DERIVED_P): New macro, means what
+ ACCESSIBLY_DERIVED_FROM_P meant before.
+ (ACCESSIBLY_DERIVED_FROM_P): Now disregards ambiguity.
+
+ * cvt.c (build_up_reference): Call get_binfo with PROTECT == 1.
+
+ * search.c (get_base_distance_recursive): Members and friends of
+ a class X can implicitly convert an X* to a pointer to a private or
+ protected immediate base class of X.
+ (get_binfo_recursive): Ditto.
+ (get_base_distance): Ignore ambiguity if PROTECT < 0.
+ (get_binfo): Lose multiple values of PROTECT.
+ (compute_access): Protected is OK if the start of the
+ search is an accessible base class of current_class_type.
+
+ * method.c (build_opfncall): Do check access on operator new here.
+
+ * decl.c (finish_function): Don't check access on operator new
+ here.
+
+Sun Feb 6 14:06:58 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (xref_tag): The base of a derived struct is NOT always
+ public. Duh.
+
+ * pt.c (do_explicit_instantiation): New function, called from
+ parser to do explicit function instantiation.
+ (type_unification): Allow the args list to be terminated with
+ void_list_node.
+ (do_pending_expansions): Look at i->interface for non-member
+ templates.
+
+ * parse.y (datadef): Move explicit_instantiation here.
+ (structsp): From here.
+ (datadef): Complain about `int;'.
+
+Sun Feb 6 12:33:18 1994 Per Bothner (bothner@kalessin.cygnus.com)
+
+ * pt.c (end_template_instantiation), cp-tree.h: Remove unused
+ second parameter, and simplify first from a TREE_LIST where
+ we only care about its TREE_VALUE to just the value (an IDENTIFIER).
+ * pt.c (instantiate_member_templates): Simplify argument list
+ from a TREE_LIST to just an IDENTIFIER.
+ * lex.c (yyprint): PRE_PARSED_CLASS_DECL is now just an IDENTIFIER.
+ * parse.y (template_instantiate_once): Simplify accordingly.
+ * decl.c (inner_binding_level): New. Use various places to
+ simplify.
+
+Sun Feb 6 02:49:37 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck2.c (build_functional_cast): int() -> int(0).
+
+Sat Feb 5 00:53:21 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * class.c (finish_struct): Don't do a bitwise copy for op= if the
+ class has a virtual function table.
+
+ * typeck.c (convert_for_initialization): Restore warnings about
+ not using defined op=. Should really be my_friendly_aborts, I
+ s'pose.
+
+Fri Feb 4 14:21:00 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * class.c (finish_struct): Tidy up conditions for doing bitwise
+ copies of objects.
+
+ * decl.c (build_default_constructor): #if 0 out.
+
+ * *: Eradicate TYPE_GETS_{ASSIGNMENT,ASSIGN_REF,CONST_ASSIGN_REF,
+ CONST_INIT_REF}, TYPE_HAS_REAL_CONSTRUCTOR.
+
+ * decl.c (grokdeclarator): Don't return void_type_node for
+ friends being defined here.
+
+ * init.c (perform_member_init): Only do the init if it's useful.
+
+ * lex.c (default_copy_constructor_body): If we don't need to do
+ memberwise init, just call __builtin_memcpy.
+ (default_assign_ref_body): Ditto.
+
+ * decl.c (grokdeclarator): If friendp && virtualp, friendp = 0.
+
+Fri Feb 4 13:02:56 1994 Mike Stump <mrs@cygnus.com>
+
+ * lex.c (reinit_parse_for_method, cons_up_default_function):
+ Don't give warn_if_unknown_interface warning when it came from a
+ system header file.
+ * pt.c (end_template_decl, instantiate_template): Ditto.
+ * decl.c (start_decl): Ditto.
+
+Fri Feb 4 00:41:21 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (grokdeclarator): Don't try to set TYPE_WAS_ANONYMOUS on
+ enums.
+
+ * decl2.c (constructor_name_full): Use IS_AGGR_TYPE_CODE instead of
+ IS_AGGR_TYPE, since we don't know it's a type.
+
+Thu Feb 3 11:36:46 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (grokdeclarator): Don't complain about anonymous unions.
+
+ * cp-tree.h (TYPE_WAS_ANONYMOUS): This struct was originally
+ anonymous, but had a name given to it by a typedef.
+
+ * decl.c (grokdeclarator): When renaming an anonymous struct, set
+ TYPE_WAS_ANONYMOUS.
+
+ * decl2.c (constructor_name_full): Use TYPE_WAS_ANONYMOUS.
+
+ * cp-tree.h (DECL_UNDEFINED_FRIENDS): #if 0 out.
+
+ * init.c (xref_friend): Don't set up DECL_UNDEFINED_FRIENDS.
+ (embrace_waiting_friends): Don't use DECL_UNDEFINED_FRIENDS.
+
+ * decl.c (grokdeclarator): Set TYPE_NESTED_NAME properly on nested
+ anonymous structs that get typedef'd.
+
+ * decl.c (grokdeclarator): Always return void_type_node for
+ friends.
+
+ * error.c (dump_function_decl): Don't use DECL_CLASS_CONTEXT for
+ friends.
+ (dump_function_decl): Don't print out default args for
+ a function used in an expression.
+
+ * decl.c (grokdeclarator): Give error on abstract declarator used
+ in an invalid context (i.e. `void (*)();').
+
+ * error.c (cp_line_of): Support _TYPE nodes.
+ (cp_file_of): Ditto.
+
+ * cvt.c (build_up_reference): Don't abort if passed a SAVE_EXPR;
+ it can happen for the RHS of an assignment stmt where the LHS is
+ a COND_EXPR.
+
+ * init.c (expand_aggr_init_1): Deal with bracketed initializer
+ lists properly.
+
+ * class.c (finish_struct): Deal with enumerators and typedefs
+ again.
+
+Wed Feb 2 11:30:22 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * class.c (finish_struct): Tidy up loop over fields.
+
+ * errfn.c (cp_thing): Don't advance twice after a format.
+
+ * class.c (finish_struct): Complain about needing a constructor
+ if a member has only non-default constructors, and don't try to
+ generate a default constructor.
+
+ * decl.c (finish_decl): Also do the constructor thing if
+ TYPE_NEEDS_CONSTRUCTING is set (for arrays).
+
+ * search.c (unuse_fields): New function: mark all fields in this
+ type unused.
+ (dfs_unuse_fields): Helper function.
+
+ * class.c (pushclass): If the new class is the same as the old
+ class, still unuse the fields.
+ (unuse_fields): Move to search.c.
+
+ * decl.c (grok_op_properties): Add friendp argument.
+ (grokfndecl): Pass it.
+ (start_method): Ditto.
+
+ * decl2.c (delete_sanity): Add use_global_delete parameter to catch
+ ::delete calls.
+
+ * parse.y (unary_expr): Pass new parameter to delete_sanity.
+
+ * lex.c (default_copy_constructor_body): Don't choke if the union
+ has no fields.
+ (default_assign_ref_body): Ditto.
+
+ * call.c (compute_conversion_costs_ansi): Do the right thing for
+ ellipsis matches.
+
+ * decl.c (push_to_top_level): Optimize.
+
+ * decl.c (start_function): Look for the lexical scope of a friend
+ in DECL_CLASS_CONTEXT.
+
+ * init.c (do_friend): Set DECL_CLASS_CONTEXT on global friends.
+
+Tue Feb 1 15:59:24 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-tree.h (TREE_GETS_PLACED_NEW): New macro.
+
+ * init.c (init_init_processing): Don't assign BIN/BID to the
+ IDENTIFIER_GLOBAL_VALUEs of their respective operators.
+ (build_new): Check TREE_GETS_PLACED_NEW.
+
+ * decl.c (grok_op_properties): Don't set TREE_GETS_NEW for a decl of
+ op new with placement, set TREE_GETS_PLACED_NEW.
+
+ * cp-tree.h (ANON_UNION_P): New macro. Applies to decls.
+
+ * class.c (finish_struct): Don't treat anonymous unions like
+ other aggregate members. Do synthesize methods for unions without
+ a name, since they may or may not be "anonymous unions".
+
+ * decl2.c (grok_x_components): Wipe out memory of synthesized methods
+ in anonymous unions.
+
+ * lex.c (default_copy_constructor_body): Support unions.
+ (default_assign_ref_body): Ditto.
+
+Mon Jan 31 12:07:30 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-tree.h: Fix documentation of LOOKUP_GLOBAL, add prototypes.
+
+ * error.c (args_as_string): New function (%A), like type_as_string
+ except NULL_TREE -> "..."
+
+ * call.c (build_overload_call_real): Fix for new overloading.
+
+ * decl.c (grok_op_properties): Set all of the TYPE_OVERLOADS_* flags
+ here.
+
+ * parse.y (operator_name): Instead of here.
+
+ * typeck2.c (build_functional_cast): Treat a TREE_LIST as a list
+ of functions.
+
+ * call.c (build_overload_call_real): Support LOOKUP_SPECULATIVELY.
+
+ * method.c (build_opfncall): Don't need to massage return value
+ any more, call build_overload_call with all flags.
+
+ * typeck.c (build_x_binary_op): Put back speculative call to
+ build_opfncall.
+ (build_x_unary_op): Ditto.
+ (build_x_conditional_expr): Ditto.
+
+Mon Jan 31 10:00:30 1994 Mike Stump <mrs@cygnus.com>
+
+ * cvt.c (build_type_conversion_1): Change call to pedwarn into
+ warning, and conditionalize upon warn_cast_qual.
+
+Fri Jan 28 11:48:15 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * search.c (lookup_field): If xbasetype is a binfo, copy it to
+ avoid clobbering its inheritance info.
+
+ * call.c (build_method_call): Don't overwrite basetype_path with
+ TYPE_BINFO (inst_ptr_basetype) if they have the same type.
+
+ * search.c (compute_access): Fix handling of protected inheritance
+ and friendship with the enclosing class.
+
+ * typeck2.c (store_init_value): Allow passing of TREE_CHAIN for
+ initialization of arbitrary variable.
+
+ * typeck2.c (build_functional_cast): Only try calling a method if
+ one exists.
+
+ * decl.c (grokdeclarator): Move handling of constructor syntax
+ initialization into first loop for generality.
+ (parmlist_is_random): Lose.
+
+ * lex.c (cons_up_default_function): Set TREE_PARMLIST on arguments
+ to default function.
+
+Thu Jan 27 19:26:51 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (grokparms): Abort if we get called with something we don't
+ expect.
+
+Thu Jan 27 17:37:25 1994 Mike Stump <mrs@cygnus.com>
+
+ * call.c (build_overload_call_real): Change argument complain to
+ flags to match style of rest of code. Pass it down to
+ build_function_call_real as necessary.
+ * call.c (build_overload_call, build_overload_call_maybe): Change
+ argument complain to flags to match style of rest of code.
+ * cp-tree.h (build_function_call_real): Added fourth flags
+ argument.
+ * cvt.c (convert_to_reference): Only give warning messages, if
+ LOOKUP_COMPLAIN is set.
+ * typeck.c (build_x_function_call): Change simple complain
+ argument to build_overload_call_maybe and build_overload_call, to
+ LOOKUP_COMPLAIN to match style of rest of code.
+ * typeck2.c (build_functional_cast): Ditto.
+ * typeck.c (build_function_call_real): Add flags, so that we can
+ not complain, if we don't want to complain. Complain about
+ arguments, if we are complaining, otherwise don't.
+ * typeck.c (build_function_call, build_function_call_maybe):
+ Stick in flags argument.
+ * typeck.c (build_x_binary_op, build_x_unary_op,
+ build_x_conditional_expr, build_x_compound_expr): Follow style of
+ build_x_indirect_ref, as it is more correct and more common.
+
+Thu Jan 27 14:36:20 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * call.c (build_method_call): Don't check for being called with
+ a pointer.
+
+ * decl2.c (finish_file): Don't play with DECL_CLASS_CONTEXT for the
+ static initializer function.
+
+ * init.c (build_member_call): Use convert_force here, too.
+
+ * search.c (compute_access): Only treat static members specially
+ if they are referenced directly.
+
+Wed Jan 26 18:28:14 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * gxxint.texi (Access Control): New node.
+
+ * search.c (current_scope): New function; returns whichever of
+ current_class_type and current_function_decl is the most nested.
+ (compute_access): Total overhaul to make it clearer and more
+ correct. Don't use the cache for now; in the only situation where
+ it was used before, it gained nothing. This frees up three of the
+ DECL_LANG_FLAGs for possible other use!
+
+ * cp-tree.h: #if 0 out DECL_PUBLIC & friends.
+
+ * typeck.c (build_component_ref_1): Don't check DECL_PUBLIC.
+
+ * call.c (build_method_call): Use convert_force to cast `this' --
+ rely on the access checking for the method itself.
+
+ * init.c (is_friend): Do the nesting thing, handle types. I am
+ my own friend.
+ (is_friend_type): Become a shell for is_friend.
+ (add_friend): Never stick in ctype.
+ Why are the friendship functions in init.c, anyway?
+
+Wed Jan 26 17:50:00 1994 Mike Stump <mrs@cygnus.com>
+
+ * cvt.c (build_type_conversion_1): Don't conditionalize call to
+ pedwarn upon pedantic.
+
+Wed Jan 26 17:20:46 1994 Mike Stump <mrs@cygnus.com>
+
+ * cvt.c (convert_to_reference): Add 8.4.3 checking so that one
+ gets a warning if one tries to initialize a non-const & from a
+ non-lvalue.
+ * cvt.c (convert_to_reference): Use %P format for argument
+ numbers in warnings.
+
+Wed Jan 26 14:35:06 1994 Mike Stump <mrs@cygnus.com>
+
+ * init.c (build_delete): Follow style in call.c to construct the
+ virtual call to the desctructor, as that code is right. Fixes a
+ problem of the compiler saying a pointer conversion is ambiguous.
+
+Wed Jan 26 11:28:14 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-tree.h (VTABLE_NAME_P): Change other occurrence of
+ VTABLE_NAME_FORMAT to VTABLE_NAME.
+
+ * *: s/visibility/access/g
+
+Tue Jan 25 18:39:12 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (build_modify_expr): Don't smash references if INIT_EXPR.
+
+Tue Jan 25 13:54:29 1994 Mike Stump <mrs@cygnus.com>
+
+ * init.c (build_delete): Back out Jan 17th & 18th pacthes, as
+ they break libg++.
+
+Tue Jan 25 13:11:45 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * decl.c (duplicate_decls): Fix pointer arithmetic.
+
+Mon Jan 24 15:50:06 1994 Chip Salzenberg (chip@fin.uucp)
+
+ [ cp-* changes propagated from c-* changes in 940114 snapshot ]
+ * cp-parse.y (maybe_attribute): Allow multiple __attribute__
+ clauses on a declaration.
+
+Mon Jan 24 17:06:23 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * class.c (finish_struct): Do synthesize methods for anon
+ structs, just not unions.
+
+Mon Jan 24 13:50:13 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * decl.c (xref_tag): handle anonymous nested type.
+ * decl.c (globalize_nested_type): add no globalize bit check.
+ * spew.c (hack_more_ids) : templated nested decl not push top
+ level.
+
+ * parse.y : get rid of 'goto do_components'. It is much better
+ for debugging.
+
+ * decl.c (is_anon_name): get rid of the function and use the
+ macro ANON_AGGRNAME_P.
+ * pt.c : ditto.
+
+Fri Jan 21 14:06:02 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * class.c (finish_struct): Don't synthesize any methods for
+ anonymous structs/unions.
+
+ * typeck.c (build_modify_expr): Don't treat pmf's as class objects.
+
+Thu Jan 20 18:56:46 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * method.c (build_opfncall): Call build_indirect_ref on
+ synthesized instance for operator delete.
+
+ * pt.c (type_unification): Don't abort if called with a list of
+ types in ARGS.
+
+ * class.c (instantiate_type): Deal with function templates.
+
+Thu Jan 20 16:55:35 1994 Jim Wilson (wilson@sphagnum.cygnus.com)
+
+ * Makefile.in (CC): Default to cc not gcc.
+
+Thu Jan 20 13:47:54 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (build_modify_expr): Call constructor if appropriate.
+
+ * decl.c (push_to_top_level): Clear out class-level bindings cache.
+
+Wed Jan 19 13:51:22 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * call.c (resolve_scope_to_name): Work recursively (previously only
+ looked down one level).
+
+ * lex.c (do_pending_inlines): If we're still dealing with the last
+ batch of inlines, don't start working on a new one.
+
+ * Makefile.in (stamp-parse): Update conflict count.
+ (TAGS): Fix.
+
+ * parse.y (explicit_instantiation): New rule; implements
+ 'template A<int>' syntax (though not 'template foo(int)' yet).
+ (structsp): Add explicit_instantiation.
+
+Tue Jan 18 13:53:05 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * class.c (finish_struct, etc.): Simplify decision to synthesize
+ a destructor.
+
+ * call.c, class.c, cp-tree.h, decl.c, init.c,
+ ptree.c, search.c, typeck.c, typeck2.c: Nuke
+ TYPE_NEEDS_CONSTRUCTOR (change all calls to TYPE_NEEDS_CONSTRUCTING).
+ * init.c (expand_aggr_init_1): Don't try non-constructor methods
+ of initializing objects.
+ (build_new): Don't try other methods if the constructor lookup fails.
+
+ * class.c (finish_base_struct): Set cant_have_default_ctor and
+ cant_synth_copy_ctor properly.
+ (finish_struct): Ditto.
+
+Mon Jan 17 13:58:18 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * typeck.c (build_modify_expr_1): #if 0 out again.
+ (build_modify_expr): #if 0 out memberwise init code again.
+
+ * lex.c (default_copy_constructor_body): Be const-correct.
+ (default_assign_ref_body): Ditto.
+
+ * init.c (perform_member_init): Use TYPE_HAS_CONSTRUCTOR to decide
+ whether or not to use it, rather than TYPE_NEEDS_CONSTRUCTING.
+ (expand_aggr_init): Disable silent conversion from initializer list
+ to list of args for a constructor.
+
+ * class.c (base_info): Lose needs_default_ctor.
+ (finish_base_struct): Ditto.
+ (finish_struct): Ditto.
+
+ * decl.c (init_decl_processing): Don't turn off flag_default_inline
+ just because flag_no_inline is on.
+ (finish_decl): Use TYPE_HAS_CONSTRUCTOR to decide to use
+ constructor.
+
+ * class.c (finish_struct): Synthesize default ctor whenever
+ allowed.
+
+ * Makefile.in (TAGS): Don't try to run etags on cp-parse.y.
+
+Sat Jan 15 18:34:33 1994 Mike Stump <mrs@cygnus.com>
+
+ * Makefile.in, configure: Handle the C++ front-end in a
+ subdirectory.
+ * cp-*: Move C++ front-end to cp/*.
+
+Fri Jan 14 14:09:37 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-typeck.c (build_function_call_real): Modify to match other
+ instances of taking the address of the function.
+
+ * cp-class.c (finish_struct): Set TYPE_HAS_REAL_CONSTRUCTOR to 1 if
+ there are non-synthesized constructors.
+ Only set TYPE_NEEDS_CONSTRUCTOR if TYPE_HAS_REAL_CONSTRUCTOR.
+ Always generate copy constructor if possible.
+
+ * cp-tree.h (lang_type): Add has_real_constructor bitfield.
+ (TYPE_HAS_REAL_CONSTRUCTOR): Define.
+
+ * cp-lex.c (default_copy_constructor_body): Use init syntax
+ for all bases.
+
+ * cp-type2.c (store_init_value): Only give error for initializer list
+ if TYPE_HAS_REAL_CONSTRUCTOR.
+
+Thu Jan 13 15:38:29 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-tree.h (DECL_SYNTHESIZED): Add defn.
+ (lang_decl): Add synthesized bitfield to decl_flags.
+
+ * cp-lex.c (cons_up_default_function): Use DECL_SYNTHESIZED to mark
+ artificial methods, rather than a line # of 0.
+
+Fri Jan 14 18:25:29 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * cp-decl (xref_tag): fix a bug in conflict type.
+ * cp-parse.y : add SCOPED_NAME for uninstantiated template nested
+ type reference.
+ * cp-spew.c (yylex) : generated SCOPED_NAME token.
+ * cp-lex.c (yyprint): handle SCOPED_NAME.
+
+Fri Jan 14 17:00:29 1994 Mike Stump <mrs@cygnus.com>
+
+ * cp-decl.c (pushdecl): Revert patch from Jan 11 19:33:03, as it is
+ not right.
+
+Thu Jan 13 14:00:35 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * cp-decl2.c (grok_x_components): fix a bug that enum type does not
+ have type_flags.
+
+Thu Jan 13 11:39:34 1994 Mike Stump <mrs@cygnus.com>
+
+ Ensure that all vtable pointers are initialized with all the right
+ values.
+
+ * cp-class.c (is_normal): Changed to reflect new meaning of
+ CLASSTYPE_VFIELD_PARENT.
+ * cp-class.c (maybe_fixup_vptrs): Use of
+ CLASSTYPE_NEEDS_VIRTUAL_REINIT here is misguided. Use
+ BINFO_MODIFIED instead.
+ * cp-class.c (finish_struct): Changed to reflect new meaning of
+ CLASSTYPE_VFIELD_PARENT.
+ * cp-decl.c (get_binfo_from_vfield): Removed, unneeded now.
+ * cp-decl.c (finish_function): Use init_vtbl_ptrs, instead of open
+ coding it here.
+ * cp-init.c (init_vfields): Changed name to init_vtbl_ptrs, and
+ re-implement.
+ * cp-init.c (emit_base_init): Use new name init_vtbl_ptrs.
+ * cp-tree.h (vfield_parent): Changed to integer.
+ * cp-tree.h (CLASSTYPE_VFIELD_PARENT): Changed docs to reflect new
+ meaning.
+ * cp-tree.h (init_vtbl_ptrs): Added init_vtbl_ptrs.
+
+Wed Jan 12 18:24:16 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * cp-decl.c (xref_tag): re-implement globalize nested type.
+ * cp-decl2.c (grok_x_components): ditto.
+ * cp-parse.y: ditto.
+ * cp-tree.h (lang_type): add no_globalize bit in type_flags.
+
+Wed Jan 12 14:08:09 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-decl.c (grokdeclarator): Don't set TREE_PUBLIC on friend
+ decls with a definition attached.
+
+ * cp-typeck.c (build_modify_expr): Undo previous change in the case
+ of INIT_EXPRs.
+
+Tue Jan 11 19:33:03 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-typeck.c (build_modify_expr): Replace code for generating
+ assignment semantics for classes with an error.
+ (build_modify_expr_1): #if 0 out.
+
+ * cp-decl.c (pushdecl): Patch bogus design of pushdecl
+ behavior for overloaded functions (it doesn't push anything).
+
+ * cp-class.c (finish_struct): When generating default op=,
+ set TYPE_HAS_ASSIGNMENT.
+
+Mon Jan 10 18:48:06 1994 Mike Stump <mrs@cygnus.com>
+
+ * cp-cvt.c (convert): Make {double, clashing enum} -> enum
+ invalid.
+ * cp-typeck.c (convert_for_assignment): Simplify.
+ * cp-decl2.c (warn_enum_clash): Removed.
+ * invoke.texi (-Wenum-clash): Removed.
+ * toplev.c (-Wenum-clash): Removed.
+
+Mon Jan 10 17:48:37 1994 Kung Hsu (kung@mexican.cygnus.com)
+
+ * cp-decl.c (finish_decl): fix incorrect popclass call.
+
+ * cp-decl.c (is_anon_name): new function, check whether the name
+ is anonymous name generated by compiler.
+ * cp-decl.c (grokdeclarator): allow nested SCOPE_REF
+ * cp-spew.c (hack_more_ids): handle nested type in template.
+ * cp-parse.y : handle nested type reference in uninstantiated
+ template.
+ * cp-call.c (build_method_call): handle uninstantiated template
+ case.
+ * cp-pt.c (search_nested_type_in_tmpl): new function, search nested
+ type in template.
+ * cp-pt.c (lookup_nested_type_by_name): new function, lookup nested
+ type by name.
+ * cp-pt.c (tsubst): handle nested type search by name.
+
+Mon Jan 10 14:32:18 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-init.c (build_member_call): Propagate qualifiers to new type.
+
+ * cp-call.c (build_method_call): Count functions the new way.
+
+Fri Jan 7 19:03:26 1994 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-decl.c (pushtag): Set DECL_ASSEMBLER_NAME for nested classes,
+ too.
+
+Tue Jan 4 16:45:51 1994 Kung Hsu (kung@cirdan.cygnus.com)
+
+ * cp-parse.y: change to handle whether to globalize nested class.
+ * cp-decl.c(xref_tag, maybe_globalize_type): Ditto.
+
+Mon Jan 3 22:22:32 1994 Gerald Baumgartner (gb@cygnus.com)
+
+ * Makefile.in cp-call.c cp-class.c cp-cvt.c cp-decl.c cp-decl2.c
+ cp-error.c cp-init.c cp-lex.c cp-lex.h cp-method.c cp-parse.y
+ cp-spew.c cp-tree.c cp-tree.h cp-type2.c cp-typeck.c cp-xref.c
+ gplus.gperf toplev.c: Incorporated C++ signature extension.
+ * cp-sig.c: New file, contains most of signature processing.
+ * cp-hash.h: Regenerated from gplus.gperf.
+
+ * gcc.1 g++.1: Added explanation for the `-fhandle-signatures'
+ and `-fno-handle-signatures' command line flags.
+
+ * gcc.texi: Changed the last-modification date.
+ * invoke.texi: Added `-fhandle-signatures' in the list of
+ C++ language options. Added explanation for this option.
+
+Tue Dec 28 21:10:03 1993 Mike Stump <mrs@cygnus.com>
+
+ * cp-init.c (expand_vec_init): Remove comptypes test, as it is too
+ harsh here.
+
+Tue Dec 28 13:42:22 1993 Mike Stump <mrs@cygnus.com>
+
+ * cp-pt.c (do_pending_expansions): Decide to expand a template
+ member function, based upon it's class type, not the class type of
+ the first place it was declared.
+
+Tue Dec 28 05:42:31 1993 Mike Stump <mrs@cygnus.com>
+
+ * cp-class.c (is_normal): New routine, use to determine when the
+ given binfo is the normal one. (The one that should have the simple
+ vtable name.)
+ * cp-class.c (modify_other_vtable_entries): Use DECL_ASSEMBLER_NAME
+ to check if two fndecls are `the same'. Sometimes this routine can
+ modify the main vtable, and normal should be 1, in that case, so use
+ is_normal() to determine if this is the main vtable for the class.
+ Don't recurse down virtual bases, as they are shared, and we take
+ care of them elsewhere.
+ * cp-class.c (modify_vtable_entries): If we have already updated the
+ vtable with the new virtual, don't do it again.
+ * cp-class.c (finish_struct): Set CLASSTYPE_VFIELD_PARENT as
+ appropriate. Do virtual function overriding in virtual bases, after
+ normal overriding, so that the base function list in DECL_VINDEX is
+ not overridden, before we have a chance to run through the list.
+ Use DECL_ASSEMBLER_NAME to check if two fndecls are `the same'.
+ Make sure we pass the right address into modify_vtable_entries.
+ * cp-tree.h (CLASSTYPE_VFIELD_PARENT): New field to indicate which
+ binfo is the one that has the vtable that we based our vtable on.
+
+Fri Dec 24 09:40:52 1993 Michael Tiemann (tiemann@blues.cygnus.com)
+
+ * cp-typeck.c (c_expand_start_case): Use default_conversion to
+ convert expression from reference type if necessary.
+
+Wed Dec 22 17:58:43 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-typeck.c (build_unary_op): Make sure that it's a TREE_LIST before
+ trying to read its TREE_VALUE.
+
+ * cp-class.c (finish_struct_methods): Clear DECL_IN_AGGR_P here.
+ (finish_struct): Instead of here.
+
+Tue Dec 21 14:34:25 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * cp-tree.c (list_hash_lookup_or_cons): Make sure the type doesn't
+ have TYPE_PTRMEMFUNC_P set before we try to build its
+ CLASSTYPE_ID_AS_LIST.
+ (get_decl_list): Likewise, when trying to read it.
+
+ * cp-tree.h (VTABLE_NAME): No def with NO_{DOLLAR,DOT} defined.
+ (VTABLE_NAME_P): Use it instead of VTABLE_NAME_FORMAT.
+
+Mon Dec 20 13:35:03 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * cp-typeck.c (rationalize_conditional_expr): New function.
+ (unary_complex_lvalue): Use it.
+ (build_modify_expr): Use it, since trying to do an ADDR_EXPR of it
+ with build_unary_op won't cut it. Don't wrap the COND_EXPR with a
+ SAVE_EXPR either.
+
+ * cp-decl2.c (explicit_warn_return_type): Deleted variable.
+ (lang_decode_option): Set warn_return_type, not explicit_*, for
+ -Wreturn-type and -Wall. This is what rest_of_compilation uses to
+ decide if it should go into jump_optimize or not.
+ * cp-tree.h (explicit_warn_return_type): Deleted.
+ * cp-decl.c (grokdeclarator): Use warn_return_type, not explicit_*.
+ (finish_function): Also complain about no return in a non-void fn if
+ we're being pedantic (don't rely on use of -Wreturn-type).
+
+Fri Dec 17 15:45:46 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * cp-decl.c (grokdeclarator): Forbid declaration of a function as
+ static if it's being done inside another function.
+
+ * cp-search.c (compute_visibility): Check for friendship both ways.
+
+Fri Dec 17 14:28:25 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-cvt.c (build_default_binary_type_conversion): Make error
+ messages more helpful.
+
+ * cp-error.c (op_as_string): New function, returns "operator =="
+ given EQ_EXPR or suchlike.
+
+Fri Dec 17 13:28:11 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * cp-call.c (print_n_candidates): New function.
+ (build_overload_call_real): Use it when we complain about a call
+ being ambiguous.
+
+Fri Dec 17 12:41:17 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-call.c (build_method_call): Fix checking for static call
+ context.
+
+ * cp-method.c (build_opfncall): Call build_indirect_ref on argument
+ to operator new.
+
+ * cp-init.c (build_new): Don't mess with rval when building
+ indirect ref.
+
+Thu Dec 16 16:48:05 1993 Kung Hsu (kung@cirdan.cygnus.com)
+
+ * cp-lex.c (default_assign_ref_body): add check when TYPE_NESTED_
+ NAME(type) may not be exist. It's not a problem for old compiler.
+
+Thu Dec 16 14:46:06 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * cp-tree.h (CLASSTYPE_ALTERS_VISIBILITIES_P): Delete macro, it's
+ never used for anything.
+ (struct lang_type, member type_flags): Delete field
+ `alters_visibility', and up `dummy' by 1.
+ * cp-class.c (finish_base_struct): Delete code that copies the
+ setting of CLASSTYPE_ALTERS_VISIBILITIES_P.
+ (finish_struct): Delete code that sets it.
+
+Thu Dec 16 14:44:39 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-decl.c, cp-init.c, cp-typeck.c: Fix arguments to
+ build_method_call that I messed up before.
+
+ * cp-search.c (get_base_distance): If protect > 1, allow immediate
+ private base.
+
+ * cp-class.c (finish_base_struct): Set cant_synth_* correctly.
+ (finish_struct): Ditto. Well, nigh-correctly; it won't deal
+ properly with the case where a class contains an object of an
+ ambiguous base class which has a protected op=. Should be fixed
+ when the access control code gets overhauled.
+ (finish_struct_methods): Set TYPE_HAS_NONPUBLIC_* correctly.
+
+Thu Dec 16 12:17:06 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * cp-lex.c (real_yylex): Turn the code back on that deals with
+ __FUNCTION__ and __PRETTY_FUNCTION__. Don't use lookup_name, to
+ avoid the ambiguity problems that led to it being turned off in the
+ first place.
+
+ * cp-method.c (hack_identifier): Also check for a TYPE_PTRMEMFUNC_P
+ to see if something is a method.
+
+Wed Dec 15 18:35:58 1993 Mike Stump <mrs@cygnus.com>
+
+ * cp-typeck.c (build_modify_expr): Avoid error messages on small
+ enum bit fields.
+ * cp-typeck.c (convert_for_assignment): Add missing argument to
+ cp_warning and cp_pedwarn calls.
+
+Wed Dec 15 18:25:32 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-parse.y (member_init): ANSI C++ doesn't forbid old-style base
+ initializers; it's just anachronistic.
+
+ * cp-decl.c (finish_decl): Don't require external-linkage arrays
+ to have a complete type at declaration time when pedantic.
+
+Tue Dec 14 11:37:23 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-decl.c (pushdecl): Don't set DECL_CONTEXT if it's already set.
+
+ * cp-call.c (build_method_call): Don't dereference pointer given
+ as instance.
+
+ * cp-decl.c (finish_function): Don't pass pointer to
+ build_method_call.
+ (finish_function): Ditto.
+
+ * cp-typeck.c (build_x_function_call): Ditto.
+
+ * cp-method.c (build_component_type_expr): Ditto.
+
+ * cp-init.c (build_member_call): Ditto.
+ (build_new): Ditto.
+
+Mon Dec 13 18:04:33 1993 Kung Hsu (kung@cirdan.cygnus.com)
+
+ * cp-decl.c (xref_tag): fix regression created by changes made
+ in Dec. 7 1993.
+ * cp-decl.c (xref_defn_tag): fix parallel nested class problem.
+
+Fri Dec 10 12:40:25 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * cp-call.c (compute_conversion_costs_ansi) [DEBUG_MATCHING]: Print
+ out the final evaluation of the function, so we can see if ELLIPSIS,
+ USER, and EVIL were set at the end.
+
+ * cp-call.c (convert_harshness_ansi): When the parm isn't an lvalue,
+ only go for setting TRIVIAL_CODE if we are dealing with types that
+ are compatible.
+
+Thu Dec 9 18:27:22 1993 Mike Stump <mrs@cygnus.com>
+
+ * cp-decl.c (flag_huge_objects): New flag to allow large objects.
+ * toplev.c (lang_options): Ditto.
+ * cp-decl2.c (flag_huge_objects, lang_f_options): Ditto.
+ * cp-decl.c (delta_type_node): New type for delta entries.
+ * cp-tree.h (delta_type_node): Ditto.
+ * cp-decl.c (init_decl_processing): Setup delta_type_node.
+ * cp-decl.c (init_decl_processing, build_ptrmemfunc_type): Use
+ delta_type_node instead of short_integer_type_node.
+ * cp-class.c (build_vtable_entry): Ditto.
+
+Thu Dec 9 16:19:05 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * cp-tree.h (OPERATOR_TYPENAME_P): Define outside of
+ NO_{DOLLAR,DOT} macro checks, so it always gets defined.
+ (VTABLE_NAME_P): Define for NO_DOT && NO_DOLLAR_IN_LABEL.
+
+Wed Dec 8 17:38:06 1993 Mike Stump <mrs@cygnus.com>
+
+ * cp-decl.c (finish_decl): Make sure things that can go into
+ "common", do go into common, if -fcommon is given.
+
+Wed Dec 8 13:01:54 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * cp-call.c (print_harshness) [DEBUG_MATCHING]: New function.
+ (compute_conversion_costs_ansi) [DEBUG_MATCHING]: Print out
+ argument matching diagnostics to make instantly clear what the
+ compiler is doing.
+
+ * cp-call.c (convert_harshness_ansi): If the parm isn't an lvalue,
+ then check to see if the penalty was increased due to
+ signed/unsigned mismatch, and use a TRIVIAL_CODE if it wasn't.
+
+Tue Dec 7 18:29:14 1993 Kung Hsu (kung@cirdan.cygnus.com)
+
+ * cp-decl.c (xref_tag, pushtag): Fix nested class search/resolution
+ problem.
+
+Tue Dec 7 16:09:34 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-class.c (finish_struct): Before synthesizing methods, if no
+ methods have yet been declared then set nonprivate_method. Don't
+ set non_private method after synthesizing a method.
+
+ * cp-lex.c (extract_interface_info): If flag_alt_external_templates
+ is set, tie emitted code to the location of template instantiation,
+ rather than definition.
+
+ * cp-tree.h: Declare flag_alt_external_templates.
+
+ * cp-decl2.c (lang_decode_option): Support -falt-external-templates.
+
+ * toplev.c (lang_options): Ditto.
+
+ Mon Oct 4 12:50:02 1993 Chip Salzenberg (chip@fin.uucp)
+
+ [changes propagated from 930810 snapshot]
+ * cp-decl.c (init_decl_processing): Make long long available for use
+ as SIZE_TYPE and PTRDIFF_TYPE.
+ (finish_decl): Allow file-scope static incomplete array.
+ (grokdeclarator): Don't pass on const and volatile fron function
+ value type to function type.
+ Warn here for volatile fn returning non-void type.
+ * cp-parse.y (attrib): Accept attributes `volatile' with alias
+ `noreturn', and `const'.
+ * cp-typeck.c (default_conversion): Don't lose const and volatile.
+ (build_binary_op_nodefault): Generate pedantic warning for comparison
+ of complete pointer type with incomplete pointer type.
+ (build_c_cast): Be careful that null pointer constant be INTEGER_CST.
+
+Tue Dec 7 10:46:48 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-init.c (expand_vec_init): When creating a temporary for copying
+ arrays, use the type of the source, not the target.
+
+ * cp-cvt.c (convert): Pass an argument for errtype to
+ convert_to_reference.
+
+ * cp-error.c (dump_expr, COMPONENT_REF & CALL_EXPR): Deal with
+ methods, -> and `this'.
+
+Mon Dec 6 17:12:33 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-error.c (parm_as_string): New function; returns `this' or arg
+ number. Corresponds to %P.
+ (dump_expr): Deal with method calls.
+
+ * cp-cvt.c (convert_to_reference): Stop using warn_for_assignment.
+ * cp-typeck.c (convert_for_assignment): Ditto.
+ (warn_for_assignment): Lose.
+
+Mon Dec 6 11:33:35 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * cp-call.c (ideal_candidate_ansi): Delete code that was never
+ doing anything useful. Instead, sort once, and DO NOT wipe
+ out any codes with EVIL_CODE, since that's what we use as a
+ marker for the end of the list of candidates.
+
+ * cp-cvt.c (convert_to_aggr): Make sure to always set H_LEN.
+
+Mon Dec 6 12:49:17 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-init.c (get_aggr_from_typedef): New function, like
+ is_aggr_typedef but returns the _TYPE.
+
+ * cp-call.c, cp-init.c, cp-method.c: Eradicate err_name.
+
+Sun Dec 5 18:12:48 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * cp-lex.c (readescape): Pedwarn when a hex escape is out of range.
+
+Thu Nov 25 23:50:19 1993 Chip Salzenberg (chip@fin.uucp)
+
+ Delay language context change until beginning of next decl.
+
+ * cp-lex.h (c_header_level): Removed.
+ (pending_lang_change): Declared.
+ * cp-lex.c (c_header_level): Renamed from in_c_header, made static.
+ (pending_lang_change): Defined.
+ (check_newline): Rework code that recognizes line number and
+ filename changes. Instead of pushing and popping lang context,
+ increment and decrement pending_lang_change.
+ (do_pending_lang_change): Push and pop lang context according
+ to value of pending_lang_change.
+ * cp-parse.y (extdefs): Use lang_extdef instead of extdef.
+ (extdef): Same as extdef, but call do_pending_lang_change() first.
+
+Mon Nov 15 15:39:15 1993 Chip Salzenberg (chip@fin.uucp)
+
+ * cp-typeck.c (build_binary_op_nodefault): Warn for ordered
+ compare of ptr with 0 only if pedantic in both cases.
+
+Thu Nov 25 13:31:37 1993 Chip Salzenberg (chip@fin.uucp)
+
+ Reinstate the below patch, which got lost in the Cygnus merge:
+ Tue Nov 23 13:59:24 1993 Hallvard B Furuseth (hbf@durin.uio.no)
+ * cp-parse.y (maybe_type_qual): Don't fail to set $$.
+
+Wed Nov 17 19:03:30 1993 Chip Salzenberg (chip@fin.uucp)
+
+ * cp-parse.y (attrib): Allow "ident(ident)" like the C front end.
+
+Fri Oct 22 20:43:37 1993 Paul Eggert (eggert@twinsun.com)
+
+ * cp-lex.c (real_yylex): Diagnose floating point constants
+ that are too large.
+
+Wed Nov 17 19:10:37 1993 Chip Salzenberg (chip@fin.uucp)
+
+ * cp-type2.c (build_functional_cast): ARM page 16: When a class
+ and an object, function or enumerator are declared in the same
+ scope with the same name, the class name is hidden.
+
+Wed Nov 17 19:07:18 1993 Chip Salzenberg (chip@fin.uucp)
+
+ * cp-call.c (convert_harshness_ansi): Distinguish float, double,
+ and long double from each other when overloading.
+ (compute_conversion_costs_{ansi,old}, build_method_call,
+ build_overlay_call_real, convert_to_aggr): Always set and
+ always use H_LEN member of candidate structure.
+
+Mon Oct 11 23:10:53 1993 Chip Salzenberg (chip@fin.uucp)
+
+ * cp-decl.c (duplicate_decls): Note redeclarations of library
+ functions, and generate distinct warnings for them.
+
+Mon Oct 4 12:26:49 1993 Chip Salzenberg (chip@fin.uucp)
+
+ Support format warnings in G++.
+
+ * cp-tree.h: Protect against multiple inclusion.
+ Declare all public functions in c-common.c (copy from c-tree.h).
+ (STDIO_PROTO): Define.
+ (warn_format): Declare.
+ (record_format_info): Remove declaration.
+ * cp-decl.c (init_decl_processing): Call init_function_format_info.
+ * cp-decl2.c (lang_decode_option): Make "-Wall" include warn_format.
+ * cp-typeck.c (build_function_call_real): Call check_function_format.
+ (record_format_info): Remove -- obsolete stub.
+
+Sat Jul 24 12:04:29 1993 Chip Salzenberg (chip@fin.uucp)
+
+ * cp-decl.c (duplicate_decls): Don't warn for non-extern var decl
+ following an extern one (for -Wredundant-decls).
+ * cp-parse.y (primary): In statement expression case, if compstmt
+ returns something other than a BLOCK, return it unchanged.
+
+Thu Dec 2 20:44:58 1993 Chip Salzenberg (chip@fin.uucp)
+
+ * cp-decl.c (warn_extern_redeclared_static): New function made
+ from code extracted from pushdecl.
+ (duplicate_decls, pushdecl): Call new function.
+ (lookup_name_current_level): Allow for IDENTIFIER_GLOBAL_VALUE
+ to be a TREE_LIST when function is declared in 'extern "C" {}'.
+
+Fri Dec 3 16:01:10 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-class.c (duplicate_tag_error): Use cp_error.
+ (finish_base_struct): Check for ambiguity with direct base, and don't
+ generate op= or copy ctor if it exists.
+
+Fri Dec 3 15:32:34 1993 Kung Hsu (kung@cirdan.cygnus.com)
+
+ * cp-init.c (expand_member_init): when initializer name is null,
+ don't try to build it now because emit_base_init will handle it.
+
+Fri Dec 3 12:28:59 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-lex.c (init_lex): Initialize input_filename to "<internal>" for
+ code such as ExceptionHandler::operator=.
+
+Fri Dec 3 10:32:08 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-decl.c (grokdeclarator): Don't try to print out dname when
+ complaining about arrays of references if decl_context==TYPENAME,
+ since it will be null.
+
+ * cp-decl2.c: Default to flag_ansi_overloading.
+
+Thu Dec 2 18:05:56 1993 Kung Hsu (kung@cirdan.cygnus.com)
+
+ * cp-call.c (build_method_call): use binfo from instance if it's
+ different from binfo (basetype_path) passed from above.
+
+Thu Dec 2 12:48:36 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+Wed Nov 17 19:14:29 1993 Chip Salzenberg (chip@fin.uucp)
+
+ cp-error.c (dump_expr): Use unsigned chars to output a
+ TREE_REAL_CST in hex.
+
+Thu Dec 2 11:05:48 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-class.c (finish_struct): Fix typo in setting
+ cant_synth_asn_ref.
+
+ * cp-tree.h (TYPE_NESTED_NAME): New macro, does
+ DECL_NESTED_TYPENAME (TYPE_NAME (NODE)).
+
+ * cp-lex.c (default_copy_constructor_body): Change
+ DECL_NAME (TYPE_NAME (btype)) to TYPE_NESTED_NAME (btype).
+ (default_assign_ref_body): Ditto.
+ (default_copy_constructor_body): Call operator= explicitly for
+ base classes that have no constructor.
+
+Thu Dec 2 10:47:15 1993 Michael Tiemann (tiemann@blues.cygnus.com)
+
+ * cp-call.c (build_method_call): If the instance variable is
+ converted to error_mark_node when we're trying to convert it to the
+ base type of a method we're looking up, return error_mark_node.
+
+Thu Dec 2 10:41:16 1993 Torbjorn Granlund (tege@cygnus.com)
+
+ * cp-typeck.c (build_binary_op_nodefault): In *_DIV_EXPR *_MOD_EXPR
+ cases, tests for unsigned operands by peeking inside a NOP_EXPR.
+
+Wed Dec 1 13:33:34 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * cp-call.c (compute_conversion_costs_ansi): Use the size of struct
+ harshness_code, not the size of short, for clearing out the
+ ansi_harshness.
+
+ * cp-call.c (print_candidates): New function.
+ (build_method_call): When we had some candidates, but didn't get a
+ usable match, don't report that we got an error with the first
+ candidate. Instead, say there were no matches, and list the
+ candidates with print_candidates. In the second pass, make sure we
+ clear out ever_seen, so we can accurately count the number of
+ functions that qualified.
+
+Wed Dec 1 09:53:59 1993 Torbjorn Granlund (tege@cygnus.com)
+
+ * cp-typeck.c (build_binary_op_nodefault): Shorten for *_MOD_EXPR
+ only if op1 is known to be != -1.
+ (build_binary_op_nodefault): Handle *_DIV_EXPR likewise.
+
+Tue Nov 30 14:07:26 1993 Brendan Kehoe (brendan@lisa.cygnus.com)
+
+ * cp-method.c (hack_identifier): If the field itself is private, and
+ not from a private base class, say so.
+
+Mon Nov 29 03:00:56 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-decl.c (grokdeclarator): Always warn on initialization of
+ const member.
+
+Wed Nov 24 00:49:35 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-class.c (finish_struct): Set TYPE_GETS_CONST_* properly.
+ (finish_base_struct): Set cant_synth_asn_ref properly.
+
+ * cp-lex.c (cons_up_default_function): Add section for operator=.
+ (default_assign_ref_body): New function, mostly cribbed from
+ default_copy_constructor_body.
+
+ * cp-class.c (base_info): Add members cant_synth_copy_ctor,
+ cant_synth_asn_ref, no_const_asn_ref.
+ (finish_base_struct): Update no_const_asn_ref, note that you should
+ update cant_synth_*, propagate TYPE_GETS_ASSIGN_REF.
+ (finish_struct): Add decls for cant_synth_*, no_const_asn_ref, and
+ initialize them properly. Set no_const_asn_ref properly. Set
+ cant_synth_* in some of the situations where they should be set.
+ Propagate TYPE_GETS_ASSIGN_REF. Use cant_synth_copy_ctor. Add call
+ to cons_up_default_function for operator=.
+
+Tue Nov 23 20:24:58 1993 Mike Stump <mrs@cygnus.com>
+
+ * cp-cvt.c (convert_force): Add code to perform casting of pointer
+ to member function types.
+ * cp-typeck.c (build_ptrmemfunc): Add FORCE parameter to indicate
+ when the conversion should be done, regardless.
+ * cp-tree.h (build_ptrmemfunc): Ditto.
+ * cp-type2.c (digest_init): Ditto.
+ * cp-typeck.c (convert_for_assignment): Ditto.
+
+Tue Nov 23 18:06:58 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-error.c (dump_expr): Do the right thing for variables of
+ reference type.
+
+ * cp-decl.c (grok_op_properties): Set TYPE_HAS_ASSIGN_REF
+ and its kin properly.
+ (xref_tag): Propagate TYPE_GETS_ASSIGN_REF.
+
+Tue Nov 23 12:26:13 1993 Mike Stump <mrs@cygnus.com>
+
+ * cp-method.c (build_opfncall): Don't count pointer to member
+ functions as aggregates here, as we don't want to look up methods in
+ them. The compiler would core dump if we did, as they don't have
+ normal names.
+ * cp-typeck.c (build_indirect_ref): Improve wording on error
+ message.
+
+Mon Nov 22 14:22:23 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-decl.c (grok_op_properties): Allow operator?: with pedwarn
+ (since it's supported in other compiler bits).
+
+ * cp-method.c (report_type_mismatch): Use cp_error; ignore err_name
+ argument.
+
+ * cp-error.c (dump_function_decl): Don't print return type for
+ constructors and destructors.
+
+ * cp-cvt.c (cp_convert_to_pointer): Import code from
+ convert_to_pointer so we can return error_mark_node in the case of an
+ error, and to allow more meaningful error messages.
+ (build_type_conversion): Don't go through void* when trying
+ to convert to a pointer type.
+
+ * cp-decl.c (grokfndecl): Move call to grok_op_properties back
+ after grokclassfn so that it's dealing with the right decl.
+ (grok_op_properties): Don't assert !methodp for op new and op delete.
+
+ * cp-init.c (build_delete): Don't use TYPE_BUILT_IN (there are now
+ no uses of it in the compiler).
+
+ * cp-call.c (build_scoped_method_call): Fix for destructors of simple
+ types.
+ (build_method_call): Ditto.
+
+Fri Nov 19 12:59:38 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-tree.c (count_functions): Abstraction function.
+
+ * cp-call.c (build_overload_call_real): Deal with new overloading
+ properly, remove dead code.
+
+ * gcc.c (default_compilers): Generate and use .ii files in the
+ intermediate stage of compiling C++ source.
+
+Fri Nov 19 11:26:09 1993 Jim Wilson (wilson@sphagnum.cygnus.com)
+
+ * cp-expr.c (cplus_expand_expr): Make call_target a valid memory
+ address before using it, so it can be later safely compared.
+
+Fri Nov 12 15:30:27 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-pt.c (tsubst): Deal with new overloading.
+
+ * cp-typeck.c (fntype_p): is the arg function type?
+ (comp_target_parms): pedwarn on conversion from (anything) to (...).
+ (build_x_function_call): Deal with new overloading.
+
+ * cp-tree.c (decl_list_length): Deal with new overloading.
+ (decl_value_member): Like value_member, but for DECL_CHAINs.
+
+ * cp-decl.c (duplicate_decls): Deal with new overloading.
+ (start_decl): Ditto.
+
+ * cp-class.c (instantiate_type): Deal with new overloading.
+
+ * cp-call.c (convert_harshness_ansi): Deal with new overloading.
+ (convert_harshness_old): Deal with new overloading.
+ (build_overload_call_real): Ditto.
+
+Mon Nov 8 13:50:49 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-tree.c (get_unique_fn): New function; returns FUNCTION_DECL
+ if unambiguous, NULL_TREE otherwise.
+ (get_first_fn): Returns the first appropriate FUNCTION_DECL.
+ (is_overloaded_fn): Returns whether or not the passed tree is
+ a function or list of functions.
+
+ * cp-init.c (init_init_processing): use `get_first_fn' to find
+ the FUNCTION_DEFN for new and delete.
+
+ * cp-decl.c (push_overloaded_decl): Use new overloading strategy, cut
+ code size in half (I spit on special cases).
+
+Tue Sep 7 20:03:33 1993 Jason Merrill (jason@deneb.cygnus.com)
+
+ * cp-decl.c: Allow references and template type parameters as well
+
+Local Variables:
+eval: (auto-fill-mode)
+left-margin: 8
+fill-column: 76
+End:
diff --git a/contrib/gcc/cp/Make-lang.in b/contrib/gcc/cp/Make-lang.in
new file mode 100644
index 0000000..c9d0a39
--- /dev/null
+++ b/contrib/gcc/cp/Make-lang.in
@@ -0,0 +1,197 @@
+# Top level makefile fragment for GNU C++.
+# Copyright (C) 1994, 1995 Free Software Foundation, Inc.
+
+#This file is part of GNU CC.
+
+#GNU CC is free software; you can redistribute it and/or modify
+#it under the terms of the GNU General Public License as published by
+#the Free Software Foundation; either version 2, or (at your option)
+#any later version.
+
+#GNU CC is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+#GNU General Public License for more details.
+
+#You should have received a copy of the GNU General Public License
+#along with GNU CC; see the file COPYING. If not, write to
+#the Free Software Foundation, 59 Temple Place - Suite 330,
+#Boston, MA 02111-1307, USA.
+
+# This file provides the language dependent support in the main Makefile.
+# Each language makefile fragment must provide the following targets:
+#
+# foo.all.build, foo.all.cross, foo.start.encap, foo.rest.encap,
+# foo.info, foo.dvi,
+# foo.install-normal, foo.install-common, foo.install-info, foo.install-man,
+# foo.uninstall, foo.distdir,
+# foo.mostlyclean, foo.clean, foo.distclean, foo.extraclean,
+# foo.maintainer-clean, foo.stage1, foo.stage2, foo.stage3, foo.stage4
+#
+# where `foo' is the name of the language.
+#
+# It should also provide rules for:
+#
+# - making any compiler driver (eg: g++)
+# - the compiler proper (eg: cc1plus)
+# - define the names for selecting the language in LANGUAGES.
+
+# Extra flags to pass to recursive makes.
+CXX_FLAGS_TO_PASS = \
+ "CXX_FOR_BUILD=$(CXX_FOR_BUILD)" \
+ "CXXFLAGS=$(CXXFLAGS)" \
+ "CXX_FOR_TARGET=$(CXX_FOR_TARGET)"
+
+# Actual names to use when installing a native compiler.
+CXX_INSTALL_NAME = `t='$(program_transform_name)'; echo c++ | sed $$t`
+GXX_INSTALL_NAME = `t='$(program_transform_name)'; echo g++ | sed $$t`
+
+# Actual names to use when installing a cross-compiler.
+CXX_CROSS_NAME = `t='$(program_transform_cross_name)'; echo c++ | sed $$t`
+GXX_CROSS_NAME = `t='$(program_transform_cross_name)'; echo g++ | sed $$t`
+
+# The name to use for the demangler program.
+DEMANGLER_PROG = c++filt
+
+# Define the names for selecting c++ in LANGUAGES.
+# Note that it would be nice to move the dependency on g++
+# into the C++ rule, but that needs a little bit of work
+# to do the right thing within all.cross.
+C++ c++: cc1plus
+
+# Tell GNU make to ignore these if they exist.
+.PHONY: C++ c++
+
+# Create the compiler driver for g++.
+g++: $(srcdir)/cp/g++.c $(CONFIG_H) $(LIBDEPS)
+ $(CC) $(ALL_CFLAGS) $(INCLUDES) $(LDFLAGS) -o $@ $(srcdir)/cp/g++.c $(LIBS)
+
+# Create a version of the g++ driver which calls the cross-compiler.
+g++-cross: $(srcdir)/cp/g++.c version.o $(LIBDEPS)
+ $(CC) $(ALL_CFLAGS) $(INCLUDES) $(LDFLAGS) -o $@ \
+ -DGCC_NAME=\"$(GCC_CROSS_NAME)\" $(srcdir)/cp/g++.c version.o $(LIBS)
+
+cxxmain.o: cplus-dem.c demangle.h
+ rm -f cxxmain.c
+ ln -s $(srcdir)/cplus-dem.c cxxmain.c > /dev/null 2>&1 \
+ || cp $(srcdir)/cplus-dem.c cxxmain.c
+ $(CC) -c -DMAIN $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \
+ -DVERSION=\"$(version)\" cxxmain.c
+ rm -f cxxmain.c
+
+$(DEMANGLER_PROG): cxxmain.o underscore.o getopt.o getopt1.o $(LIBDEPS)
+ $(CC) $(ALL_CFLAGS) $(LDFLAGS) $(LIBS) -o $@ \
+ cxxmain.o underscore.o getopt.o getopt1.o
+
+CXX_SRCS = $(srcdir)/cp/call.c $(srcdir)/cp/decl2.c \
+ $(srcdir)/cp/except.c $(srcdir)/cp/input.c $(srcdir)/cp/pt.c \
+ $(srcdir)/cp/spew.c $(srcdir)/cp/xref.c $(srcdir)/cp/class.c \
+ $(srcdir)/cp/edsel.c $(srcdir)/cp/expr.c $(srcdir)/cp/lex.c \
+ $(srcdir)/cp/ptree.c $(srcdir)/cp/tree.c $(srcdir)/cp/cvt.c \
+ $(srcdir)/cp/errfn.c $(srcdir)/cp/gc.c $(srcdir)/cp/method.c \
+ $(srcdir)/cp/search.c $(srcdir)/cp/typeck.c $(srcdir)/cp/decl.c \
+ $(srcdir)/cp/error.c $(srcdir)/cp/init.c $(srcdir)/cp/parse.y \
+ $(srcdir)/cp/sig.c $(srcdir)/cp/typeck2.c $(srcdir)/cp/repo.c
+
+cc1plus: $(P) $(CXX_SRCS) $(LIBDEPS) stamp-objlist c-common.o c-pragma.o
+ cd cp; $(MAKE) $(FLAGS_TO_PASS) $(CXX_FLAGS_TO_PASS) ../cc1plus
+
+# Build hooks:
+
+c++.all.build: g++ $(DEMANGLER_PROG)
+c++.all.cross: g++-cross $(DEMANGLER_PROG)
+c++.start.encap: g++
+c++.rest.encap: $(DEMANGLER_PROG)
+
+c++.info:
+c++.dvi:
+
+# Install hooks:
+# cc1plus is installed elsewhere as part of $(COMPILERS).
+
+# Nothing to do here.
+c++.install-normal:
+
+# Install the driver program as $(target)-g++
+# and also as either g++ (if native) or $(tooldir)/bin/g++.
+c++.install-common:
+ -if [ -f cc1plus$(exeext) ] ; then \
+ if [ -f g++-cross$(exeext) ] ; then \
+ rm -f $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
+ $(INSTALL_PROGRAM) g++-cross$(exeext) $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
+ chmod a+x $(bindir)/$(GXX_CROSS_NAME)$(exeext); \
+ rm -f $(bindir)/$(CXX_CROSS_NAME)$(exeext); \
+ ln $(bindir)/$(GXX_CROSS_NAME)$(exeext) $(bindir)/$(CXX_CROSS_NAME)$(exeext) \
+ > /dev/null 2>&1 \
+ || cp $(bindir)/$(GXX_CROSS_NAME)$(exeext) $(bindir)/$(CXX_CROSS_NAME)$(exeext) ; \
+ else \
+ rm -f $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
+ $(INSTALL_PROGRAM) g++$(exeext) $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
+ chmod a+x $(bindir)/$(GXX_INSTALL_NAME)$(exeext); \
+ rm -f $(bindir)/$(CXX_INSTALL_NAME)$(exeext); \
+ ln $(bindir)/$(GXX_INSTALL_NAME)$(exeext) $(bindir)/$(CXX_INSTALL_NAME)$(exeext) \
+ > /dev/null 2>&1 \
+ || cp $(bindir)/$(GXX_INSTALL_NAME)$(exeext) $(bindir)/$(CXX_INSTALL_NAME)$(exeext) ; \
+ fi ; \
+ fi
+
+c++.install-info:
+
+c++.install-man: $(srcdir)/cp/g++.1
+ -if [ -f cc1plus$(exeext) ] ; then \
+ if [ -f g++-cross$(exeext) ] ; then \
+ rm -f $(mandir)/$(GXX_CROSS_NAME)$(manext); \
+ $(INSTALL_DATA) $(srcdir)/cp/g++.1 $(mandir)/$(GXX_CROSS_NAME)$(manext); \
+ chmod a-x $(mandir)/$(GXX_CROSS_NAME)$(manext); \
+ else \
+ rm -f $(mandir)/$(GXX_INSTALL_NAME)$(manext); \
+ $(INSTALL_DATA) $(srcdir)/cp/g++.1 $(mandir)/$(GXX_INSTALL_NAME)$(manext); \
+ chmod a-x $(mandir)/$(GXX_INSTALL_NAME)$(manext); \
+ fi; \
+ else true; fi
+
+c++.uninstall:
+ -rm -rf $(bindir)/$(CXX_INSTALL_NAME)$(exeext)
+ -rm -rf $(bindir)/$(CXX_CROSS_NAME)$(exeext)
+ -rm -rf $(bindir)/$(GXX_INSTALL_NAME)$(exeext)
+ -rm -rf $(bindir)/$(GXX_CROSS_NAME)$(exeext)
+ -rm -rf $(mandir)/$(GXX_INSTALL_NAME)$(manext)
+ -rm -rf $(mandir)/$(GXX_CROSS_NAME)$(manext)
+
+# Clean hooks:
+# A lot of the ancillary files are deleted by the main makefile.
+# We just have to delete files specific to us.
+
+c++.mostlyclean:
+ -rm -f cp/*$(objext) $(DEMANGLER_PROG)
+c++.clean:
+c++.distclean:
+ -rm -f cp/config.status cp/Makefile
+ -rm -f cp/parse.output
+c++.extraclean:
+c++.maintainer-clean:
+ -rm -f cp/parse.c cp/parse.h
+
+# Stage hooks:
+# The main makefile has already created stage?/cp.
+
+c++.stage1:
+ -mv cp/*$(objext) stage1/cp
+c++.stage2:
+ -mv cp/*$(objext) stage2/cp
+c++.stage3:
+ -mv cp/*$(objext) stage3/cp
+c++.stage4:
+ -mv cp/*$(objext) stage4/cp
+
+# Maintenance hooks:
+
+# This target creates the files that can be rebuilt, but go in the
+# distribution anyway. It then copies the files to the distdir directory.
+c++.distdir:
+ mkdir tmp/cp
+ cd cp ; $(MAKE) $(FLAGS_TO_PASS) $(CXX_FLAGS_TO_PASS) parse.c hash.h
+ cd cp; \
+ for file in *[0-9a-zA-Z+]; do \
+ ln $$file ../tmp/cp >/dev/null 2>&1 || cp $$file ../tmp/cp; \
+ done
diff --git a/contrib/gcc/cp/Makefile.in b/contrib/gcc/cp/Makefile.in
new file mode 100644
index 0000000..11466b2
--- /dev/null
+++ b/contrib/gcc/cp/Makefile.in
@@ -0,0 +1,265 @@
+# Makefile for GNU C++ compiler.
+# Copyright (C) 1987, 88, 90-4, 1995 Free Software Foundation, Inc.
+
+#This file is part of GNU CC.
+
+#GNU CC is free software; you can redistribute it and/or modify
+#it under the terms of the GNU General Public License as published by
+#the Free Software Foundation; either version 2, or (at your option)
+#any later version.
+
+#GNU CC is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+#GNU General Public License for more details.
+
+#You should have received a copy of the GNU General Public License
+#along with GNU CC; see the file COPYING. If not, write to
+#the Free Software Foundation, 59 Temple Place - Suite 330,
+#Boston, MA 02111-1307, USA.
+
+# The makefile built from this file lives in the language subdirectory.
+# Its purpose is to provide support for:
+#
+# 1) recursion where necessary, and only then (building .o's), and
+# 2) building and debugging cc1 from the language subdirectory, and
+# 3) nothing else.
+#
+# The parent makefile handles all other chores, with help from the
+# language makefile fragment, of course.
+#
+# The targets for external use are:
+# all, TAGS, ???mostlyclean, ???clean.
+
+# Suppress smart makes who think they know how to automake Yacc files
+.y.c:
+
+# Variables that exist for you to override.
+# See below for how to change them for certain systems.
+
+ALLOCA =
+
+# Various ways of specifying flags for compilations:
+# CFLAGS is for the user to override to, e.g., do a bootstrap with -O2.
+# BOOT_CFLAGS is the value of CFLAGS to pass
+# to the stage2 and stage3 compilations
+# XCFLAGS is used for most compilations but not when using the GCC just built.
+XCFLAGS =
+CFLAGS = -g
+BOOT_CFLAGS = -O $(CFLAGS)
+# These exists to be overridden by the x-* and t-* files, respectively.
+X_CFLAGS =
+T_CFLAGS =
+
+X_CPPFLAGS =
+T_CPPFLAGS =
+
+CC = cc
+BISON = bison
+BISONFLAGS =
+LEX = flex
+LEXFLAGS =
+AR = ar
+AR_FLAGS = rc
+SHELL = /bin/sh
+MAKEINFO = makeinfo
+TEXI2DVI = texi2dvi
+
+# Define this as & to perform parallel make on a Sequent.
+# Note that this has some bugs, and it seems currently necessary
+# to compile all the gen* files first by hand to avoid erroneous results.
+P =
+
+# This is used in the definition of SUBDIR_USE_ALLOCA.
+# ??? Perhaps it would be better if it just looked for *gcc*.
+OLDCC = cc
+
+# This is used instead of ALL_CFLAGS when compiling with GCC_FOR_TARGET.
+# It omits XCFLAGS, and specifies -B./.
+# It also specifies -B$(tooldir)/ to find as and ld for a cross compiler.
+GCC_CFLAGS=$(INTERNAL_CFLAGS) $(X_CFLAGS) $(T_CFLAGS) $(CFLAGS)
+
+# Tools to use when building a cross-compiler.
+# These are used because `configure' appends `cross-make'
+# to the makefile when making a cross-compiler.
+
+target= ... `configure' substitutes actual target name here.
+xmake_file= ... `configure' substitutes actual x- file name here.
+tmake_file= ... `configure' substitutes actual t- file name here.
+#version=`sed -e 's/.*\"\([^ \"]*\)[ \"].*/\1/' < $(srcdir)/version.c`
+#mainversion=`sed -e 's/.*\"\([0-9]*\.[0-9]*\).*/\1/' < $(srcdir)/version.c`
+
+# Directory where sources are, from where we are.
+srcdir = .
+
+# Additional system libraries to link with.
+CLIB=
+
+# Change this to a null string if obstacks are installed in the
+# system library.
+OBSTACK=obstack.o
+
+# Choose the real default target.
+ALL=all
+
+# End of variables for you to override.
+
+# Definition of `all' is here so that new rules inserted by sed
+# do not specify the default target.
+all: all.indirect
+
+# This tells GNU Make version 3 not to put all variables in the environment.
+.NOEXPORT:
+
+# sed inserts variable overrides after the following line.
+####target overrides
+####host overrides
+####cross overrides
+####build overrides
+
+# Now figure out from those variables how to compile and link.
+
+all.indirect: Makefile ../cc1plus
+
+# IN_GCC tells obstack.h that we are using gcc's <stddef.h> file.
+INTERNAL_CFLAGS = $(CROSS) -DIN_GCC
+
+# This is the variable actually used when we compile.
+ALL_CFLAGS = $(INTERNAL_CFLAGS) $(X_CFLAGS) $(T_CFLAGS) $(CFLAGS) $(XCFLAGS)
+
+# Likewise.
+ALL_CPPFLAGS = $(CPPFLAGS) $(X_CPPFLAGS) $(T_CPPFLAGS)
+
+# Even if ALLOCA is set, don't use it if compiling with GCC.
+
+SUBDIR_OBSTACK = `if [ x$(OBSTACK) != x ]; then echo ../$(OBSTACK); else true; fi`
+SUBDIR_USE_ALLOCA = `case "${CC}" in "${OLDCC}") if [ x$(ALLOCA) != x ]; then echo ../$(ALLOCA); else true; fi ;; esac`
+SUBDIR_MALLOC = `if [ x$(MALLOC) != x ]; then echo ../$(MALLOC); else true; fi`
+
+# How to link with both our special library facilities
+# and the system's installed libraries.
+LIBS = $(SUBDIR_OBSTACK) $(SUBDIR_USE_ALLOCA) $(SUBDIR_MALLOC) $(CLIB)
+
+# Specify the directories to be searched for header files.
+# Both . and srcdir are used, in that order,
+# so that tm.h and config.h will be found in the compilation
+# subdirectory rather than in the source directory.
+INCLUDES = -I. -I.. -I$(srcdir) -I$(srcdir)/.. -I$(srcdir)/../config
+
+# Always use -I$(srcdir)/config when compiling.
+.c.o:
+ $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $<
+
+# This tells GNU make version 3 not to export all the variables
+# defined in this file into the environment.
+.NOEXPORT:
+
+# Lists of files for various purposes.
+
+# Language-specific object files for g++
+
+CXX_OBJS = call.o decl.o errfn.o expr.o pt.o sig.o typeck2.o \
+ class.o decl2.o error.o gc.o lex.o parse.o ptree.o spew.o typeck.o cvt.o \
+ edsel.o except.o init.o method.o search.o tree.o xref.o repo.o
+
+# Language-independent object files.
+OBJS = `cat ../stamp-objlist` ../c-common.o ../c-pragma.o
+OBJDEPS = ../stamp-objlist ../c-common.o ../c-pragma.o
+
+compiler: ../cc1plus
+../cc1plus: $(P) $(CXX_OBJS) $(OBJDEPS) $(LIBDEPS)
+ rm -f ../cc1plus$(exeext)
+ $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ \
+ $(CXX_OBJS) $(OBJS) $(LIBS)
+
+Makefile: $(srcdir)/Makefile.in $(srcdir)/../configure
+ cd ..; $(SHELL) config.status
+
+native: config.status ../cc1plus
+
+# Compiling object files from source files.
+
+# Note that dependencies on obstack.h are not written
+# because that file is not part of GCC.
+
+# C++ language specific files.
+
+RTL_H = $(srcdir)/../rtl.h $(srcdir)/../rtl.def \
+ $(srcdir)/../machmode.h $(srcdir)/../machmode.def
+TREE_H = $(srcdir)/../tree.h $(srcdir)/../real.h $(srcdir)/../tree.def \
+ $(srcdir)/../machmode.h $(srcdir)/../machmode.def
+CXX_TREE_H = $(TREE_H) cp-tree.h tree.def
+PARSE_H = $(srcdir)/parse.h
+PARSE_C = $(srcdir)/parse.c
+
+parse.o : $(PARSE_C) $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h lex.h
+ $(CC) -c $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(BIG_SWITCHFLAG) \
+ `echo $(PARSE_C) | sed 's,^\./,,'`
+
+CONFLICTS = expect 5 shift/reduce conflicts and 38 reduce/reduce conflicts.
+$(PARSE_H) : $(PARSE_C)
+$(PARSE_C) : $(srcdir)/parse.y
+ @echo $(CONFLICTS)
+ cd $(srcdir); $(BISON) $(BISONFLAGS) -d -o parse.c parse.y
+ cd $(srcdir); grep '^#define[ ]*YYEMPTY' parse.c >>parse.h
+#$(PARSE_C) $(PARSE_H) : stamp-parse ; @true
+#stamp-parse: $(srcdir)/parse.y
+# @echo $(CONFLICTS)
+# $(BISON) $(BISONFLAGS) -d $(srcdir)/parse.y
+# grep '^#define[ ]*YYEMPTY' y.tab.c >>y.tab.h
+# $(srcdir)/../move-if-change y.tab.c $(PARSE_C)
+# $(srcdir)/../move-if-change y.tab.h $(PARSE_H)
+# cp $(PARSE_C) y.tab.c
+# touch stamp-parse
+
+# hash.h really depends on $(srcdir)/gxx.gperf.
+# But this would screw things for people that don't have gperf,
+# if gxx.gpref got touched, say.
+# Thus you have to remove hash.h to force it to be re-made.
+$(srcdir)/hash.h:
+ gperf -p -j1 -g -o -t -N is_reserved_word '-k1,4,7,$$' \
+ $(srcdir)/gxx.gperf >$(srcdir)/hash.h
+
+spew.o : spew.c $(CONFIG_H) $(CXX_TREE_H) \
+ $(PARSE_H) $(srcdir)/../flags.h lex.h
+lex.o : lex.c $(CONFIG_H) $(CXX_TREE_H) \
+ $(PARSE_H) input.c $(srcdir)/../flags.h hash.h lex.h $(srcdir)/../c-pragma.h
+decl.o : decl.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h \
+ lex.h decl.h $(srcdir)/../stack.h
+decl2.o : decl2.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h \
+ lex.h decl.h
+typeck2.o : typeck2.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h
+typeck.o : typeck.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h $(RTL_H)
+class.o : class.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h
+call.o : call.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h class.h
+init.o : init.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h $(RTL_H)
+method.o : method.c $(CONFIG_H) $(CXX_TREE_H) class.h
+cvt.o : cvt.c $(CONFIG_H) $(CXX_TREE_H) class.h
+search.o : search.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../stack.h $(srcdir)/../flags.h
+tree.o : tree.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h
+ptree.o : ptree.c $(CONFIG_H) $(CXX_TREE_H)
+gc.o : gc.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h
+except.o : except.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h $(RTL_H)
+expr.o : expr.c $(CONFIG_H) $(CXX_TREE_H) $(RTL_H) $(srcdir)/../flags.h \
+ $(srcdir)/../expr.h ../insn-codes.h
+edsel.o : edsel.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../stack.h $(srcdir)/../flags.h
+xref.o : xref.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../input.h
+pt.o : pt.c $(CONFIG_H) $(CXX_TREE_H) decl.h $(PARSE_H)
+error.o : error.c $(CONFIG_H) $(CXX_TREE_H)
+errfn.o : errfn.c $(CONFIG_H) $(CXX_TREE_H)
+sig.o : sig.c $(CONFIG_H) $(CXX_TREE_H) $(srcdir)/../flags.h
+repo.o : repo.c $(CONFIG_H) $(CXX_TREE_H)
+
+# These exist for maintenance purposes.
+
+# Update the tags table.
+TAGS: force
+ cd $(srcdir) ; \
+ etags *.c *.h ; \
+ echo 'l' | tr 'l' '\f' >> TAGS ; \
+ echo 'parse.y,0' >> TAGS ; \
+ etags -a ../*.h ../*.c;
+
+.PHONY: TAGS
+
+force:
diff --git a/contrib/gcc/cp/call.c b/contrib/gcc/cp/call.c
new file mode 100644
index 0000000..3f293ac
--- /dev/null
+++ b/contrib/gcc/cp/call.c
@@ -0,0 +1,2993 @@
+/* Functions related to invoking methods and overloaded functions.
+ Copyright (C) 1987, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+ Contributed by Michael Tiemann (tiemann@cygnus.com) and
+ hacked by Brendan Kehoe (brendan@cygnus.com).
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+/* High-level class interface. */
+
+#include "config.h"
+#include "tree.h"
+#include <stdio.h>
+#include "cp-tree.h"
+#include "class.h"
+#include "output.h"
+#include "flags.h"
+
+#include "obstack.h"
+#define obstack_chunk_alloc xmalloc
+#define obstack_chunk_free free
+
+extern void sorry ();
+
+extern int inhibit_warnings;
+extern int flag_assume_nonnull_objects;
+extern tree ctor_label, dtor_label;
+
+/* From typeck.c: */
+extern tree unary_complex_lvalue ();
+
+/* Compute the ease with which a conversion can be performed
+ between an expected and the given type. */
+static struct harshness_code convert_harshness ();
+
+#define EVIL_RETURN(ARG) ((ARG).code = EVIL_CODE, (ARG))
+#define STD_RETURN(ARG) ((ARG).code = STD_CODE, (ARG))
+#define QUAL_RETURN(ARG) ((ARG).code = QUAL_CODE, (ARG))
+#define TRIVIAL_RETURN(ARG) ((ARG).code = TRIVIAL_CODE, (ARG))
+#define ZERO_RETURN(ARG) ((ARG).code = 0, (ARG))
+
+/* Ordering function for overload resolution. Compare two candidates
+ by gross quality. */
+int
+rank_for_overload (x, y)
+ struct candidate *x, *y;
+{
+ if (y->h.code & (EVIL_CODE|ELLIPSIS_CODE|USER_CODE))
+ return y->h.code - x->h.code;
+ if (x->h.code & (EVIL_CODE|ELLIPSIS_CODE|USER_CODE))
+ return -1;
+
+ /* This is set by compute_conversion_costs, for calling a non-const
+ member function from a const member function. */
+ if ((y->harshness[0].code & CONST_CODE) ^ (x->harshness[0].code & CONST_CODE))
+ return y->harshness[0].code - x->harshness[0].code;
+
+ if (y->h.code & STD_CODE)
+ {
+ if (x->h.code & STD_CODE)
+ return y->h.distance - x->h.distance;
+ return 1;
+ }
+ if (x->h.code & STD_CODE)
+ return -1;
+
+ return y->h.code - x->h.code;
+}
+
+/* Compare two candidates, argument by argument. */
+int
+rank_for_ideal (x, y)
+ struct candidate *x, *y;
+{
+ int i;
+
+ if (x->h_len != y->h_len)
+ abort ();
+
+ for (i = 0; i < x->h_len; i++)
+ {
+ if (y->harshness[i].code - x->harshness[i].code)
+ return y->harshness[i].code - x->harshness[i].code;
+ if ((y->harshness[i].code & STD_CODE)
+ && (y->harshness[i].distance - x->harshness[i].distance))
+ return y->harshness[i].distance - x->harshness[i].distance;
+
+ /* They're both the same code. Now see if we're dealing with an
+ integral promotion that needs a finer grain of accuracy. */
+ if (y->harshness[0].code & PROMO_CODE
+ && (y->harshness[i].int_penalty ^ x->harshness[i].int_penalty))
+ return y->harshness[i].int_penalty - x->harshness[i].int_penalty;
+ }
+ return 0;
+}
+
+/* TYPE is the type we wish to convert to. PARM is the parameter
+ we have to work with. We use a somewhat arbitrary cost function
+ to measure this conversion. */
+static struct harshness_code
+convert_harshness (type, parmtype, parm)
+ register tree type, parmtype;
+ tree parm;
+{
+ struct harshness_code h;
+ register enum tree_code codel;
+ register enum tree_code coder;
+ int lvalue;
+
+ h.code = 0;
+ h.distance = 0;
+ h.int_penalty = 0;
+
+#ifdef GATHER_STATISTICS
+ n_convert_harshness++;
+#endif
+
+ if (TREE_CODE (parmtype) == REFERENCE_TYPE)
+ {
+ if (parm)
+ parm = convert_from_reference (parm);
+ parmtype = TREE_TYPE (parmtype);
+ lvalue = 1;
+ }
+ else if (parm)
+ lvalue = lvalue_p (parm);
+ else
+ lvalue = 0;
+
+ if (TYPE_PTRMEMFUNC_P (type))
+ type = TYPE_PTRMEMFUNC_FN_TYPE (type);
+ if (TYPE_PTRMEMFUNC_P (parmtype))
+ parmtype = TYPE_PTRMEMFUNC_FN_TYPE (parmtype);
+
+ codel = TREE_CODE (type);
+ coder = TREE_CODE (parmtype);
+
+ if (TYPE_MAIN_VARIANT (parmtype) == TYPE_MAIN_VARIANT (type))
+ return ZERO_RETURN (h);
+
+ if (coder == ERROR_MARK)
+ return EVIL_RETURN (h);
+
+ if (codel == REFERENCE_TYPE)
+ {
+ tree ttl, ttr;
+ int constp = parm ? TREE_READONLY (parm) : TYPE_READONLY (parmtype);
+ int volatilep = (parm ? TREE_THIS_VOLATILE (parm)
+ : TYPE_VOLATILE (parmtype));
+ register tree intype = TYPE_MAIN_VARIANT (parmtype);
+ register enum tree_code form = TREE_CODE (intype);
+ int penalty = 0;
+
+ ttl = TREE_TYPE (type);
+
+ /* Only allow const reference binding if we were given a parm to deal
+ with, since it isn't really a conversion. This is a hack to
+ prevent build_type_conversion from finding this conversion, but
+ still allow overloading to find it. */
+ if (! lvalue && ! (parm && TYPE_READONLY (ttl)))
+ return EVIL_RETURN (h);
+
+ if (TYPE_READONLY (ttl) < constp
+ || TYPE_VOLATILE (ttl) < volatilep)
+ return EVIL_RETURN (h);
+
+ /* When passing a non-const argument into a const reference, dig it a
+ little, so a non-const reference is preferred over this one. */
+ penalty = ((TYPE_READONLY (ttl) > constp)
+ + (TYPE_VOLATILE (ttl) > volatilep));
+
+ ttl = TYPE_MAIN_VARIANT (ttl);
+
+ if (form == OFFSET_TYPE)
+ {
+ intype = TREE_TYPE (intype);
+ form = TREE_CODE (intype);
+ }
+
+ ttr = intype;
+
+ if (TREE_CODE (ttl) == ARRAY_TYPE && TREE_CODE (ttr) == ARRAY_TYPE)
+ {
+ if (comptypes (ttl, ttr, 1))
+ return ZERO_RETURN (h);
+ return EVIL_RETURN (h);
+ }
+
+ h = convert_harshness (ttl, ttr, NULL_TREE);
+ if (penalty && h.code == 0)
+ {
+ h.code = QUAL_CODE;
+ h.int_penalty = penalty;
+ }
+ return h;
+ }
+
+ if (codel == POINTER_TYPE && fntype_p (parmtype))
+ {
+ tree p1, p2;
+ struct harshness_code h1, h2;
+
+ /* Get to the METHOD_TYPE or FUNCTION_TYPE that this might be. */
+ type = TREE_TYPE (type);
+
+ if (coder == POINTER_TYPE)
+ {
+ parmtype = TREE_TYPE (parmtype);
+ coder = TREE_CODE (parmtype);
+ }
+
+ if (coder != TREE_CODE (type))
+ return EVIL_RETURN (h);
+
+ if (type != parmtype && coder == METHOD_TYPE)
+ {
+ tree ttl = TYPE_METHOD_BASETYPE (type);
+ tree ttr = TYPE_METHOD_BASETYPE (parmtype);
+
+ int b_or_d = get_base_distance (ttr, ttl, 0, 0);
+ if (b_or_d < 0)
+ {
+ b_or_d = get_base_distance (ttl, ttr, 0, 0);
+ if (b_or_d < 0)
+ return EVIL_RETURN (h);
+ h.distance = -b_or_d;
+ }
+ else
+ h.distance = b_or_d;
+ h.code = STD_CODE;
+
+ type = build_function_type
+ (TREE_TYPE (type), TREE_CHAIN (TYPE_ARG_TYPES (type)));
+ parmtype = build_function_type
+ (TREE_TYPE (parmtype), TREE_CHAIN (TYPE_ARG_TYPES (parmtype)));
+ }
+
+ /* We allow the default conversion between function type
+ and pointer-to-function type for free. */
+ if (comptypes (type, parmtype, 1))
+ return h;
+
+ if (pedantic)
+ return EVIL_RETURN (h);
+
+ /* Compare return types. */
+ p1 = TREE_TYPE (type);
+ p2 = TREE_TYPE (parmtype);
+ h2 = convert_harshness (p1, p2, NULL_TREE);
+ if (h2.code & EVIL_CODE)
+ return h2;
+
+ h1.code = TRIVIAL_CODE;
+ h1.distance = 0;
+
+ if (h2.distance != 0)
+ {
+ tree binfo;
+
+ /* This only works for pointers. */
+ if (TREE_CODE (p1) != POINTER_TYPE
+ && TREE_CODE (p1) != REFERENCE_TYPE)
+ return EVIL_RETURN (h);
+
+ p1 = TREE_TYPE (p1);
+ p2 = TREE_TYPE (p2);
+ /* Don't die if we happen to be dealing with void*. */
+ if (!IS_AGGR_TYPE (p1) || !IS_AGGR_TYPE (p2))
+ return EVIL_RETURN (h);
+ if (h2.distance < 0)
+ binfo = get_binfo (p2, p1, 0);
+ else
+ binfo = get_binfo (p1, p2, 0);
+
+ if (! BINFO_OFFSET_ZEROP (binfo))
+ {
+#if 0
+ static int explained = 0;
+ if (h2.distance < 0)
+ message_2_types (sorry, "cannot cast `%s' to `%s' at function call site", p2, p1);
+ else
+ message_2_types (sorry, "cannot cast `%s' to `%s' at function call site", p1, p2);
+
+ if (! explained++)
+ sorry ("(because pointer values change during conversion)");
+#endif
+ return EVIL_RETURN (h);
+ }
+ }
+
+ h1.code |= h2.code;
+ if (h2.distance > h1.distance)
+ h1.distance = h2.distance;
+
+ p1 = TYPE_ARG_TYPES (type);
+ p2 = TYPE_ARG_TYPES (parmtype);
+ while (p1 && TREE_VALUE (p1) != void_type_node
+ && p2 && TREE_VALUE (p2) != void_type_node)
+ {
+ h2 = convert_harshness (TREE_VALUE (p1), TREE_VALUE (p2),
+ NULL_TREE);
+ if (h2.code & EVIL_CODE)
+ return h2;
+
+ if (h2.distance)
+ {
+ /* This only works for pointers and references. */
+ if (TREE_CODE (TREE_VALUE (p1)) != POINTER_TYPE
+ && TREE_CODE (TREE_VALUE (p1)) != REFERENCE_TYPE)
+ return EVIL_RETURN (h);
+ h2.distance = - h2.distance;
+ }
+
+ h1.code |= h2.code;
+ if (h2.distance > h1.distance)
+ h1.distance = h2.distance;
+ p1 = TREE_CHAIN (p1);
+ p2 = TREE_CHAIN (p2);
+ }
+ if (p1 == p2)
+ return h1;
+ if (p2)
+ {
+ if (p1)
+ return EVIL_RETURN (h);
+ h1.code |= ELLIPSIS_CODE;
+ return h1;
+ }
+ if (p1)
+ {
+ if (TREE_PURPOSE (p1) == NULL_TREE)
+ h1.code |= EVIL_CODE;
+ return h1;
+ }
+ }
+ else if (codel == POINTER_TYPE && coder == OFFSET_TYPE)
+ {
+ tree ttl, ttr;
+
+ /* Get to the OFFSET_TYPE that this might be. */
+ type = TREE_TYPE (type);
+
+ if (coder != TREE_CODE (type))
+ return EVIL_RETURN (h);
+
+ ttl = TYPE_OFFSET_BASETYPE (type);
+ ttr = TYPE_OFFSET_BASETYPE (parmtype);
+
+ if (ttl == ttr)
+ h.code = 0;
+ else
+ {
+ int b_or_d = get_base_distance (ttr, ttl, 0, 0);
+ if (b_or_d < 0)
+ {
+ b_or_d = get_base_distance (ttl, ttr, 0, 0);
+ if (b_or_d < 0)
+ return EVIL_RETURN (h);
+ h.distance = -b_or_d;
+ }
+ else
+ h.distance = b_or_d;
+ h.code = STD_CODE;
+ }
+
+ /* Now test the OFFSET_TYPE's target compatibility. */
+ type = TREE_TYPE (type);
+ parmtype = TREE_TYPE (parmtype);
+ }
+
+ if (coder == UNKNOWN_TYPE)
+ {
+ if (codel == FUNCTION_TYPE
+ || codel == METHOD_TYPE
+ || (codel == POINTER_TYPE
+ && (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE
+ || TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE)))
+ return TRIVIAL_RETURN (h);
+ return EVIL_RETURN (h);
+ }
+
+ if (coder == VOID_TYPE)
+ return EVIL_RETURN (h);
+
+ if (codel == BOOLEAN_TYPE)
+ {
+ if (INTEGRAL_CODE_P (coder) || coder == REAL_TYPE)
+ return STD_RETURN (h);
+ else if (coder == POINTER_TYPE || coder == OFFSET_TYPE)
+ {
+ /* Make this worse than any conversion to another pointer.
+ FIXME this is how I think the language should work, but it may not
+ end up being how the language is standardized (jason 1/30/95). */
+ h.distance = 32767;
+ return STD_RETURN (h);
+ }
+ return EVIL_RETURN (h);
+ }
+
+ if (INTEGRAL_CODE_P (codel))
+ {
+ /* Control equivalence of ints an enums. */
+
+ if (codel == ENUMERAL_TYPE
+ && flag_int_enum_equivalence == 0)
+ {
+ /* Enums can be converted to ints, but not vice-versa. */
+ if (coder != ENUMERAL_TYPE
+ || TYPE_MAIN_VARIANT (type) != TYPE_MAIN_VARIANT (parmtype))
+ return EVIL_RETURN (h);
+ }
+
+ /* else enums and ints (almost) freely interconvert. */
+
+ if (INTEGRAL_CODE_P (coder))
+ {
+ if (TYPE_MAIN_VARIANT (type)
+ == TYPE_MAIN_VARIANT (type_promotes_to (parmtype)))
+ {
+ h.code = PROMO_CODE;
+#if 0 /* What purpose does this serve? -jason */
+ /* A char, short, wchar_t, etc., should promote to an int if
+ it can handle it, otherwise to an unsigned. So we'll make
+ an unsigned. */
+ if (type != integer_type_node)
+ h.int_penalty = 1;
+#endif
+ }
+ else
+ h.code = STD_CODE;
+
+ return h;
+ }
+ else if (coder == REAL_TYPE)
+ {
+ h.code = STD_CODE;
+ h.distance = 0;
+ return h;
+ }
+ }
+
+ if (codel == REAL_TYPE)
+ {
+ if (coder == REAL_TYPE)
+ {
+ if (TYPE_MAIN_VARIANT (type)
+ == TYPE_MAIN_VARIANT (type_promotes_to (parmtype)))
+ h.code = PROMO_CODE;
+ else
+ h.code = STD_CODE;
+
+ return h;
+ }
+ else if (INTEGRAL_CODE_P (coder))
+ {
+ h.code = STD_CODE;
+ h.distance = 0;
+ return h;
+ }
+ }
+
+ /* Convert arrays which have not previously been converted. */
+#if 0
+ if (codel == ARRAY_TYPE)
+ codel = POINTER_TYPE;
+#endif
+ if (coder == ARRAY_TYPE)
+ {
+ coder = POINTER_TYPE;
+ if (parm)
+ {
+ parm = decay_conversion (parm);
+ parmtype = TREE_TYPE (parm);
+ }
+ else
+ parmtype = build_pointer_type (TREE_TYPE (parmtype));
+ }
+
+ /* Conversions among pointers */
+ if (codel == POINTER_TYPE && coder == POINTER_TYPE)
+ {
+ register tree ttl = TYPE_MAIN_VARIANT (TREE_TYPE (type));
+ register tree ttr = TYPE_MAIN_VARIANT (TREE_TYPE (parmtype));
+ int penalty = 4 * (ttl != ttr);
+
+ /* Anything converts to void *. Since this may be `const void *'
+ (etc.) use VOID_TYPE instead of void_type_node. Otherwise, the
+ targets must be the same, except that we do allow (at some cost)
+ conversion between signed and unsigned pointer types. */
+
+ if ((TREE_CODE (ttl) == METHOD_TYPE
+ || TREE_CODE (ttl) == FUNCTION_TYPE)
+ && TREE_CODE (ttl) == TREE_CODE (ttr))
+ {
+ if (comptypes (ttl, ttr, -1))
+ {
+ h.code = penalty ? STD_CODE : 0;
+ h.distance = 0;
+ }
+ else
+ h.code = EVIL_CODE;
+ return h;
+ }
+
+#if 1
+ if (TREE_CODE (ttl) != VOID_TYPE
+ && (TREE_CODE (ttr) != VOID_TYPE || !parm || !integer_zerop (parm)))
+ {
+ if (TREE_UNSIGNED (ttl) != TREE_UNSIGNED (ttr))
+ {
+ ttl = unsigned_type (ttl);
+ ttr = unsigned_type (ttr);
+ penalty = 10;
+ }
+ if (comp_target_types (type, parmtype, 1) <= 0)
+ return EVIL_RETURN (h);
+ }
+#else
+ if (!(TREE_CODE (ttl) == VOID_TYPE
+ || TREE_CODE (ttr) == VOID_TYPE
+ || (TREE_UNSIGNED (ttl) ^ TREE_UNSIGNED (ttr)
+ && (ttl = unsigned_type (ttl),
+ ttr = unsigned_type (ttr),
+ penalty = 10, 0))
+ || (comp_target_types (ttl, ttr, 0) > 0)))
+ return EVIL_RETURN (h);
+#endif
+
+ if (penalty == 10 || ttr == ttl)
+ {
+ tree tmp1 = TREE_TYPE (type), tmp2 = TREE_TYPE (parmtype);
+
+ /* If one was unsigned but the other wasn't, then we need to
+ do a standard conversion from T to unsigned T. */
+ if (penalty == 10)
+ h.code = PROMO_CODE; /* was STD_CODE */
+ else
+ h.code = 0;
+
+ /* Note conversion from `T*' to `const T*',
+ or `T*' to `volatile T*'. */
+ if (ttl == ttr
+ && ((TYPE_READONLY (tmp1) != TREE_READONLY (tmp2))
+ || (TYPE_VOLATILE (tmp1) != TYPE_VOLATILE (tmp2))))
+ h.code |= QUAL_CODE;
+
+ h.distance = 0;
+ return h;
+ }
+
+
+ if (TREE_CODE (ttl) == RECORD_TYPE && TREE_CODE (ttr) == RECORD_TYPE)
+ {
+ int b_or_d = get_base_distance (ttl, ttr, 0, 0);
+ if (b_or_d < 0)
+ {
+ b_or_d = get_base_distance (ttr, ttl, 0, 0);
+ if (b_or_d < 0)
+ return EVIL_RETURN (h);
+ h.distance = -b_or_d;
+ }
+ else
+ h.distance = b_or_d;
+ h.code = STD_CODE;
+ return h;
+ }
+
+ /* If converting from a `class*' to a `void*', make it
+ less favorable than any inheritance relationship. */
+ if (TREE_CODE (ttl) == VOID_TYPE && IS_AGGR_TYPE (ttr))
+ {
+ h.code = STD_CODE;
+ h.distance = CLASSTYPE_MAX_DEPTH (ttr)+1;
+ return h;
+ }
+
+ h.code = penalty ? STD_CODE : PROMO_CODE;
+ /* Catch things like `const char *' -> `const void *'
+ vs `const char *' -> `void *'. */
+ if (ttl != ttr)
+ {
+ tree tmp1 = TREE_TYPE (type), tmp2 = TREE_TYPE (parmtype);
+ if ((TYPE_READONLY (tmp1) != TREE_READONLY (tmp2))
+ || (TYPE_VOLATILE (tmp1) != TYPE_VOLATILE (tmp2)))
+ h.code |= QUAL_CODE;
+ }
+ return h;
+ }
+
+ if (codel == POINTER_TYPE && coder == INTEGER_TYPE)
+ {
+ /* This is not a bad match, but don't let it beat
+ integer-enum combinations. */
+ if (parm && integer_zerop (parm))
+ {
+ h.code = STD_CODE;
+ h.distance = 0;
+ return h;
+ }
+ }
+
+ /* C++: Since the `this' parameter of a signature member function
+ is represented as a signature pointer to handle default implementations
+ correctly, we can have the case that `type' is a signature pointer
+ while `parmtype' is a pointer to a signature table. We don't really
+ do any conversions in this case, so just return 0. */
+
+ if (codel == RECORD_TYPE && coder == POINTER_TYPE
+ && IS_SIGNATURE_POINTER (type) && IS_SIGNATURE (TREE_TYPE (parmtype)))
+ return ZERO_RETURN (h);
+
+ if (codel == RECORD_TYPE && coder == RECORD_TYPE)
+ {
+ int b_or_d = get_base_distance (type, parmtype, 0, 0);
+ if (b_or_d < 0)
+ {
+ b_or_d = get_base_distance (parmtype, type, 0, 0);
+ if (b_or_d < 0)
+ return EVIL_RETURN (h);
+ h.distance = -b_or_d;
+ }
+ else
+ h.distance = b_or_d;
+ h.code = STD_CODE;
+ return h;
+ }
+ return EVIL_RETURN (h);
+}
+
+/* A clone of build_type_conversion for checking user-defined conversions in
+ overload resolution. */
+
+int
+user_harshness (type, parmtype, parm)
+ register tree type, parmtype;
+ tree parm;
+{
+ tree conv;
+ tree winner = NULL_TREE;
+ int code;
+
+ {
+ tree typename = build_typename_overload (type);
+ if (lookup_fnfields (TYPE_BINFO (parmtype), typename, 0))
+ return 0;
+ }
+
+ for (conv = lookup_conversions (parmtype); conv; conv = TREE_CHAIN (conv))
+ {
+ struct harshness_code tmp;
+
+ if (winner && TREE_PURPOSE (winner) == TREE_PURPOSE (conv))
+ continue;
+
+ if (tmp = convert_harshness (type, TREE_VALUE (conv), NULL_TREE),
+ tmp.code < USER_CODE && tmp.distance >= 0)
+ {
+ if (winner)
+ return EVIL_CODE;
+ else
+ {
+ winner = conv;
+ code = tmp.code;
+ }
+ }
+ }
+
+ if (winner)
+ return code;
+
+ return -1;
+}
+
+int
+can_convert (to, from)
+ tree to, from;
+{
+ struct harshness_code h;
+ h = convert_harshness (to, from, NULL_TREE);
+ return h.code < USER_CODE && h.distance >= 0;
+}
+
+int
+can_convert_arg (to, from, arg)
+ tree to, from, arg;
+{
+ struct harshness_code h;
+ h = convert_harshness (to, from, arg);
+ return h.code < USER_CODE && h.distance >= 0;
+}
+
+#ifdef DEBUG_MATCHING
+static char *
+print_harshness (h)
+ struct harshness_code *h;
+{
+ static char buf[1024];
+ char tmp[1024];
+
+ bzero (buf, 1024 * sizeof (char));
+ strcat (buf, "codes=[");
+ if (h->code & EVIL_CODE)
+ strcat (buf, "EVIL");
+ if (h->code & CONST_CODE)
+ strcat (buf, " CONST");
+ if (h->code & ELLIPSIS_CODE)
+ strcat (buf, " ELLIPSIS");
+ if (h->code & USER_CODE)
+ strcat (buf, " USER");
+ if (h->code & STD_CODE)
+ strcat (buf, " STD");
+ if (h->code & PROMO_CODE)
+ strcat (buf, " PROMO");
+ if (h->code & QUAL_CODE)
+ strcat (buf, " QUAL");
+ if (h->code & TRIVIAL_CODE)
+ strcat (buf, " TRIVIAL");
+ if (buf[0] == '\0')
+ strcat (buf, "0");
+
+ sprintf (tmp, "] distance=%d int_penalty=%d", h->distance, h->int_penalty);
+
+ strcat (buf, tmp);
+
+ return buf;
+}
+#endif
+
+/* Algorithm: For each argument, calculate how difficult it is to
+ make FUNCTION accept that argument. If we can easily tell that
+ FUNCTION won't be acceptable to one of the arguments, then we
+ don't need to compute the ease of converting the other arguments,
+ since it will never show up in the intersection of all arguments'
+ favorite functions.
+
+ Conversions between builtin and user-defined types are allowed, but
+ no function involving such a conversion is preferred to one which
+ does not require such a conversion. Furthermore, such conversions
+ must be unique. */
+
+void
+compute_conversion_costs (function, tta_in, cp, arglen)
+ tree function;
+ tree tta_in;
+ struct candidate *cp;
+ int arglen;
+{
+ tree ttf_in = TYPE_ARG_TYPES (TREE_TYPE (function));
+ tree ttf = ttf_in;
+ tree tta = tta_in;
+
+ /* Start out with no strikes against. */
+ int evil_strikes = 0;
+ int ellipsis_strikes = 0;
+ int user_strikes = 0;
+ int b_or_d_strikes = 0;
+ int easy_strikes = 0;
+
+ int strike_index = 0, win;
+ struct harshness_code lose;
+ extern int cp_silent;
+
+#ifdef GATHER_STATISTICS
+ n_compute_conversion_costs++;
+#endif
+
+#ifndef DEBUG_MATCHING
+ /* We don't emit any warnings or errors while trying out each candidate. */
+ cp_silent = 1;
+#endif
+
+ cp->function = function;
+ cp->arg = tta ? TREE_VALUE (tta) : NULL_TREE;
+ cp->u.bad_arg = 0; /* optimistic! */
+
+ cp->h.code = 0;
+ cp->h.distance = 0;
+ cp->h.int_penalty = 0;
+ bzero ((char *) cp->harshness,
+ (cp->h_len + 1) * sizeof (struct harshness_code));
+
+ while (ttf && tta)
+ {
+ struct harshness_code h;
+
+ if (ttf == void_list_node)
+ break;
+
+ if (type_unknown_p (TREE_VALUE (tta)))
+ {
+ /* Must perform some instantiation here. */
+ tree rhs = TREE_VALUE (tta);
+ tree lhstype = TREE_VALUE (ttf);
+
+ /* Keep quiet about possible contravariance violations. */
+ int old_inhibit_warnings = inhibit_warnings;
+ inhibit_warnings = 1;
+
+ /* @@ This is to undo what `grokdeclarator' does to
+ parameter types. It really should go through
+ something more general. */
+
+ TREE_TYPE (tta) = unknown_type_node;
+ rhs = instantiate_type (lhstype, rhs, 0);
+ inhibit_warnings = old_inhibit_warnings;
+
+ if (TREE_CODE (rhs) == ERROR_MARK)
+ h.code = EVIL_CODE;
+ else
+ h = convert_harshness (lhstype, TREE_TYPE (rhs), rhs);
+ }
+ else
+ {
+#ifdef DEBUG_MATCHING
+ static tree old_function = NULL_TREE;
+
+ if (!old_function || function != old_function)
+ {
+ cp_error ("trying %D", function);
+ old_function = function;
+ }
+
+ cp_error (" doing (%T) %E against arg %T",
+ TREE_TYPE (TREE_VALUE (tta)), TREE_VALUE (tta),
+ TREE_VALUE (ttf));
+#endif
+
+ h = convert_harshness (TREE_VALUE (ttf),
+ TREE_TYPE (TREE_VALUE (tta)),
+ TREE_VALUE (tta));
+
+#ifdef DEBUG_MATCHING
+ cp_error (" evaluated %s", print_harshness (&h));
+#endif
+ }
+
+ cp->harshness[strike_index] = h;
+ if ((h.code & EVIL_CODE)
+ || ((h.code & STD_CODE) && h.distance < 0))
+ {
+ cp->u.bad_arg = strike_index;
+ evil_strikes = 1;
+ }
+ else if (h.code & ELLIPSIS_CODE)
+ ellipsis_strikes += 1;
+#if 0
+ /* This is never set by `convert_harshness'. */
+ else if (h.code & USER_CODE)
+ {
+ user_strikes += 1;
+ }
+#endif
+ else
+ {
+ if ((h.code & STD_CODE) && h.distance)
+ {
+ if (h.distance > b_or_d_strikes)
+ b_or_d_strikes = h.distance;
+ }
+ else
+ easy_strikes += (h.code & (STD_CODE|PROMO_CODE|TRIVIAL_CODE));
+ cp->h.code |= h.code;
+ /* Make sure we communicate this. */
+ cp->h.int_penalty += h.int_penalty;
+ }
+
+ ttf = TREE_CHAIN (ttf);
+ tta = TREE_CHAIN (tta);
+ strike_index += 1;
+ }
+
+ if (tta)
+ {
+ /* ran out of formals, and parmlist is fixed size. */
+ if (ttf /* == void_type_node */)
+ {
+ cp->h.code = EVIL_CODE;
+ cp->u.bad_arg = -1;
+ cp_silent = 0;
+ return;
+ }
+ else
+ {
+ struct harshness_code h;
+ int l = list_length (tta);
+ ellipsis_strikes += l;
+ h.code = ELLIPSIS_CODE;
+ h.distance = 0;
+ h.int_penalty = 0;
+ for (; l; --l)
+ cp->harshness[strike_index++] = h;
+ }
+ }
+ else if (ttf && ttf != void_list_node)
+ {
+ /* ran out of actuals, and no defaults. */
+ if (TREE_PURPOSE (ttf) == NULL_TREE)
+ {
+ cp->h.code = EVIL_CODE;
+ cp->u.bad_arg = -2;
+ cp_silent = 0;
+ return;
+ }
+ /* Store index of first default. */
+ cp->harshness[arglen].distance = strike_index+1;
+ }
+ else
+ cp->harshness[arglen].distance = 0;
+
+ /* Argument list lengths work out, so don't need to check them again. */
+ if (evil_strikes)
+ {
+ /* We do not check for derived->base conversions here, since in
+ no case would they give evil strike counts, unless such conversions
+ are somehow ambiguous. */
+
+ /* See if any user-defined conversions apply.
+ But make sure that we do not loop. */
+ static int dont_convert_types = 0;
+
+ if (dont_convert_types)
+ {
+ cp->h.code = EVIL_CODE;
+ cp_silent = 0;
+ return;
+ }
+
+ win = 0; /* Only get one chance to win. */
+ ttf = TYPE_ARG_TYPES (TREE_TYPE (function));
+ tta = tta_in;
+ strike_index = 0;
+ evil_strikes = 0;
+
+ while (ttf && tta)
+ {
+ if (ttf == void_list_node)
+ break;
+
+ lose = cp->harshness[strike_index];
+ if ((lose.code & EVIL_CODE)
+ || ((lose.code & STD_CODE) && lose.distance < 0))
+ {
+ tree actual_type = TREE_TYPE (TREE_VALUE (tta));
+ tree formal_type = TREE_VALUE (ttf);
+ int extra_conversions = 0;
+
+ dont_convert_types = 1;
+
+ if (TREE_CODE (formal_type) == REFERENCE_TYPE)
+ formal_type = TREE_TYPE (formal_type);
+ if (TREE_CODE (actual_type) == REFERENCE_TYPE)
+ actual_type = TREE_TYPE (actual_type);
+
+ if (formal_type != error_mark_node
+ && actual_type != error_mark_node)
+ {
+ formal_type = TYPE_MAIN_VARIANT (formal_type);
+ actual_type = TYPE_MAIN_VARIANT (actual_type);
+
+ if (TYPE_HAS_CONSTRUCTOR (formal_type))
+ {
+ /* If it has a constructor for this type,
+ try to use it. */
+ /* @@ There is no way to save this result yet, so
+ success is a NULL_TREE for now. */
+ if (convert_to_aggr (formal_type, TREE_VALUE (tta), 0, 1)
+ != error_mark_node)
+ win++;
+ }
+ if (TYPE_LANG_SPECIFIC (actual_type)
+ && TYPE_HAS_CONVERSION (actual_type))
+ {
+ int extra = user_harshness (formal_type, actual_type);
+
+ if (extra == EVIL_CODE)
+ win += 2;
+ else if (extra >= 0)
+ {
+ win++;
+ extra_conversions = extra;
+ }
+ }
+ }
+ dont_convert_types = 0;
+
+ if (win == 1)
+ {
+ user_strikes += 1;
+ cp->harshness[strike_index].code
+ = USER_CODE | (extra_conversions ? STD_CODE : 0);
+ win = 0;
+ }
+ else
+ {
+ if (cp->u.bad_arg > strike_index)
+ cp->u.bad_arg = strike_index;
+
+ evil_strikes = win ? 2 : 1;
+ break;
+ }
+ }
+
+ ttf = TREE_CHAIN (ttf);
+ tta = TREE_CHAIN (tta);
+ strike_index += 1;
+ }
+ }
+
+ /* Const member functions get a small penalty because defaulting
+ to const is less useful than defaulting to non-const. */
+ /* This is bogus, it does not correspond to anything in the ARM.
+ This code will be fixed when this entire section is rewritten
+ to conform to the ARM. (mrs) */
+ if (TREE_CODE (TREE_TYPE (function)) == METHOD_TYPE)
+ {
+ tree this_parm = TREE_VALUE (ttf_in);
+
+ if (TREE_CODE (this_parm) == RECORD_TYPE /* Is `this' a sig ptr? */
+ ? TYPE_READONLY (TREE_TYPE (TREE_TYPE (TYPE_FIELDS (this_parm))))
+ : TYPE_READONLY (TREE_TYPE (this_parm)))
+ {
+ cp->harshness[0].code |= TRIVIAL_CODE;
+ ++easy_strikes;
+ }
+ else
+ {
+ /* Calling a non-const member function from a const member function
+ is probably invalid, but for now we let it only draw a warning.
+ We indicate that such a mismatch has occurred by setting the
+ harshness to a maximum value. */
+ if (TREE_CODE (TREE_TYPE (TREE_VALUE (tta_in))) == POINTER_TYPE
+ && (TYPE_READONLY (TREE_TYPE (TREE_TYPE (TREE_VALUE (tta_in))))))
+ cp->harshness[0].code |= CONST_CODE;
+ }
+ }
+
+ if (evil_strikes)
+ cp->h.code = EVIL_CODE;
+ if (ellipsis_strikes)
+ cp->h.code |= ELLIPSIS_CODE;
+ if (user_strikes)
+ cp->h.code |= USER_CODE;
+ cp_silent = 0;
+#ifdef DEBUG_MATCHING
+ cp_error ("final eval %s", print_harshness (&cp->h));
+#endif
+}
+
+/* Subroutine of ideal_candidate. See if X or Y is a better match
+ than the other. */
+static int
+strictly_better (x, y)
+ unsigned short x, y;
+{
+ unsigned short xor;
+
+ if (x == y)
+ return 0;
+
+ xor = x ^ y;
+ if (xor >= x || xor >= y)
+ return 1;
+ return 0;
+}
+
+/* When one of several possible overloaded functions and/or methods
+ can be called, choose the best candidate for overloading.
+
+ BASETYPE is the context from which we start method resolution
+ or NULL if we are comparing overloaded functions.
+ CANDIDATES is the array of candidates we have to choose from.
+ N_CANDIDATES is the length of CANDIDATES.
+ PARMS is a TREE_LIST of parameters to the function we'll ultimately
+ choose. It is modified in place when resolving methods. It is not
+ modified in place when resolving overloaded functions.
+ LEN is the length of the parameter list. */
+
+static struct candidate *
+ideal_candidate (basetype, candidates, n_candidates, parms, len)
+ tree basetype;
+ struct candidate *candidates;
+ int n_candidates;
+ tree parms;
+ int len;
+{
+ struct candidate *cp = candidates+n_candidates;
+ int i, j = -1, best_code;
+
+ /* For each argument, sort the functions from best to worst for the arg.
+ For each function that's not best for this arg, set its overall
+ harshness to EVIL so that other args won't like it. The candidate
+ list for the last argument is the intersection of all the best-liked
+ functions. */
+
+#if 0
+ for (i = 0; i < len; i++)
+ {
+ qsort (candidates, n_candidates, sizeof (struct candidate),
+ rank_for_overload);
+ best_code = cp[-1].h.code;
+
+ /* To find out functions that are worse than that represented
+ by BEST_CODE, we can't just do a comparison like h.code>best_code.
+ The total harshness for the "best" fn may be 8|8 for two args, and
+ the harshness for the next-best may be 8|2. If we just compared,
+ that would be checking 8>10, which would lead to the next-best
+ being disqualified. What we actually want to do is get rid
+ of functions that are definitely worse than that represented
+ by best_code, i.e. those which have bits set higher than the
+ highest in best_code. Sooooo, what we do is clear out everything
+ represented by best_code, and see if we still come up with something
+ higher. If so (e.g., 8|8 vs 8|16), it'll disqualify it properly. */
+ for (j = n_candidates-2; j >= 0; j--)
+ if ((candidates[j].h.code & ~best_code) > best_code)
+ candidates[j].h.code = EVIL_CODE;
+ }
+
+ if (cp[-1].h.code & EVIL_CODE)
+ return NULL;
+#else
+ qsort (candidates, n_candidates, sizeof (struct candidate),
+ rank_for_overload);
+ best_code = cp[-1].h.code;
+#endif
+
+ /* If they're at least as good as each other, do an arg-by-arg check. */
+ if (! strictly_better (cp[-1].h.code, cp[-2].h.code))
+ {
+ int better = 0;
+ int worse = 0;
+
+ for (j = 0; j < n_candidates; j++)
+ if (! strictly_better (candidates[j].h.code, best_code))
+ break;
+
+ qsort (candidates+j, n_candidates-j, sizeof (struct candidate),
+ rank_for_ideal);
+ for (i = 0; i < len; i++)
+ {
+ if (cp[-1].harshness[i].code < cp[-2].harshness[i].code)
+ better = 1;
+ else if (cp[-1].harshness[i].code > cp[-2].harshness[i].code)
+ worse = 1;
+ else if (cp[-1].harshness[i].code & STD_CODE)
+ {
+ /* If it involves a standard conversion, let the
+ inheritance lattice be the final arbiter. */
+ if (cp[-1].harshness[i].distance > cp[-2].harshness[i].distance)
+ worse = 1;
+ else if (cp[-1].harshness[i].distance < cp[-2].harshness[i].distance)
+ better = 1;
+ }
+ else if (cp[-1].harshness[i].code & PROMO_CODE)
+ {
+ /* For integral promotions, take into account a finer
+ granularity for determining which types should be favored
+ over others in such promotions. */
+ if (cp[-1].harshness[i].int_penalty > cp[-2].harshness[i].int_penalty)
+ worse = 1;
+ else if (cp[-1].harshness[i].int_penalty < cp[-2].harshness[i].int_penalty)
+ better = 1;
+ }
+ }
+
+ if (! better || worse)
+ return NULL;
+ }
+ return cp-1;
+}
+
+/* Assume that if the class referred to is not in the
+ current class hierarchy, that it may be remote.
+ PARENT is assumed to be of aggregate type here. */
+static int
+may_be_remote (parent)
+ tree parent;
+{
+ if (TYPE_OVERLOADS_METHOD_CALL_EXPR (parent) == 0)
+ return 0;
+
+ if (current_class_type == NULL_TREE)
+ return 0;
+
+ if (parent == current_class_type)
+ return 0;
+
+ if (UNIQUELY_DERIVED_FROM_P (parent, current_class_type))
+ return 0;
+ return 1;
+}
+
+tree
+build_vfield_ref (datum, type)
+ tree datum, type;
+{
+ tree rval;
+ int old_assume_nonnull_objects = flag_assume_nonnull_objects;
+
+ if (datum == error_mark_node)
+ return error_mark_node;
+
+ /* Vtable references are always made from non-null objects. */
+ flag_assume_nonnull_objects = 1;
+ if (TREE_CODE (TREE_TYPE (datum)) == REFERENCE_TYPE)
+ datum = convert_from_reference (datum);
+
+ if (! TYPE_USES_COMPLEX_INHERITANCE (type))
+ rval = build (COMPONENT_REF, TREE_TYPE (CLASSTYPE_VFIELD (type)),
+ datum, CLASSTYPE_VFIELD (type));
+ else
+ rval = build_component_ref (datum, DECL_NAME (CLASSTYPE_VFIELD (type)), 0, 0);
+ flag_assume_nonnull_objects = old_assume_nonnull_objects;
+
+ return rval;
+}
+
+/* Build a call to a member of an object. I.e., one that overloads
+ operator ()(), or is a pointer-to-function or pointer-to-method. */
+static tree
+build_field_call (basetype_path, instance_ptr, name, parms)
+ tree basetype_path, instance_ptr, name, parms;
+{
+ tree field, instance;
+
+ if (instance_ptr == current_class_decl)
+ {
+ /* Check to see if we really have a reference to an instance variable
+ with `operator()()' overloaded. */
+ field = IDENTIFIER_CLASS_VALUE (name);
+
+ if (field == NULL_TREE)
+ {
+ cp_error ("`this' has no member named `%D'", name);
+ return error_mark_node;
+ }
+
+ if (TREE_CODE (field) == FIELD_DECL)
+ {
+ /* If it's a field, try overloading operator (),
+ or calling if the field is a pointer-to-function. */
+ instance = build_component_ref_1 (C_C_D, field, 0);
+ if (instance == error_mark_node)
+ return error_mark_node;
+
+ if (TYPE_LANG_SPECIFIC (TREE_TYPE (instance))
+ && TYPE_OVERLOADS_CALL_EXPR (TREE_TYPE (instance)))
+ return build_opfncall (CALL_EXPR, LOOKUP_NORMAL, instance, parms, NULL_TREE);
+
+ if (TREE_CODE (TREE_TYPE (instance)) == POINTER_TYPE)
+ {
+ if (TREE_CODE (TREE_TYPE (TREE_TYPE (instance))) == FUNCTION_TYPE)
+ return build_function_call (instance, parms);
+ else if (TREE_CODE (TREE_TYPE (TREE_TYPE (instance))) == METHOD_TYPE)
+ return build_function_call (instance, tree_cons (NULL_TREE, current_class_decl, parms));
+ }
+ }
+ return NULL_TREE;
+ }
+
+ /* Check to see if this is not really a reference to an instance variable
+ with `operator()()' overloaded. */
+ field = lookup_field (basetype_path, name, 1, 0);
+
+ /* This can happen if the reference was ambiguous or for access
+ violations. */
+ if (field == error_mark_node)
+ return error_mark_node;
+
+ if (field)
+ {
+ tree basetype;
+ tree ftype = TREE_TYPE (field);
+
+ if (TREE_CODE (ftype) == REFERENCE_TYPE)
+ ftype = TREE_TYPE (ftype);
+
+ if (TYPE_LANG_SPECIFIC (ftype) && TYPE_OVERLOADS_CALL_EXPR (ftype))
+ {
+ /* Make the next search for this field very short. */
+ basetype = DECL_FIELD_CONTEXT (field);
+ instance_ptr = convert_pointer_to (basetype, instance_ptr);
+
+ instance = build_indirect_ref (instance_ptr, NULL_PTR);
+ return build_opfncall (CALL_EXPR, LOOKUP_NORMAL,
+ build_component_ref_1 (instance, field, 0),
+ parms, NULL_TREE);
+ }
+ if (TREE_CODE (ftype) == POINTER_TYPE)
+ {
+ if (TREE_CODE (TREE_TYPE (ftype)) == FUNCTION_TYPE
+ || TREE_CODE (TREE_TYPE (ftype)) == METHOD_TYPE)
+ {
+ /* This is a member which is a pointer to function. */
+ tree ref
+ = build_component_ref_1 (build_indirect_ref (instance_ptr,
+ NULL_PTR),
+ field, LOOKUP_COMPLAIN);
+ if (ref == error_mark_node)
+ return error_mark_node;
+ return build_function_call (ref, parms);
+ }
+ }
+ else if (TREE_CODE (ftype) == METHOD_TYPE)
+ {
+ error ("invalid call via pointer-to-member function");
+ return error_mark_node;
+ }
+ else
+ return NULL_TREE;
+ }
+ return NULL_TREE;
+}
+
+tree
+find_scoped_type (type, inner_name, inner_types)
+ tree type, inner_name, inner_types;
+{
+ tree tags = CLASSTYPE_TAGS (type);
+
+ while (tags)
+ {
+ /* The TREE_PURPOSE of an enum tag (which becomes a member of the
+ enclosing class) is set to the name for the enum type. So, if
+ inner_name is `bar', and we strike `baz' for `enum bar { baz }',
+ then this test will be true. */
+ if (TREE_PURPOSE (tags) == inner_name)
+ {
+ if (inner_types == NULL_TREE)
+ return DECL_NESTED_TYPENAME (TYPE_NAME (TREE_VALUE (tags)));
+ return resolve_scope_to_name (TREE_VALUE (tags), inner_types);
+ }
+ tags = TREE_CHAIN (tags);
+ }
+
+#if 0
+ /* XXX This needs to be fixed better. */
+ if (TREE_CODE (type) == UNINSTANTIATED_P_TYPE)
+ {
+ sorry ("nested class lookup in template type");
+ return NULL_TREE;
+ }
+#endif
+
+ /* Look for a TYPE_DECL. */
+ for (tags = TYPE_FIELDS (type); tags; tags = TREE_CHAIN (tags))
+ if (TREE_CODE (tags) == TYPE_DECL && DECL_NAME (tags) == inner_name)
+ {
+ /* Code by raeburn. */
+ if (inner_types == NULL_TREE)
+ return DECL_NESTED_TYPENAME (tags);
+ return resolve_scope_to_name (TREE_TYPE (tags), inner_types);
+ }
+
+ return NULL_TREE;
+}
+
+/* Resolve an expression NAME1::NAME2::...::NAMEn to
+ the name that names the above nested type. INNER_TYPES
+ is a chain of nested type names (held together by SCOPE_REFs);
+ OUTER_TYPE is the type we know to enclose INNER_TYPES.
+ Returns NULL_TREE if there is an error. */
+tree
+resolve_scope_to_name (outer_type, inner_stuff)
+ tree outer_type, inner_stuff;
+{
+ register tree tmp;
+ tree inner_name, inner_type;
+
+ if (outer_type == NULL_TREE && current_class_type != NULL_TREE)
+ {
+ /* We first try to look for a nesting in our current class context,
+ then try any enclosing classes. */
+ tree type = current_class_type;
+
+ while (type && (TREE_CODE (type) == RECORD_TYPE
+ || TREE_CODE (type) == UNION_TYPE))
+ {
+ tree rval = resolve_scope_to_name (type, inner_stuff);
+
+ if (rval != NULL_TREE)
+ return rval;
+ type = DECL_CONTEXT (TYPE_NAME (type));
+ }
+ }
+
+ if (TREE_CODE (inner_stuff) == SCOPE_REF)
+ {
+ inner_name = TREE_OPERAND (inner_stuff, 0);
+ inner_type = TREE_OPERAND (inner_stuff, 1);
+ }
+ else
+ {
+ inner_name = inner_stuff;
+ inner_type = NULL_TREE;
+ }
+
+ if (outer_type == NULL_TREE)
+ {
+ tree x;
+ /* If we have something that's already a type by itself,
+ use that. */
+ if (IDENTIFIER_HAS_TYPE_VALUE (inner_name))
+ {
+ if (inner_type)
+ return resolve_scope_to_name (IDENTIFIER_TYPE_VALUE (inner_name),
+ inner_type);
+ return inner_name;
+ }
+
+ x = lookup_name (inner_name, 0);
+
+ if (x && TREE_CODE (x) == NAMESPACE_DECL)
+ {
+ x = lookup_namespace_name (x, inner_type);
+ return x;
+ }
+ return NULL_TREE;
+ }
+
+ if (! IS_AGGR_TYPE (outer_type))
+ return NULL_TREE;
+
+ /* Look for member classes or enums. */
+ tmp = find_scoped_type (outer_type, inner_name, inner_type);
+
+ /* If it's not a type in this class, then go down into the
+ base classes and search there. */
+ if (! tmp && TYPE_BINFO (outer_type))
+ {
+ tree binfos = TYPE_BINFO_BASETYPES (outer_type);
+ int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+
+ for (i = 0; i < n_baselinks; i++)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ tmp = resolve_scope_to_name (BINFO_TYPE (base_binfo), inner_stuff);
+ if (tmp)
+ return tmp;
+ }
+ tmp = NULL_TREE;
+ }
+
+ return tmp;
+}
+
+/* Build a method call of the form `EXP->SCOPES::NAME (PARMS)'.
+ This is how virtual function calls are avoided. */
+tree
+build_scoped_method_call (exp, scopes, name, parms)
+ tree exp, scopes, name, parms;
+{
+ /* Because this syntactic form does not allow
+ a pointer to a base class to be `stolen',
+ we need not protect the derived->base conversion
+ that happens here.
+
+ @@ But we do have to check access privileges later. */
+ tree basename = resolve_scope_to_name (NULL_TREE, scopes);
+ tree basetype, binfo, decl;
+ tree type = TREE_TYPE (exp);
+
+ if (type == error_mark_node
+ || basename == NULL_TREE)
+ return error_mark_node;
+
+ basetype = IDENTIFIER_TYPE_VALUE (basename);
+
+ if (TREE_CODE (type) == REFERENCE_TYPE)
+ type = TREE_TYPE (type);
+
+ /* Destructors can be "called" for simple types; see 5.2.4 and 12.4 Note
+ that explicit ~int is caught in the parser; this deals with typedefs
+ and template parms. */
+ if (TREE_CODE (name) == BIT_NOT_EXPR && ! is_aggr_typedef (basename, 0))
+ {
+ if (type != basetype)
+ cp_error ("type of `%E' does not match destructor type `%T' (type was `%T')",
+ exp, basetype, type);
+ name = TREE_OPERAND (name, 0);
+ if (basetype != get_type_value (name))
+ cp_error ("qualified type `%T' does not match destructor name `~%T'",
+ basetype, name);
+ return convert (void_type_node, exp);
+ }
+
+ if (! is_aggr_typedef (basename, 1))
+ return error_mark_node;
+
+ if (! IS_AGGR_TYPE (type))
+ {
+ cp_error ("base object `%E' of scoped method call is of non-aggregate type `%T'",
+ exp, type);
+ return error_mark_node;
+ }
+
+ if ((binfo = binfo_or_else (basetype, type)))
+ {
+ if (binfo == error_mark_node)
+ return error_mark_node;
+ if (TREE_CODE (exp) == INDIRECT_REF)
+ decl = build_indirect_ref (convert_pointer_to (binfo,
+ build_unary_op (ADDR_EXPR, exp, 0)), NULL_PTR);
+ else
+ decl = build_scoped_ref (exp, scopes);
+
+ /* Call to a destructor. */
+ if (TREE_CODE (name) == BIT_NOT_EXPR)
+ {
+ /* Explicit call to destructor. */
+ name = TREE_OPERAND (name, 0);
+ if (! (name == constructor_name (TREE_TYPE (decl))
+ || TREE_TYPE (decl) == get_type_value (name)))
+ {
+ cp_error
+ ("qualified type `%T' does not match destructor name `~%T'",
+ TREE_TYPE (decl), name);
+ return error_mark_node;
+ }
+ if (! TYPE_HAS_DESTRUCTOR (TREE_TYPE (decl)))
+ return convert (void_type_node, exp);
+
+ return build_delete (TREE_TYPE (decl), decl, integer_two_node,
+ LOOKUP_NORMAL|LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR,
+ 0);
+ }
+
+ /* Call to a method. */
+ return build_method_call (decl, name, parms, binfo,
+ LOOKUP_NORMAL|LOOKUP_NONVIRTUAL);
+ }
+ return error_mark_node;
+}
+
+static void
+print_candidates (candidates)
+ tree candidates;
+{
+ cp_error_at ("candidates are: %D", TREE_VALUE (candidates));
+ candidates = TREE_CHAIN (candidates);
+
+ while (candidates)
+ {
+ cp_error_at (" %D", TREE_VALUE (candidates));
+ candidates = TREE_CHAIN (candidates);
+ }
+}
+
+static void
+print_n_candidates (candidates, n)
+ struct candidate *candidates;
+ int n;
+{
+ int i;
+
+ cp_error_at ("candidates are: %D", candidates[0].function);
+ for (i = 1; i < n; i++)
+ cp_error_at (" %D", candidates[i].function);
+}
+
+/* Build something of the form ptr->method (args)
+ or object.method (args). This can also build
+ calls to constructors, and find friends.
+
+ Member functions always take their class variable
+ as a pointer.
+
+ INSTANCE is a class instance.
+
+ NAME is the name of the method desired, usually an IDENTIFIER_NODE.
+
+ PARMS help to figure out what that NAME really refers to.
+
+ BASETYPE_PATH, if non-NULL, contains a chain from the type of INSTANCE
+ down to the real instance type to use for access checking. We need this
+ information to get protected accesses correct. This parameter is used
+ by build_member_call.
+
+ FLAGS is the logical disjunction of zero or more LOOKUP_
+ flags. See cp-tree.h for more info.
+
+ If this is all OK, calls build_function_call with the resolved
+ member function.
+
+ This function must also handle being called to perform
+ initialization, promotion/coercion of arguments, and
+ instantiation of default parameters.
+
+ Note that NAME may refer to an instance variable name. If
+ `operator()()' is defined for the type of that field, then we return
+ that result. */
+tree
+build_method_call (instance, name, parms, basetype_path, flags)
+ tree instance, name, parms, basetype_path;
+ int flags;
+{
+ register tree function, fntype, value_type;
+ register tree basetype, save_basetype;
+ register tree baselink, result, method_name, parmtypes, parm;
+ tree last;
+ int pass;
+ enum access_type access = access_public;
+
+ /* Range of cases for vtable optimization. */
+ enum vtable_needs { not_needed, maybe_needed, unneeded, needed };
+ enum vtable_needs need_vtbl = not_needed;
+
+ char *name_kind;
+ int ever_seen = 0;
+ tree instance_ptr = NULL_TREE;
+ int all_virtual = flag_all_virtual;
+ int static_call_context = 0;
+ tree found_fns = NULL_TREE;
+
+ /* Keep track of `const' and `volatile' objects. */
+ int constp, volatilep;
+
+#ifdef GATHER_STATISTICS
+ n_build_method_call++;
+#endif
+
+ if (instance == error_mark_node
+ || name == error_mark_node
+ || parms == error_mark_node
+ || (instance != NULL_TREE && TREE_TYPE (instance) == error_mark_node))
+ return error_mark_node;
+
+ /* This is the logic that magically deletes the second argument to
+ operator delete, if it is not needed. */
+ if (name == ansi_opname[(int) DELETE_EXPR] && list_length (parms)==2)
+ {
+ tree save_last = TREE_CHAIN (parms);
+ tree result;
+ /* get rid of unneeded argument */
+ TREE_CHAIN (parms) = NULL_TREE;
+ result = build_method_call (instance, name, parms, basetype_path,
+ (LOOKUP_SPECULATIVELY|flags)
+ &~LOOKUP_COMPLAIN);
+ /* If it finds a match, return it. */
+ if (result)
+ return build_method_call (instance, name, parms, basetype_path, flags);
+ /* If it doesn't work, two argument delete must work */
+ TREE_CHAIN (parms) = save_last;
+ }
+ /* We already know whether it's needed or not for vec delete. */
+ else if (name == ansi_opname[(int) VEC_DELETE_EXPR]
+ && ! TYPE_VEC_DELETE_TAKES_SIZE (TREE_TYPE (instance)))
+ TREE_CHAIN (parms) = NULL_TREE;
+
+ if (TREE_CODE (name) == BIT_NOT_EXPR)
+ {
+ flags |= LOOKUP_DESTRUCTOR;
+ name = TREE_OPERAND (name, 0);
+ if (parms)
+ error ("destructors take no parameters");
+ basetype = TREE_TYPE (instance);
+ if (TREE_CODE (basetype) == REFERENCE_TYPE)
+ basetype = TREE_TYPE (basetype);
+ if (! ((IS_AGGR_TYPE (basetype)
+ && name == constructor_name (basetype))
+ || basetype == get_type_value (name)))
+ {
+ cp_error ("destructor name `~%D' does not match type `%T' of expression",
+ name, basetype);
+ return convert (void_type_node, instance);
+ }
+
+ if (! TYPE_HAS_DESTRUCTOR (basetype))
+ return convert (void_type_node, instance);
+ instance = default_conversion (instance);
+ instance_ptr = build_unary_op (ADDR_EXPR, instance, 0);
+ return build_delete (build_pointer_type (basetype),
+ instance_ptr, integer_two_node,
+ LOOKUP_NORMAL|LOOKUP_DESTRUCTOR, 0);
+ }
+
+ {
+ char *xref_name;
+
+ /* Initialize name for error reporting. */
+ if (IDENTIFIER_OPNAME_P (name) && ! IDENTIFIER_TYPENAME_P (name))
+ {
+ char *p = operator_name_string (name);
+ xref_name = (char *)alloca (strlen (p) + 10);
+ sprintf (xref_name, "operator %s", p);
+ }
+ else if (TREE_CODE (name) == SCOPE_REF)
+ xref_name = IDENTIFIER_POINTER (TREE_OPERAND (name, 1));
+ else
+ xref_name = IDENTIFIER_POINTER (name);
+
+ GNU_xref_call (current_function_decl, xref_name);
+ }
+
+ if (instance == NULL_TREE)
+ {
+ basetype = NULL_TREE;
+ /* Check cases where this is really a call to raise
+ an exception. */
+ if (current_class_type && TREE_CODE (name) == IDENTIFIER_NODE)
+ {
+ basetype = purpose_member (name, CLASSTYPE_TAGS (current_class_type));
+ if (basetype)
+ basetype = TREE_VALUE (basetype);
+ }
+ else if (TREE_CODE (name) == SCOPE_REF
+ && TREE_CODE (TREE_OPERAND (name, 0)) == IDENTIFIER_NODE)
+ {
+ if (! is_aggr_typedef (TREE_OPERAND (name, 0), 1))
+ return error_mark_node;
+ basetype = purpose_member (TREE_OPERAND (name, 1),
+ CLASSTYPE_TAGS (IDENTIFIER_TYPE_VALUE (TREE_OPERAND (name, 0))));
+ if (basetype)
+ basetype = TREE_VALUE (basetype);
+ }
+
+ if (basetype != NULL_TREE)
+ ;
+ /* call to a constructor... */
+ else if (basetype_path)
+ basetype = BINFO_TYPE (basetype_path);
+ else if (IDENTIFIER_HAS_TYPE_VALUE (name))
+ {
+ basetype = IDENTIFIER_TYPE_VALUE (name);
+ name = constructor_name_full (basetype);
+ }
+ else
+ {
+ tree typedef_name = lookup_name (name, 1);
+ if (typedef_name && TREE_CODE (typedef_name) == TYPE_DECL)
+ {
+ /* Canonicalize the typedef name. */
+ basetype = TREE_TYPE (typedef_name);
+ name = TYPE_IDENTIFIER (basetype);
+ }
+ else
+ {
+ cp_error ("no constructor named `%T' in scope",
+ name);
+ return error_mark_node;
+ }
+ }
+
+ if (! IS_AGGR_TYPE (basetype))
+ {
+ non_aggr_error:
+ if ((flags & LOOKUP_COMPLAIN) && TREE_CODE (basetype) != ERROR_MARK)
+ cp_error ("request for member `%D' in `%E', which is of non-aggregate type `%T'",
+ name, instance, basetype);
+
+ return error_mark_node;
+ }
+ }
+ else if (instance == C_C_D || instance == current_class_decl)
+ {
+ /* When doing initialization, we side-effect the TREE_TYPE of
+ C_C_D, hence we cannot set up BASETYPE from CURRENT_CLASS_TYPE. */
+ basetype = TREE_TYPE (C_C_D);
+
+ /* Anything manifestly `this' in constructors and destructors
+ has a known type, so virtual function tables are not needed. */
+ if (TYPE_VIRTUAL_P (basetype)
+ && !(flags & LOOKUP_NONVIRTUAL))
+ need_vtbl = (dtor_label || ctor_label)
+ ? unneeded : maybe_needed;
+
+ /* If `this' is a signature pointer and `name' is not a constructor,
+ we are calling a signature member function. In that case, set the
+ `basetype' to the signature type and dereference the `optr' field. */
+ if (IS_SIGNATURE_POINTER (basetype)
+ && TYPE_IDENTIFIER (basetype) != name)
+ {
+ basetype = SIGNATURE_TYPE (basetype);
+ instance_ptr = build_optr_ref (instance);
+ instance_ptr = convert (build_pointer_type (basetype), instance_ptr);
+ basetype_path = TYPE_BINFO (basetype);
+ }
+ else
+ {
+ instance = C_C_D;
+ instance_ptr = current_class_decl;
+ basetype_path = TYPE_BINFO (current_class_type);
+ }
+ result = build_field_call (basetype_path, instance_ptr, name, parms);
+
+ if (result)
+ return result;
+ }
+ else if (TREE_CODE (instance) == RESULT_DECL)
+ {
+ basetype = TREE_TYPE (instance);
+ /* Should we ever have to make a virtual function reference
+ from a RESULT_DECL, know that it must be of fixed type
+ within the scope of this function. */
+ if (!(flags & LOOKUP_NONVIRTUAL) && TYPE_VIRTUAL_P (basetype))
+ need_vtbl = maybe_needed;
+ instance_ptr = build1 (ADDR_EXPR, build_pointer_type (basetype), instance);
+ }
+ else
+ {
+ /* The MAIN_VARIANT of the type that `instance_ptr' winds up being. */
+ tree inst_ptr_basetype;
+
+ static_call_context =
+ (TREE_CODE (instance) == INDIRECT_REF
+ && TREE_CODE (TREE_OPERAND (instance, 0)) == NOP_EXPR
+ && TREE_OPERAND (TREE_OPERAND (instance, 0), 0) == error_mark_node);
+
+ if (TREE_CODE (instance) == OFFSET_REF)
+ instance = resolve_offset_ref (instance);
+
+ /* the base type of an instance variable is pointer to class */
+ basetype = TREE_TYPE (instance);
+
+ if (TREE_CODE (basetype) == REFERENCE_TYPE)
+ {
+ basetype = TREE_TYPE (basetype);
+ if (! IS_AGGR_TYPE (basetype))
+ goto non_aggr_error;
+ /* Call to convert not needed because we are remaining
+ within the same type. */
+ instance_ptr = build1 (NOP_EXPR, build_pointer_type (basetype),
+ instance);
+ inst_ptr_basetype = TYPE_MAIN_VARIANT (basetype);
+ }
+ else
+ {
+ if (! IS_AGGR_TYPE (basetype)
+ && ! (TYPE_LANG_SPECIFIC (basetype)
+ && (IS_SIGNATURE_POINTER (basetype)
+ || IS_SIGNATURE_REFERENCE (basetype))))
+ goto non_aggr_error;
+
+ /* If `instance' is a signature pointer/reference and `name' is
+ not a constructor, we are calling a signature member function.
+ In that case set the `basetype' to the signature type. */
+ if ((IS_SIGNATURE_POINTER (basetype)
+ || IS_SIGNATURE_REFERENCE (basetype))
+ && TYPE_IDENTIFIER (basetype) != name)
+ basetype = SIGNATURE_TYPE (basetype);
+
+ if ((IS_SIGNATURE (basetype)
+ && (instance_ptr = instance))
+ || (lvalue_p (instance)
+ && (instance_ptr = build_unary_op (ADDR_EXPR, instance, 0)))
+ || (instance_ptr = unary_complex_lvalue (ADDR_EXPR, instance)))
+ {
+ if (instance_ptr == error_mark_node)
+ return error_mark_node;
+ }
+ else if (TREE_CODE (instance) == NOP_EXPR
+ || TREE_CODE (instance) == CONSTRUCTOR)
+ {
+ /* A cast is not an lvalue. Initialize a fresh temp
+ with the value we are casting from, and proceed with
+ that temporary. We can't cast to a reference type,
+ so that simplifies the initialization to something
+ we can manage. */
+ tree temp = get_temp_name (TREE_TYPE (instance), 0);
+ if (IS_AGGR_TYPE (TREE_TYPE (instance)))
+ expand_aggr_init (temp, instance, 0, flags);
+ else
+ {
+ store_init_value (temp, instance);
+ expand_decl_init (temp);
+ }
+ instance = temp;
+ instance_ptr = build_unary_op (ADDR_EXPR, instance, 0);
+ }
+ else
+ {
+ if (TREE_CODE (instance) != CALL_EXPR)
+ my_friendly_abort (125);
+ if (TYPE_NEEDS_CONSTRUCTING (basetype))
+ instance = build_cplus_new (basetype, instance, 0);
+ else
+ {
+ instance = get_temp_name (basetype, 0);
+ TREE_ADDRESSABLE (instance) = 1;
+ }
+ instance_ptr = build_unary_op (ADDR_EXPR, instance, 0);
+ }
+ /* @@ Should we call comp_target_types here? */
+ if (IS_SIGNATURE (basetype))
+ inst_ptr_basetype = basetype;
+ else
+ inst_ptr_basetype = TREE_TYPE (TREE_TYPE (instance_ptr));
+ if (TYPE_MAIN_VARIANT (basetype) == TYPE_MAIN_VARIANT (inst_ptr_basetype))
+ basetype = inst_ptr_basetype;
+ else
+ {
+ instance_ptr = convert (build_pointer_type (basetype), instance_ptr);
+ if (instance_ptr == error_mark_node)
+ return error_mark_node;
+ }
+ }
+
+ /* After converting `instance_ptr' above, `inst_ptr_basetype' was
+ not updated, so we use `basetype' instead. */
+ if (basetype_path == NULL_TREE
+ && IS_SIGNATURE (basetype))
+ basetype_path = TYPE_BINFO (basetype);
+ else if (basetype_path == NULL_TREE ||
+ BINFO_TYPE (basetype_path) != TYPE_MAIN_VARIANT (inst_ptr_basetype))
+ basetype_path = TYPE_BINFO (inst_ptr_basetype);
+
+ result = build_field_call (basetype_path, instance_ptr, name, parms);
+ if (result)
+ return result;
+
+ if (!(flags & LOOKUP_NONVIRTUAL) && TYPE_VIRTUAL_P (basetype))
+ {
+ if (TREE_SIDE_EFFECTS (instance_ptr))
+ {
+ /* This action is needed because the instance is needed
+ for providing the base of the virtual function table.
+ Without using a SAVE_EXPR, the function we are building
+ may be called twice, or side effects on the instance
+ variable (such as a post-increment), may happen twice. */
+ instance_ptr = save_expr (instance_ptr);
+ instance = build_indirect_ref (instance_ptr, NULL_PTR);
+ }
+ else if (TREE_CODE (TREE_TYPE (instance)) == POINTER_TYPE)
+ {
+ /* This happens when called for operator new (). */
+ instance = build_indirect_ref (instance, NULL_PTR);
+ }
+
+ need_vtbl = maybe_needed;
+ }
+ }
+
+ if (TYPE_SIZE (basetype) == 0)
+ {
+ /* This is worth complaining about, I think. */
+ cp_error ("cannot lookup method in incomplete type `%T'", basetype);
+ return error_mark_node;
+ }
+
+ save_basetype = TYPE_MAIN_VARIANT (basetype);
+
+#if 0
+ if (all_virtual == 1
+ && (! strncmp (IDENTIFIER_POINTER (name), OPERATOR_METHOD_FORMAT,
+ OPERATOR_METHOD_LENGTH)
+ || instance_ptr == NULL_TREE
+ || (TYPE_OVERLOADS_METHOD_CALL_EXPR (basetype) == 0)))
+ all_virtual = 0;
+#endif
+
+ last = NULL_TREE;
+ for (parmtypes = NULL_TREE, parm = parms; parm; parm = TREE_CHAIN (parm))
+ {
+ tree t = TREE_TYPE (TREE_VALUE (parm));
+ if (TREE_CODE (t) == OFFSET_TYPE)
+ {
+ /* Convert OFFSET_TYPE entities to their normal selves. */
+ TREE_VALUE (parm) = resolve_offset_ref (TREE_VALUE (parm));
+ t = TREE_TYPE (TREE_VALUE (parm));
+ }
+ if (TREE_CODE (TREE_VALUE (parm)) == OFFSET_REF
+ && TREE_CODE (t) == METHOD_TYPE)
+ {
+ TREE_VALUE (parm) = build_unary_op (ADDR_EXPR, TREE_VALUE (parm), 0);
+ }
+#if 0
+ /* This breaks reference-to-array parameters. */
+ if (TREE_CODE (t) == ARRAY_TYPE)
+ {
+ /* Perform the conversion from ARRAY_TYPE to POINTER_TYPE in place.
+ This eliminates needless calls to `compute_conversion_costs'. */
+ TREE_VALUE (parm) = default_conversion (TREE_VALUE (parm));
+ t = TREE_TYPE (TREE_VALUE (parm));
+ }
+#endif
+ if (t == error_mark_node)
+ return error_mark_node;
+ last = build_tree_list (NULL_TREE, t);
+ parmtypes = chainon (parmtypes, last);
+ }
+
+ if (instance && IS_SIGNATURE (basetype))
+ {
+ /* @@ Should this be the constp/volatilep flags for the optr field
+ of the signature pointer? */
+ constp = TYPE_READONLY (basetype);
+ volatilep = TYPE_VOLATILE (basetype);
+ parms = tree_cons (NULL_TREE, instance_ptr, parms);
+ }
+ else if (instance)
+ {
+ /* TREE_READONLY (instance) fails for references. */
+ constp = TYPE_READONLY (TREE_TYPE (TREE_TYPE (instance_ptr)));
+ volatilep = TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (instance_ptr)));
+ parms = tree_cons (NULL_TREE, instance_ptr, parms);
+ }
+ else
+ {
+ /* Raw constructors are always in charge. */
+ if (TYPE_USES_VIRTUAL_BASECLASSES (basetype)
+ && ! (flags & LOOKUP_HAS_IN_CHARGE))
+ {
+ flags |= LOOKUP_HAS_IN_CHARGE;
+ parms = tree_cons (NULL_TREE, integer_one_node, parms);
+ parmtypes = tree_cons (NULL_TREE, integer_type_node, parmtypes);
+ }
+
+ constp = 0;
+ volatilep = 0;
+ instance_ptr = build_int_2 (0, 0);
+ TREE_TYPE (instance_ptr) = build_pointer_type (basetype);
+ parms = tree_cons (NULL_TREE, instance_ptr, parms);
+ }
+
+ parmtypes = tree_cons (NULL_TREE, TREE_TYPE (instance_ptr), parmtypes);
+
+ if (last == NULL_TREE)
+ last = parmtypes;
+
+ /* Look up function name in the structure type definition. */
+
+ if ((IDENTIFIER_HAS_TYPE_VALUE (name)
+ && ! IDENTIFIER_OPNAME_P (name)
+ && IS_AGGR_TYPE (IDENTIFIER_TYPE_VALUE (name))
+ && TREE_CODE (IDENTIFIER_TYPE_VALUE (name)) != UNINSTANTIATED_P_TYPE)
+ || name == constructor_name (basetype))
+ {
+ tree tmp = NULL_TREE;
+ if (IDENTIFIER_TYPE_VALUE (name) == basetype
+ || name == constructor_name (basetype))
+ tmp = TYPE_BINFO (basetype);
+ else
+ tmp = get_binfo (IDENTIFIER_TYPE_VALUE (name), basetype, 0);
+
+ if (tmp != NULL_TREE)
+ {
+ name_kind = "constructor";
+
+ if (TYPE_USES_VIRTUAL_BASECLASSES (basetype)
+ && ! (flags & LOOKUP_HAS_IN_CHARGE))
+ {
+ /* Constructors called for initialization
+ only are never in charge. */
+ tree tmplist;
+
+ flags |= LOOKUP_HAS_IN_CHARGE;
+ tmplist = tree_cons (NULL_TREE, integer_zero_node,
+ TREE_CHAIN (parms));
+ TREE_CHAIN (parms) = tmplist;
+ tmplist = tree_cons (NULL_TREE, integer_type_node, TREE_CHAIN (parmtypes));
+ TREE_CHAIN (parmtypes) = tmplist;
+ }
+ basetype = BINFO_TYPE (tmp);
+ }
+ else
+ name_kind = "method";
+ }
+ else
+ name_kind = "method";
+
+ if (basetype_path == NULL_TREE
+ || BINFO_TYPE (basetype_path) != TYPE_MAIN_VARIANT (basetype))
+ basetype_path = TYPE_BINFO (basetype);
+ result = lookup_fnfields (basetype_path, name,
+ (flags & LOOKUP_COMPLAIN));
+ if (result == error_mark_node)
+ return error_mark_node;
+
+
+#if 0
+ /* Now, go look for this method name. We do not find destructors here.
+
+ Putting `void_list_node' on the end of the parmtypes
+ fakes out `build_decl_overload' into doing the right thing. */
+ TREE_CHAIN (last) = void_list_node;
+ method_name = build_decl_overload (name, parmtypes,
+ 1 + (name == constructor_name (save_basetype)
+ || name == constructor_name_full (save_basetype)));
+ TREE_CHAIN (last) = NULL_TREE;
+#endif
+
+ for (pass = 0; pass < 2; pass++)
+ {
+ struct candidate *candidates;
+ struct candidate *cp;
+ int len;
+ unsigned best = 1;
+
+ /* This increments every time we go up the type hierarchy.
+ The idea is to prefer a function of the derived class if possible. */
+ int b_or_d = 0;
+
+ baselink = result;
+
+ if (pass > 0)
+ {
+ candidates
+ = (struct candidate *) alloca ((ever_seen+1)
+ * sizeof (struct candidate));
+ bzero ((char *) candidates, (ever_seen + 1) * sizeof (struct candidate));
+ cp = candidates;
+ len = list_length (parms);
+ ever_seen = 0;
+
+ /* First see if a global function has a shot at it. */
+ if (flags & LOOKUP_GLOBAL)
+ {
+ tree friend_parms;
+ tree parm = instance_ptr;
+
+ if (TREE_CODE (TREE_TYPE (parm)) == REFERENCE_TYPE)
+ parm = convert_from_reference (parm);
+ else if (TREE_CODE (TREE_TYPE (parm)) == POINTER_TYPE)
+ parm = build_indirect_ref (parm, "friendifying parms (compiler error)");
+ else
+ my_friendly_abort (167);
+
+ friend_parms = tree_cons (NULL_TREE, parm, TREE_CHAIN (parms));
+
+ cp->h_len = len;
+ cp->harshness = (struct harshness_code *)
+ alloca ((len + 1) * sizeof (struct harshness_code));
+
+ result = build_overload_call (name, friend_parms, 0, cp);
+ /* If it turns out to be the one we were actually looking for
+ (it was probably a friend function), the return the
+ good result. */
+ if (TREE_CODE (result) == CALL_EXPR)
+ return result;
+
+ while ((cp->h.code & EVIL_CODE) == 0)
+ {
+ /* non-standard uses: set the field to 0 to indicate
+ we are using a non-member function. */
+ cp->u.field = 0;
+ if (cp->harshness[len].distance == 0
+ && cp->h.code < best)
+ best = cp->h.code;
+ cp += 1;
+ }
+ }
+ }
+
+ while (baselink)
+ {
+ /* We have a hit (of sorts). If the parameter list is
+ "error_mark_node", or some variant thereof, it won't
+ match any methods. Since we have verified that the is
+ some method vaguely matching this one (in name at least),
+ silently return.
+
+ Don't stop for friends, however. */
+ basetype_path = TREE_PURPOSE (baselink);
+
+ function = TREE_VALUE (baselink);
+ if (TREE_CODE (basetype_path) == TREE_LIST)
+ basetype_path = TREE_VALUE (basetype_path);
+ basetype = BINFO_TYPE (basetype_path);
+
+#if 0
+ /* Cast the instance variable if necessary. */
+ if (basetype != TYPE_MAIN_VARIANT
+ (TREE_TYPE (TREE_TYPE (TREE_VALUE (parms)))))
+ {
+ if (basetype == save_basetype)
+ TREE_VALUE (parms) = instance_ptr;
+ else
+ {
+ tree type = build_pointer_type
+ (build_type_variant (basetype, constp, volatilep));
+ TREE_VALUE (parms) = convert_force (type, instance_ptr, 0);
+ }
+ }
+
+ /* FIXME: this is the wrong place to get an error. Hopefully
+ the access-control rewrite will make this change more cleanly. */
+ if (TREE_VALUE (parms) == error_mark_node)
+ return error_mark_node;
+#endif
+
+ if (DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (function)))
+ function = DECL_CHAIN (function);
+
+ for (; function; function = DECL_CHAIN (function))
+ {
+#ifdef GATHER_STATISTICS
+ n_inner_fields_searched++;
+#endif
+ ever_seen++;
+ if (pass > 0)
+ found_fns = tree_cons (NULL_TREE, function, found_fns);
+
+ /* Not looking for friends here. */
+ if (TREE_CODE (TREE_TYPE (function)) == FUNCTION_TYPE
+ && ! DECL_STATIC_FUNCTION_P (function))
+ continue;
+
+#if 0
+ if (pass == 0
+ && DECL_ASSEMBLER_NAME (function) == method_name)
+ goto found;
+#endif
+
+ if (pass > 0)
+ {
+ tree these_parms = parms;
+
+#ifdef GATHER_STATISTICS
+ n_inner_fields_searched++;
+#endif
+ cp->h_len = len;
+ cp->harshness = (struct harshness_code *)
+ alloca ((len + 1) * sizeof (struct harshness_code));
+
+ if (DECL_STATIC_FUNCTION_P (function))
+ these_parms = TREE_CHAIN (these_parms);
+ compute_conversion_costs (function, these_parms, cp, len);
+
+ if ((cp->h.code & EVIL_CODE) == 0)
+ {
+ cp->u.field = function;
+ cp->function = function;
+ cp->basetypes = basetype_path;
+
+ /* Don't allow non-converting constructors to convert. */
+ if (flags & LOOKUP_ONLYCONVERTING
+ && DECL_LANG_SPECIFIC (function)
+ && DECL_NONCONVERTING_P (function))
+ continue;
+
+ /* No "two-level" conversions. */
+ if (flags & LOOKUP_NO_CONVERSION
+ && (cp->h.code & USER_CODE))
+ continue;
+
+ cp++;
+ }
+ }
+ }
+ /* Now we have run through one link's member functions.
+ arrange to head-insert this link's links. */
+ baselink = next_baselink (baselink);
+ b_or_d += 1;
+ /* Don't grab functions from base classes. lookup_fnfield will
+ do the work to get us down into the right place. */
+ baselink = NULL_TREE;
+ }
+ if (pass == 0)
+ {
+ tree igv = lookup_name_nonclass (name);
+
+ /* No exact match could be found. Now try to find match
+ using default conversions. */
+ if ((flags & LOOKUP_GLOBAL) && igv)
+ {
+ if (TREE_CODE (igv) == FUNCTION_DECL)
+ ever_seen += 1;
+ else if (TREE_CODE (igv) == TREE_LIST)
+ ever_seen += count_functions (igv);
+ }
+
+ if (ever_seen == 0)
+ {
+ if ((flags & (LOOKUP_SPECULATIVELY|LOOKUP_COMPLAIN))
+ == LOOKUP_SPECULATIVELY)
+ return NULL_TREE;
+
+ TREE_CHAIN (last) = void_list_node;
+ if (flags & LOOKUP_GLOBAL)
+ cp_error ("no global or member function `%D(%A)' defined",
+ name, parmtypes);
+ else
+ cp_error ("no member function `%T::%D(%A)' defined",
+ save_basetype, name, TREE_CHAIN (parmtypes));
+ return error_mark_node;
+ }
+ continue;
+ }
+
+ if (cp - candidates != 0)
+ {
+ /* Rank from worst to best. Then cp will point to best one.
+ Private fields have their bits flipped. For unsigned
+ numbers, this should make them look very large.
+ If the best alternate has a (signed) negative value,
+ then all we ever saw were private members. */
+ if (cp - candidates > 1)
+ {
+ int n_candidates = cp - candidates;
+ extern int warn_synth;
+ TREE_VALUE (parms) = instance_ptr;
+ cp = ideal_candidate (save_basetype, candidates,
+ n_candidates, parms, len);
+ if (cp == (struct candidate *)0)
+ {
+ if (flags & LOOKUP_COMPLAIN)
+ {
+ TREE_CHAIN (last) = void_list_node;
+ cp_error ("call of overloaded %s `%D(%A)' is ambiguous",
+ name_kind, name, TREE_CHAIN (parmtypes));
+ print_n_candidates (candidates, n_candidates);
+ }
+ return error_mark_node;
+ }
+ if (cp->h.code & EVIL_CODE)
+ return error_mark_node;
+ if (warn_synth
+ && DECL_NAME (cp->function) == ansi_opname[MODIFY_EXPR]
+ && DECL_ARTIFICIAL (cp->function)
+ && n_candidates == 2)
+ {
+ cp_warning ("using synthesized `%#D' for copy assignment",
+ cp->function);
+ cp_warning_at (" where cfront would use `%#D'",
+ candidates->function);
+ }
+ }
+ else if (cp[-1].h.code & EVIL_CODE)
+ {
+ if (flags & LOOKUP_COMPLAIN)
+ cp_error ("ambiguous type conversion requested for %s `%D'",
+ name_kind, name);
+ return error_mark_node;
+ }
+ else
+ cp--;
+
+ /* The global function was the best, so use it. */
+ if (cp->u.field == 0)
+ {
+ /* We must convert the instance pointer into a reference type.
+ Global overloaded functions can only either take
+ aggregate objects (which come for free from references)
+ or reference data types anyway. */
+ TREE_VALUE (parms) = copy_node (instance_ptr);
+ TREE_TYPE (TREE_VALUE (parms)) = build_reference_type (TREE_TYPE (TREE_TYPE (instance_ptr)));
+ return build_function_call (cp->function, parms);
+ }
+
+ function = cp->function;
+ basetype_path = cp->basetypes;
+ if (! DECL_STATIC_FUNCTION_P (function))
+ TREE_VALUE (parms) = cp->arg;
+ goto found_and_maybe_warn;
+ }
+
+ if (flags & (LOOKUP_COMPLAIN|LOOKUP_SPECULATIVELY))
+ {
+ if ((flags & (LOOKUP_SPECULATIVELY|LOOKUP_COMPLAIN))
+ == LOOKUP_SPECULATIVELY)
+ return NULL_TREE;
+
+ if (DECL_STATIC_FUNCTION_P (cp->function))
+ parms = TREE_CHAIN (parms);
+ if (ever_seen)
+ {
+ if (flags & LOOKUP_SPECULATIVELY)
+ return NULL_TREE;
+ if (static_call_context
+ && TREE_CODE (TREE_TYPE (cp->function)) == METHOD_TYPE)
+ cp_error ("object missing in call to `%D'", cp->function);
+ else if (ever_seen > 1)
+ {
+ TREE_CHAIN (last) = void_list_node;
+ cp_error ("no matching function for call to `%T::%D (%A)%V'",
+ TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (instance_ptr))),
+ name, TREE_CHAIN (parmtypes),
+ TREE_TYPE (TREE_TYPE (instance_ptr)));
+ TREE_CHAIN (last) = NULL_TREE;
+ print_candidates (found_fns);
+ }
+ else
+ report_type_mismatch (cp, parms, name_kind);
+ return error_mark_node;
+ }
+
+ if ((flags & (LOOKUP_SPECULATIVELY|LOOKUP_COMPLAIN))
+ == LOOKUP_COMPLAIN)
+ {
+ cp_error ("%T has no method named %D", save_basetype, name);
+ return error_mark_node;
+ }
+ return NULL_TREE;
+ }
+ continue;
+
+ found_and_maybe_warn:
+ if ((cp->harshness[0].code & CONST_CODE)
+ /* 12.1p2: Constructors can be called for const objects. */
+ && ! DECL_CONSTRUCTOR_P (cp->function))
+ {
+ if (flags & LOOKUP_COMPLAIN)
+ {
+ cp_error_at ("non-const member function `%D'", cp->function);
+ error ("called for const object at this point in file");
+ }
+ /* Not good enough for a match. */
+ else
+ return error_mark_node;
+ }
+ goto found;
+ }
+ /* Silently return error_mark_node. */
+ return error_mark_node;
+
+ found:
+ if (flags & LOOKUP_PROTECT)
+ access = compute_access (basetype_path, function);
+
+ if (access == access_private)
+ {
+ if (flags & LOOKUP_COMPLAIN)
+ {
+ cp_error_at ("%s `%+#D' is %s", name_kind, function,
+ TREE_PRIVATE (function) ? "private"
+ : "from private base class");
+ error ("within this context");
+ }
+ return error_mark_node;
+ }
+ else if (access == access_protected)
+ {
+ if (flags & LOOKUP_COMPLAIN)
+ {
+ cp_error_at ("%s `%+#D' %s", name_kind, function,
+ TREE_PROTECTED (function) ? "is protected"
+ : "has protected accessibility");
+ error ("within this context");
+ }
+ return error_mark_node;
+ }
+
+ /* From here on down, BASETYPE is the type that INSTANCE_PTR's
+ type (if it exists) is a pointer to. */
+
+ if (DECL_ABSTRACT_VIRTUAL_P (function)
+ && instance == C_C_D
+ && DECL_CONSTRUCTOR_P (current_function_decl)
+ && ! (flags & LOOKUP_NONVIRTUAL)
+ && value_member (function, get_abstract_virtuals (basetype)))
+ cp_error ("abstract virtual `%#D' called from constructor", function);
+
+ if (IS_SIGNATURE (basetype) && static_call_context)
+ {
+ cp_error ("cannot call signature member function `%T::%D' without signature pointer/reference",
+ basetype, name);
+ return error_mark_node;
+ }
+ else if (IS_SIGNATURE (basetype))
+ return build_signature_method_call (basetype, instance, function, parms);
+
+ function = DECL_MAIN_VARIANT (function);
+ /* Declare external function if necessary. */
+ assemble_external (function);
+
+#if 1
+ /* Is it a synthesized method that needs to be synthesized? */
+ if (DECL_ARTIFICIAL (function) && ! flag_no_inline
+ && ! DECL_INITIAL (function)
+ /* Kludge: don't synthesize for default args. */
+ && current_function_decl)
+ synthesize_method (function);
+#endif
+
+ if (pedantic && DECL_THIS_INLINE (function) && ! DECL_ARTIFICIAL (function)
+ && ! DECL_INITIAL (function) && ! DECL_PENDING_INLINE_INFO (function))
+ cp_warning ("inline function `%#D' called before definition", function);
+
+ fntype = TREE_TYPE (function);
+ if (TREE_CODE (fntype) == POINTER_TYPE)
+ fntype = TREE_TYPE (fntype);
+ basetype = DECL_CLASS_CONTEXT (function);
+
+ /* If we are referencing a virtual function from an object
+ of effectively static type, then there is no need
+ to go through the virtual function table. */
+ if (need_vtbl == maybe_needed)
+ {
+ int fixed_type = resolves_to_fixed_type_p (instance, 0);
+
+ if (all_virtual == 1
+ && DECL_VINDEX (function)
+ && may_be_remote (basetype))
+ need_vtbl = needed;
+ else if (DECL_VINDEX (function))
+ need_vtbl = fixed_type ? unneeded : needed;
+ else
+ need_vtbl = not_needed;
+ }
+
+ if (TREE_CODE (fntype) == METHOD_TYPE && static_call_context
+ && !DECL_CONSTRUCTOR_P (function))
+ {
+ /* Let's be nice to the user for now, and give reasonable
+ default behavior. */
+ instance_ptr = current_class_decl;
+ if (instance_ptr)
+ {
+ if (basetype != current_class_type)
+ {
+ tree binfo = get_binfo (basetype, current_class_type, 1);
+ if (binfo == NULL_TREE)
+ {
+ error_not_base_type (function, current_class_type);
+ return error_mark_node;
+ }
+ else if (basetype == error_mark_node)
+ return error_mark_node;
+ }
+ }
+ /* Only allow a static member function to call another static member
+ function. */
+ else if (DECL_LANG_SPECIFIC (function)
+ && !DECL_STATIC_FUNCTION_P (function))
+ {
+ cp_error ("cannot call member function `%D' without object",
+ function);
+ return error_mark_node;
+ }
+ }
+
+ value_type = TREE_TYPE (fntype) ? TREE_TYPE (fntype) : void_type_node;
+
+ if (TYPE_SIZE (value_type) == 0)
+ {
+ if (flags & LOOKUP_COMPLAIN)
+ incomplete_type_error (0, value_type);
+ return error_mark_node;
+ }
+
+ if (DECL_STATIC_FUNCTION_P (function))
+ parms = convert_arguments (NULL_TREE, TYPE_ARG_TYPES (fntype),
+ TREE_CHAIN (parms), function, LOOKUP_NORMAL);
+ else if (need_vtbl == unneeded)
+ {
+ int sub_flags = DECL_CONSTRUCTOR_P (function) ? flags : LOOKUP_NORMAL;
+ basetype = TREE_TYPE (instance);
+ if (TYPE_METHOD_BASETYPE (TREE_TYPE (function)) != TYPE_MAIN_VARIANT (basetype)
+ && TYPE_USES_COMPLEX_INHERITANCE (basetype))
+ {
+ basetype = DECL_CLASS_CONTEXT (function);
+ instance_ptr = convert_pointer_to (basetype, instance_ptr);
+ instance = build_indirect_ref (instance_ptr, NULL_PTR);
+ }
+ parms = tree_cons (NULL_TREE, instance_ptr,
+ convert_arguments (NULL_TREE, TREE_CHAIN (TYPE_ARG_TYPES (fntype)), TREE_CHAIN (parms), function, sub_flags));
+ }
+ else
+ {
+ if ((flags & LOOKUP_NONVIRTUAL) == 0)
+ basetype = DECL_CONTEXT (function);
+
+ /* First parm could be integer_zerop with casts like
+ ((Object*)0)->Object::IsA() */
+ if (!integer_zerop (TREE_VALUE (parms)))
+ {
+ /* Since we can't have inheritance with a union, doing get_binfo
+ on it won't work. We do all the convert_pointer_to_real
+ stuff to handle MI correctly...for unions, that's not
+ an issue, so we must short-circuit that extra work here. */
+ tree tmp = TREE_TYPE (TREE_TYPE (TREE_VALUE (parms)));
+ if (tmp != NULL_TREE && TREE_CODE (tmp) == UNION_TYPE)
+ instance_ptr = TREE_VALUE (parms);
+ else
+ {
+ tree binfo = get_binfo (basetype,
+ TREE_TYPE (TREE_TYPE (TREE_VALUE (parms))),
+ 0);
+ instance_ptr = convert_pointer_to_real (binfo, TREE_VALUE (parms));
+ }
+ instance_ptr
+ = convert_pointer_to (build_type_variant (basetype,
+ constp, volatilep),
+ instance_ptr);
+
+ if (TREE_CODE (instance_ptr) == COND_EXPR)
+ {
+ instance_ptr = save_expr (instance_ptr);
+ instance = build_indirect_ref (instance_ptr, NULL_PTR);
+ }
+ else if (TREE_CODE (instance_ptr) == NOP_EXPR
+ && TREE_CODE (TREE_OPERAND (instance_ptr, 0)) == ADDR_EXPR
+ && TREE_OPERAND (TREE_OPERAND (instance_ptr, 0), 0) == instance)
+ ;
+ /* The call to `convert_pointer_to' may return error_mark_node. */
+ else if (TREE_CODE (instance_ptr) == ERROR_MARK)
+ return instance_ptr;
+ else if (instance == NULL_TREE
+ || TREE_CODE (instance) != INDIRECT_REF
+ || TREE_OPERAND (instance, 0) != instance_ptr)
+ instance = build_indirect_ref (instance_ptr, NULL_PTR);
+ }
+ parms = tree_cons (NULL_TREE, instance_ptr,
+ convert_arguments (NULL_TREE, TREE_CHAIN (TYPE_ARG_TYPES (fntype)), TREE_CHAIN (parms), function, LOOKUP_NORMAL));
+ }
+
+#if 0
+ /* Constructors do not overload method calls. */
+ else if (TYPE_OVERLOADS_METHOD_CALL_EXPR (basetype)
+ && name != TYPE_IDENTIFIER (basetype)
+ && (TREE_CODE (function) != FUNCTION_DECL
+ || strncmp (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (function)),
+ OPERATOR_METHOD_FORMAT,
+ OPERATOR_METHOD_LENGTH))
+ && (may_be_remote (basetype) || instance != C_C_D))
+ {
+ tree fn_as_int;
+
+ parms = TREE_CHAIN (parms);
+
+ if (!all_virtual && TREE_CODE (function) == FUNCTION_DECL)
+ fn_as_int = build_unary_op (ADDR_EXPR, function, 0);
+ else
+ fn_as_int = convert (TREE_TYPE (default_conversion (function)), DECL_VINDEX (function));
+ if (all_virtual == 1)
+ fn_as_int = convert (integer_type_node, fn_as_int);
+
+ result = build_opfncall (METHOD_CALL_EXPR, LOOKUP_NORMAL, instance, fn_as_int, parms);
+
+ if (result == NULL_TREE)
+ {
+ compiler_error ("could not overload `operator->()(...)'");
+ return error_mark_node;
+ }
+ else if (result == error_mark_node)
+ return error_mark_node;
+
+#if 0
+ /* Do this if we want the result of operator->() to inherit
+ the type of the function it is subbing for. */
+ TREE_TYPE (result) = value_type;
+#endif
+
+ return result;
+ }
+#endif
+
+ if (parms == error_mark_node
+ || (parms && TREE_CHAIN (parms) == error_mark_node))
+ return error_mark_node;
+
+ if (need_vtbl == needed)
+ {
+ function = build_vfn_ref (&TREE_VALUE (parms), instance,
+ DECL_VINDEX (function));
+ TREE_TYPE (function) = build_pointer_type (fntype);
+ }
+
+ if (TREE_CODE (function) == FUNCTION_DECL)
+ GNU_xref_call (current_function_decl,
+ IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (function)));
+
+ {
+ int is_constructor;
+
+ if (TREE_CODE (function) == FUNCTION_DECL)
+ {
+ is_constructor = DECL_CONSTRUCTOR_P (function);
+ TREE_USED (function) = 1;
+ function = default_conversion (function);
+ }
+ else
+ {
+ is_constructor = 0;
+ function = default_conversion (function);
+ }
+
+ result = build_nt (CALL_EXPR, function, parms, NULL_TREE);
+
+ TREE_TYPE (result) = value_type;
+ TREE_SIDE_EFFECTS (result) = 1;
+ TREE_HAS_CONSTRUCTOR (result) = is_constructor;
+ result = convert_from_reference (result);
+ return result;
+ }
+}
+
+/* Similar to `build_method_call', but for overloaded non-member functions.
+ The name of this function comes through NAME. The name depends
+ on PARMS.
+
+ Note that this function must handle simple `C' promotions,
+ as well as variable numbers of arguments (...), and
+ default arguments to boot.
+
+ If the overloading is successful, we return a tree node which
+ contains the call to the function.
+
+ If overloading produces candidates which are probable, but not definite,
+ we hold these candidates. If FINAL_CP is non-zero, then we are free
+ to assume that final_cp points to enough storage for all candidates that
+ this function might generate. The `harshness' array is preallocated for
+ the first candidate, but not for subsequent ones.
+
+ Note that the DECL_RTL of FUNCTION must be made to agree with this
+ function's new name. */
+
+tree
+build_overload_call_real (fnname, parms, flags, final_cp, buildxxx)
+ tree fnname, parms;
+ int flags;
+ struct candidate *final_cp;
+ int buildxxx;
+{
+ /* must check for overloading here */
+ tree overload_name, functions, function, parm;
+ tree parmtypes = NULL_TREE, last = NULL_TREE;
+ register tree outer;
+ int length;
+ int parmlength = list_length (parms);
+
+ struct candidate *candidates, *cp;
+
+ if (final_cp)
+ {
+ final_cp[0].h.code = 0;
+ final_cp[0].h.distance = 0;
+ final_cp[0].function = 0;
+ /* end marker. */
+ final_cp[1].h.code = EVIL_CODE;
+ }
+
+ for (parm = parms; parm; parm = TREE_CHAIN (parm))
+ {
+ register tree t = TREE_TYPE (TREE_VALUE (parm));
+
+ if (t == error_mark_node)
+ {
+ if (final_cp)
+ final_cp->h.code = EVIL_CODE;
+ return error_mark_node;
+ }
+ if (TREE_CODE (t) == OFFSET_TYPE)
+#if 0
+ /* This breaks reference-to-array parameters. */
+ || TREE_CODE (t) == ARRAY_TYPE
+#endif
+ {
+ /* Perform the conversion from ARRAY_TYPE to POINTER_TYPE in place.
+ Also convert OFFSET_TYPE entities to their normal selves.
+ This eliminates needless calls to `compute_conversion_costs'. */
+ TREE_VALUE (parm) = default_conversion (TREE_VALUE (parm));
+ t = TREE_TYPE (TREE_VALUE (parm));
+ }
+ last = build_tree_list (NULL_TREE, t);
+ parmtypes = chainon (parmtypes, last);
+ }
+ if (last)
+ TREE_CHAIN (last) = void_list_node;
+ else
+ parmtypes = void_list_node;
+
+ if (is_overloaded_fn (fnname))
+ {
+ functions = fnname;
+ if (TREE_CODE (fnname) == TREE_LIST)
+ fnname = TREE_PURPOSE (functions);
+ else if (TREE_CODE (fnname) == FUNCTION_DECL)
+ fnname = DECL_NAME (functions);
+ }
+ else
+ functions = lookup_name_nonclass (fnname);
+
+ if (functions == NULL_TREE)
+ {
+ if (flags & LOOKUP_SPECULATIVELY)
+ return NULL_TREE;
+ if (flags & LOOKUP_COMPLAIN)
+ error ("only member functions apply");
+ if (final_cp)
+ final_cp->h.code = EVIL_CODE;
+ return error_mark_node;
+ }
+
+ if (TREE_CODE (functions) == FUNCTION_DECL && ! IDENTIFIER_OPNAME_P (fnname))
+ {
+ functions = DECL_MAIN_VARIANT (functions);
+ if (final_cp)
+ {
+ /* We are just curious whether this is a viable alternative or
+ not. */
+ compute_conversion_costs (functions, parms, final_cp, parmlength);
+ return functions;
+ }
+ else
+ return build_function_call_real (functions, parms, 1, flags);
+ }
+
+ if (TREE_CODE (functions) == TREE_LIST
+ && TREE_VALUE (functions) == NULL_TREE)
+ {
+ if (flags & LOOKUP_SPECULATIVELY)
+ return NULL_TREE;
+
+ if (flags & LOOKUP_COMPLAIN)
+ cp_error ("function `%D' declared overloaded, but no instances of that function declared",
+ TREE_PURPOSE (functions));
+ if (final_cp)
+ final_cp->h.code = EVIL_CODE;
+ return error_mark_node;
+ }
+
+ length = count_functions (functions);
+
+ if (final_cp)
+ candidates = final_cp;
+ else
+ {
+ candidates
+ = (struct candidate *)alloca ((length+1) * sizeof (struct candidate));
+ bzero ((char *) candidates, (length + 1) * sizeof (struct candidate));
+ }
+
+ cp = candidates;
+
+ my_friendly_assert (is_overloaded_fn (functions), 169);
+
+ functions = get_first_fn (functions);
+
+ /* OUTER is the list of FUNCTION_DECLS, in a TREE_LIST. */
+ for (outer = functions; outer; outer = DECL_CHAIN (outer))
+ {
+ int template_cost = 0;
+ function = outer;
+ if (TREE_CODE (function) != FUNCTION_DECL
+ && ! (TREE_CODE (function) == TEMPLATE_DECL
+ && ! DECL_TEMPLATE_IS_CLASS (function)
+ && TREE_CODE (DECL_TEMPLATE_RESULT (function)) == FUNCTION_DECL))
+ {
+ enum tree_code code = TREE_CODE (function);
+ if (code == TEMPLATE_DECL)
+ code = TREE_CODE (DECL_TEMPLATE_RESULT (function));
+ if (code == CONST_DECL)
+ cp_error_at
+ ("enumeral value `%D' conflicts with function of same name",
+ function);
+ else if (code == VAR_DECL)
+ {
+ if (TREE_STATIC (function))
+ cp_error_at
+ ("variable `%D' conflicts with function of same name",
+ function);
+ else
+ cp_error_at
+ ("constant field `%D' conflicts with function of same name",
+ function);
+ }
+ else if (code == TYPE_DECL)
+ continue;
+ else
+ my_friendly_abort (2);
+ error ("at this point in file");
+ continue;
+ }
+ if (TREE_CODE (function) == TEMPLATE_DECL)
+ {
+ int ntparms = TREE_VEC_LENGTH (DECL_TEMPLATE_PARMS (function));
+ tree *targs = (tree *) alloca (sizeof (tree) * ntparms);
+ int i;
+
+ i = type_unification (DECL_TEMPLATE_PARMS (function), targs,
+ TYPE_ARG_TYPES (TREE_TYPE (function)),
+ parms, &template_cost, 0);
+ if (i == 0)
+ function = instantiate_template (function, targs);
+ }
+
+ if (TREE_CODE (function) == TEMPLATE_DECL)
+ {
+ /* Unconverted template -- failed match. */
+ cp->function = function;
+ cp->u.bad_arg = -4;
+ cp->h.code = EVIL_CODE;
+ }
+ else
+ {
+ struct candidate *cp2;
+
+ /* Check that this decl is not the same as a function that's in
+ the list due to some template instantiation. */
+ cp2 = candidates;
+ while (cp2 != cp)
+ if (cp2->function == function)
+ break;
+ else
+ cp2 += 1;
+ if (cp2->function == function)
+ continue;
+
+ function = DECL_MAIN_VARIANT (function);
+
+ /* Can't use alloca here, since result might be
+ passed to calling function. */
+ cp->h_len = parmlength;
+ cp->harshness = (struct harshness_code *)
+ oballoc ((parmlength + 1) * sizeof (struct harshness_code));
+
+ compute_conversion_costs (function, parms, cp, parmlength);
+
+ /* Make sure this is clear as well. */
+ cp->h.int_penalty += template_cost;
+
+ if ((cp[0].h.code & EVIL_CODE) == 0)
+ {
+ cp[1].h.code = EVIL_CODE;
+ cp++;
+ }
+ }
+ }
+
+ if (cp - candidates)
+ {
+ tree rval = error_mark_node;
+
+ /* Leave marker. */
+ cp[0].h.code = EVIL_CODE;
+ if (cp - candidates > 1)
+ {
+ struct candidate *best_cp
+ = ideal_candidate (NULL_TREE, candidates,
+ cp - candidates, parms, parmlength);
+ if (best_cp == (struct candidate *)0)
+ {
+ if (flags & LOOKUP_COMPLAIN)
+ {
+ cp_error ("call of overloaded `%D' is ambiguous", fnname);
+ print_n_candidates (candidates, cp - candidates);
+ }
+ return error_mark_node;
+ }
+ else
+ rval = best_cp->function;
+ }
+ else
+ {
+ cp -= 1;
+ if (cp->h.code & EVIL_CODE)
+ {
+ if (flags & LOOKUP_COMPLAIN)
+ error ("type conversion ambiguous");
+ }
+ else
+ rval = cp->function;
+ }
+
+ if (final_cp)
+ return rval;
+
+ return buildxxx ? build_function_call_real (rval, parms, 0, flags)
+ : build_function_call_real (rval, parms, 1, flags);
+ }
+
+ if (flags & LOOKUP_SPECULATIVELY)
+ return NULL_TREE;
+
+ if (flags & LOOKUP_COMPLAIN)
+ report_type_mismatch (cp, parms, "function",
+ decl_as_string (cp->function, 1));
+
+ return error_mark_node;
+}
+
+tree
+build_overload_call (fnname, parms, flags, final_cp)
+ tree fnname, parms;
+ int flags;
+ struct candidate *final_cp;
+{
+ return build_overload_call_real (fnname, parms, flags, final_cp, 0);
+}
+
+tree
+build_overload_call_maybe (fnname, parms, flags, final_cp)
+ tree fnname, parms;
+ int flags;
+ struct candidate *final_cp;
+{
+ return build_overload_call_real (fnname, parms, flags, final_cp, 1);
+}
diff --git a/contrib/gcc/cp/class.c b/contrib/gcc/cp/class.c
new file mode 100644
index 0000000..e289304
--- /dev/null
+++ b/contrib/gcc/cp/class.c
@@ -0,0 +1,5086 @@
+/* Functions related to building classes and their related objects.
+ Copyright (C) 1987, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+ Contributed by Michael Tiemann (tiemann@cygnus.com)
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+/* High-level class interface. */
+
+#include "config.h"
+#include "tree.h"
+#include <stdio.h>
+#include "cp-tree.h"
+#include "flags.h"
+#include "rtl.h"
+#include "output.h"
+
+#include "obstack.h"
+#define obstack_chunk_alloc xmalloc
+#define obstack_chunk_free free
+
+extern struct obstack permanent_obstack;
+
+/* This is how we tell when two virtual member functions are really the
+ same. */
+#define SAME_FN(FN1DECL, FN2DECL) (DECL_ASSEMBLER_NAME (FN1DECL) == DECL_ASSEMBLER_NAME (FN2DECL))
+
+extern void set_class_shadows PROTO ((tree));
+
+/* Way of stacking class types. */
+static tree *current_class_base, *current_class_stack;
+static int current_class_stacksize;
+int current_class_depth;
+
+struct class_level
+{
+ /* The previous class level. */
+ struct class_level *level_chain;
+
+ /* The class instance variable, as a PARM_DECL. */
+ tree decl;
+ /* The class instance variable, as an object. */
+ tree object;
+ /* The virtual function table pointer
+ for the class instance variable. */
+ tree vtable_decl;
+
+ /* Name of the current class. */
+ tree name;
+ /* Type of the current class. */
+ tree type;
+
+ /* Flags for this class level. */
+ int this_is_variable;
+ int memoized_lookups;
+ int save_memoized;
+ int unused;
+};
+
+tree current_class_decl, C_C_D; /* PARM_DECL: the class instance variable */
+
+/* The following two can be derived from the previous one */
+tree current_class_name; /* IDENTIFIER_NODE: name of current class */
+tree current_class_type; /* _TYPE: the type of the current class */
+tree previous_class_type; /* _TYPE: the previous type that was a class */
+tree previous_class_values; /* TREE_LIST: copy of the class_shadowed list
+ when leaving an outermost class scope. */
+static tree get_vfield_name PROTO((tree));
+tree the_null_vtable_entry;
+
+/* Way of stacking language names. */
+tree *current_lang_base, *current_lang_stack;
+int current_lang_stacksize;
+
+/* Names of languages we recognize. */
+tree lang_name_c, lang_name_cplusplus;
+tree current_lang_name;
+
+char *dont_allow_type_definitions;
+
+/* When layout out an aggregate type, the size of the
+ basetypes (virtual and non-virtual) is passed to layout_record
+ via this node. */
+static tree base_layout_decl;
+
+/* Variables shared between class.c and call.c. */
+
+int n_vtables = 0;
+int n_vtable_entries = 0;
+int n_vtable_searches = 0;
+int n_vtable_elems = 0;
+int n_convert_harshness = 0;
+int n_compute_conversion_costs = 0;
+int n_build_method_call = 0;
+int n_inner_fields_searched = 0;
+
+/* Virtual baseclass things. */
+tree
+build_vbase_pointer (exp, type)
+ tree exp, type;
+{
+ char *name;
+
+ name = (char *) alloca (TYPE_NAME_LENGTH (type) + sizeof (VBASE_NAME) + 1);
+ sprintf (name, VBASE_NAME_FORMAT, TYPE_NAME_STRING (type));
+ return build_component_ref (exp, get_identifier (name), 0, 0);
+}
+
+/* Is the type of the EXPR, the complete type of the object?
+ If we are going to be wrong, we must be conservative, and return 0. */
+int
+complete_type_p (expr)
+ tree expr;
+{
+ tree type = TYPE_MAIN_VARIANT (TREE_TYPE (expr));
+ while (1)
+ {
+ switch (TREE_CODE (expr))
+ {
+ case SAVE_EXPR:
+ case INDIRECT_REF:
+ case ADDR_EXPR:
+ case NOP_EXPR:
+ case CONVERT_EXPR:
+ expr = TREE_OPERAND (expr, 0);
+ continue;
+
+ case CALL_EXPR:
+ if (! TREE_HAS_CONSTRUCTOR (expr))
+ break;
+ /* fall through... */
+ case VAR_DECL:
+ case FIELD_DECL:
+ if (TREE_CODE (TREE_TYPE (expr)) == ARRAY_TYPE
+ && IS_AGGR_TYPE (TREE_TYPE (TREE_TYPE (expr)))
+ && TYPE_MAIN_VARIANT (TREE_TYPE (expr)) == type)
+ return 1;
+ /* fall through... */
+ case TARGET_EXPR:
+ case PARM_DECL:
+ if (IS_AGGR_TYPE (TREE_TYPE (expr))
+ && TYPE_MAIN_VARIANT (TREE_TYPE (expr)) == type)
+ return 1;
+ /* fall through... */
+ case PLUS_EXPR:
+ default:
+ break;
+ }
+ break;
+ }
+ return 0;
+}
+
+/* Build multi-level access to EXPR using hierarchy path PATH.
+ CODE is PLUS_EXPR if we are going with the grain,
+ and MINUS_EXPR if we are not (in which case, we cannot traverse
+ virtual baseclass links).
+
+ TYPE is the type we want this path to have on exit.
+
+ ALIAS_THIS is non-zero if EXPR in an expression involving `this'. */
+tree
+build_vbase_path (code, type, expr, path, alias_this)
+ enum tree_code code;
+ tree type, expr, path;
+ int alias_this;
+{
+ register int changed = 0;
+ tree last = NULL_TREE, last_virtual = NULL_TREE;
+ int nonnull = 0;
+ int fixed_type_p = resolves_to_fixed_type_p (expr, &nonnull);
+ tree null_expr = 0, nonnull_expr;
+ tree basetype;
+ tree offset = integer_zero_node;
+
+ if (nonnull == 0 && (alias_this && flag_this_is_variable <= 0))
+ nonnull = 1;
+
+ /* We need additional logic to convert back to the unconverted type
+ (the static type of the complete object), and then convert back
+ to the type we want. Until that is done, or until we can
+ recognize when that is, we cannot do the short cut logic. (mrs) */
+ /* Do this, until we can undo any previous conversions. See net35.C
+ for a testcase. */
+ fixed_type_p = complete_type_p (expr);
+
+ if (!fixed_type_p && TREE_SIDE_EFFECTS (expr))
+ expr = save_expr (expr);
+ nonnull_expr = expr;
+
+ if (BINFO_INHERITANCE_CHAIN (path))
+ {
+ tree reverse_path = NULL_TREE;
+
+ while (path)
+ {
+ tree r = copy_node (path);
+ BINFO_INHERITANCE_CHAIN (r) = reverse_path;
+ reverse_path = r;
+ path = BINFO_INHERITANCE_CHAIN (path);
+ }
+ path = reverse_path;
+ }
+
+ basetype = BINFO_TYPE (path);
+
+ while (path)
+ {
+ if (TREE_VIA_VIRTUAL (path))
+ {
+ last_virtual = BINFO_TYPE (path);
+ if (code == PLUS_EXPR)
+ {
+ changed = ! fixed_type_p;
+
+ if (changed)
+ {
+ extern int flag_assume_nonnull_objects;
+ tree ind;
+
+ /* We already check for ambiguous things in the caller, just
+ find a path. */
+ if (last)
+ {
+ tree binfo = get_binfo (last, TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (nonnull_expr))), 0);
+ nonnull_expr = convert_pointer_to_real (binfo, nonnull_expr);
+ }
+ ind = build_indirect_ref (nonnull_expr, NULL_PTR);
+ nonnull_expr = build_vbase_pointer (ind, last_virtual);
+ if (nonnull == 0
+ && (TREE_CODE (type) == POINTER_TYPE
+ || !flag_assume_nonnull_objects)
+ && null_expr == NULL_TREE)
+ {
+ null_expr = build1 (NOP_EXPR, build_pointer_type (last_virtual), integer_zero_node);
+ expr = build (COND_EXPR, build_pointer_type (last_virtual),
+ build (EQ_EXPR, boolean_type_node, expr,
+ integer_zero_node),
+ null_expr, nonnull_expr);
+ }
+ }
+ /* else we'll figure out the offset below. */
+
+ /* Happens in the case of parse errors. */
+ if (nonnull_expr == error_mark_node)
+ return error_mark_node;
+ }
+ else
+ {
+ cp_error ("cannot cast up from virtual baseclass `%T'",
+ last_virtual);
+ return error_mark_node;
+ }
+ }
+ last = path;
+ path = BINFO_INHERITANCE_CHAIN (path);
+ }
+ /* LAST is now the last basetype assoc on the path. */
+
+ /* A pointer to a virtual base member of a non-null object
+ is non-null. Therefore, we only need to test for zeroness once.
+ Make EXPR the canonical expression to deal with here. */
+ if (null_expr)
+ {
+ TREE_OPERAND (expr, 2) = nonnull_expr;
+ TREE_TYPE (TREE_OPERAND (expr, 1)) = TREE_TYPE (nonnull_expr);
+ }
+ else
+ expr = nonnull_expr;
+
+ /* If we go through any virtual base pointers, make sure that
+ casts to BASETYPE from the last virtual base class use
+ the right value for BASETYPE. */
+ if (changed)
+ {
+ tree intype = TREE_TYPE (TREE_TYPE (expr));
+ if (TYPE_MAIN_VARIANT (intype) != BINFO_TYPE (last))
+ {
+ tree binfo = get_binfo (last, TYPE_MAIN_VARIANT (intype), 0);
+ offset = BINFO_OFFSET (binfo);
+ }
+ }
+ else
+ {
+ if (last_virtual)
+ {
+ offset = BINFO_OFFSET (binfo_member (last_virtual,
+ CLASSTYPE_VBASECLASSES (basetype)));
+ offset = size_binop (PLUS_EXPR, offset, BINFO_OFFSET (last));
+ }
+ else
+ offset = BINFO_OFFSET (last);
+ }
+
+ if (TREE_INT_CST_LOW (offset))
+ {
+ /* Bash types to make the backend happy. */
+ offset = convert (type, offset);
+ expr = build1 (NOP_EXPR, type, expr);
+
+ /* For multiple inheritance: if `this' can be set by any
+ function, then it could be 0 on entry to any function.
+ Preserve such zeroness here. Otherwise, only in the
+ case of constructors need we worry, and in those cases,
+ it will be zero, or initialized to some valid value to
+ which we may add. */
+ if (nonnull == 0)
+ {
+ if (null_expr)
+ TREE_TYPE (null_expr) = type;
+ else
+ null_expr = build1 (NOP_EXPR, type, integer_zero_node);
+ if (TREE_SIDE_EFFECTS (expr))
+ expr = save_expr (expr);
+
+ return build (COND_EXPR, type,
+ build (EQ_EXPR, boolean_type_node, expr, integer_zero_node),
+ null_expr,
+ build (code, type, expr, offset));
+ }
+ else return build (code, type, expr, offset);
+ }
+
+ /* Cannot change the TREE_TYPE of a NOP_EXPR here, since it may
+ be used multiple times in initialization of multiple inheritance. */
+ if (null_expr)
+ {
+ TREE_TYPE (expr) = type;
+ return expr;
+ }
+ else
+ return build1 (NOP_EXPR, type, expr);
+}
+
+/* Virtual function things. */
+
+/* Virtual functions to be dealt with after laying out our base
+ classes. We do all overrides after we layout virtual base classes.
+ */
+static tree pending_hard_virtuals;
+static int doing_hard_virtuals;
+
+/* Build an entry in the virtual function table.
+ DELTA is the offset for the `this' pointer.
+ PFN is an ADDR_EXPR containing a pointer to the virtual function.
+ Note that the index (DELTA2) in the virtual function table
+ is always 0. */
+tree
+build_vtable_entry (delta, pfn)
+ tree delta, pfn;
+{
+
+ if (flag_vtable_thunks)
+ {
+ HOST_WIDE_INT idelta = TREE_INT_CST_LOW (delta);
+ extern tree make_thunk ();
+ if (idelta)
+ {
+ pfn = build1 (ADDR_EXPR, vtable_entry_type,
+ make_thunk (pfn, idelta));
+ TREE_READONLY (pfn) = 1;
+ TREE_CONSTANT (pfn) = 1;
+ }
+#ifdef GATHER_STATISTICS
+ n_vtable_entries += 1;
+#endif
+ return pfn;
+ }
+ else
+ {
+ extern int flag_huge_objects;
+ tree elems = tree_cons (NULL_TREE, delta,
+ tree_cons (NULL_TREE, integer_zero_node,
+ build_tree_list (NULL_TREE, pfn)));
+ tree entry = build (CONSTRUCTOR, vtable_entry_type, NULL_TREE, elems);
+
+ /* DELTA is constructed by `size_int', which means it may be an
+ unsigned quantity on some platforms. Therefore, we cannot use
+ `int_fits_type_p', because when DELTA is really negative,
+ `force_fit_type' will make it look like a very large number. */
+
+ if ((TREE_INT_CST_LOW (TYPE_MAX_VALUE (delta_type_node))
+ < TREE_INT_CST_LOW (delta))
+ || (TREE_INT_CST_LOW (delta)
+ < TREE_INT_CST_LOW (TYPE_MIN_VALUE (delta_type_node))))
+ if (flag_huge_objects)
+ sorry ("object size exceeds built-in limit for virtual function table implementation");
+ else
+ sorry ("object size exceeds normal limit for virtual function table implementation, recompile all source and use -fhuge-objects");
+
+ TREE_CONSTANT (entry) = 1;
+ TREE_STATIC (entry) = 1;
+ TREE_READONLY (entry) = 1;
+
+#ifdef GATHER_STATISTICS
+ n_vtable_entries += 1;
+#endif
+
+ return entry;
+ }
+}
+
+/* Given an object INSTANCE, return an expression which yields the
+ virtual function corresponding to INDEX. There are many special
+ cases for INSTANCE which we take care of here, mainly to avoid
+ creating extra tree nodes when we don't have to. */
+tree
+build_vfn_ref (ptr_to_instptr, instance, idx)
+ tree *ptr_to_instptr, instance;
+ tree idx;
+{
+ extern int building_cleanup;
+ tree vtbl, aref;
+ tree basetype = TREE_TYPE (instance);
+
+ if (TREE_CODE (basetype) == REFERENCE_TYPE)
+ basetype = TREE_TYPE (basetype);
+
+ if (instance == C_C_D)
+ vtbl = build_indirect_ref (build_vfield_ref (instance, basetype),
+ NULL_PTR);
+ else
+ {
+ if (optimize)
+ {
+ /* Try to figure out what a reference refers to, and
+ access its virtual function table directly. */
+ tree ref = NULL_TREE;
+
+ if (TREE_CODE (instance) == INDIRECT_REF
+ && TREE_CODE (TREE_TYPE (TREE_OPERAND (instance, 0))) == REFERENCE_TYPE)
+ ref = TREE_OPERAND (instance, 0);
+ else if (TREE_CODE (TREE_TYPE (instance)) == REFERENCE_TYPE)
+ ref = instance;
+
+ if (ref && TREE_CODE (ref) == VAR_DECL
+ && DECL_INITIAL (ref))
+ {
+ tree init = DECL_INITIAL (ref);
+
+ while (TREE_CODE (init) == NOP_EXPR
+ || TREE_CODE (init) == NON_LVALUE_EXPR)
+ init = TREE_OPERAND (init, 0);
+ if (TREE_CODE (init) == ADDR_EXPR)
+ {
+ init = TREE_OPERAND (init, 0);
+ if (IS_AGGR_TYPE (TREE_TYPE (init))
+ && (TREE_CODE (init) == PARM_DECL
+ || TREE_CODE (init) == VAR_DECL))
+ instance = init;
+ }
+ }
+ }
+
+ if (IS_AGGR_TYPE (TREE_TYPE (instance))
+ && (TREE_CODE (instance) == RESULT_DECL
+ || TREE_CODE (instance) == PARM_DECL
+ || TREE_CODE (instance) == VAR_DECL))
+ vtbl = TYPE_BINFO_VTABLE (basetype);
+ else
+ vtbl = build_indirect_ref (build_vfield_ref (instance, basetype),
+ NULL_PTR);
+ }
+ assemble_external (vtbl);
+ aref = build_array_ref (vtbl, idx);
+
+ /* Save the intermediate result in a SAVE_EXPR so we don't have to
+ compute each component of the virtual function pointer twice. */
+ if (!building_cleanup && TREE_CODE (aref) == INDIRECT_REF)
+ TREE_OPERAND (aref, 0) = save_expr (TREE_OPERAND (aref, 0));
+
+ if (flag_vtable_thunks)
+ return aref;
+ else
+ {
+ if (ptr_to_instptr)
+ *ptr_to_instptr
+ = build (PLUS_EXPR, TREE_TYPE (*ptr_to_instptr),
+ *ptr_to_instptr,
+ convert (ptrdiff_type_node,
+ build_component_ref (aref, delta_identifier, 0, 0)));
+ return build_component_ref (aref, pfn_identifier, 0, 0);
+ }
+}
+
+/* Return the name of the virtual function table (as an IDENTIFIER_NODE)
+ for the given TYPE. */
+static tree
+get_vtable_name (type)
+ tree type;
+{
+ tree type_id = build_typename_overload (type);
+ char *buf = (char *)alloca (strlen (VTABLE_NAME_FORMAT)
+ + IDENTIFIER_LENGTH (type_id) + 2);
+ char *ptr = IDENTIFIER_POINTER (type_id);
+ int i;
+ for (i = 0; ptr[i] == OPERATOR_TYPENAME_FORMAT[i]; i++) ;
+#if 0
+ /* We don't take off the numbers; prepare_fresh_vtable uses the
+ DECL_ASSEMBLER_NAME for the type, which includes the number
+ in `3foo'. If we were to pull them off here, we'd end up with
+ something like `_vt.foo.3bar', instead of a uniform definition. */
+ while (ptr[i] >= '0' && ptr[i] <= '9')
+ i += 1;
+#endif
+ sprintf (buf, VTABLE_NAME_FORMAT, ptr+i);
+ return get_identifier (buf);
+}
+
+/* Build a virtual function for type TYPE.
+ If BINFO is non-NULL, build the vtable starting with the initial
+ approximation that it is the same as the one which is the head of
+ the association list. */
+static tree
+build_vtable (binfo, type)
+ tree binfo, type;
+{
+ tree name = get_vtable_name (type);
+ tree virtuals, decl;
+
+ if (binfo)
+ {
+ virtuals = copy_list (BINFO_VIRTUALS (binfo));
+ decl = build_decl (VAR_DECL, name, TREE_TYPE (BINFO_VTABLE (binfo)));
+ }
+ else
+ {
+ virtuals = NULL_TREE;
+ decl = build_decl (VAR_DECL, name, void_type_node);
+ }
+
+#ifdef GATHER_STATISTICS
+ n_vtables += 1;
+ n_vtable_elems += list_length (virtuals);
+#endif
+
+ /* Set TREE_PUBLIC and TREE_EXTERN as appropriate. */
+ import_export_vtable (decl, type, 0);
+
+ IDENTIFIER_GLOBAL_VALUE (name) = decl = pushdecl_top_level (decl);
+ /* Initialize the association list for this type, based
+ on our first approximation. */
+ TYPE_BINFO_VTABLE (type) = decl;
+ TYPE_BINFO_VIRTUALS (type) = virtuals;
+
+ TREE_STATIC (decl) = 1;
+#ifndef WRITABLE_VTABLES
+ /* Make them READONLY by default. (mrs) */
+ TREE_READONLY (decl) = 1;
+#endif
+ /* At one time the vtable info was grabbed 2 words at a time. This
+ fails on sparc unless you have 8-byte alignment. (tiemann) */
+ DECL_ALIGN (decl) = MAX (TYPE_ALIGN (double_type_node),
+ DECL_ALIGN (decl));
+
+ /* Why is this conditional? (mrs) */
+ if (binfo && write_virtuals >= 0)
+ DECL_VIRTUAL_P (decl) = 1;
+ DECL_CONTEXT (decl) = type;
+
+ binfo = TYPE_BINFO (type);
+ SET_BINFO_NEW_VTABLE_MARKED (binfo);
+ return decl;
+}
+
+/* Given a base type PARENT, and a derived type TYPE, build
+ a name which distinguishes exactly the PARENT member of TYPE's type.
+
+ FORMAT is a string which controls how sprintf formats the name
+ we have generated.
+
+ For example, given
+
+ class A; class B; class C : A, B;
+
+ it is possible to distinguish "A" from "C's A". And given
+
+ class L;
+ class A : L; class B : L; class C : A, B;
+
+ it is possible to distinguish "L" from "A's L", and also from
+ "C's L from A".
+
+ Make sure to use the DECL_ASSEMBLER_NAME of the TYPE_NAME of the
+ type, as template have DECL_NAMEs like: X<int>, whereas the
+ DECL_ASSEMBLER_NAME is set to be something the assembler can handle.
+ */
+static tree
+build_type_pathname (format, parent, type)
+ char *format;
+ tree parent, type;
+{
+ extern struct obstack temporary_obstack;
+ char *first, *base, *name;
+ int i;
+ tree id;
+
+ parent = TYPE_MAIN_VARIANT (parent);
+
+ /* Remember where to cut the obstack to. */
+ first = obstack_base (&temporary_obstack);
+
+ /* Put on TYPE+PARENT. */
+ obstack_grow (&temporary_obstack,
+ TYPE_ASSEMBLER_NAME_STRING (type),
+ TYPE_ASSEMBLER_NAME_LENGTH (type));
+#ifdef JOINER
+ obstack_1grow (&temporary_obstack, JOINER);
+#else
+ obstack_1grow (&temporary_obstack, '_');
+#endif
+ obstack_grow0 (&temporary_obstack,
+ TYPE_ASSEMBLER_NAME_STRING (parent),
+ TYPE_ASSEMBLER_NAME_LENGTH (parent));
+ i = obstack_object_size (&temporary_obstack);
+ base = obstack_base (&temporary_obstack);
+ obstack_finish (&temporary_obstack);
+
+ /* Put on FORMAT+TYPE+PARENT. */
+ obstack_blank (&temporary_obstack, strlen (format) + i + 1);
+ name = obstack_base (&temporary_obstack);
+ sprintf (name, format, base);
+ id = get_identifier (name);
+ obstack_free (&temporary_obstack, first);
+
+ return id;
+}
+
+/* Update the rtti info for this class. */
+static void
+set_rtti_entry (virtuals, offset, type)
+ tree virtuals, offset, type;
+{
+ if (! flag_vtable_thunks)
+ TREE_VALUE (virtuals)
+ = build_vtable_entry (offset,
+ (flag_rtti
+ ? build_t_desc (type, 0)
+ : integer_zero_node));
+ else
+ {
+ tree vfn = build1 (NOP_EXPR, vfunc_ptr_type_node, offset);
+ TREE_CONSTANT (vfn) = 1;
+
+ TREE_VALUE (virtuals)
+ = build_vtable_entry (integer_zero_node, vfn);
+ /* The second slot is for the tdesc pointer when thunks are used. */
+ vfn = flag_rtti
+ ? build_t_desc (type, 0)
+ : integer_zero_node;
+ vfn = build1 (NOP_EXPR, vfunc_ptr_type_node, vfn);
+ TREE_CONSTANT (vfn) = 1;
+
+ TREE_VALUE (TREE_CHAIN (virtuals))
+ = build_vtable_entry (integer_zero_node, vfn);
+ }
+}
+
+/* Give TYPE a new virtual function table which is initialized
+ with a skeleton-copy of its original initialization. The only
+ entry that changes is the `delta' entry, so we can really
+ share a lot of structure.
+
+ FOR_TYPE is the derived type which caused this table to
+ be needed.
+
+ BINFO is the type association which provided TYPE for FOR_TYPE. */
+static void
+prepare_fresh_vtable (binfo, for_type)
+ tree binfo, for_type;
+{
+ tree basetype = BINFO_TYPE (binfo);
+ tree orig_decl = BINFO_VTABLE (binfo);
+ /* This name is too simplistic. We can have multiple basetypes for
+ for_type, and we really want different names. (mrs) */
+ tree name = build_type_pathname (VTABLE_NAME_FORMAT, basetype, for_type);
+ tree new_decl = build_decl (VAR_DECL, name, TREE_TYPE (orig_decl));
+ tree path, offset;
+ int result;
+
+ /* Remember which class this vtable is really for. */
+ DECL_CONTEXT (new_decl) = for_type;
+
+ TREE_STATIC (new_decl) = 1;
+ BINFO_VTABLE (binfo) = pushdecl_top_level (new_decl);
+ DECL_VIRTUAL_P (new_decl) = 1;
+#ifndef WRITABLE_VTABLES
+ /* Make them READONLY by default. (mrs) */
+ TREE_READONLY (new_decl) = 1;
+#endif
+ DECL_ALIGN (new_decl) = DECL_ALIGN (orig_decl);
+
+ /* Make fresh virtual list, so we can smash it later. */
+ BINFO_VIRTUALS (binfo) = copy_list (BINFO_VIRTUALS (binfo));
+
+ if (TREE_VIA_VIRTUAL (binfo))
+ offset = BINFO_OFFSET (binfo_member (BINFO_TYPE (binfo),
+ CLASSTYPE_VBASECLASSES (for_type)));
+ else
+ offset = BINFO_OFFSET (binfo);
+
+ set_rtti_entry (BINFO_VIRTUALS (binfo),
+ size_binop (MINUS_EXPR, integer_zero_node, offset),
+ for_type);
+
+#ifdef GATHER_STATISTICS
+ n_vtables += 1;
+ n_vtable_elems += list_length (BINFO_VIRTUALS (binfo));
+#endif
+
+ /* Set TREE_PUBLIC and TREE_EXTERN as appropriate. */
+ import_export_vtable (new_decl, for_type, 0);
+
+ if (TREE_VIA_VIRTUAL (binfo))
+ my_friendly_assert (binfo == binfo_member (BINFO_TYPE (binfo),
+ CLASSTYPE_VBASECLASSES (current_class_type)),
+ 170);
+ SET_BINFO_NEW_VTABLE_MARKED (binfo);
+}
+
+/* Access the virtual function table entry that logically
+ contains BASE_FNDECL. VIRTUALS is the virtual function table's
+ initializer. We can run off the end, when dealing with virtual
+ destructors in MI situations, return NULL_TREE in that case. */
+static tree
+get_vtable_entry (virtuals, base_fndecl)
+ tree virtuals, base_fndecl;
+{
+ unsigned HOST_WIDE_INT n = (HOST_BITS_PER_WIDE_INT >= BITS_PER_WORD
+ ? (TREE_INT_CST_LOW (DECL_VINDEX (base_fndecl))
+ & (((unsigned HOST_WIDE_INT)1<<(BITS_PER_WORD-1))-1))
+ : TREE_INT_CST_LOW (DECL_VINDEX (base_fndecl)));
+
+#ifdef GATHER_STATISTICS
+ n_vtable_searches += n;
+#endif
+
+ while (n > 0 && virtuals)
+ {
+ --n;
+ virtuals = TREE_CHAIN (virtuals);
+ }
+ return virtuals;
+}
+
+/* Put new entry ENTRY into virtual function table initializer
+ VIRTUALS.
+
+ Also update DECL_VINDEX (FNDECL). */
+
+static void
+modify_vtable_entry (old_entry_in_list, new_entry, fndecl)
+ tree old_entry_in_list, new_entry, fndecl;
+{
+ tree base_fndecl = TREE_OPERAND (FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (old_entry_in_list)), 0);
+
+#ifdef NOTQUITE
+ cp_warning ("replaced %D with %D", DECL_ASSEMBLER_NAME (base_fndecl),
+ DECL_ASSEMBLER_NAME (fndecl));
+#endif
+ TREE_VALUE (old_entry_in_list) = new_entry;
+
+ /* Now assign virtual dispatch information, if unset. */
+ /* We can dispatch this, through any overridden base function. */
+ if (TREE_CODE (DECL_VINDEX (fndecl)) != INTEGER_CST)
+ {
+ DECL_VINDEX (fndecl) = DECL_VINDEX (base_fndecl);
+ DECL_CONTEXT (fndecl) = DECL_CONTEXT (base_fndecl);
+ }
+}
+
+/* Access the virtual function table entry i. VIRTUALS is the virtual
+ function table's initializer. */
+static tree
+get_vtable_entry_n (virtuals, n)
+ tree virtuals;
+ unsigned HOST_WIDE_INT n;
+{
+ while (n > 0)
+ {
+ --n;
+ virtuals = TREE_CHAIN (virtuals);
+ }
+ return virtuals;
+}
+
+/* Add a virtual function to all the appropriate vtables for the class
+ T. DECL_VINDEX(X) should be error_mark_node, if we want to
+ allocate a new slot in our table. If it is error_mark_node, we
+ know that no other function from another vtable is overridden by X.
+ HAS_VIRTUAL keeps track of how many virtuals there are in our main
+ vtable for the type, and we build upon the PENDING_VIRTUALS list
+ and return it. */
+static tree
+add_virtual_function (pending_virtuals, has_virtual, fndecl, t)
+ tree pending_virtuals;
+ int *has_virtual;
+ tree fndecl;
+ tree t; /* Structure type. */
+{
+ /* FUNCTION_TYPEs and OFFSET_TYPEs no longer freely
+ convert to void *. Make such a conversion here. */
+ tree vfn = build1 (ADDR_EXPR, vfunc_ptr_type_node, fndecl);
+ TREE_CONSTANT (vfn) = 1;
+
+#ifndef DUMB_USER
+ if (current_class_type == 0)
+ cp_warning ("internal problem, current_class_type is zero when adding `%D', please report",
+ fndecl);
+ if (current_class_type && t != current_class_type)
+ cp_warning ("internal problem, current_class_type differs when adding `%D', please report",
+ fndecl);
+#endif
+
+ /* If the virtual function is a redefinition of a prior one,
+ figure out in which base class the new definition goes,
+ and if necessary, make a fresh virtual function table
+ to hold that entry. */
+ if (DECL_VINDEX (fndecl) == error_mark_node)
+ {
+ tree entry;
+
+ if (flag_rtti && *has_virtual == 0)
+ {
+ /* CLASSTYPE_RTTI is only used as a Boolean (NULL or not). */
+ CLASSTYPE_RTTI (t) = integer_one_node;
+ }
+
+ /* If we are using thunks, use two slots at the front, one
+ for the offset pointer, one for the tdesc pointer. */
+ if (*has_virtual == 0 && flag_vtable_thunks)
+ {
+ *has_virtual = 1;
+ }
+
+ /* Build a new INT_CST for this DECL_VINDEX. */
+ {
+ static tree index_table[256];
+ tree index;
+ /* We skip a slot for the offset/tdesc entry. */
+ int i = ++(*has_virtual);
+
+ if (i >= 256 || index_table[i] == 0)
+ {
+ index = build_int_2 (i, 0);
+ if (i < 256)
+ index_table[i] = index;
+ }
+ else
+ index = index_table[i];
+
+ /* Now assign virtual dispatch information. */
+ DECL_VINDEX (fndecl) = index;
+ DECL_CONTEXT (fndecl) = t;
+ }
+ entry = build_vtable_entry (integer_zero_node, vfn);
+ pending_virtuals = tree_cons (DECL_VINDEX (fndecl), entry, pending_virtuals);
+ }
+ /* Might already be INTEGER_CST if declared twice in class. We will
+ give error later or we've already given it. */
+ else if (TREE_CODE (DECL_VINDEX (fndecl)) != INTEGER_CST)
+ {
+ /* Need an entry in some other virtual function table.
+ Deal with this after we have laid out our virtual base classes. */
+ pending_hard_virtuals = temp_tree_cons (fndecl, vfn, pending_hard_virtuals);
+ }
+ return pending_virtuals;
+}
+
+/* Obstack on which to build the vector of class methods. */
+struct obstack class_obstack;
+extern struct obstack *current_obstack;
+
+/* Add method METHOD to class TYPE. This is used when a method
+ has been defined which did not initially appear in the class definition,
+ and helps cut down on spurious error messages.
+
+ FIELDS is the entry in the METHOD_VEC vector entry of the class type where
+ the method should be added. */
+void
+add_method (type, fields, method)
+ tree type, *fields, method;
+{
+ /* We must make a copy of METHOD here, since we must be sure that
+ we have exclusive title to this method's DECL_CHAIN. */
+ tree decl;
+
+ push_obstacks (&permanent_obstack, &permanent_obstack);
+ {
+ decl = copy_node (method);
+ if (DECL_RTL (decl) == 0
+ && (!processing_template_decl
+ || !uses_template_parms (decl)))
+ {
+ make_function_rtl (decl);
+ DECL_RTL (method) = DECL_RTL (decl);
+ }
+ }
+
+ if (fields && *fields)
+ {
+ /* Take care not to hide destructor. */
+ DECL_CHAIN (decl) = DECL_CHAIN (*fields);
+ DECL_CHAIN (*fields) = decl;
+ }
+ else if (CLASSTYPE_METHOD_VEC (type) == 0)
+ {
+ tree method_vec = make_node (TREE_VEC);
+ if (TYPE_IDENTIFIER (type) == DECL_NAME (decl))
+ {
+ TREE_VEC_ELT (method_vec, 0) = decl;
+ TREE_VEC_LENGTH (method_vec) = 1;
+ }
+ else
+ {
+ /* ??? Is it possible for there to have been enough room in the
+ current chunk for the tree_vec structure but not a tree_vec
+ plus a tree*? Will this work in that case? */
+ obstack_free (current_obstack, method_vec);
+ obstack_blank (current_obstack, sizeof (struct tree_vec) + sizeof (tree *));
+ TREE_VEC_ELT (method_vec, 1) = decl;
+ TREE_VEC_LENGTH (method_vec) = 2;
+ obstack_finish (current_obstack);
+ }
+ CLASSTYPE_METHOD_VEC (type) = method_vec;
+ }
+ else
+ {
+ tree method_vec = CLASSTYPE_METHOD_VEC (type);
+ int len = TREE_VEC_LENGTH (method_vec);
+
+ /* Adding a new ctor or dtor. This is easy because our
+ METHOD_VEC always has a slot for such entries. */
+ if (TYPE_IDENTIFIER (type) == DECL_NAME (decl))
+ {
+ /* TREE_VEC_ELT (method_vec, 0) = decl; */
+ if (decl != TREE_VEC_ELT (method_vec, 0))
+ {
+ DECL_CHAIN (decl) = TREE_VEC_ELT (method_vec, 0);
+ TREE_VEC_ELT (method_vec, 0) = decl;
+ }
+ }
+ else
+ {
+ /* This is trickier. We try to extend the TREE_VEC in-place,
+ but if that does not work, we copy all its data to a new
+ TREE_VEC that's large enough. */
+ struct obstack *ob = &class_obstack;
+ tree *end = (tree *)obstack_next_free (ob);
+
+ if (end != TREE_VEC_END (method_vec))
+ {
+ ob = current_obstack;
+ TREE_VEC_LENGTH (method_vec) += 1;
+ TREE_VEC_ELT (method_vec, len) = NULL_TREE;
+ method_vec = copy_node (method_vec);
+ TREE_VEC_LENGTH (method_vec) -= 1;
+ }
+ else
+ {
+ tree tmp_vec = (tree) obstack_base (ob);
+ if (obstack_room (ob) < sizeof (tree))
+ {
+ obstack_blank (ob, sizeof (struct tree_common)
+ + tree_code_length[(int) TREE_VEC]
+ * sizeof (char *)
+ + len * sizeof (tree));
+ tmp_vec = (tree) obstack_base (ob);
+ bcopy ((char *) method_vec, (char *) tmp_vec,
+ (sizeof (struct tree_common)
+ + tree_code_length[(int) TREE_VEC] * sizeof (char *)
+ + (len-1) * sizeof (tree)));
+ method_vec = tmp_vec;
+ }
+ else
+ obstack_blank (ob, sizeof (tree));
+ }
+
+ obstack_finish (ob);
+ TREE_VEC_ELT (method_vec, len) = decl;
+ TREE_VEC_LENGTH (method_vec) = len + 1;
+ CLASSTYPE_METHOD_VEC (type) = method_vec;
+
+ if (TYPE_BINFO_BASETYPES (type) && CLASSTYPE_BASELINK_VEC (type))
+ {
+ /* ??? May be better to know whether these can be extended? */
+ tree baselink_vec = CLASSTYPE_BASELINK_VEC (type);
+
+ TREE_VEC_LENGTH (baselink_vec) += 1;
+ CLASSTYPE_BASELINK_VEC (type) = copy_node (baselink_vec);
+ TREE_VEC_LENGTH (baselink_vec) -= 1;
+
+ TREE_VEC_ELT (CLASSTYPE_BASELINK_VEC (type), len) = 0;
+ }
+ }
+ }
+ DECL_CONTEXT (decl) = type;
+ DECL_CLASS_CONTEXT (decl) = type;
+
+ pop_obstacks ();
+}
+
+/* Subroutines of finish_struct. */
+
+/* Look through the list of fields for this struct, deleting
+ duplicates as we go. This must be recursive to handle
+ anonymous unions.
+
+ FIELD is the field which may not appear anywhere in FIELDS.
+ FIELD_PTR, if non-null, is the starting point at which
+ chained deletions may take place.
+ The value returned is the first acceptable entry found
+ in FIELDS.
+
+ Note that anonymous fields which are not of UNION_TYPE are
+ not duplicates, they are just anonymous fields. This happens
+ when we have unnamed bitfields, for example. */
+static tree
+delete_duplicate_fields_1 (field, fields)
+ tree field, fields;
+{
+ tree x;
+ tree prev = 0;
+ if (DECL_NAME (field) == 0)
+ {
+ if (TREE_CODE (TREE_TYPE (field)) != UNION_TYPE)
+ return fields;
+
+ for (x = TYPE_FIELDS (TREE_TYPE (field)); x; x = TREE_CHAIN (x))
+ fields = delete_duplicate_fields_1 (x, fields);
+ return fields;
+ }
+ else
+ {
+ for (x = fields; x; prev = x, x = TREE_CHAIN (x))
+ {
+ if (DECL_NAME (x) == 0)
+ {
+ if (TREE_CODE (TREE_TYPE (x)) != UNION_TYPE)
+ continue;
+ TYPE_FIELDS (TREE_TYPE (x))
+ = delete_duplicate_fields_1 (field, TYPE_FIELDS (TREE_TYPE (x)));
+ if (TYPE_FIELDS (TREE_TYPE (x)) == 0)
+ {
+ if (prev == 0)
+ fields = TREE_CHAIN (fields);
+ else
+ TREE_CHAIN (prev) = TREE_CHAIN (x);
+ }
+ }
+ else
+ {
+ if (DECL_NAME (field) == DECL_NAME (x))
+ {
+ if (TREE_CODE (field) == CONST_DECL
+ && TREE_CODE (x) == CONST_DECL)
+ cp_error_at ("duplicate enum value `%D'", x);
+ else if (TREE_CODE (field) == CONST_DECL
+ || TREE_CODE (x) == CONST_DECL)
+ cp_error_at ("duplicate field `%D' (as enum and non-enum)",
+ x);
+ else if (TREE_CODE (field) == TYPE_DECL
+ && TREE_CODE (x) == TYPE_DECL)
+ cp_error_at ("duplicate nested type `%D'", x);
+ else if (TREE_CODE (field) == TYPE_DECL
+ || TREE_CODE (x) == TYPE_DECL)
+ cp_error_at ("duplicate field `%D' (as type and non-type)",
+ x);
+ else
+ cp_error_at ("duplicate member `%D'", x);
+ if (prev == 0)
+ fields = TREE_CHAIN (fields);
+ else
+ TREE_CHAIN (prev) = TREE_CHAIN (x);
+ }
+ }
+ }
+ }
+ return fields;
+}
+
+static void
+delete_duplicate_fields (fields)
+ tree fields;
+{
+ tree x;
+ for (x = fields; x && TREE_CHAIN (x); x = TREE_CHAIN (x))
+ TREE_CHAIN (x) = delete_duplicate_fields_1 (x, TREE_CHAIN (x));
+}
+
+/* Change the access of FDECL to ACCESS in T.
+ Return 1 if change was legit, otherwise return 0. */
+static int
+alter_access (t, fdecl, access)
+ tree t;
+ tree fdecl;
+ enum access_type access;
+{
+ tree elem = purpose_member (t, DECL_ACCESS (fdecl));
+ if (elem && TREE_VALUE (elem) != (tree)access)
+ {
+ if (TREE_CODE (TREE_TYPE (fdecl)) == FUNCTION_DECL)
+ {
+ cp_error_at ("conflicting access specifications for method `%D', ignored", TREE_TYPE (fdecl));
+ }
+ else
+ error ("conflicting access specifications for field `%s', ignored",
+ IDENTIFIER_POINTER (DECL_NAME (fdecl)));
+ }
+ else if (TREE_PRIVATE (fdecl))
+ {
+ if (access != access_private)
+ cp_error_at ("cannot make private `%D' non-private", fdecl);
+ goto alter;
+ }
+ else if (TREE_PROTECTED (fdecl))
+ {
+ if (access != access_protected)
+ cp_error_at ("cannot make protected `%D' non-protected", fdecl);
+ goto alter;
+ }
+ /* ARM 11.3: an access declaration may not be used to restrict access
+ to a member that is accessible in the base class. */
+ else if (access != access_public)
+ cp_error_at ("cannot reduce access of public member `%D'", fdecl);
+ else if (elem == NULL_TREE)
+ {
+ alter:
+ DECL_ACCESS (fdecl) = tree_cons (t, (tree)access,
+ DECL_ACCESS (fdecl));
+ return 1;
+ }
+ return 0;
+}
+
+/* Return the offset to the main vtable for a given base BINFO. */
+tree
+get_vfield_offset (binfo)
+ tree binfo;
+{
+ return size_binop (PLUS_EXPR,
+ size_binop (FLOOR_DIV_EXPR,
+ DECL_FIELD_BITPOS (CLASSTYPE_VFIELD (BINFO_TYPE (binfo))),
+ size_int (BITS_PER_UNIT)),
+ BINFO_OFFSET (binfo));
+}
+
+/* Get the offset to the start of the original binfo that we derived
+ this binfo from. If we find TYPE first, return the offset only
+ that far. The shortened search is useful because the this pointer
+ on method calling is expected to point to a DECL_CONTEXT (fndecl)
+ object, and not a baseclass of it. */
+static tree
+get_derived_offset (binfo, type)
+ tree binfo, type;
+{
+ tree offset1 = get_vfield_offset (TYPE_BINFO (BINFO_TYPE (binfo)));
+ tree offset2;
+ int i;
+ while (BINFO_BASETYPES (binfo)
+ && (i=CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (binfo))) != -1)
+ {
+ tree binfos = BINFO_BASETYPES (binfo);
+ if (BINFO_TYPE (binfo) == type)
+ break;
+ binfo = TREE_VEC_ELT (binfos, i);
+ }
+ offset2 = get_vfield_offset (TYPE_BINFO (BINFO_TYPE (binfo)));
+ return size_binop (MINUS_EXPR, offset1, offset2);
+}
+
+/* If FOR_TYPE needs to reinitialize virtual function table pointers
+ for TYPE's sub-objects, add such reinitializations to BASE_INIT_LIST.
+ Returns BASE_INIT_LIST appropriately modified. */
+
+static tree
+maybe_fixup_vptrs (for_type, binfo, base_init_list)
+ tree for_type, binfo, base_init_list;
+{
+ /* Now reinitialize any slots that don't fall under our virtual
+ function table pointer. */
+ tree vfields = CLASSTYPE_VFIELDS (BINFO_TYPE (binfo));
+ while (vfields)
+ {
+ tree basetype = VF_NORMAL_VALUE (vfields)
+ ? TYPE_MAIN_VARIANT (VF_NORMAL_VALUE (vfields))
+ : VF_BASETYPE_VALUE (vfields);
+
+ tree base_binfo = get_binfo (basetype, for_type, 0);
+ /* Punt until this is implemented. */
+ if (1 /* BINFO_MODIFIED (base_binfo) */)
+ {
+ tree base_offset = get_vfield_offset (base_binfo);
+ if (! tree_int_cst_equal (base_offset, get_vfield_offset (TYPE_BINFO (for_type)))
+ && ! tree_int_cst_equal (base_offset, get_vfield_offset (binfo)))
+ base_init_list = tree_cons (error_mark_node, base_binfo,
+ base_init_list);
+ }
+ vfields = TREE_CHAIN (vfields);
+ }
+ return base_init_list;
+}
+
+/* If TYPE does not have a constructor, then the compiler must
+ manually deal with all of the initialization this type requires.
+
+ If a base initializer exists only to fill in the virtual function
+ table pointer, then we mark that fact with the TREE_VIRTUAL bit.
+ This way, we avoid multiple initializations of the same field by
+ each virtual function table up the class hierarchy.
+
+ Virtual base class pointers are not initialized here. They are
+ initialized only at the "top level" of object creation. If we
+ initialized them here, we would have to skip a lot of work. */
+
+static void
+build_class_init_list (type)
+ tree type;
+{
+ tree base_init_list = NULL_TREE;
+ tree member_init_list = NULL_TREE;
+
+ /* Since we build member_init_list and base_init_list using
+ tree_cons, backwards fields the all through work. */
+ tree x;
+ tree binfos = BINFO_BASETYPES (TYPE_BINFO (type));
+ int i, n_baseclasses = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+
+ for (x = TYPE_FIELDS (type); x; x = TREE_CHAIN (x))
+ {
+ if (TREE_CODE (x) != FIELD_DECL)
+ continue;
+
+ if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (x))
+ || DECL_INITIAL (x) != NULL_TREE)
+ member_init_list = tree_cons (x, type, member_init_list);
+ }
+ member_init_list = nreverse (member_init_list);
+
+ /* We will end up doing this last. Need special marker
+ to avoid infinite regress. */
+ if (TYPE_VIRTUAL_P (type))
+ {
+ base_init_list = build_tree_list (error_mark_node, TYPE_BINFO (type));
+ if (CLASSTYPE_NEEDS_VIRTUAL_REINIT (type) == 0)
+ TREE_VALUE (base_init_list) = NULL_TREE;
+ TREE_ADDRESSABLE (base_init_list) = 1;
+ }
+
+ /* Each base class which needs to have initialization
+ of some kind gets to make such requests known here. */
+ for (i = n_baseclasses-1; i >= 0; i--)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ tree blist;
+
+ /* Don't initialize virtual baseclasses this way. */
+ if (TREE_VIA_VIRTUAL (base_binfo))
+ continue;
+
+ if (TYPE_HAS_CONSTRUCTOR (BINFO_TYPE (base_binfo)))
+ {
+ /* ...and the last shall come first... */
+ base_init_list = maybe_fixup_vptrs (type, base_binfo, base_init_list);
+ base_init_list = tree_cons (NULL_TREE, base_binfo, base_init_list);
+ continue;
+ }
+
+ if ((blist = CLASSTYPE_BASE_INIT_LIST (BINFO_TYPE (base_binfo))) == NULL_TREE)
+ /* Nothing to initialize. */
+ continue;
+
+ /* ...ditto... */
+ base_init_list = maybe_fixup_vptrs (type, base_binfo, base_init_list);
+
+ /* This is normally true for single inheritance.
+ The win is we can shrink the chain of initializations
+ to be done by only converting to the actual type
+ we are interested in. */
+ if (TREE_VALUE (blist)
+ && TREE_CODE (TREE_VALUE (blist)) == TREE_VEC
+ && tree_int_cst_equal (BINFO_OFFSET (base_binfo),
+ BINFO_OFFSET (TREE_VALUE (blist))))
+ {
+ if (base_init_list)
+ {
+ /* Does it do more than just fill in a
+ virtual function table pointer? */
+ if (! TREE_ADDRESSABLE (blist))
+ base_init_list = build_tree_list (blist, base_init_list);
+ /* Can we get by just with the virtual function table
+ pointer that it fills in? */
+ else if (TREE_ADDRESSABLE (base_init_list)
+ && TREE_VALUE (base_init_list) == 0)
+ base_init_list = blist;
+ /* Maybe, but it is not obvious as the previous case. */
+ else if (! CLASSTYPE_NEEDS_VIRTUAL_REINIT (type))
+ {
+ tree last = tree_last (base_init_list);
+ while (TREE_VALUE (last)
+ && TREE_CODE (TREE_VALUE (last)) == TREE_LIST)
+ last = tree_last (TREE_VALUE (last));
+ if (TREE_VALUE (last) == 0)
+ base_init_list = build_tree_list (blist, base_init_list);
+ }
+ }
+ else
+ base_init_list = blist;
+ }
+ else
+ {
+ /* The function expand_aggr_init knows how to do the
+ initialization of `basetype' without getting
+ an explicit `blist'. */
+ if (base_init_list)
+ base_init_list = tree_cons (NULL_TREE, base_binfo, base_init_list);
+ else
+ base_init_list = CLASSTYPE_BINFO_AS_LIST (BINFO_TYPE (base_binfo));
+ }
+ }
+
+ if (base_init_list)
+ if (member_init_list)
+ CLASSTYPE_BASE_INIT_LIST (type) = build_tree_list (base_init_list, member_init_list);
+ else
+ CLASSTYPE_BASE_INIT_LIST (type) = base_init_list;
+ else if (member_init_list)
+ CLASSTYPE_BASE_INIT_LIST (type) = member_init_list;
+}
+
+struct base_info
+{
+ int has_virtual;
+ int max_has_virtual;
+ int n_ancestors;
+ tree vfield;
+ tree vfields;
+ char cant_have_default_ctor;
+ char cant_have_const_ctor;
+ char cant_synth_copy_ctor;
+ char cant_synth_asn_ref;
+ char no_const_asn_ref;
+ char needs_virtual_dtor;
+};
+
+/* Record information about type T derived from its base classes.
+ Store most of that information in T itself, and place the
+ remaining information in the struct BASE_INFO.
+
+ Propagate basetype offsets throughout the lattice. Note that the
+ lattice topped by T is really a pair: it's a DAG that gives the
+ structure of the derivation hierarchy, and it's a list of the
+ virtual baseclasses that appear anywhere in the DAG. When a vbase
+ type appears in the DAG, it's offset is 0, and it's children start
+ their offsets from that point. When a vbase type appears in the list,
+ its offset is the offset it has in the hierarchy, and its children's
+ offsets include that offset in theirs.
+
+ Returns the index of the first base class to have virtual functions,
+ or -1 if no such base class.
+
+ Note that at this point TYPE_BINFO (t) != t_binfo. */
+
+static int
+finish_base_struct (t, b, t_binfo)
+ tree t;
+ struct base_info *b;
+ tree t_binfo;
+{
+ tree binfos = BINFO_BASETYPES (t_binfo);
+ int i, n_baseclasses = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+ int first_vfn_base_index = -1;
+ bzero ((char *) b, sizeof (struct base_info));
+
+ for (i = 0; i < n_baseclasses; i++)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ tree basetype = BINFO_TYPE (base_binfo);
+
+ /* If the type of basetype is incomplete, then
+ we already complained about that fact
+ (and we should have fixed it up as well). */
+ if (TYPE_SIZE (basetype) == 0)
+ {
+ int j;
+ /* The base type is of incomplete type. It is
+ probably best to pretend that it does not
+ exist. */
+ if (i == n_baseclasses-1)
+ TREE_VEC_ELT (binfos, i) = NULL_TREE;
+ TREE_VEC_LENGTH (binfos) -= 1;
+ n_baseclasses -= 1;
+ for (j = i; j+1 < n_baseclasses; j++)
+ TREE_VEC_ELT (binfos, j) = TREE_VEC_ELT (binfos, j+1);
+ }
+
+ if (TYPE_HAS_INIT_REF (basetype)
+ && !TYPE_HAS_CONST_INIT_REF (basetype))
+ b->cant_have_const_ctor = 1;
+ if (! TYPE_HAS_INIT_REF (basetype)
+ || (TYPE_HAS_NONPUBLIC_CTOR (basetype) == 2
+ && ! is_friend_type (t, basetype)))
+ b->cant_synth_copy_ctor = 1;
+
+ if (TYPE_HAS_CONSTRUCTOR (basetype)
+ && ! TYPE_HAS_DEFAULT_CONSTRUCTOR (basetype))
+ {
+ b->cant_have_default_ctor = 1;
+ if (! TYPE_HAS_CONSTRUCTOR (t))
+ {
+ cp_pedwarn ("base `%T' with only non-default constructor",
+ basetype);
+ cp_pedwarn ("in class without a constructor");
+ }
+ }
+
+ if (TYPE_HAS_ASSIGN_REF (basetype)
+ && !TYPE_HAS_CONST_ASSIGN_REF (basetype))
+ b->no_const_asn_ref = 1;
+ if (! TYPE_HAS_ASSIGN_REF (basetype)
+ || TYPE_HAS_ABSTRACT_ASSIGN_REF (basetype)
+ || (TYPE_HAS_NONPUBLIC_ASSIGN_REF (basetype) == 2
+ && ! is_friend_type (t, basetype)))
+ b->cant_synth_asn_ref = 1;
+
+ b->n_ancestors += CLASSTYPE_N_SUPERCLASSES (basetype);
+ TYPE_NEEDS_CONSTRUCTING (t) |= TYPE_NEEDS_CONSTRUCTING (basetype);
+ TYPE_NEEDS_DESTRUCTOR (t) |= TYPE_NEEDS_DESTRUCTOR (basetype);
+ TYPE_HAS_COMPLEX_ASSIGN_REF (t) |= TYPE_HAS_COMPLEX_ASSIGN_REF (basetype);
+ TYPE_HAS_COMPLEX_INIT_REF (t) |= TYPE_HAS_COMPLEX_INIT_REF (basetype);
+
+ TYPE_OVERLOADS_CALL_EXPR (t) |= TYPE_OVERLOADS_CALL_EXPR (basetype);
+ TYPE_OVERLOADS_ARRAY_REF (t) |= TYPE_OVERLOADS_ARRAY_REF (basetype);
+ TYPE_OVERLOADS_ARROW (t) |= TYPE_OVERLOADS_ARROW (basetype);
+
+ if (! TREE_VIA_VIRTUAL (base_binfo)
+#if 0
+ /* This cannot be done, as prepare_fresh_vtable wants to modify
+ binfos associated with vfields anywhere in the hierarchy, not
+ just immediate base classes. Due to unsharing, the compiler
+ might consume 3% more memory on a real program.
+ */
+ && ! BINFO_OFFSET_ZEROP (base_binfo)
+#endif
+ && BINFO_BASETYPES (base_binfo))
+ {
+ tree base_binfos = BINFO_BASETYPES (base_binfo);
+ tree chain = NULL_TREE;
+ int j;
+
+ /* Now unshare the structure beneath BASE_BINFO. */
+ for (j = TREE_VEC_LENGTH (base_binfos)-1;
+ j >= 0; j--)
+ {
+ tree base_base_binfo = TREE_VEC_ELT (base_binfos, j);
+ if (! TREE_VIA_VIRTUAL (base_base_binfo))
+ TREE_VEC_ELT (base_binfos, j)
+ = make_binfo (BINFO_OFFSET (base_base_binfo),
+ base_base_binfo,
+ BINFO_VTABLE (base_base_binfo),
+ BINFO_VIRTUALS (base_base_binfo),
+ chain);
+ chain = TREE_VEC_ELT (base_binfos, j);
+ TREE_VIA_PUBLIC (chain) = TREE_VIA_PUBLIC (base_base_binfo);
+ TREE_VIA_PROTECTED (chain) = TREE_VIA_PROTECTED (base_base_binfo);
+ BINFO_INHERITANCE_CHAIN (chain) = base_binfo;
+ }
+
+ /* Completely unshare potentially shared data, and
+ update what is ours. */
+ propagate_binfo_offsets (base_binfo, BINFO_OFFSET (base_binfo));
+ }
+
+ if (! TREE_VIA_VIRTUAL (base_binfo))
+ CLASSTYPE_N_SUPERCLASSES (t) += 1;
+
+ if (TYPE_VIRTUAL_P (basetype))
+ {
+ /* If there's going to be a destructor needed, make
+ sure it will be virtual. */
+ b->needs_virtual_dtor = 1;
+
+ /* Don't borrow virtuals from virtual baseclasses. */
+ if (TREE_VIA_VIRTUAL (base_binfo))
+ continue;
+
+ if (first_vfn_base_index < 0)
+ {
+ tree vfields;
+ first_vfn_base_index = i;
+
+ /* Update these two, now that we know what vtable we are
+ going to extend. This is so that we can add virtual
+ functions, and override them properly. */
+ BINFO_VTABLE (t_binfo) = TYPE_BINFO_VTABLE (basetype);
+ BINFO_VIRTUALS (t_binfo) = TYPE_BINFO_VIRTUALS (basetype);
+ b->has_virtual = CLASSTYPE_VSIZE (basetype);
+ b->vfield = CLASSTYPE_VFIELD (basetype);
+ b->vfields = copy_list (CLASSTYPE_VFIELDS (basetype));
+ vfields = b->vfields;
+ while (vfields)
+ {
+ if (VF_BINFO_VALUE (vfields) == NULL_TREE
+ || ! TREE_VIA_VIRTUAL (VF_BINFO_VALUE (vfields)))
+ {
+ tree value = VF_BASETYPE_VALUE (vfields);
+ if (DECL_NAME (CLASSTYPE_VFIELD (value))
+ == DECL_NAME (CLASSTYPE_VFIELD (basetype)))
+ VF_NORMAL_VALUE (b->vfields) = basetype;
+ else
+ VF_NORMAL_VALUE (b->vfields) = VF_NORMAL_VALUE (vfields);
+ }
+ vfields = TREE_CHAIN (vfields);
+ }
+ CLASSTYPE_VFIELD (t) = b->vfield;
+ }
+ else
+ {
+ /* Only add unique vfields, and flatten them out as we go. */
+ tree vfields = CLASSTYPE_VFIELDS (basetype);
+ while (vfields)
+ {
+ if (VF_BINFO_VALUE (vfields) == NULL_TREE
+ || ! TREE_VIA_VIRTUAL (VF_BINFO_VALUE (vfields)))
+ {
+ tree value = VF_BASETYPE_VALUE (vfields);
+ b->vfields = tree_cons (base_binfo, value, b->vfields);
+ if (DECL_NAME (CLASSTYPE_VFIELD (value))
+ == DECL_NAME (CLASSTYPE_VFIELD (basetype)))
+ VF_NORMAL_VALUE (b->vfields) = basetype;
+ else
+ VF_NORMAL_VALUE (b->vfields) = VF_NORMAL_VALUE (vfields);
+ }
+ vfields = TREE_CHAIN (vfields);
+ }
+
+ if (b->has_virtual == 0)
+ {
+ first_vfn_base_index = i;
+
+ /* Update these two, now that we know what vtable we are
+ going to extend. This is so that we can add virtual
+ functions, and override them properly. */
+ BINFO_VTABLE (t_binfo) = TYPE_BINFO_VTABLE (basetype);
+ BINFO_VIRTUALS (t_binfo) = TYPE_BINFO_VIRTUALS (basetype);
+ b->has_virtual = CLASSTYPE_VSIZE (basetype);
+ b->vfield = CLASSTYPE_VFIELD (basetype);
+ CLASSTYPE_VFIELD (t) = b->vfield;
+ /* When we install the first one, set the VF_NORMAL_VALUE
+ to be the current class, as this it is the most derived
+ class. Hopefully, this is not set to something else
+ later. (mrs) */
+ vfields = b->vfields;
+ while (vfields)
+ {
+ if (DECL_NAME (CLASSTYPE_VFIELD (t))
+ == DECL_NAME (CLASSTYPE_VFIELD (basetype)))
+ {
+ VF_NORMAL_VALUE (vfields) = t;
+ /* There should only be one of them! And it should
+ always be found, if we get into here. (mrs) */
+ break;
+ }
+ vfields = TREE_CHAIN (vfields);
+ }
+ }
+ }
+ }
+ }
+
+ /* Must come after offsets are fixed for all bases. */
+ for (i = 0; i < n_baseclasses; i++)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ tree basetype = BINFO_TYPE (base_binfo);
+
+ if (get_base_distance (basetype, t_binfo, 0, (tree*)0) == -2)
+ {
+ cp_warning ("direct base `%T' inaccessible in `%T' due to ambiguity",
+ basetype, t);
+ b->cant_synth_asn_ref = 1;
+ b->cant_synth_copy_ctor = 1;
+ }
+ }
+ {
+ tree v = get_vbase_types (t_binfo);
+
+ for (; v; v = TREE_CHAIN (v))
+ {
+ tree basetype = BINFO_TYPE (v);
+ if (get_base_distance (basetype, t_binfo, 0, (tree*)0) == -2)
+ {
+ if (extra_warnings)
+ cp_warning ("virtual base `%T' inaccessible in `%T' due to ambiguity",
+ basetype, t);
+ b->cant_synth_asn_ref = 1;
+ b->cant_synth_copy_ctor = 1;
+ }
+ }
+ }
+
+ {
+ tree vfields;
+ /* Find the base class with the largest number of virtual functions. */
+ for (vfields = b->vfields; vfields; vfields = TREE_CHAIN (vfields))
+ {
+ if (CLASSTYPE_VSIZE (VF_BASETYPE_VALUE (vfields)) > b->max_has_virtual)
+ b->max_has_virtual = CLASSTYPE_VSIZE (VF_BASETYPE_VALUE (vfields));
+ if (VF_DERIVED_VALUE (vfields)
+ && CLASSTYPE_VSIZE (VF_DERIVED_VALUE (vfields)) > b->max_has_virtual)
+ b->max_has_virtual = CLASSTYPE_VSIZE (VF_DERIVED_VALUE (vfields));
+ }
+ }
+
+ if (b->vfield == 0)
+ /* If all virtual functions come only from virtual baseclasses. */
+ return -1;
+ return first_vfn_base_index;
+}
+
+static int
+typecode_p (type, code)
+ tree type;
+ enum tree_code code;
+{
+ return (TREE_CODE (type) == code
+ || (TREE_CODE (type) == REFERENCE_TYPE
+ && TREE_CODE (TREE_TYPE (type)) == code));
+}
+
+/* Set memoizing fields and bits of T (and its variants) for later use.
+ MAX_HAS_VIRTUAL is the largest size of any T's virtual function tables. */
+static void
+finish_struct_bits (t, max_has_virtual)
+ tree t;
+ int max_has_virtual;
+{
+ int i, n_baseclasses = CLASSTYPE_N_BASECLASSES (t);
+ tree method_vec = CLASSTYPE_METHOD_VEC (t);
+
+ /* Fix up variants (if any). */
+ tree variants = TYPE_NEXT_VARIANT (t);
+ while (variants)
+ {
+ /* These fields are in the _TYPE part of the node, not in
+ the TYPE_LANG_SPECIFIC component, so they are not shared. */
+ TYPE_HAS_CONSTRUCTOR (variants) = TYPE_HAS_CONSTRUCTOR (t);
+ TYPE_HAS_DESTRUCTOR (variants) = TYPE_HAS_DESTRUCTOR (t);
+ TYPE_NEEDS_CONSTRUCTING (variants) = TYPE_NEEDS_CONSTRUCTING (t);
+ TYPE_NEEDS_DESTRUCTOR (variants) = TYPE_NEEDS_DESTRUCTOR (t);
+
+ TYPE_USES_COMPLEX_INHERITANCE (variants) = TYPE_USES_COMPLEX_INHERITANCE (t);
+ TYPE_VIRTUAL_P (variants) = TYPE_VIRTUAL_P (t);
+ TYPE_USES_VIRTUAL_BASECLASSES (variants) = TYPE_USES_VIRTUAL_BASECLASSES (t);
+ /* Copy whatever these are holding today. */
+ TYPE_MIN_VALUE (variants) = TYPE_MIN_VALUE (t);
+ TYPE_MAX_VALUE (variants) = TYPE_MAX_VALUE (t);
+ variants = TYPE_NEXT_VARIANT (variants);
+ }
+
+ if (n_baseclasses && max_has_virtual)
+ {
+ /* Done by `finish_struct' for classes without baseclasses. */
+ int might_have_abstract_virtuals = CLASSTYPE_ABSTRACT_VIRTUALS (t) != 0;
+ tree binfos = TYPE_BINFO_BASETYPES (t);
+ for (i = n_baseclasses-1; i >= 0; i--)
+ {
+ might_have_abstract_virtuals
+ |= (CLASSTYPE_ABSTRACT_VIRTUALS (BINFO_TYPE (TREE_VEC_ELT (binfos, i))) != 0);
+ if (might_have_abstract_virtuals)
+ break;
+ }
+ if (might_have_abstract_virtuals)
+ {
+ /* We use error_mark_node from override_one_vtable to signal
+ an artificial abstract. */
+ if (CLASSTYPE_ABSTRACT_VIRTUALS (t) == error_mark_node)
+ CLASSTYPE_ABSTRACT_VIRTUALS (t) = NULL_TREE;
+ CLASSTYPE_ABSTRACT_VIRTUALS (t) = get_abstract_virtuals (t);
+ }
+ }
+
+ if (n_baseclasses)
+ {
+ /* Notice whether this class has type conversion functions defined. */
+ tree binfo = TYPE_BINFO (t);
+ tree binfos = BINFO_BASETYPES (binfo);
+ tree basetype;
+
+ for (i = n_baseclasses-1; i >= 0; i--)
+ {
+ basetype = BINFO_TYPE (TREE_VEC_ELT (binfos, i));
+
+ if (TYPE_HAS_CONVERSION (basetype))
+ {
+ TYPE_HAS_CONVERSION (t) = 1;
+ TYPE_HAS_INT_CONVERSION (t) |= TYPE_HAS_INT_CONVERSION (basetype);
+ TYPE_HAS_REAL_CONVERSION (t) |= TYPE_HAS_REAL_CONVERSION (basetype);
+ }
+ if (CLASSTYPE_MAX_DEPTH (basetype) >= CLASSTYPE_MAX_DEPTH (t))
+ CLASSTYPE_MAX_DEPTH (t) = CLASSTYPE_MAX_DEPTH (basetype) + 1;
+ }
+ }
+
+ /* If this type has a copy constructor, force its mode to be BLKmode, and
+ force its TREE_ADDRESSABLE bit to be nonzero. This will cause it to
+ be passed by invisible reference and prevent it from being returned in
+ a register. */
+ if (! TYPE_HAS_TRIVIAL_INIT_REF (t))
+ {
+ tree variants;
+ if (TREE_CODE (TYPE_NAME (t)) == TYPE_DECL)
+ DECL_MODE (TYPE_NAME (t)) = BLKmode;
+ for (variants = t; variants; variants = TYPE_NEXT_VARIANT (variants))
+ {
+ TYPE_MODE (variants) = BLKmode;
+ TREE_ADDRESSABLE (variants) = 1;
+ }
+ }
+}
+
+/* Add FN to the method_vec growing on the class_obstack. Used by
+ finish_struct_methods. */
+static void
+grow_method (fn, method_vec_ptr)
+ tree fn;
+ tree *method_vec_ptr;
+{
+ tree method_vec = (tree)obstack_base (&class_obstack);
+ tree *testp = &TREE_VEC_ELT (method_vec, 0);
+ if (*testp == NULL_TREE)
+ testp++;
+ while (((HOST_WIDE_INT) testp
+ < (HOST_WIDE_INT) obstack_next_free (&class_obstack))
+ && DECL_NAME (*testp) != DECL_NAME (fn))
+ testp++;
+ if ((HOST_WIDE_INT) testp
+ < (HOST_WIDE_INT) obstack_next_free (&class_obstack))
+ {
+ tree x, prev_x;
+
+ for (x = *testp; x; x = DECL_CHAIN (x))
+ {
+ if (DECL_NAME (fn) == ansi_opname[(int) DELETE_EXPR]
+ || DECL_NAME (fn) == ansi_opname[(int) VEC_DELETE_EXPR])
+ {
+ /* ANSI C++ June 5 1992 WP 12.5.5.1 */
+ cp_error_at ("`%D' overloaded", fn);
+ cp_error_at ("previous declaration as `%D' here", x);
+ }
+ if (DECL_ASSEMBLER_NAME (fn)==DECL_ASSEMBLER_NAME (x))
+ {
+ /* We complain about multiple destructors on sight,
+ so we do not repeat the warning here. Friend-friend
+ ambiguities are warned about outside this loop. */
+ if (!DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (fn)))
+ cp_error_at ("ambiguous method `%#D' in structure", fn);
+ break;
+ }
+ prev_x = x;
+ }
+ if (x == 0)
+ {
+ if (*testp)
+ DECL_CHAIN (prev_x) = fn;
+ else
+ *testp = fn;
+ }
+ }
+ else
+ {
+ obstack_ptr_grow (&class_obstack, fn);
+ *method_vec_ptr = (tree)obstack_base (&class_obstack);
+ }
+}
+
+/* Warn about duplicate methods in fn_fields. Also compact method
+ lists so that lookup can be made faster.
+
+ Algorithm: Outer loop builds lists by method name. Inner loop
+ checks for redundant method names within a list.
+
+ Data Structure: List of method lists. The outer list is a
+ TREE_LIST, whose TREE_PURPOSE field is the field name and the
+ TREE_VALUE is the DECL_CHAIN of the FUNCTION_DECLs. TREE_CHAIN
+ links the entire list of methods for TYPE_METHODS. Friends are
+ chained in the same way as member functions (? TREE_CHAIN or
+ DECL_CHAIN), but they live in the TREE_TYPE field of the outer
+ list. That allows them to be quickly deleted, and requires no
+ extra storage.
+
+ If there are any constructors/destructors, they are moved to the
+ front of the list. This makes pushclass more efficient.
+
+ We also link each field which has shares a name with its baseclass
+ to the head of the list of fields for that base class. This allows
+ us to reduce search time in places like `build_method_call' to
+ consider only reasonably likely functions. */
+
+static tree
+finish_struct_methods (t, fn_fields, nonprivate_method)
+ tree t;
+ tree fn_fields;
+ int nonprivate_method;
+{
+ tree method_vec;
+ tree save_fn_fields = tree_cons (NULL_TREE, NULL_TREE, fn_fields);
+ tree lastp;
+ tree name = constructor_name (t);
+ int i, n_baseclasses = CLASSTYPE_N_BASECLASSES (t);
+
+ /* Now prepare to gather fn_fields into vector. */
+ struct obstack *ambient_obstack = current_obstack;
+ current_obstack = &class_obstack;
+ method_vec = make_node (TREE_VEC);
+ /* Room has been saved for constructors and destructors. */
+ current_obstack = ambient_obstack;
+ /* Now make this a live vector. */
+ obstack_free (&class_obstack, method_vec);
+ obstack_blank (&class_obstack, sizeof (struct tree_vec));
+
+ /* First fill in entry 0 with the constructors, and the next few with
+ type conversion operators (if any). */
+
+ for (lastp = save_fn_fields; fn_fields; fn_fields = TREE_CHAIN (lastp))
+ {
+ tree fn_name = DECL_NAME (fn_fields);
+ if (fn_name == NULL_TREE)
+ fn_name = name;
+
+ /* Clear out this flag.
+
+ @@ Doug may figure out how to break
+ @@ this with nested classes and friends. */
+ DECL_IN_AGGR_P (fn_fields) = 0;
+
+ /* Note here that a copy ctor is private, so we don't dare generate
+ a default copy constructor for a class that has a member
+ of this type without making sure they have access to it. */
+ if (fn_name == name)
+ {
+ tree parmtypes = FUNCTION_ARG_CHAIN (fn_fields);
+ tree parmtype = parmtypes ? TREE_VALUE (parmtypes) : void_type_node;
+
+ if (TREE_CODE (parmtype) == REFERENCE_TYPE
+ && TYPE_MAIN_VARIANT (TREE_TYPE (parmtype)) == t)
+ {
+ if (TREE_CHAIN (parmtypes) == NULL_TREE
+ || TREE_CHAIN (parmtypes) == void_list_node
+ || TREE_PURPOSE (TREE_CHAIN (parmtypes)))
+ {
+ if (TREE_PROTECTED (fn_fields))
+ TYPE_HAS_NONPUBLIC_CTOR (t) = 1;
+ else if (TREE_PRIVATE (fn_fields))
+ TYPE_HAS_NONPUBLIC_CTOR (t) = 2;
+ }
+ }
+ /* Constructors are handled easily in search routines. */
+ DECL_CHAIN (fn_fields) = TREE_VEC_ELT (method_vec, 0);
+ TREE_VEC_ELT (method_vec, 0) = fn_fields;
+ }
+ else if (IDENTIFIER_TYPENAME_P (fn_name))
+ {
+ tree return_type = TREE_TYPE (TREE_TYPE (fn_fields));
+
+ if (typecode_p (return_type, INTEGER_TYPE)
+ || typecode_p (return_type, BOOLEAN_TYPE)
+ || typecode_p (return_type, ENUMERAL_TYPE))
+ TYPE_HAS_INT_CONVERSION (t) = 1;
+ else if (typecode_p (return_type, REAL_TYPE))
+ TYPE_HAS_REAL_CONVERSION (t) = 1;
+
+ grow_method (fn_fields, &method_vec);
+ }
+ else
+ {
+ lastp = fn_fields;
+ continue;
+ }
+
+ TREE_CHAIN (lastp) = TREE_CHAIN (fn_fields);
+ TREE_CHAIN (fn_fields) = NULL_TREE;
+ }
+
+ fn_fields = TREE_CHAIN (save_fn_fields);
+ while (fn_fields)
+ {
+ tree nextp;
+ tree fn_name = DECL_NAME (fn_fields);
+ if (fn_name == NULL_TREE)
+ fn_name = name;
+
+ nextp = TREE_CHAIN (fn_fields);
+ TREE_CHAIN (fn_fields) = NULL_TREE;
+
+ if (fn_name == ansi_opname[(int) MODIFY_EXPR])
+ {
+ tree parmtype = TREE_VALUE (FUNCTION_ARG_CHAIN (fn_fields));
+
+ if (copy_assignment_arg_p (parmtype, DECL_VIRTUAL_P (fn_fields)))
+ {
+ if (TREE_PROTECTED (fn_fields))
+ TYPE_HAS_NONPUBLIC_ASSIGN_REF (t) = 1;
+ else if (TREE_PRIVATE (fn_fields))
+ TYPE_HAS_NONPUBLIC_ASSIGN_REF (t) = 2;
+ }
+ }
+
+ grow_method (fn_fields, &method_vec);
+ fn_fields = nextp;
+ }
+
+ TREE_VEC_LENGTH (method_vec) = (tree *)obstack_next_free (&class_obstack)
+ - (&TREE_VEC_ELT (method_vec, 0));
+ obstack_finish (&class_obstack);
+ CLASSTYPE_METHOD_VEC (t) = method_vec;
+
+ if (nonprivate_method == 0
+ && CLASSTYPE_FRIEND_CLASSES (t) == NULL_TREE
+ && DECL_FRIENDLIST (TYPE_NAME (t)) == NULL_TREE)
+ {
+ tree binfos = BINFO_BASETYPES (TYPE_BINFO (t));
+ for (i = 0; i < n_baseclasses; i++)
+ if (TREE_VIA_PUBLIC (TREE_VEC_ELT (binfos, i))
+ || TREE_VIA_PROTECTED (TREE_VEC_ELT (binfos, i)))
+ {
+ nonprivate_method = 1;
+ break;
+ }
+ if (nonprivate_method == 0)
+ cp_warning ("all member functions in class `%T' are private", t);
+ }
+
+ /* If there are constructors (and destructors), they are at the
+ front. Place destructors at very front. Also warn if all
+ constructors and/or destructors are private (in which case this
+ class is effectively unusable. */
+ if (TYPE_HAS_DESTRUCTOR (t))
+ {
+ tree dtor, prev;
+
+ for (dtor = TREE_VEC_ELT (method_vec, 0);
+ dtor;
+ prev = dtor, dtor = DECL_CHAIN (dtor))
+ {
+ if (DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (dtor)))
+ {
+ if (TREE_PRIVATE (dtor)
+ && CLASSTYPE_FRIEND_CLASSES (t) == NULL_TREE
+ && DECL_FRIENDLIST (TYPE_NAME (t)) == NULL_TREE
+ && warn_ctor_dtor_privacy)
+ cp_warning ("`%#T' only defines a private destructor and has no friends",
+ t);
+ break;
+ }
+ }
+
+ /* Wild parse errors can cause this to happen. */
+ if (dtor == NULL_TREE)
+ TYPE_HAS_DESTRUCTOR (t) = 0;
+ else if (dtor != TREE_VEC_ELT (method_vec, 0))
+ {
+ DECL_CHAIN (prev) = DECL_CHAIN (dtor);
+ DECL_CHAIN (dtor) = TREE_VEC_ELT (method_vec, 0);
+ TREE_VEC_ELT (method_vec, 0) = dtor;
+ }
+ }
+
+ /* Now for each member function (except for constructors and
+ destructors), compute where member functions of the same
+ name reside in base classes. */
+ if (n_baseclasses != 0
+ && TREE_VEC_LENGTH (method_vec) > 1)
+ {
+ int len = TREE_VEC_LENGTH (method_vec);
+ tree baselink_vec = make_tree_vec (len);
+ int any_links = 0;
+ tree baselink_binfo = build_tree_list (NULL_TREE, TYPE_BINFO (t));
+
+ for (i = 1; i < len; i++)
+ {
+ TREE_VEC_ELT (baselink_vec, i)
+ = get_baselinks (baselink_binfo, t, DECL_NAME (TREE_VEC_ELT (method_vec, i)));
+ if (TREE_VEC_ELT (baselink_vec, i) != 0)
+ any_links = 1;
+ }
+ if (any_links != 0)
+ CLASSTYPE_BASELINK_VEC (t) = baselink_vec;
+ else
+ obstack_free (current_obstack, baselink_vec);
+ }
+
+ /* Now add the methods to the TYPE_METHODS of T, arranged in a chain. */
+ {
+ tree x, last_x = NULL_TREE;
+ int limit = TREE_VEC_LENGTH (method_vec);
+
+ for (i = 1; i < limit; i++)
+ {
+ for (x = TREE_VEC_ELT (method_vec, i); x; x = DECL_CHAIN (x))
+ {
+ if (last_x != NULL_TREE)
+ TREE_CHAIN (last_x) = x;
+ last_x = x;
+ }
+ }
+
+ /* Put ctors and dtors at the front of the list. */
+ x = TREE_VEC_ELT (method_vec, 0);
+ if (x)
+ {
+ while (DECL_CHAIN (x))
+ {
+ /* Let's avoid being circular about this. */
+ if (x == DECL_CHAIN (x))
+ break;
+ TREE_CHAIN (x) = DECL_CHAIN (x);
+ x = DECL_CHAIN (x);
+ }
+ if (TREE_VEC_LENGTH (method_vec) > 1)
+ TREE_CHAIN (x) = TREE_VEC_ELT (method_vec, 1);
+ else
+ TREE_CHAIN (x) = NULL_TREE;
+ }
+ }
+
+ TYPE_METHODS (t) = method_vec;
+
+ return method_vec;
+}
+
+/* Emit error when a duplicate definition of a type is seen. Patch up. */
+
+void
+duplicate_tag_error (t)
+ tree t;
+{
+ cp_error ("redefinition of `%#T'", t);
+ cp_error_at ("previous definition here", t);
+
+ /* Pretend we haven't defined this type. */
+
+ /* All of the component_decl's were TREE_CHAINed together in the parser.
+ finish_struct_methods walks these chains and assembles all methods with
+ the same base name into DECL_CHAINs. Now we don't need the parser chains
+ anymore, so we unravel them.
+ */
+ /*
+ * This used to be in finish_struct, but it turns out that the
+ * TREE_CHAIN is used by dbxout_type_methods and perhaps some other things...
+ */
+ if (CLASSTYPE_METHOD_VEC(t))
+ {
+ tree tv = CLASSTYPE_METHOD_VEC(t);
+ int i, len = TREE_VEC_LENGTH (tv);
+ for (i = 0; i < len; i++)
+ {
+ tree unchain = TREE_VEC_ELT (tv, i);
+ while (unchain != NULL_TREE)
+ {
+ TREE_CHAIN (unchain) = NULL_TREE;
+ unchain = DECL_CHAIN(unchain);
+ }
+ }
+ }
+
+ if (TYPE_LANG_SPECIFIC (t))
+ {
+ tree as_list = CLASSTYPE_AS_LIST (t);
+ tree binfo = TYPE_BINFO (t);
+ tree binfo_as_list = CLASSTYPE_BINFO_AS_LIST (t);
+ int interface_only = CLASSTYPE_INTERFACE_ONLY (t);
+ int interface_unknown = CLASSTYPE_INTERFACE_UNKNOWN (t);
+
+ bzero ((char *) TYPE_LANG_SPECIFIC (t), sizeof (struct lang_type));
+ BINFO_BASETYPES(binfo) = NULL_TREE;
+
+ CLASSTYPE_AS_LIST (t) = as_list;
+ TYPE_BINFO (t) = binfo;
+ CLASSTYPE_BINFO_AS_LIST (t) = binfo_as_list;
+ CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
+ SET_CLASSTYPE_INTERFACE_UNKNOWN_X (t, interface_unknown);
+ CLASSTYPE_VBASE_SIZE (t) = integer_zero_node;
+ TYPE_REDEFINED (t) = 1;
+ }
+ TYPE_SIZE (t) = NULL_TREE;
+ TYPE_MODE (t) = VOIDmode;
+ TYPE_FIELDS (t) = NULL_TREE;
+ TYPE_METHODS (t) = NULL_TREE;
+ TYPE_VFIELD (t) = NULL_TREE;
+ TYPE_CONTEXT (t) = NULL_TREE;
+}
+
+/* finish up all new vtables. */
+static void
+finish_vtbls (binfo, do_self, t)
+ tree binfo, t;
+ int do_self;
+{
+ tree binfos = BINFO_BASETYPES (binfo);
+ int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+
+ /* Should we use something besides CLASSTYPE_VFIELDS? */
+ if (do_self && CLASSTYPE_VFIELDS (BINFO_TYPE (binfo)))
+ {
+ if (BINFO_NEW_VTABLE_MARKED (binfo))
+ {
+ tree decl, context;
+
+ decl = BINFO_VTABLE (binfo);
+ context = DECL_CONTEXT (decl);
+ DECL_CONTEXT (decl) = 0;
+ if (write_virtuals >= 0
+ && DECL_INITIAL (decl) != BINFO_VIRTUALS (binfo))
+ DECL_INITIAL (decl) = build_nt (CONSTRUCTOR, NULL_TREE,
+ BINFO_VIRTUALS (binfo));
+ cp_finish_decl (decl, DECL_INITIAL (decl), NULL_TREE, 0, 0);
+ DECL_CONTEXT (decl) = context;
+ }
+ CLEAR_BINFO_NEW_VTABLE_MARKED (binfo);
+ }
+
+ for (i = 0; i < n_baselinks; i++)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ int is_not_base_vtable =
+ i != CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (binfo));
+ if (TREE_VIA_VIRTUAL (base_binfo))
+ {
+ base_binfo = binfo_member (BINFO_TYPE (base_binfo), CLASSTYPE_VBASECLASSES (t));
+ }
+ finish_vtbls (base_binfo, is_not_base_vtable, t);
+ }
+}
+
+/* True if we should override the given BASE_FNDECL with the given
+ FNDECL. */
+static int
+overrides (fndecl, base_fndecl)
+ tree fndecl, base_fndecl;
+{
+ /* Destructors have special names. */
+ if (DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (base_fndecl)) &&
+ DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (fndecl)))
+ return 1;
+ if (DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (base_fndecl)) ||
+ DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (fndecl)))
+ return 0;
+ if (DECL_NAME (fndecl) == DECL_NAME (base_fndecl))
+ {
+ tree rettype, base_rettype, types, base_types;
+#if 0
+ retypes = TREE_TYPE (TREE_TYPE (fndecl));
+ base_retypes = TREE_TYPE (TREE_TYPE (base_fndecl));
+#endif
+ types = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
+ base_types = TYPE_ARG_TYPES (TREE_TYPE (base_fndecl));
+ if ((TYPE_READONLY (TREE_TYPE (TREE_VALUE (base_types)))
+ == TYPE_READONLY (TREE_TYPE (TREE_VALUE (types))))
+ && compparms (TREE_CHAIN (base_types), TREE_CHAIN (types), 3))
+ return 1;
+ }
+ return 0;
+}
+
+static tree
+get_class_offset_1 (parent, binfo, context, t, fndecl)
+ tree parent, binfo, context, t, fndecl;
+{
+ tree binfos = BINFO_BASETYPES (binfo);
+ int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+ tree rval = NULL_TREE;
+
+ if (binfo == parent)
+ return error_mark_node;
+
+ for (i = 0; i < n_baselinks; i++)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ tree nrval;
+
+ if (TREE_VIA_VIRTUAL (base_binfo))
+ base_binfo = binfo_member (BINFO_TYPE (base_binfo),
+ CLASSTYPE_VBASECLASSES (t));
+ nrval = get_class_offset_1 (parent, base_binfo, context, t, fndecl);
+ /* See if we have a new value */
+ if (nrval && (nrval != error_mark_node || rval==0))
+ {
+ /* Only compare if we have two offsets */
+ if (rval && rval != error_mark_node
+ && ! tree_int_cst_equal (nrval, rval))
+ {
+ /* Only give error if the two offsets are different */
+ error ("every virtual function must have a unique final overrider");
+ cp_error (" found two (or more) `%T' class subobjects in `%T'", context, t);
+ cp_error (" with virtual `%D' from virtual base class", fndecl);
+ return rval;
+ }
+ rval = nrval;
+ }
+
+ if (rval && BINFO_TYPE (binfo) == context)
+ {
+ my_friendly_assert (rval == error_mark_node
+ || tree_int_cst_equal (rval, BINFO_OFFSET (binfo)), 999);
+ rval = BINFO_OFFSET (binfo);
+ }
+ }
+ return rval;
+}
+
+/* Get the offset to the CONTEXT subobject that is related to the
+ given BINFO. */
+static tree
+get_class_offset (context, t, binfo, fndecl)
+ tree context, t, binfo, fndecl;
+{
+ tree first_binfo = binfo;
+ tree offset;
+ int i;
+
+ if (context == t)
+ return integer_zero_node;
+
+ if (BINFO_TYPE (binfo) == context)
+ return BINFO_OFFSET (binfo);
+
+ /* Check less derived binfos first. */
+ while (BINFO_BASETYPES (binfo)
+ && (i=CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (binfo))) != -1)
+ {
+ tree binfos = BINFO_BASETYPES (binfo);
+ binfo = TREE_VEC_ELT (binfos, i);
+ if (BINFO_TYPE (binfo) == context)
+ return BINFO_OFFSET (binfo);
+ }
+
+ /* Ok, not found in the less derived binfos, now check the more
+ derived binfos. */
+ offset = get_class_offset_1 (first_binfo, TYPE_BINFO (t), context, t, fndecl);
+ if (offset==0 || TREE_CODE (offset) != INTEGER_CST)
+ my_friendly_abort (999); /* we have to find it. */
+ return offset;
+}
+
+/* Skip RTTI information at the front of the virtual list. */
+unsigned HOST_WIDE_INT
+skip_rtti_stuff (virtuals)
+ tree *virtuals;
+{
+ int n;
+
+ n = 0;
+ if (*virtuals)
+ {
+ /* We always reserve a slot for the offset/tdesc entry. */
+ ++n;
+ *virtuals = TREE_CHAIN (*virtuals);
+ }
+ if (flag_vtable_thunks && *virtuals)
+ {
+ /* The second slot is reserved for the tdesc pointer when thunks
+ are used. */
+ ++n;
+ *virtuals = TREE_CHAIN (*virtuals);
+ }
+ return n;
+}
+
+static void
+modify_one_vtable (binfo, t, fndecl, pfn)
+ tree binfo, t, fndecl, pfn;
+{
+ tree virtuals = BINFO_VIRTUALS (binfo);
+ tree old_rtti;
+ unsigned HOST_WIDE_INT n;
+
+ /* update rtti entry */
+ if (flag_rtti)
+ {
+ if (binfo == TYPE_BINFO (t))
+ {
+ if (! BINFO_NEW_VTABLE_MARKED (binfo))
+ build_vtable (TYPE_BINFO (DECL_CONTEXT (CLASSTYPE_VFIELD (t))), t);
+ }
+ else
+ {
+ if (! BINFO_NEW_VTABLE_MARKED (binfo))
+ prepare_fresh_vtable (binfo, t);
+ }
+ }
+ if (fndecl == NULL_TREE)
+ return;
+
+ n = skip_rtti_stuff (&virtuals);
+
+ while (virtuals)
+ {
+ tree current_fndecl = TREE_VALUE (virtuals);
+ current_fndecl = FNADDR_FROM_VTABLE_ENTRY (current_fndecl);
+ current_fndecl = TREE_OPERAND (current_fndecl, 0);
+ if (current_fndecl && overrides (fndecl, current_fndecl))
+ {
+ tree base_offset, offset;
+ tree context = DECL_CLASS_CONTEXT (fndecl);
+ tree vfield = CLASSTYPE_VFIELD (t);
+ tree this_offset;
+
+ offset = get_class_offset (context, t, binfo, fndecl);
+
+ /* Find the right offset for the this pointer based on the
+ base class we just found. We have to take into
+ consideration the virtual base class pointers that we
+ stick in before the virtual function table pointer.
+
+ Also, we want just the delta between the most base class
+ that we derived this vfield from and us. */
+ base_offset = size_binop (PLUS_EXPR,
+ get_derived_offset (binfo, DECL_CONTEXT (current_fndecl)),
+ BINFO_OFFSET (binfo));
+ this_offset = size_binop (MINUS_EXPR, offset, base_offset);
+
+ /* Make sure we can modify the derived association with immunity. */
+ if (TREE_USED (binfo))
+ my_friendly_assert (0, 999);
+
+ if (binfo == TYPE_BINFO (t))
+ {
+ /* In this case, it is *type*'s vtable we are modifying.
+ We start with the approximation that it's vtable is that
+ of the immediate base class. */
+ if (! BINFO_NEW_VTABLE_MARKED (binfo))
+ build_vtable (TYPE_BINFO (DECL_CONTEXT (vfield)), t);
+ }
+ else
+ {
+ /* This is our very own copy of `basetype' to play with.
+ Later, we will fill in all the virtual functions
+ that override the virtual functions in these base classes
+ which are not defined by the current type. */
+ if (! BINFO_NEW_VTABLE_MARKED (binfo))
+ prepare_fresh_vtable (binfo, t);
+ }
+
+#ifdef NOTQUITE
+ cp_warning ("in %D", DECL_NAME (BINFO_VTABLE (binfo)));
+#endif
+ modify_vtable_entry (get_vtable_entry_n (BINFO_VIRTUALS (binfo), n),
+ build_vtable_entry (this_offset, pfn),
+ fndecl);
+ }
+ ++n;
+ virtuals = TREE_CHAIN (virtuals);
+ }
+}
+
+/* These are the ones that are not through virtual base classes. */
+static void
+modify_all_direct_vtables (binfo, do_self, t, fndecl, pfn)
+ tree binfo, t, fndecl, pfn;
+ int do_self;
+{
+ tree binfos = BINFO_BASETYPES (binfo);
+ int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+
+ /* Should we use something besides CLASSTYPE_VFIELDS? */
+ if (do_self && CLASSTYPE_VFIELDS (BINFO_TYPE (binfo)))
+ {
+ modify_one_vtable (binfo, t, fndecl, pfn);
+ }
+
+ for (i = 0; i < n_baselinks; i++)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ int is_not_base_vtable =
+ i != CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (binfo));
+ if (! TREE_VIA_VIRTUAL (base_binfo))
+ modify_all_direct_vtables (base_binfo, is_not_base_vtable, t, fndecl, pfn);
+ }
+}
+
+/* Fixup all the delta entries in this one vtable that need updating. */
+static void
+fixup_vtable_deltas1 (binfo, t)
+ tree binfo, t;
+{
+ tree virtuals = BINFO_VIRTUALS (binfo);
+ unsigned HOST_WIDE_INT n;
+
+ n = skip_rtti_stuff (&virtuals);
+
+ while (virtuals)
+ {
+ tree fndecl = TREE_VALUE (virtuals);
+ tree pfn = FNADDR_FROM_VTABLE_ENTRY (fndecl);
+ tree delta = DELTA_FROM_VTABLE_ENTRY (fndecl);
+ fndecl = TREE_OPERAND (pfn, 0);
+ if (fndecl)
+ {
+ tree base_offset, offset;
+ tree context = DECL_CLASS_CONTEXT (fndecl);
+ tree vfield = CLASSTYPE_VFIELD (t);
+ tree this_offset;
+
+ offset = get_class_offset (context, t, binfo, fndecl);
+
+ /* Find the right offset for the this pointer based on the
+ base class we just found. We have to take into
+ consideration the virtual base class pointers that we
+ stick in before the virtual function table pointer.
+
+ Also, we want just the delta between the most base class
+ that we derived this vfield from and us. */
+ base_offset = size_binop (PLUS_EXPR,
+ get_derived_offset (binfo, DECL_CONTEXT (fndecl)),
+ BINFO_OFFSET (binfo));
+ this_offset = size_binop (MINUS_EXPR, offset, base_offset);
+
+ if (! tree_int_cst_equal (this_offset, delta))
+ {
+ /* Make sure we can modify the derived association with immunity. */
+ if (TREE_USED (binfo))
+ my_friendly_assert (0, 999);
+
+ if (binfo == TYPE_BINFO (t))
+ {
+ /* In this case, it is *type*'s vtable we are modifying.
+ We start with the approximation that it's vtable is that
+ of the immediate base class. */
+ if (! BINFO_NEW_VTABLE_MARKED (binfo))
+ build_vtable (TYPE_BINFO (DECL_CONTEXT (vfield)), t);
+ }
+ else
+ {
+ /* This is our very own copy of `basetype' to play with.
+ Later, we will fill in all the virtual functions
+ that override the virtual functions in these base classes
+ which are not defined by the current type. */
+ if (! BINFO_NEW_VTABLE_MARKED (binfo))
+ prepare_fresh_vtable (binfo, t);
+ }
+
+ modify_vtable_entry (get_vtable_entry_n (BINFO_VIRTUALS (binfo), n),
+ build_vtable_entry (this_offset, pfn),
+ fndecl);
+ }
+ }
+ ++n;
+ virtuals = TREE_CHAIN (virtuals);
+ }
+}
+
+/* Fixup all the delta entries in all the direct vtables that need updating.
+ This happens when we have non-overridden virtual functions from a
+ virtual base class, that are at a different offset, in the new
+ hierarchy, because the layout of the virtual bases has changed. */
+static void
+fixup_vtable_deltas (binfo, init_self, t)
+ tree binfo, t;
+ int init_self;
+{
+ tree binfos = BINFO_BASETYPES (binfo);
+ int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+
+ for (i = 0; i < n_baselinks; i++)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ int is_not_base_vtable =
+ i != CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (binfo));
+ if (! TREE_VIA_VIRTUAL (base_binfo))
+ fixup_vtable_deltas (base_binfo, is_not_base_vtable, t);
+ }
+ /* Should we use something besides CLASSTYPE_VFIELDS? */
+ if (init_self && CLASSTYPE_VFIELDS (BINFO_TYPE (binfo)))
+ {
+ fixup_vtable_deltas1 (binfo, t);
+ }
+}
+
+/* These are the ones that are through virtual base classes. */
+static void
+modify_all_indirect_vtables (binfo, do_self, via_virtual, t, fndecl, pfn)
+ tree binfo, t, fndecl, pfn;
+ int do_self, via_virtual;
+{
+ tree binfos = BINFO_BASETYPES (binfo);
+ int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+
+ /* Should we use something besides CLASSTYPE_VFIELDS? */
+ if (do_self && via_virtual && CLASSTYPE_VFIELDS (BINFO_TYPE (binfo)))
+ {
+ modify_one_vtable (binfo, t, fndecl, pfn);
+ }
+
+ for (i = 0; i < n_baselinks; i++)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ int is_not_base_vtable =
+ i != CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (binfo));
+ if (TREE_VIA_VIRTUAL (base_binfo))
+ {
+ via_virtual = 1;
+ base_binfo = binfo_member (BINFO_TYPE (base_binfo), CLASSTYPE_VBASECLASSES (t));
+ }
+ modify_all_indirect_vtables (base_binfo, is_not_base_vtable, via_virtual, t, fndecl, pfn);
+ }
+}
+
+static void
+modify_all_vtables (t, fndecl, vfn)
+ tree t, fndecl, vfn;
+{
+ /* Do these first, so that we will make use of any non-virtual class's
+ vtable, over a virtual classes vtable. */
+ modify_all_direct_vtables (TYPE_BINFO (t), 1, t, fndecl, vfn);
+ if (TYPE_USES_VIRTUAL_BASECLASSES (t))
+ modify_all_indirect_vtables (TYPE_BINFO (t), 1, 0, t, fndecl, vfn);
+}
+
+/* Here, we already know that they match in every respect.
+ All we have to check is where they had their declarations. */
+static int
+strictly_overrides (fndecl1, fndecl2)
+ tree fndecl1, fndecl2;
+{
+ int distance = get_base_distance (DECL_CLASS_CONTEXT (fndecl2),
+ DECL_CLASS_CONTEXT (fndecl1),
+ 0, (tree *)0);
+ if (distance == -2 || distance > 0)
+ return 1;
+ return 0;
+}
+
+/* Merge overrides for one vtable.
+ If we want to merge in same function, we are fine.
+ else
+ if one has a DECL_CLASS_CONTEXT that is a parent of the
+ other, than choose the more derived one
+ else
+ potentially ill-formed (see 10.3 [class.virtual])
+ we have to check later to see if there was an
+ override in this class. If there was ok, if not
+ then it is ill-formed. (mrs)
+
+ We take special care to reuse a vtable, if we can. */
+static void
+override_one_vtable (binfo, old, t)
+ tree binfo, old, t;
+{
+ tree virtuals = BINFO_VIRTUALS (binfo);
+ tree old_virtuals = BINFO_VIRTUALS (old);
+ enum { REUSE_NEW, REUSE_OLD, UNDECIDED, NEITHER } choose = UNDECIDED;
+
+ /* If we have already committed to modifying it, then don't try and
+ reuse another vtable. */
+ if (BINFO_NEW_VTABLE_MARKED (binfo))
+ choose = NEITHER;
+
+ skip_rtti_stuff (&virtuals);
+ skip_rtti_stuff (&old_virtuals);
+
+ while (virtuals)
+ {
+ tree fndecl = TREE_VALUE (virtuals);
+ tree old_fndecl = TREE_VALUE (old_virtuals);
+ fndecl = FNADDR_FROM_VTABLE_ENTRY (fndecl);
+ old_fndecl = FNADDR_FROM_VTABLE_ENTRY (old_fndecl);
+ fndecl = TREE_OPERAND (fndecl, 0);
+ old_fndecl = TREE_OPERAND (old_fndecl, 0);
+ /* First check to see if they are the same. */
+ if (DECL_ASSEMBLER_NAME (fndecl) == DECL_ASSEMBLER_NAME (old_fndecl))
+ {
+ /* No need to do anything. */
+ }
+ else if (strictly_overrides (fndecl, old_fndecl))
+ {
+ if (choose == UNDECIDED)
+ choose = REUSE_NEW;
+ else if (choose == REUSE_OLD)
+ {
+ choose = NEITHER;
+ if (! BINFO_NEW_VTABLE_MARKED (binfo))
+ {
+ prepare_fresh_vtable (binfo, t);
+ override_one_vtable (binfo, old, t);
+ return;
+ }
+ }
+ }
+ else if (strictly_overrides (old_fndecl, fndecl))
+ {
+ if (choose == UNDECIDED)
+ choose = REUSE_OLD;
+ else if (choose == REUSE_NEW)
+ {
+ choose = NEITHER;
+ if (! BINFO_NEW_VTABLE_MARKED (binfo))
+ {
+ prepare_fresh_vtable (binfo, t);
+ override_one_vtable (binfo, old, t);
+ return;
+ }
+ TREE_VALUE (virtuals) = TREE_VALUE (old_virtuals);
+ }
+ else if (choose == NEITHER)
+ {
+ TREE_VALUE (virtuals) = TREE_VALUE (old_virtuals);
+ }
+ }
+ else
+ {
+ choose = NEITHER;
+ if (! BINFO_NEW_VTABLE_MARKED (binfo))
+ {
+ prepare_fresh_vtable (binfo, t);
+ override_one_vtable (binfo, old, t);
+ return;
+ }
+ {
+ /* This MUST be overridden, or the class is ill-formed. */
+ /* For now, we just make it abstract. */
+ tree fndecl = TREE_OPERAND (FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (virtuals)), 0);
+ tree vfn;
+
+ fndecl = copy_node (fndecl);
+ copy_lang_decl (fndecl);
+ DECL_ABSTRACT_VIRTUAL_P (fndecl) = 1;
+ /* Make sure we search for it later. */
+ if (! CLASSTYPE_ABSTRACT_VIRTUALS (t))
+ CLASSTYPE_ABSTRACT_VIRTUALS (t) = error_mark_node;
+
+ vfn = build1 (ADDR_EXPR, vfunc_ptr_type_node, fndecl);
+ TREE_CONSTANT (vfn) = 1;
+
+ /* We can use integer_zero_node, as we will will core dump
+ if this is used anyway. */
+ TREE_VALUE (virtuals) = build_vtable_entry (integer_zero_node, vfn);
+ }
+ }
+ virtuals = TREE_CHAIN (virtuals);
+ old_virtuals = TREE_CHAIN (old_virtuals);
+ }
+
+ /* Let's reuse the old vtable. */
+ if (choose == REUSE_OLD)
+ {
+ BINFO_VTABLE (binfo) = BINFO_VTABLE (old);
+ BINFO_VIRTUALS (binfo) = BINFO_VIRTUALS (old);
+ }
+}
+
+/* Merge in overrides for virtual bases.
+ BINFO is the hierarchy we want to modify, and OLD has the potential
+ overrides. */
+static void
+merge_overrides (binfo, old, do_self, t)
+ tree binfo, old, t;
+ int do_self;
+{
+ tree binfos = BINFO_BASETYPES (binfo);
+ tree old_binfos = BINFO_BASETYPES (old);
+ int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+
+ /* Should we use something besides CLASSTYPE_VFIELDS? */
+ if (do_self && CLASSTYPE_VFIELDS (BINFO_TYPE (binfo)))
+ {
+ override_one_vtable (binfo, old, t);
+ }
+
+ for (i = 0; i < n_baselinks; i++)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ tree old_base_binfo = TREE_VEC_ELT (old_binfos, i);
+ int is_not_base_vtable =
+ i != CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (binfo));
+ if (! TREE_VIA_VIRTUAL (base_binfo))
+ merge_overrides (base_binfo, old_base_binfo, is_not_base_vtable, t);
+ }
+}
+
+extern int interface_only, interface_unknown;
+
+/* Create a RECORD_TYPE or UNION_TYPE node for a C struct or union declaration
+ (or C++ class declaration).
+
+ For C++, we must handle the building of derived classes.
+ Also, C++ allows static class members. The way that this is
+ handled is to keep the field name where it is (as the DECL_NAME
+ of the field), and place the overloaded decl in the DECL_FIELD_BITPOS
+ of the field. layout_record and layout_union will know about this.
+
+ More C++ hair: inline functions have text in their
+ DECL_PENDING_INLINE_INFO nodes which must somehow be parsed into
+ meaningful tree structure. After the struct has been laid out, set
+ things up so that this can happen.
+
+ And still more: virtual functions. In the case of single inheritance,
+ when a new virtual function is seen which redefines a virtual function
+ from the base class, the new virtual function is placed into
+ the virtual function table at exactly the same address that
+ it had in the base class. When this is extended to multiple
+ inheritance, the same thing happens, except that multiple virtual
+ function tables must be maintained. The first virtual function
+ table is treated in exactly the same way as in the case of single
+ inheritance. Additional virtual function tables have different
+ DELTAs, which tell how to adjust `this' to point to the right thing.
+
+ LIST_OF_FIELDLISTS is just that. The elements of the list are
+ TREE_LIST elements, whose TREE_PURPOSE field tells what access
+ the list has, and the TREE_VALUE slot gives the actual fields.
+
+ If flag_all_virtual == 1, then we lay all functions into
+ the virtual function table, as though they were declared
+ virtual. Constructors do not lay down in the virtual function table.
+
+ If flag_all_virtual == 2, then we lay all functions into
+ the virtual function table, such that virtual functions
+ occupy a space by themselves, and then all functions
+ of the class occupy a space by themselves. This is illustrated
+ in the following diagram:
+
+ class A; class B : A;
+
+ Class A's vtbl: Class B's vtbl:
+ --------------------------------------------------------------------
+ | A's virtual functions| | B's virtual functions |
+ | | | (may inherit some from A). |
+ --------------------------------------------------------------------
+ | All of A's functions | | All of A's functions |
+ | (such as a->A::f). | | (such as b->A::f) |
+ --------------------------------------------------------------------
+ | B's new virtual functions |
+ | (not defined in A.) |
+ -------------------------------
+ | All of B's functions |
+ | (such as b->B::f) |
+ -------------------------------
+
+ this allows the program to make references to any function, virtual
+ or otherwise in a type-consistent manner. */
+
+tree
+finish_struct_1 (t, warn_anon)
+ tree t;
+ int warn_anon;
+{
+ int old;
+ int round_up_size = 1;
+
+ tree name = TYPE_IDENTIFIER (t);
+ enum tree_code code = TREE_CODE (t);
+ tree fields = TYPE_FIELDS (t);
+ tree fn_fields = CLASSTYPE_METHODS (t);
+ tree x, last_x, method_vec;
+ int needs_virtual_dtor;
+ int all_virtual;
+ int has_virtual;
+ int max_has_virtual;
+ tree pending_virtuals = NULL_TREE;
+ tree abstract_virtuals = NULL_TREE;
+ tree vfield;
+ tree vfields;
+ int cant_have_default_ctor;
+ int cant_have_const_ctor;
+ int cant_synth_copy_ctor;
+ int cant_synth_asn_ref;
+ int no_const_asn_ref;
+
+ /* The index of the first base class which has virtual
+ functions. Only applied to non-virtual baseclasses. */
+ int first_vfn_base_index;
+
+ int n_baseclasses;
+ int any_default_members = 0;
+ int const_sans_init = 0;
+ int ref_sans_init = 0;
+ int nonprivate_method = 0;
+ tree t_binfo = TYPE_BINFO (t);
+ tree access_decls = NULL_TREE;
+ int aggregate = 1;
+
+ if (warn_anon && code != UNION_TYPE && ANON_AGGRNAME_P (TYPE_IDENTIFIER (t)))
+ pedwarn ("anonymous class type not used to declare any objects");
+
+ if (TYPE_SIZE (t))
+ {
+ if (IS_AGGR_TYPE (t))
+ cp_error ("redefinition of `%#T'", t);
+ else
+ my_friendly_abort (172);
+ popclass (0);
+ return t;
+ }
+
+ if (dont_allow_type_definitions)
+ {
+ pedwarn ("types cannot be defined %s",
+ dont_allow_type_definitions);
+ }
+
+ GNU_xref_decl (current_function_decl, t);
+
+ /* If this type was previously laid out as a forward reference,
+ make sure we lay it out again. */
+
+ TYPE_SIZE (t) = NULL_TREE;
+ CLASSTYPE_GOT_SEMICOLON (t) = 0;
+
+#if 0
+ /* This is in general too late to do this. I moved the main case up to
+ left_curly, what else needs to move? */
+ if (! IS_SIGNATURE (t))
+ {
+ my_friendly_assert (CLASSTYPE_INTERFACE_ONLY (t) == interface_only, 999);
+ my_friendly_assert (CLASSTYPE_INTERFACE_KNOWN (t) == ! interface_unknown, 999);
+ }
+#endif
+
+#if 0
+ if (flag_rtti)
+ build_t_desc (t, 0);
+#endif
+
+ TYPE_BINFO (t) = NULL_TREE;
+
+ old = suspend_momentary ();
+
+ /* Install struct as DECL_FIELD_CONTEXT of each field decl.
+ Also process specified field sizes.
+ Set DECL_FIELD_SIZE to the specified size, or 0 if none specified.
+ The specified size is found in the DECL_INITIAL.
+ Store 0 there, except for ": 0" fields (so we can find them
+ and delete them, below). */
+
+ if (t_binfo && BINFO_BASETYPES (t_binfo))
+ n_baseclasses = TREE_VEC_LENGTH (BINFO_BASETYPES (t_binfo));
+ else
+ n_baseclasses = 0;
+
+ if (n_baseclasses > 0)
+ {
+ struct base_info base_info;
+
+ /* If using multiple inheritance, this may cause variants of our
+ basetypes to be used (instead of their canonical forms). */
+ tree vf = layout_basetypes (t, BINFO_BASETYPES (t_binfo));
+ last_x = tree_last (vf);
+ fields = chainon (vf, fields);
+
+ first_vfn_base_index = finish_base_struct (t, &base_info, t_binfo);
+ /* Remember where we got our vfield from */
+ CLASSTYPE_VFIELD_PARENT (t) = first_vfn_base_index;
+ has_virtual = base_info.has_virtual;
+ max_has_virtual = base_info.max_has_virtual;
+ CLASSTYPE_N_SUPERCLASSES (t) += base_info.n_ancestors;
+ vfield = base_info.vfield;
+ vfields = base_info.vfields;
+ cant_have_default_ctor = base_info.cant_have_default_ctor;
+ cant_have_const_ctor = base_info.cant_have_const_ctor;
+ cant_synth_copy_ctor = base_info.cant_synth_copy_ctor;
+ cant_synth_asn_ref = base_info.cant_synth_asn_ref;
+ no_const_asn_ref = base_info.no_const_asn_ref;
+ needs_virtual_dtor = base_info.needs_virtual_dtor;
+ n_baseclasses = TREE_VEC_LENGTH (BINFO_BASETYPES (t_binfo));
+ aggregate = 0;
+ }
+ else
+ {
+ first_vfn_base_index = -1;
+ has_virtual = 0;
+ max_has_virtual = has_virtual;
+ vfield = NULL_TREE;
+ vfields = NULL_TREE;
+ last_x = NULL_TREE;
+ cant_have_default_ctor = 0;
+ cant_have_const_ctor = 0;
+ cant_synth_copy_ctor = 0;
+ cant_synth_asn_ref = 0;
+ no_const_asn_ref = 0;
+ needs_virtual_dtor = 0;
+ }
+
+#if 0
+ /* Both of these should be done before now. */
+ if (write_virtuals == 3 && CLASSTYPE_INTERFACE_KNOWN (t)
+ && ! IS_SIGNATURE (t))
+ {
+ my_friendly_assert (CLASSTYPE_INTERFACE_ONLY (t) == interface_only, 999);
+ my_friendly_assert (CLASSTYPE_VTABLE_NEEDS_WRITING (t) == ! interface_only, 999);
+ }
+#endif
+
+ /* The three of these are approximations which may later be
+ modified. Needed at this point to make add_virtual_function
+ and modify_vtable_entries work. */
+ TREE_CHAIN (t_binfo) = TYPE_BINFO (t);
+ TYPE_BINFO (t) = t_binfo;
+ CLASSTYPE_VFIELDS (t) = vfields;
+ CLASSTYPE_VFIELD (t) = vfield;
+
+ if (IS_SIGNATURE (t))
+ all_virtual = 0;
+ else if (flag_all_virtual == 1 && TYPE_OVERLOADS_METHOD_CALL_EXPR (t))
+ all_virtual = 1;
+ else
+ all_virtual = 0;
+
+ for (x = CLASSTYPE_METHODS (t); x; x = TREE_CHAIN (x))
+ {
+ GNU_xref_member (current_class_name, x);
+
+ nonprivate_method |= ! TREE_PRIVATE (x);
+
+ /* If this was an evil function, don't keep it in class. */
+ if (IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (x)))
+ continue;
+
+ DECL_CLASS_CONTEXT (x) = t;
+
+ /* Do both of these, even though they're in the same union;
+ if the insn `r' member and the size `i' member are
+ different sizes, as on the alpha, the larger of the two
+ will end up with garbage in it. */
+ DECL_SAVED_INSNS (x) = NULL_RTX;
+ DECL_FIELD_SIZE (x) = 0;
+
+ /* The name of the field is the original field name
+ Save this in auxiliary field for later overloading. */
+ if (DECL_VINDEX (x)
+ || (all_virtual == 1 && ! DECL_CONSTRUCTOR_P (x)))
+ {
+ pending_virtuals = add_virtual_function (pending_virtuals,
+ &has_virtual, x, t);
+ if (DECL_ABSTRACT_VIRTUAL_P (x))
+ abstract_virtuals = tree_cons (NULL_TREE, x, abstract_virtuals);
+ else
+ TREE_USED (x) = 1;
+ }
+ }
+
+ for (x = TYPE_FIELDS (t); x; x = TREE_CHAIN (x))
+ {
+ GNU_xref_member (current_class_name, x);
+
+ /* Handle access declarations. */
+ if (DECL_NAME (x) && TREE_CODE (DECL_NAME (x)) == SCOPE_REF)
+ {
+ tree fdecl = TREE_OPERAND (DECL_NAME (x), 1);
+ enum access_type access
+ = TREE_PRIVATE (x) ? access_private :
+ TREE_PROTECTED (x) ? access_protected : access_public;
+
+ if (last_x)
+ TREE_CHAIN (last_x) = TREE_CHAIN (x);
+ else
+ fields = TREE_CHAIN (x);
+
+ access_decls = tree_cons ((tree) access, fdecl, access_decls);
+ continue;
+ }
+
+ last_x = x;
+
+ if (TREE_CODE (x) == TYPE_DECL)
+ continue;
+
+ /* If we've gotten this far, it's a data member, possibly static,
+ or an enumerator. */
+
+ DECL_FIELD_CONTEXT (x) = t;
+
+ /* ``A local class cannot have static data members.'' ARM 9.4 */
+ if (current_function_decl && TREE_STATIC (x))
+ cp_error_at ("field `%D' in local class cannot be static", x);
+
+ /* Perform error checking that did not get done in
+ grokdeclarator. */
+ if (TREE_CODE (TREE_TYPE (x)) == FUNCTION_TYPE)
+ {
+ cp_error_at ("field `%D' invalidly declared function type",
+ x);
+ TREE_TYPE (x) = build_pointer_type (TREE_TYPE (x));
+ }
+ else if (TREE_CODE (TREE_TYPE (x)) == METHOD_TYPE)
+ {
+ cp_error_at ("field `%D' invalidly declared method type", x);
+ TREE_TYPE (x) = build_pointer_type (TREE_TYPE (x));
+ }
+ else if (TREE_CODE (TREE_TYPE (x)) == OFFSET_TYPE)
+ {
+ cp_error_at ("field `%D' invalidly declared offset type", x);
+ TREE_TYPE (x) = build_pointer_type (TREE_TYPE (x));
+ }
+
+#if 0
+ if (DECL_NAME (x) == constructor_name (t))
+ cant_have_default_ctor = cant_synth_copy_ctor = 1;
+#endif
+
+ if (TREE_TYPE (x) == error_mark_node)
+ continue;
+
+ DECL_SAVED_INSNS (x) = NULL_RTX;
+ DECL_FIELD_SIZE (x) = 0;
+
+ /* When this goes into scope, it will be a non-local reference. */
+ DECL_NONLOCAL (x) = 1;
+
+ if (TREE_CODE (x) == CONST_DECL)
+ continue;
+
+ if (TREE_CODE (x) == VAR_DECL)
+ {
+ if (TREE_CODE (t) == UNION_TYPE)
+ /* Unions cannot have static members. */
+ cp_error_at ("field `%D' declared static in union", x);
+
+ continue;
+ }
+
+ /* Now it can only be a FIELD_DECL. */
+
+ if (TREE_PRIVATE (x) || TREE_PROTECTED (x))
+ aggregate = 0;
+
+ /* If this is of reference type, check if it needs an init.
+ Also do a little ANSI jig if necessary. */
+ if (TREE_CODE (TREE_TYPE (x)) == REFERENCE_TYPE)
+ {
+ if (DECL_INITIAL (x) == NULL_TREE)
+ ref_sans_init = 1;
+
+ /* ARM $12.6.2: [A member initializer list] (or, for an
+ aggregate, initialization by a brace-enclosed list) is the
+ only way to initialize nonstatic const and reference
+ members. */
+ cant_synth_asn_ref = 1;
+ cant_have_default_ctor = 1;
+
+ if (! TYPE_HAS_CONSTRUCTOR (t) && extra_warnings)
+ {
+ if (DECL_NAME (x))
+ cp_warning_at ("non-static reference `%#D' in class without a constructor", x);
+ else
+ cp_warning_at ("non-static reference in class without a constructor", x);
+ }
+ }
+
+ /* If any field is const, the structure type is pseudo-const. */
+ if (TREE_READONLY (x))
+ {
+ C_TYPE_FIELDS_READONLY (t) = 1;
+ if (DECL_INITIAL (x) == NULL_TREE)
+ const_sans_init = 1;
+
+ /* ARM $12.6.2: [A member initializer list] (or, for an
+ aggregate, initialization by a brace-enclosed list) is the
+ only way to initialize nonstatic const and reference
+ members. */
+ cant_synth_asn_ref = 1;
+ cant_have_default_ctor = 1;
+
+ if (! TYPE_HAS_CONSTRUCTOR (t) && !IS_SIGNATURE (t)
+ && extra_warnings)
+ {
+ if (DECL_NAME (x))
+ cp_warning_at ("non-static const member `%#D' in class without a constructor", x);
+ else
+ cp_warning_at ("non-static const member in class without a constructor", x);
+ }
+ }
+ else
+ {
+ /* A field that is pseudo-const makes the structure
+ likewise. */
+ tree t1 = TREE_TYPE (x);
+ while (TREE_CODE (t1) == ARRAY_TYPE)
+ t1 = TREE_TYPE (t1);
+ if (IS_AGGR_TYPE (t1))
+ {
+ if (C_TYPE_FIELDS_READONLY (t1))
+ C_TYPE_FIELDS_READONLY (t) = 1;
+ if (CLASSTYPE_READONLY_FIELDS_NEED_INIT (t1))
+ const_sans_init = 1;
+ }
+ }
+
+ /* We set DECL_BIT_FIELD tentatively in grokbitfield.
+ If the type and width are valid, we'll keep it set.
+ Otherwise, the flag is cleared. */
+ if (DECL_BIT_FIELD (x))
+ {
+ DECL_BIT_FIELD (x) = 0;
+ /* Invalid bit-field size done by grokfield. */
+ /* Detect invalid bit-field type. */
+ if (DECL_INITIAL (x)
+ && ! INTEGRAL_TYPE_P (TREE_TYPE (x)))
+ {
+ cp_error_at ("bit-field `%#D' with non-integral type", x);
+ DECL_INITIAL (x) = NULL;
+ }
+
+ /* Detect and ignore out of range field width. */
+ if (DECL_INITIAL (x))
+ {
+ register int width = TREE_INT_CST_LOW (DECL_INITIAL (x));
+
+ if (width < 0)
+ {
+ DECL_INITIAL (x) = NULL;
+ cp_error_at ("negative width in bit-field `%D'", x);
+ }
+ else if (width == 0 && DECL_NAME (x) != 0)
+ {
+ DECL_INITIAL (x) = NULL;
+ cp_error_at ("zero width for bit-field `%D'", x);
+ }
+ else if (width
+ > TYPE_PRECISION (long_long_unsigned_type_node))
+ {
+ /* The backend will dump if you try to use something
+ too big; avoid that. */
+ DECL_INITIAL (x) = NULL;
+ sorry ("bit-fields larger than %d bits",
+ TYPE_PRECISION (long_long_unsigned_type_node));
+ cp_error_at (" in declaration of `%D'", x);
+ }
+ else if (width > TYPE_PRECISION (TREE_TYPE (x))
+ && TREE_CODE (TREE_TYPE (x)) != ENUMERAL_TYPE)
+ {
+ cp_warning_at ("width of `%D' exceeds its type", x);
+ }
+ else if (TREE_CODE (TREE_TYPE (x)) == ENUMERAL_TYPE
+ && ((min_precision (TYPE_MIN_VALUE (TREE_TYPE (x)),
+ TREE_UNSIGNED (TREE_TYPE (x))) > width)
+ || (min_precision (TYPE_MAX_VALUE (TREE_TYPE (x)),
+ TREE_UNSIGNED (TREE_TYPE (x))) > width)))
+ {
+ cp_warning_at ("`%D' is too small to hold all values of `%#T'",
+ x, TREE_TYPE (x));
+ }
+ }
+
+ /* Process valid field width. */
+ if (DECL_INITIAL (x))
+ {
+ register int width = TREE_INT_CST_LOW (DECL_INITIAL (x));
+
+ if (width == 0)
+ {
+#ifdef EMPTY_FIELD_BOUNDARY
+ /* field size 0 => mark following field as "aligned" */
+ if (TREE_CHAIN (x))
+ DECL_ALIGN (TREE_CHAIN (x))
+ = MAX (DECL_ALIGN (TREE_CHAIN (x)), EMPTY_FIELD_BOUNDARY);
+ /* field of size 0 at the end => round up the size. */
+ else
+ round_up_size = EMPTY_FIELD_BOUNDARY;
+#endif
+#ifdef PCC_BITFIELD_TYPE_MATTERS
+ DECL_ALIGN (x) = MAX (DECL_ALIGN (x),
+ TYPE_ALIGN (TREE_TYPE (x)));
+#endif
+ }
+ else
+ {
+ DECL_INITIAL (x) = NULL_TREE;
+ DECL_FIELD_SIZE (x) = width;
+ DECL_BIT_FIELD (x) = 1;
+ /* Traditionally a bit field is unsigned
+ even if declared signed. */
+ if (flag_traditional
+ && TREE_CODE (TREE_TYPE (x)) == INTEGER_TYPE)
+ TREE_TYPE (x) = unsigned_type_node;
+ }
+ }
+ else
+ /* Non-bit-fields are aligned for their type. */
+ DECL_ALIGN (x) = MAX (DECL_ALIGN (x), TYPE_ALIGN (TREE_TYPE (x)));
+ }
+ else
+ {
+ tree type = TREE_TYPE (x);
+
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ type = TREE_TYPE (type);
+
+ if (TYPE_LANG_SPECIFIC (type) && ! ANON_UNION_P (x)
+ && ! TYPE_PTRMEMFUNC_P (type))
+ {
+ /* Never let anything with uninheritable virtuals
+ make it through without complaint. */
+ if (CLASSTYPE_ABSTRACT_VIRTUALS (type))
+ abstract_virtuals_error (x, type);
+
+ /* Don't let signatures make it through either. */
+ if (IS_SIGNATURE (type))
+ signature_error (x, type);
+
+ if (code == UNION_TYPE)
+ {
+ char *fie = NULL;
+ if (TYPE_NEEDS_CONSTRUCTING (type))
+ fie = "constructor";
+ else if (TYPE_NEEDS_DESTRUCTOR (type))
+ fie = "destructor";
+ else if (TYPE_HAS_REAL_ASSIGNMENT (type))
+ fie = "assignment operator";
+ if (fie)
+ cp_error_at ("member `%#D' with %s not allowed in union", x,
+ fie);
+ }
+ else
+ {
+ TYPE_NEEDS_CONSTRUCTING (t) |= TYPE_NEEDS_CONSTRUCTING (type);
+ TYPE_NEEDS_DESTRUCTOR (t) |= TYPE_NEEDS_DESTRUCTOR (type);
+ TYPE_HAS_COMPLEX_ASSIGN_REF (t) |= TYPE_HAS_COMPLEX_ASSIGN_REF (type);
+ TYPE_HAS_COMPLEX_INIT_REF (t) |= TYPE_HAS_COMPLEX_INIT_REF (type);
+ }
+
+ if (! TYPE_HAS_INIT_REF (type)
+ || (TYPE_HAS_NONPUBLIC_CTOR (type)
+ && ! is_friend (t, type)))
+ cant_synth_copy_ctor = 1;
+ else if (!TYPE_HAS_CONST_INIT_REF (type))
+ cant_have_const_ctor = 1;
+
+ if (! TYPE_HAS_ASSIGN_REF (type)
+ || (TYPE_HAS_NONPUBLIC_ASSIGN_REF (type)
+ && ! is_friend (t, type)))
+ cant_synth_asn_ref = 1;
+ else if (!TYPE_HAS_CONST_ASSIGN_REF (type))
+ no_const_asn_ref = 1;
+
+ if (TYPE_HAS_CONSTRUCTOR (type)
+ && ! TYPE_HAS_DEFAULT_CONSTRUCTOR (type))
+ {
+ cant_have_default_ctor = 1;
+#if 0
+ /* This is wrong for aggregates. */
+ if (! TYPE_HAS_CONSTRUCTOR (t))
+ {
+ if (DECL_NAME (x))
+ cp_pedwarn_at ("member `%#D' with only non-default constructor", x);
+ else
+ cp_pedwarn_at ("member with only non-default constructor", x);
+ cp_pedwarn_at ("in class without a constructor",
+ x);
+ }
+#endif
+ }
+ }
+ if (DECL_INITIAL (x) != NULL_TREE)
+ {
+ /* `build_class_init_list' does not recognize
+ non-FIELD_DECLs. */
+ if (code == UNION_TYPE && any_default_members != 0)
+ cp_error_at ("multiple fields in union `%T' initialized");
+ any_default_members = 1;
+ }
+ }
+ }
+
+ /* If this type has any constant members which did not come
+ with their own initialization, mark that fact here. It is
+ not an error here, since such types can be saved either by their
+ constructors, or by fortuitous initialization. */
+ CLASSTYPE_READONLY_FIELDS_NEED_INIT (t) = const_sans_init;
+ CLASSTYPE_REF_FIELDS_NEED_INIT (t) = ref_sans_init;
+ CLASSTYPE_ABSTRACT_VIRTUALS (t) = abstract_virtuals;
+
+ /* Synthesize any needed methods. Note that methods will be synthesized
+ for anonymous unions; grok_x_components undoes that. */
+
+ if (! fn_fields)
+ nonprivate_method = 1;
+
+ if (TYPE_NEEDS_DESTRUCTOR (t) && !TYPE_HAS_DESTRUCTOR (t)
+ && !IS_SIGNATURE (t))
+ {
+ /* Here we must cons up a destructor on the fly. */
+ tree dtor = cons_up_default_function (t, name, needs_virtual_dtor != 0);
+
+ /* If we couldn't make it work, then pretend we didn't need it. */
+ if (dtor == void_type_node)
+ TYPE_NEEDS_DESTRUCTOR (t) = 0;
+ else
+ {
+ /* Link dtor onto end of fn_fields. */
+
+ TREE_CHAIN (dtor) = fn_fields;
+ fn_fields = dtor;
+
+ if (DECL_VINDEX (dtor) == NULL_TREE
+ && (needs_virtual_dtor
+ || pending_virtuals != NULL_TREE
+ || pending_hard_virtuals != NULL_TREE))
+ DECL_VINDEX (dtor) = error_mark_node;
+ if (DECL_VINDEX (dtor))
+ pending_virtuals = add_virtual_function (pending_virtuals,
+ &has_virtual, dtor, t);
+ nonprivate_method = 1;
+ }
+ }
+
+ TYPE_NEEDS_DESTRUCTOR (t) |= TYPE_HAS_DESTRUCTOR (t);
+ if (flag_rtti && (max_has_virtual > 0 || needs_virtual_dtor) &&
+ has_virtual == 0)
+ has_virtual = 1;
+
+ TYPE_HAS_COMPLEX_INIT_REF (t)
+ |= (TYPE_HAS_INIT_REF (t) || TYPE_USES_VIRTUAL_BASECLASSES (t)
+ || any_default_members);
+ TYPE_NEEDS_CONSTRUCTING (t)
+ |= (TYPE_HAS_CONSTRUCTOR (t) || TYPE_USES_VIRTUAL_BASECLASSES (t)
+ || has_virtual || any_default_members || first_vfn_base_index >= 0);
+ if (! IS_SIGNATURE (t))
+ CLASSTYPE_NON_AGGREGATE (t)
+ = ! aggregate || has_virtual || TYPE_HAS_CONSTRUCTOR (t);
+
+ /* ARM $12.1: A default constructor will be generated for a class X
+ only if no constructor has been declared for class X. So we
+ check TYPE_HAS_CONSTRUCTOR also, to make sure we don't generate
+ one if they declared a constructor in this class. */
+ if (! TYPE_HAS_CONSTRUCTOR (t) && ! cant_have_default_ctor
+ && ! IS_SIGNATURE (t))
+ {
+ tree default_fn = cons_up_default_function (t, name, 2);
+ TREE_CHAIN (default_fn) = fn_fields;
+ fn_fields = default_fn;
+ }
+
+ /* Create default copy constructor, if needed. */
+ if (! TYPE_HAS_INIT_REF (t) && ! cant_synth_copy_ctor
+ && ! IS_SIGNATURE (t))
+ {
+ /* ARM 12.18: You get either X(X&) or X(const X&), but
+ not both. --Chip */
+ tree default_fn = cons_up_default_function (t, name,
+ 3 + cant_have_const_ctor);
+ TREE_CHAIN (default_fn) = fn_fields;
+ fn_fields = default_fn;
+ }
+
+ TYPE_HAS_REAL_ASSIGNMENT (t) |= TYPE_HAS_ASSIGNMENT (t);
+ TYPE_HAS_REAL_ASSIGN_REF (t) |= TYPE_HAS_ASSIGN_REF (t);
+ TYPE_HAS_COMPLEX_ASSIGN_REF (t)
+ |= TYPE_HAS_ASSIGN_REF (t) || TYPE_USES_VIRTUAL_BASECLASSES (t);
+
+ if (! TYPE_HAS_ASSIGN_REF (t) && ! cant_synth_asn_ref
+ && ! IS_SIGNATURE (t))
+ {
+ tree default_fn = cons_up_default_function (t, name,
+ 5 + no_const_asn_ref);
+ TREE_CHAIN (default_fn) = fn_fields;
+ fn_fields = default_fn;
+ }
+
+ if (fn_fields)
+ {
+ method_vec = finish_struct_methods (t, fn_fields, nonprivate_method);
+
+ if (TYPE_HAS_CONSTRUCTOR (t)
+ && CLASSTYPE_FRIEND_CLASSES (t) == NULL_TREE
+ && DECL_FRIENDLIST (TYPE_NAME (t)) == NULL_TREE)
+ {
+ int nonprivate_ctor = 0;
+ tree ctor;
+
+ for (ctor = TREE_VEC_ELT (method_vec, 0);
+ ctor;
+ ctor = DECL_CHAIN (ctor))
+ if (! TREE_PRIVATE (ctor))
+ {
+ nonprivate_ctor = 1;
+ break;
+ }
+
+ if (nonprivate_ctor == 0 && warn_ctor_dtor_privacy)
+ cp_warning ("`%#T' only defines private constructors and has no friends",
+ t);
+ }
+ }
+ else
+ {
+ method_vec = 0;
+
+ /* Just in case these got accidentally
+ filled in by syntax errors. */
+ TYPE_HAS_CONSTRUCTOR (t) = 0;
+ TYPE_HAS_DESTRUCTOR (t) = 0;
+ }
+
+ {
+ int n_methods = method_vec ? TREE_VEC_LENGTH (method_vec) : 0;
+
+ for (access_decls = nreverse (access_decls); access_decls;
+ access_decls = TREE_CHAIN (access_decls))
+ {
+ tree fdecl = TREE_VALUE (access_decls);
+ tree flist = NULL_TREE;
+ tree name;
+ enum access_type access = (enum access_type)TREE_PURPOSE(access_decls);
+ int i = TREE_VEC_ELT (method_vec, 0) ? 0 : 1;
+ tree tmp;
+
+ if (TREE_CODE (fdecl) == TREE_LIST)
+ {
+ flist = fdecl;
+ fdecl = TREE_VALUE (flist);
+ }
+
+ name = DECL_NAME (fdecl);
+
+ for (; i < n_methods; i++)
+ if (DECL_NAME (TREE_VEC_ELT (method_vec, i)) == name)
+ {
+ cp_error ("cannot adjust access to `%#D' in `%#T'", fdecl, t);
+ cp_error_at (" because of local method `%#D' with same name",
+ TREE_VEC_ELT (method_vec, i));
+ fdecl = NULL_TREE;
+ break;
+ }
+
+ if (! fdecl)
+ continue;
+
+ for (tmp = fields; tmp; tmp = TREE_CHAIN (tmp))
+ if (DECL_NAME (tmp) == name)
+ {
+ cp_error ("cannot adjust access to `%#D' in `%#T'", fdecl, t);
+ cp_error_at (" because of local field `%#D' with same name", tmp);
+ fdecl = NULL_TREE;
+ break;
+ }
+
+ if (!fdecl)
+ continue;
+
+ /* Make type T see field decl FDECL with access ACCESS.*/
+ if (flist)
+ {
+ fdecl = TREE_VALUE (flist);
+ while (fdecl)
+ {
+ if (alter_access (t, fdecl, access) == 0)
+ break;
+ fdecl = DECL_CHAIN (fdecl);
+ }
+ }
+ else
+ alter_access (t, fdecl, access);
+ }
+
+ }
+
+ if (vfield == NULL_TREE && has_virtual)
+ {
+ /* We build this decl with ptr_type_node, and
+ change the type when we know what it should be. */
+ vfield = build_lang_field_decl (FIELD_DECL, get_vfield_name (t),
+ ptr_type_node);
+ /* If you change any of the below, take a look at all the
+ other VFIELD_BASEs and VTABLE_BASEs in the code, and change
+ them too. */
+ DECL_ASSEMBLER_NAME (vfield) = get_identifier (VFIELD_BASE);
+ CLASSTYPE_VFIELD (t) = vfield;
+ DECL_VIRTUAL_P (vfield) = 1;
+ DECL_FIELD_CONTEXT (vfield) = t;
+ DECL_CLASS_CONTEXT (vfield) = t;
+ DECL_FCONTEXT (vfield) = t;
+ DECL_SAVED_INSNS (vfield) = NULL_RTX;
+ DECL_FIELD_SIZE (vfield) = 0;
+ DECL_ALIGN (vfield) = TYPE_ALIGN (ptr_type_node);
+ if (CLASSTYPE_RTTI (t))
+ {
+ /* vfield is always first entry in structure. */
+ TREE_CHAIN (vfield) = fields;
+ fields = vfield;
+ }
+ else if (last_x)
+ {
+ my_friendly_assert (TREE_CHAIN (last_x) == NULL_TREE, 175);
+ TREE_CHAIN (last_x) = vfield;
+ last_x = vfield;
+ }
+ else
+ fields = vfield;
+ vfields = chainon (vfields, CLASSTYPE_AS_LIST (t));
+ }
+
+ /* Now DECL_INITIAL is null on all members except for zero-width bit-fields.
+ And they have already done their work.
+
+ C++: maybe we will support default field initialization some day... */
+
+ /* Delete all zero-width bit-fields from the front of the fieldlist */
+ while (fields && DECL_BIT_FIELD (fields)
+ && DECL_INITIAL (fields))
+ fields = TREE_CHAIN (fields);
+ /* Delete all such fields from the rest of the fields. */
+ for (x = fields; x;)
+ {
+ if (TREE_CHAIN (x) && DECL_BIT_FIELD (TREE_CHAIN (x))
+ && DECL_INITIAL (TREE_CHAIN (x)))
+ TREE_CHAIN (x) = TREE_CHAIN (TREE_CHAIN (x));
+ else
+ x = TREE_CHAIN (x);
+ }
+ /* Delete all duplicate fields from the fields */
+ delete_duplicate_fields (fields);
+
+ /* Catch function/field name conflict. We don't need to do this for a
+ signature, since it can only contain the fields constructed in
+ append_signature_fields. */
+ if (! IS_SIGNATURE (t))
+ {
+ int n_methods = method_vec ? TREE_VEC_LENGTH (method_vec) : 0;
+ for (x = fields; x; x = TREE_CHAIN (x))
+ {
+ tree name = DECL_NAME (x);
+ int i = /*TREE_VEC_ELT (method_vec, 0) ? 0 : */ 1;
+ for (; i < n_methods; ++i)
+ if (DECL_NAME (TREE_VEC_ELT (method_vec, i)) == name)
+ {
+ cp_error_at ("data member `%#D' conflicts with", x);
+ cp_error_at ("function member `%#D'",
+ TREE_VEC_ELT (method_vec, i));
+ break;
+ }
+ }
+ }
+
+ /* Now we have the final fieldlist for the data fields. Record it,
+ then lay out the structure or union (including the fields). */
+
+ TYPE_FIELDS (t) = fields;
+
+ /* If there's a :0 field at the end, round the size to the
+ EMPTY_FIELD_BOUNDARY. */
+ TYPE_ALIGN (t) = round_up_size;
+
+ /* Pass layout information about base classes to layout_type, if any. */
+ if (n_baseclasses)
+ {
+ tree pseudo_basetype = TREE_TYPE (base_layout_decl);
+
+ TREE_CHAIN (base_layout_decl) = TYPE_FIELDS (t);
+ TYPE_FIELDS (t) = base_layout_decl;
+
+ TYPE_SIZE (pseudo_basetype) = CLASSTYPE_SIZE (t);
+ TYPE_MODE (pseudo_basetype) = TYPE_MODE (t);
+ TYPE_ALIGN (pseudo_basetype) = CLASSTYPE_ALIGN (t);
+ DECL_ALIGN (base_layout_decl) = TYPE_ALIGN (pseudo_basetype);
+ /* Don't re-use old size. */
+ DECL_SIZE (base_layout_decl) = NULL_TREE;
+ }
+
+ layout_type (t);
+
+ {
+ tree field;
+ for (field = TYPE_FIELDS (t); field; field = TREE_CHAIN (field))
+ {
+ if (TREE_STATIC (field))
+ continue;
+ if (TREE_CODE (field) != FIELD_DECL)
+ continue;
+
+ /* If this field is an anonymous union,
+ give each union-member the same position as the union has.
+
+ ??? This is a real kludge because it makes the structure
+ of the types look strange. This feature is only used by
+ C++, which should have build_component_ref build two
+ COMPONENT_REF operations, one for the union and one for
+ the inner field. We set the offset of this field to zero
+ so that either the old or the correct method will work.
+ Setting DECL_FIELD_CONTEXT is wrong unless the inner fields are
+ moved into the type of this field, but nothing seems to break
+ by doing this. */
+
+ if (DECL_NAME (field) == NULL_TREE
+ && TREE_CODE (TREE_TYPE (field)) == UNION_TYPE)
+ {
+ tree uelt = TYPE_FIELDS (TREE_TYPE (field));
+ for (; uelt; uelt = TREE_CHAIN (uelt))
+ {
+ if (TREE_CODE (uelt) != FIELD_DECL)
+ continue;
+
+ if (TREE_PRIVATE (uelt))
+ cp_pedwarn_at ("private member `%#D' in anonymous union",
+ uelt);
+ else if (TREE_PROTECTED (uelt))
+ cp_pedwarn_at ("protected member `%#D' in anonymous union",
+ uelt);
+
+ DECL_FIELD_CONTEXT (uelt) = DECL_FIELD_CONTEXT (field);
+ DECL_FIELD_BITPOS (uelt) = DECL_FIELD_BITPOS (field);
+ }
+
+ DECL_FIELD_BITPOS (field) = integer_zero_node;
+ }
+ }
+ }
+
+ if (n_baseclasses)
+ TYPE_FIELDS (t) = TREE_CHAIN (TYPE_FIELDS (t));
+
+ /* C++: do not let empty structures exist. */
+ if (integer_zerop (TYPE_SIZE (t)))
+ TYPE_SIZE (t) = TYPE_SIZE (char_type_node);
+
+ /* Set the TYPE_DECL for this type to contain the right
+ value for DECL_OFFSET, so that we can use it as part
+ of a COMPONENT_REF for multiple inheritance. */
+
+ if (TREE_CODE (TYPE_NAME (t)) == TYPE_DECL)
+ layout_decl (TYPE_NAME (t), 0);
+
+ /* Now fix up any virtual base class types that we left lying
+ around. We must get these done before we try to lay out the
+ virtual function table. */
+ doing_hard_virtuals = 1;
+ pending_hard_virtuals = nreverse (pending_hard_virtuals);
+
+ if (TYPE_USES_VIRTUAL_BASECLASSES (t))
+ {
+ tree vbases;
+
+ max_has_virtual = layout_vbasetypes (t, max_has_virtual);
+ vbases = CLASSTYPE_VBASECLASSES (t);
+ CLASSTYPE_N_VBASECLASSES (t) = list_length (vbases);
+
+ /* The rtti code should do this. (mrs) */
+#if 0
+ while (vbases)
+ {
+ /* Update rtti info with offsets for virtual baseclasses. */
+ if (flag_rtti && ! BINFO_NEW_VTABLE_MARKED (vbases))
+ prepare_fresh_vtable (vbases, t);
+ vbases = TREE_CHAIN (vbases);
+ }
+#endif
+
+ {
+ /* Now fixup overrides of all functions in vtables from all
+ direct or indirect virtual base classes. */
+ tree binfos = BINFO_BASETYPES (TYPE_BINFO (t));
+ int i, n_baseclasses = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+
+ for (i = 0; i < n_baseclasses; i++)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ tree basetype = BINFO_TYPE (base_binfo);
+ tree vbases;
+
+ vbases = CLASSTYPE_VBASECLASSES (basetype);
+ while (vbases)
+ {
+ merge_overrides (binfo_member (BINFO_TYPE (vbases),
+ CLASSTYPE_VBASECLASSES (t)),
+ vbases, 1, t);
+ vbases = TREE_CHAIN (vbases);
+ }
+ }
+ }
+
+ /* Now fixup any virtual function entries from virtual bases
+ that have different deltas. */
+ vbases = CLASSTYPE_VBASECLASSES (t);
+ while (vbases)
+ {
+ /* We might be able to shorten the amount of work we do by
+ only doing this for vtables that come from virtual bases
+ that have differing offsets, but don't want to miss any
+ entries. */
+ fixup_vtable_deltas (vbases, 1, t);
+ vbases = TREE_CHAIN (vbases);
+ }
+ }
+
+ /* Set up the DECL_FIELD_BITPOS of the vfield if we need to, as we
+ might need to know it for setting up the offsets in the vtable
+ (or in thunks) below. */
+ if (vfield != NULL_TREE
+ && DECL_FIELD_CONTEXT (vfield) != t)
+ {
+ tree binfo = get_binfo (DECL_FIELD_CONTEXT (vfield), t, 0);
+ tree offset = BINFO_OFFSET (binfo);
+
+ vfield = copy_node (vfield);
+ copy_lang_decl (vfield);
+
+ if (! integer_zerop (offset))
+ offset = size_binop (MULT_EXPR, offset, size_int (BITS_PER_UNIT));
+ DECL_FIELD_CONTEXT (vfield) = t;
+ DECL_CLASS_CONTEXT (vfield) = t;
+ DECL_FIELD_BITPOS (vfield)
+ = size_binop (PLUS_EXPR, offset, DECL_FIELD_BITPOS (vfield));
+ CLASSTYPE_VFIELD (t) = vfield;
+ }
+
+#ifdef NOTQUITE
+ cp_warning ("Doing hard virtuals for %T...", t);
+#endif
+
+ if (has_virtual > max_has_virtual)
+ max_has_virtual = has_virtual;
+ if (max_has_virtual > 0)
+ TYPE_VIRTUAL_P (t) = 1;
+
+ if (flag_rtti && TYPE_VIRTUAL_P (t) && !pending_hard_virtuals)
+ modify_all_vtables (t, NULL_TREE, NULL_TREE);
+
+ while (pending_hard_virtuals)
+ {
+ modify_all_vtables (t,
+ TREE_PURPOSE (pending_hard_virtuals),
+ TREE_VALUE (pending_hard_virtuals));
+ pending_hard_virtuals = TREE_CHAIN (pending_hard_virtuals);
+ }
+ doing_hard_virtuals = 0;
+
+ /* Under our model of GC, every C++ class gets its own virtual
+ function table, at least virtually. */
+ if (pending_virtuals || (flag_rtti && TYPE_VIRTUAL_P (t)))
+ {
+ pending_virtuals = nreverse (pending_virtuals);
+ /* We must enter these virtuals into the table. */
+ if (first_vfn_base_index < 0)
+ {
+ /* The first slot is for the rtti offset. */
+ pending_virtuals = tree_cons (NULL_TREE, NULL_TREE, pending_virtuals);
+
+ /* The second slot is for the tdesc pointer when thunks are used. */
+ if (flag_vtable_thunks)
+ pending_virtuals = tree_cons (NULL_TREE, NULL_TREE, pending_virtuals);
+
+ set_rtti_entry (pending_virtuals, integer_zero_node, t);
+ build_vtable (NULL_TREE, t);
+ }
+ else
+ {
+ tree offset;
+ /* Here we know enough to change the type of our virtual
+ function table, but we will wait until later this function. */
+
+ if (! BINFO_NEW_VTABLE_MARKED (TYPE_BINFO (t)))
+ build_vtable (TREE_VEC_ELT (TYPE_BINFO_BASETYPES (t), first_vfn_base_index), t);
+
+ offset = get_derived_offset (TYPE_BINFO (t), NULL_TREE);
+ offset = size_binop (MINUS_EXPR, integer_zero_node, offset);
+ set_rtti_entry (TYPE_BINFO_VIRTUALS (t), offset, t);
+ }
+
+ /* If this type has basetypes with constructors, then those
+ constructors might clobber the virtual function table. But
+ they don't if the derived class shares the exact vtable of the base
+ class. */
+
+ CLASSTYPE_NEEDS_VIRTUAL_REINIT (t) = 1;
+ }
+ else if (first_vfn_base_index >= 0)
+ {
+ tree binfo = TREE_VEC_ELT (TYPE_BINFO_BASETYPES (t), first_vfn_base_index);
+ /* This class contributes nothing new to the virtual function
+ table. However, it may have declared functions which
+ went into the virtual function table "inherited" from the
+ base class. If so, we grab a copy of those updated functions,
+ and pretend they are ours. */
+
+ /* See if we should steal the virtual info from base class. */
+ if (TYPE_BINFO_VTABLE (t) == NULL_TREE)
+ TYPE_BINFO_VTABLE (t) = BINFO_VTABLE (binfo);
+ if (TYPE_BINFO_VIRTUALS (t) == NULL_TREE)
+ TYPE_BINFO_VIRTUALS (t) = BINFO_VIRTUALS (binfo);
+ if (TYPE_BINFO_VTABLE (t) != BINFO_VTABLE (binfo))
+ CLASSTYPE_NEEDS_VIRTUAL_REINIT (t) = 1;
+ }
+
+ if (max_has_virtual || first_vfn_base_index >= 0)
+ {
+ CLASSTYPE_VSIZE (t) = has_virtual;
+ if (first_vfn_base_index >= 0)
+ {
+ if (pending_virtuals)
+ TYPE_BINFO_VIRTUALS (t) = chainon (TYPE_BINFO_VIRTUALS (t),
+ pending_virtuals);
+ }
+ else if (has_virtual)
+ {
+ TYPE_BINFO_VIRTUALS (t) = pending_virtuals;
+ if (write_virtuals >= 0)
+ DECL_VIRTUAL_P (TYPE_BINFO_VTABLE (t)) = 1;
+ }
+ }
+
+ /* Now lay out the virtual function table. */
+ if (has_virtual)
+ {
+ tree atype, itype;
+
+ if (TREE_TYPE (vfield) == ptr_type_node)
+ {
+ /* We must create a pointer to this table because
+ the one inherited from base class does not exist.
+ We will fill in the type when we know what it
+ should really be. Use `size_int' so values are memoized
+ in common cases. */
+ itype = build_index_type (size_int (has_virtual));
+ atype = build_array_type (vtable_entry_type, itype);
+ layout_type (atype);
+ TREE_TYPE (vfield) = build_pointer_type (atype);
+ }
+ else
+ {
+ atype = TREE_TYPE (TREE_TYPE (vfield));
+
+ if (has_virtual != TREE_INT_CST_LOW (TYPE_MAX_VALUE (TYPE_DOMAIN (atype))))
+ {
+ /* We must extend (or create) the boundaries on this array,
+ because we picked up virtual functions from multiple
+ base classes. */
+ itype = build_index_type (size_int (has_virtual));
+ atype = build_array_type (vtable_entry_type, itype);
+ layout_type (atype);
+ vfield = copy_node (vfield);
+ TREE_TYPE (vfield) = build_pointer_type (atype);
+ }
+ }
+
+ CLASSTYPE_VFIELD (t) = vfield;
+ if (TREE_TYPE (TYPE_BINFO_VTABLE (t)) != atype)
+ {
+ TREE_TYPE (TYPE_BINFO_VTABLE (t)) = atype;
+ DECL_SIZE (TYPE_BINFO_VTABLE (t)) = 0;
+ layout_decl (TYPE_BINFO_VTABLE (t), 0);
+ /* At one time the vtable info was grabbed 2 words at a time. This
+ fails on sparc unless you have 8-byte alignment. (tiemann) */
+ DECL_ALIGN (TYPE_BINFO_VTABLE (t))
+ = MAX (TYPE_ALIGN (double_type_node),
+ DECL_ALIGN (TYPE_BINFO_VTABLE (t)));
+ }
+ }
+ else if (first_vfn_base_index >= 0)
+ CLASSTYPE_VFIELD (t) = vfield;
+ CLASSTYPE_VFIELDS (t) = vfields;
+
+ finish_struct_bits (t, max_has_virtual);
+
+ /* Complete the rtl for any static member objects of the type we're
+ working on. */
+ for (x = fields; x; x = TREE_CHAIN (x))
+ {
+ if (TREE_CODE (x) == VAR_DECL && TREE_STATIC (x)
+ && TREE_TYPE (x) == t)
+ {
+ DECL_MODE (x) = TYPE_MODE (t);
+ make_decl_rtl (x, NULL, 0);
+ }
+ }
+
+ /* Now add the tags, if any, to the list of TYPE_DECLs
+ defined for this type. */
+ if (CLASSTYPE_TAGS (t))
+ {
+ x = CLASSTYPE_TAGS (t);
+ last_x = tree_last (TYPE_FIELDS (t));
+ while (x)
+ {
+ tree tag = TYPE_NAME (TREE_VALUE (x));
+
+ /* Check to see if it is already there. This will be the case if
+ was do enum { red; } color; */
+ if (chain_member (tag, TYPE_FIELDS (t)))
+ {
+ x = TREE_CHAIN (x);
+ continue;
+ }
+
+#ifdef DWARF_DEBUGGING_INFO
+ if (write_symbols == DWARF_DEBUG)
+ {
+ /* Notify dwarfout.c that this TYPE_DECL node represent a
+ gratuitous typedef. */
+ DECL_IGNORED_P (tag) = 1;
+ }
+#endif /* DWARF_DEBUGGING_INFO */
+
+ TREE_NONLOCAL_FLAG (TREE_VALUE (x)) = 0;
+ x = TREE_CHAIN (x);
+ last_x = chainon (last_x, tag);
+ }
+ if (TYPE_FIELDS (t) == NULL_TREE)
+ TYPE_FIELDS (t) = last_x;
+ CLASSTYPE_LOCAL_TYPEDECLS (t) = 1;
+ }
+
+ if (TYPE_HAS_CONSTRUCTOR (t))
+ {
+ tree vfields = CLASSTYPE_VFIELDS (t);
+
+ while (vfields)
+ {
+ /* Mark the fact that constructor for T
+ could affect anybody inheriting from T
+ who wants to initialize vtables for VFIELDS's type. */
+ if (VF_DERIVED_VALUE (vfields))
+ TREE_ADDRESSABLE (vfields) = 1;
+ vfields = TREE_CHAIN (vfields);
+ }
+ if (any_default_members != 0)
+ build_class_init_list (t);
+ }
+ else if (TYPE_NEEDS_CONSTRUCTING (t))
+ build_class_init_list (t);
+
+ if (! IS_SIGNATURE (t))
+ embrace_waiting_friends (t);
+
+ /* Write out inline function definitions. */
+ do_inline_function_hair (t, CLASSTYPE_INLINE_FRIENDS (t));
+ CLASSTYPE_INLINE_FRIENDS (t) = 0;
+
+ if (CLASSTYPE_VSIZE (t) != 0)
+ {
+#if 0
+ /* This is now done above. */
+ if (DECL_FIELD_CONTEXT (vfield) != t)
+ {
+ tree binfo = get_binfo (DECL_FIELD_CONTEXT (vfield), t, 0);
+ tree offset = BINFO_OFFSET (binfo);
+
+ vfield = copy_node (vfield);
+ copy_lang_decl (vfield);
+
+ if (! integer_zerop (offset))
+ offset = size_binop (MULT_EXPR, offset, size_int (BITS_PER_UNIT));
+ DECL_FIELD_CONTEXT (vfield) = t;
+ DECL_CLASS_CONTEXT (vfield) = t;
+ DECL_FIELD_BITPOS (vfield)
+ = size_binop (PLUS_EXPR, offset, DECL_FIELD_BITPOS (vfield));
+ CLASSTYPE_VFIELD (t) = vfield;
+ }
+#endif
+
+ /* In addition to this one, all the other vfields should be listed. */
+ /* Before that can be done, we have to have FIELD_DECLs for them, and
+ a place to find them. */
+ TYPE_NONCOPIED_PARTS (t) = build_tree_list (default_conversion (TYPE_BINFO_VTABLE (t)), vfield);
+
+ if (warn_nonvdtor && TYPE_HAS_DESTRUCTOR (t)
+ && DECL_VINDEX (TREE_VEC_ELT (method_vec, 0)) == NULL_TREE)
+ cp_warning ("`%#T' has virtual functions but non-virtual destructor",
+ t);
+ }
+
+ /* Make the rtl for any new vtables we have created, and unmark
+ the base types we marked. */
+ finish_vtbls (TYPE_BINFO (t), 1, t);
+ TYPE_BEING_DEFINED (t) = 0;
+ hack_incomplete_structures (t);
+
+#if 0
+ if (TYPE_NAME (t) && TYPE_IDENTIFIER (t))
+ undo_template_name_overload (TYPE_IDENTIFIER (t), 1);
+#endif
+ if (current_class_type)
+ popclass (0);
+ else
+ error ("trying to finish struct, but kicked out due to previous parse errors.");
+
+ resume_momentary (old);
+
+ if (flag_cadillac)
+ cadillac_finish_struct (t);
+
+#if 0
+ /* This has to be done after we have sorted out what to do with
+ the enclosing type. */
+ if (write_symbols != DWARF_DEBUG)
+ {
+ /* Be smarter about nested classes here. If a type is nested,
+ only output it if we would output the enclosing type. */
+ if (DECL_CONTEXT (TYPE_NAME (t))
+ && TREE_CODE_CLASS (TREE_CODE (DECL_CONTEXT (TYPE_NAME (t)))) == 't')
+ DECL_IGNORED_P (TYPE_NAME (t)) = TREE_ASM_WRITTEN (TYPE_NAME (t));
+ }
+#endif
+
+ if (write_symbols != DWARF_DEBUG)
+ {
+ /* If the type has methods, we want to think about cutting down
+ the amount of symbol table stuff we output. The value stored in
+ the TYPE_DECL's DECL_IGNORED_P slot is a first approximation.
+ For example, if a member function is seen and we decide to
+ write out that member function, then we can change the value
+ of the DECL_IGNORED_P slot, and the type will be output when
+ that member function's debug info is written out. */
+ if (CLASSTYPE_METHOD_VEC (t))
+ {
+ extern tree pending_vtables;
+
+ /* Don't output full info about any type
+ which does not have its implementation defined here. */
+ if (TYPE_VIRTUAL_P (t) && write_virtuals == 2)
+ TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (t))
+ = (value_member (TYPE_IDENTIFIER (t), pending_vtables) == 0);
+ else if (CLASSTYPE_INTERFACE_ONLY (t))
+ TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (t)) = 1;
+ else if (CLASSTYPE_INTERFACE_UNKNOWN (t))
+ /* Only a first approximation! */
+ TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (t)) = 1;
+ }
+ else if (CLASSTYPE_INTERFACE_ONLY (t))
+ TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (t)) = 1;
+ }
+
+ /* Finish debugging output for this type. */
+ rest_of_type_compilation (t, toplevel_bindings_p ());
+
+ return t;
+}
+
+tree
+finish_struct (t, list_of_fieldlists, warn_anon)
+ tree t;
+ tree list_of_fieldlists;
+ int warn_anon;
+{
+ tree fields = NULL_TREE, fn_fields, *tail;
+ tree *tail_user_methods = &CLASSTYPE_METHODS (t);
+ tree name = TYPE_NAME (t);
+ tree x, last_x = NULL_TREE;
+ enum access_type access;
+
+ if (TREE_CODE (name) == TYPE_DECL)
+ {
+ extern int lineno;
+
+ DECL_SOURCE_FILE (name) = input_filename;
+ /* For TYPE_DECL that are not typedefs (those marked with a line
+ number of zero, we don't want to mark them as real typedefs.
+ If this fails one needs to make sure real typedefs have a
+ previous line number, even if it is wrong, that way the below
+ will fill in the right line number. (mrs) */
+ if (DECL_SOURCE_LINE (name))
+ DECL_SOURCE_LINE (name) = lineno;
+ CLASSTYPE_SOURCE_LINE (t) = lineno;
+ name = DECL_NAME (name);
+ }
+
+ /* Append the fields we need for constructing signature tables. */
+ if (IS_SIGNATURE (t))
+ append_signature_fields (list_of_fieldlists);
+
+ tail = &fn_fields;
+ if (last_x && list_of_fieldlists)
+ TREE_CHAIN (last_x) = TREE_VALUE (list_of_fieldlists);
+
+ /* For signatures, we made all methods `public' in the parser and
+ reported an error if a access specifier was used. */
+ if (CLASSTYPE_DECLARED_CLASS (t) == 0)
+ {
+ if (list_of_fieldlists
+ && TREE_PURPOSE (list_of_fieldlists) == (tree)access_default)
+ TREE_PURPOSE (list_of_fieldlists) = (tree)access_public;
+ }
+ else if (list_of_fieldlists
+ && TREE_PURPOSE (list_of_fieldlists) == (tree)access_default)
+ TREE_PURPOSE (list_of_fieldlists) = (tree)access_private;
+
+ while (list_of_fieldlists)
+ {
+ access = (enum access_type)TREE_PURPOSE (list_of_fieldlists);
+
+ for (x = TREE_VALUE (list_of_fieldlists); x; x = TREE_CHAIN (x))
+ {
+ TREE_PRIVATE (x) = access == access_private;
+ TREE_PROTECTED (x) = access == access_protected;
+
+ /* Check for inconsistent use of this name in the class body.
+ Enums, types and static vars have already been checked. */
+ if (TREE_CODE (x) != TYPE_DECL
+ && TREE_CODE (x) != CONST_DECL && TREE_CODE (x) != VAR_DECL)
+ {
+ tree name = DECL_NAME (x);
+ tree icv;
+
+ /* Don't get confused by access decls. */
+ if (name && TREE_CODE (name) == IDENTIFIER_NODE)
+ icv = IDENTIFIER_CLASS_VALUE (name);
+ else
+ icv = NULL_TREE;
+
+ if (icv
+ /* Don't complain about constructors. */
+ && name != constructor_name (current_class_type)
+ /* Or inherited names. */
+ && id_in_current_class (name)
+ /* Or shadowed tags. */
+ && !(TREE_CODE (icv) == TYPE_DECL
+ && DECL_CONTEXT (icv) == t))
+ {
+ cp_error_at ("declaration of identifier `%D' as `%+#D'",
+ name, x);
+ cp_error_at ("conflicts with other use in class as `%#D'",
+ icv);
+ }
+ }
+
+ if (TREE_CODE (x) == FUNCTION_DECL)
+ {
+ if (last_x)
+ TREE_CHAIN (last_x) = TREE_CHAIN (x);
+ /* Link x onto end of fn_fields and CLASSTYPE_METHODS. */
+ *tail = x;
+ tail = &TREE_CHAIN (x);
+ *tail_user_methods = x;
+ tail_user_methods = &DECL_NEXT_METHOD (x);
+ continue;
+ }
+
+#if 0
+ /* Handle access declarations. */
+ if (DECL_NAME (x) && TREE_CODE (DECL_NAME (x)) == SCOPE_REF)
+ {
+ tree n = DECL_NAME (x);
+ x = build_decl
+ (USING_DECL, DECL_NAME (TREE_OPERAND (n, 1)), TREE_TYPE (x));
+ DECL_RESULT (x) = n;
+ }
+#endif
+
+ if (! fields)
+ fields = x;
+ last_x = x;
+ }
+ list_of_fieldlists = TREE_CHAIN (list_of_fieldlists);
+ /* link the tail while we have it! */
+ if (last_x)
+ {
+ TREE_CHAIN (last_x) = NULL_TREE;
+
+ if (list_of_fieldlists
+ && TREE_VALUE (list_of_fieldlists)
+ && TREE_CODE (TREE_VALUE (list_of_fieldlists)) != FUNCTION_DECL)
+ TREE_CHAIN (last_x) = TREE_VALUE (list_of_fieldlists);
+ }
+ }
+
+ *tail = NULL_TREE;
+ *tail_user_methods = NULL_TREE;
+ TYPE_FIELDS (t) = fields;
+
+ if (0 && processing_template_defn)
+ {
+ CLASSTYPE_METHOD_VEC (t) = finish_struct_methods (t, fn_fields, 1);
+ return t;
+ }
+ else
+ return finish_struct_1 (t, warn_anon);
+}
+
+/* Return non-zero if the effective type of INSTANCE is static.
+ Used to determine whether the virtual function table is needed
+ or not.
+
+ *NONNULL is set iff INSTANCE can be known to be nonnull, regardless
+ of our knowledge of its type. */
+int
+resolves_to_fixed_type_p (instance, nonnull)
+ tree instance;
+ int *nonnull;
+{
+ switch (TREE_CODE (instance))
+ {
+ case INDIRECT_REF:
+ /* Check that we are not going through a cast of some sort. */
+ if (TREE_TYPE (instance)
+ == TREE_TYPE (TREE_TYPE (TREE_OPERAND (instance, 0))))
+ instance = TREE_OPERAND (instance, 0);
+ /* fall through... */
+ case CALL_EXPR:
+ /* This is a call to a constructor, hence it's never zero. */
+ if (TREE_HAS_CONSTRUCTOR (instance))
+ {
+ if (nonnull)
+ *nonnull = 1;
+ return 1;
+ }
+ return 0;
+
+ case SAVE_EXPR:
+ /* This is a call to a constructor, hence it's never zero. */
+ if (TREE_HAS_CONSTRUCTOR (instance))
+ {
+ if (nonnull)
+ *nonnull = 1;
+ return 1;
+ }
+ return resolves_to_fixed_type_p (TREE_OPERAND (instance, 0), nonnull);
+
+ case RTL_EXPR:
+ /* This is a call to `new', hence it's never zero. */
+ if (TREE_CALLS_NEW (instance))
+ {
+ if (nonnull)
+ *nonnull = 1;
+ return 1;
+ }
+ return 0;
+
+ case PLUS_EXPR:
+ case MINUS_EXPR:
+ if (TREE_CODE (TREE_OPERAND (instance, 1)) == INTEGER_CST)
+ /* Propagate nonnull. */
+ resolves_to_fixed_type_p (TREE_OPERAND (instance, 0), nonnull);
+ if (TREE_CODE (TREE_OPERAND (instance, 0)) == ADDR_EXPR)
+ return resolves_to_fixed_type_p (TREE_OPERAND (instance, 0), nonnull);
+ return 0;
+
+ case NOP_EXPR:
+ case CONVERT_EXPR:
+ return resolves_to_fixed_type_p (TREE_OPERAND (instance, 0), nonnull);
+
+ case ADDR_EXPR:
+ if (nonnull)
+ *nonnull = 1;
+ return resolves_to_fixed_type_p (TREE_OPERAND (instance, 0), nonnull);
+
+ case COMPONENT_REF:
+ return resolves_to_fixed_type_p (TREE_OPERAND (instance, 1), nonnull);
+
+ case WITH_CLEANUP_EXPR:
+ if (TREE_CODE (TREE_OPERAND (instance, 0)) == ADDR_EXPR)
+ return resolves_to_fixed_type_p (TREE_OPERAND (instance, 0), nonnull);
+ /* fall through... */
+ case VAR_DECL:
+ case FIELD_DECL:
+ if (TREE_CODE (TREE_TYPE (instance)) == ARRAY_TYPE
+ && IS_AGGR_TYPE (TREE_TYPE (TREE_TYPE (instance))))
+ {
+ if (nonnull)
+ *nonnull = 1;
+ return 1;
+ }
+ /* fall through... */
+ case TARGET_EXPR:
+ case PARM_DECL:
+ if (IS_AGGR_TYPE (TREE_TYPE (instance)))
+ {
+ if (nonnull)
+ *nonnull = 1;
+ return 1;
+ }
+ else if (nonnull)
+ {
+ if (instance == current_class_decl
+ && flag_this_is_variable <= 0)
+ {
+ /* Some people still use `this = 0' inside destructors. */
+ *nonnull = ! DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (current_function_decl));
+ /* In a constructor, we know our type. */
+ if (flag_this_is_variable < 0)
+ return 1;
+ }
+ else if (TREE_CODE (TREE_TYPE (instance)) == REFERENCE_TYPE)
+ /* Reference variables should be references to objects. */
+ *nonnull = 1;
+ }
+ return 0;
+
+ default:
+ return 0;
+ }
+}
+
+void
+init_class_processing ()
+{
+ current_class_depth = 0;
+ current_class_stacksize = 10;
+ current_class_base = (tree *)xmalloc(current_class_stacksize * sizeof (tree));
+ current_class_stack = current_class_base;
+
+ current_lang_stacksize = 10;
+ current_lang_base = (tree *)xmalloc(current_lang_stacksize * sizeof (tree));
+ current_lang_stack = current_lang_base;
+
+ /* Keep these values lying around. */
+ the_null_vtable_entry = build_vtable_entry (integer_zero_node, integer_zero_node);
+ base_layout_decl = build_lang_field_decl (FIELD_DECL, NULL_TREE, error_mark_node);
+ TREE_TYPE (base_layout_decl) = make_node (RECORD_TYPE);
+
+ gcc_obstack_init (&class_obstack);
+}
+
+/* Set current scope to NAME. CODE tells us if this is a
+ STRUCT, UNION, or ENUM environment.
+
+ NAME may end up being NULL_TREE if this is an anonymous or
+ late-bound struct (as in "struct { ... } foo;") */
+
+/* Set global variables CURRENT_CLASS_NAME and CURRENT_CLASS_TYPE to
+ appropriate values, found by looking up the type definition of
+ NAME (as a CODE).
+
+ If MODIFY is 1, we set IDENTIFIER_CLASS_VALUE's of names
+ which can be seen locally to the class. They are shadowed by
+ any subsequent local declaration (including parameter names).
+
+ If MODIFY is 2, we set IDENTIFIER_CLASS_VALUE's of names
+ which have static meaning (i.e., static members, static
+ member functions, enum declarations, etc).
+
+ If MODIFY is 3, we set IDENTIFIER_CLASS_VALUE of names
+ which can be seen locally to the class (as in 1), but
+ know that we are doing this for declaration purposes
+ (i.e. friend foo::bar (int)).
+
+ So that we may avoid calls to lookup_name, we cache the _TYPE
+ nodes of local TYPE_DECLs in the TREE_TYPE field of the name.
+
+ For multiple inheritance, we perform a two-pass depth-first search
+ of the type lattice. The first pass performs a pre-order search,
+ marking types after the type has had its fields installed in
+ the appropriate IDENTIFIER_CLASS_VALUE slot. The second pass merely
+ unmarks the marked types. If a field or member function name
+ appears in an ambiguous way, the IDENTIFIER_CLASS_VALUE of
+ that name becomes `error_mark_node'. */
+
+void
+pushclass (type, modify)
+ tree type;
+ int modify;
+{
+ push_memoized_context (type, modify);
+
+ current_class_depth++;
+ *current_class_stack++ = current_class_name;
+ *current_class_stack++ = current_class_type;
+ if (current_class_stack >= current_class_base + current_class_stacksize)
+ {
+ current_class_base =
+ (tree *)xrealloc (current_class_base,
+ sizeof (tree) * (current_class_stacksize + 10));
+ current_class_stack = current_class_base + current_class_stacksize;
+ current_class_stacksize += 10;
+ }
+
+ current_class_name = TYPE_NAME (type);
+ if (TREE_CODE (current_class_name) == TYPE_DECL)
+ current_class_name = DECL_NAME (current_class_name);
+ current_class_type = type;
+
+ if (previous_class_type != NULL_TREE
+ && (type != previous_class_type || TYPE_SIZE (previous_class_type) == NULL_TREE)
+ && current_class_depth == 1)
+ {
+ /* Forcibly remove any old class remnants. */
+ popclass (-1);
+ previous_class_type = NULL_TREE;
+ }
+
+ pushlevel_class ();
+
+ if (modify)
+ {
+ tree tags;
+ tree this_fndecl = current_function_decl;
+
+ if (current_function_decl
+ && DECL_CONTEXT (current_function_decl)
+ && TREE_CODE (DECL_CONTEXT (current_function_decl)) == FUNCTION_DECL)
+ current_function_decl = DECL_CONTEXT (current_function_decl);
+ else
+ current_function_decl = NULL_TREE;
+
+ if (TREE_CODE (type) == UNINSTANTIATED_P_TYPE)
+ declare_uninstantiated_type_level ();
+ else if (type != previous_class_type || current_class_depth > 1)
+ {
+ build_mi_matrix (type);
+ push_class_decls (type);
+ free_mi_matrix ();
+ if (current_class_depth == 1)
+ previous_class_type = type;
+ }
+ else
+ {
+ tree item;
+
+ /* Hooray, we successfully cached; let's just install the
+ cached class_shadowed list, and walk through it to get the
+ IDENTIFIER_TYPE_VALUEs correct. */
+ set_class_shadows (previous_class_values);
+ for (item = previous_class_values; item; item = TREE_CHAIN (item))
+ {
+ tree id = TREE_PURPOSE (item);
+ tree decl = IDENTIFIER_CLASS_VALUE (id);
+
+ if (TREE_CODE (decl) == TYPE_DECL)
+ set_identifier_type_value (id, TREE_TYPE (decl));
+ }
+ unuse_fields (type);
+ }
+
+ if (IDENTIFIER_TEMPLATE (TYPE_IDENTIFIER (type)))
+ overload_template_name (current_class_name, 0);
+
+ for (tags = CLASSTYPE_TAGS (type); tags; tags = TREE_CHAIN (tags))
+ {
+ TREE_NONLOCAL_FLAG (TREE_VALUE (tags)) = 1;
+ if (! TREE_PURPOSE (tags))
+ continue;
+ pushtag (TREE_PURPOSE (tags), TREE_VALUE (tags), 0);
+ }
+
+ current_function_decl = this_fndecl;
+ }
+
+ if (flag_cadillac)
+ cadillac_push_class (type);
+}
+
+/* Get out of the current class scope. If we were in a class scope
+ previously, that is the one popped to. The flag MODIFY tells whether
+ the current scope declarations needs to be modified as a result of
+ popping to the previous scope. 0 is used for class definitions. */
+void
+popclass (modify)
+ int modify;
+{
+ if (flag_cadillac)
+ cadillac_pop_class ();
+
+ if (modify < 0)
+ {
+ /* Back this old class out completely. */
+ tree tags = CLASSTYPE_TAGS (previous_class_type);
+ tree t;
+
+ /* This code can be seen as a cache miss. When we've cached a
+ class' scope's bindings and we can't use them, we need to reset
+ them. This is it! */
+ for (t = previous_class_values; t; t = TREE_CHAIN (t))
+ IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (t)) = NULL_TREE;
+ while (tags)
+ {
+ TREE_NONLOCAL_FLAG (TREE_VALUE (tags)) = 0;
+ tags = TREE_CHAIN (tags);
+ }
+ goto ret;
+ }
+
+ if (modify)
+ {
+ /* Just remove from this class what didn't make
+ it into IDENTIFIER_CLASS_VALUE. */
+ tree tags = CLASSTYPE_TAGS (current_class_type);
+
+ while (tags)
+ {
+ TREE_NONLOCAL_FLAG (TREE_VALUE (tags)) = 0;
+ tags = TREE_CHAIN (tags);
+ }
+ if (IDENTIFIER_TEMPLATE (TYPE_IDENTIFIER (current_class_type)))
+ undo_template_name_overload (current_class_name, 0);
+ }
+
+ /* Force clearing of IDENTIFIER_CLASS_VALUEs after a class definition,
+ since not all class decls make it there currently. */
+ poplevel_class (! modify);
+
+ /* Since poplevel_class does the popping of class decls nowadays,
+ this really only frees the obstack used for these decls.
+ That's why it had to be moved down here. */
+ if (modify)
+ pop_class_decls (current_class_type);
+
+ current_class_depth--;
+ current_class_type = *--current_class_stack;
+ current_class_name = *--current_class_stack;
+
+ pop_memoized_context (modify);
+
+ ret:
+ ;
+}
+
+/* When entering a class scope, all enclosing class scopes' names with
+ static meaning (static variables, static functions, types and enumerators)
+ have to be visible. This recursive function calls pushclass for all
+ enclosing class contexts until global or a local scope is reached.
+ TYPE is the enclosed class and MODIFY is equivalent with the pushclass
+ formal of the same name. */
+
+void
+push_nested_class (type, modify)
+ tree type;
+ int modify;
+{
+ tree context;
+
+ if (type == NULL_TREE || type == error_mark_node || ! IS_AGGR_TYPE (type))
+ return;
+
+ context = DECL_CONTEXT (TYPE_NAME (type));
+
+ if (context && TREE_CODE (context) == RECORD_TYPE)
+ push_nested_class (context, 2);
+ pushclass (type, modify);
+}
+
+/* Undoes a push_nested_class call. MODIFY is passed on to popclass. */
+
+void
+pop_nested_class (modify)
+ int modify;
+{
+ tree context = DECL_CONTEXT (TYPE_NAME (current_class_type));
+
+ popclass (modify);
+ if (context && TREE_CODE (context) == RECORD_TYPE)
+ pop_nested_class (modify);
+}
+
+/* Set global variables CURRENT_LANG_NAME to appropriate value
+ so that behavior of name-mangling machinery is correct. */
+
+void
+push_lang_context (name)
+ tree name;
+{
+ *current_lang_stack++ = current_lang_name;
+ if (current_lang_stack >= current_lang_base + current_lang_stacksize)
+ {
+ current_lang_base =
+ (tree *)xrealloc (current_lang_base,
+ sizeof (tree) * (current_lang_stacksize + 10));
+ current_lang_stack = current_lang_base + current_lang_stacksize;
+ current_lang_stacksize += 10;
+ }
+
+ if (name == lang_name_cplusplus)
+ {
+ strict_prototype = strict_prototypes_lang_cplusplus;
+ current_lang_name = name;
+ }
+ else if (name == lang_name_c)
+ {
+ strict_prototype = strict_prototypes_lang_c;
+ current_lang_name = name;
+ }
+ else
+ error ("language string `\"%s\"' not recognized", IDENTIFIER_POINTER (name));
+
+ if (flag_cadillac)
+ cadillac_push_lang (name);
+}
+
+/* Get out of the current language scope. */
+void
+pop_lang_context ()
+{
+ if (flag_cadillac)
+ cadillac_pop_lang ();
+
+ current_lang_name = *--current_lang_stack;
+ if (current_lang_name == lang_name_cplusplus)
+ strict_prototype = strict_prototypes_lang_cplusplus;
+ else if (current_lang_name == lang_name_c)
+ strict_prototype = strict_prototypes_lang_c;
+}
+
+int
+root_lang_context_p ()
+{
+ return current_lang_stack == current_lang_base;
+}
+
+/* Type instantiation routines. */
+
+/* This function will instantiate the type of the expression given
+ in RHS to match the type of LHSTYPE. If LHSTYPE is NULL_TREE,
+ or other errors exist, the TREE_TYPE of RHS will be ERROR_MARK_NODE.
+
+ This function is used in build_modify_expr, convert_arguments,
+ build_c_cast, and compute_conversion_costs. */
+tree
+instantiate_type (lhstype, rhs, complain)
+ tree lhstype, rhs;
+ int complain;
+{
+ if (TREE_CODE (lhstype) == UNKNOWN_TYPE)
+ {
+ if (complain)
+ error ("not enough type information");
+ return error_mark_node;
+ }
+
+ if (TREE_TYPE (rhs) != NULL_TREE && ! (type_unknown_p (rhs)))
+ return rhs;
+
+ /* This should really only be used when attempting to distinguish
+ what sort of a pointer to function we have. For now, any
+ arithmetic operation which is not supported on pointers
+ is rejected as an error. */
+
+ switch (TREE_CODE (rhs))
+ {
+ case TYPE_EXPR:
+ case CONVERT_EXPR:
+ case SAVE_EXPR:
+ case CONSTRUCTOR:
+ case BUFFER_REF:
+ my_friendly_abort (177);
+ return error_mark_node;
+
+ case INDIRECT_REF:
+ case ARRAY_REF:
+ TREE_TYPE (rhs) = lhstype;
+ lhstype = build_pointer_type (lhstype);
+ TREE_OPERAND (rhs, 0)
+ = instantiate_type (lhstype, TREE_OPERAND (rhs, 0), complain);
+ if (TREE_OPERAND (rhs, 0) == error_mark_node)
+ return error_mark_node;
+
+ return rhs;
+
+ case NOP_EXPR:
+ rhs = copy_node (TREE_OPERAND (rhs, 0));
+ TREE_TYPE (rhs) = unknown_type_node;
+ return instantiate_type (lhstype, rhs, complain);
+
+ case COMPONENT_REF:
+ {
+ tree field = TREE_OPERAND (rhs, 1);
+ if (TREE_CODE (field) == TREE_LIST)
+ {
+ tree function = instantiate_type (lhstype, field, complain);
+ if (function == error_mark_node)
+ return error_mark_node;
+ my_friendly_assert (TREE_CODE (function) == FUNCTION_DECL, 185);
+ if (DECL_VINDEX (function))
+ {
+ tree base = TREE_OPERAND (rhs, 0);
+ tree base_ptr = build_unary_op (ADDR_EXPR, base, 0);
+ if (base_ptr == error_mark_node)
+ return error_mark_node;
+ base_ptr = convert_pointer_to (DECL_CONTEXT (function), base_ptr);
+ if (base_ptr == error_mark_node)
+ return error_mark_node;
+ return build_vfn_ref (&base_ptr, base, DECL_VINDEX (function));
+ }
+ return function;
+ }
+
+ my_friendly_assert (TREE_CODE (field) == FIELD_DECL, 178);
+ my_friendly_assert (!(TREE_CODE (TREE_TYPE (field)) == FUNCTION_TYPE
+ || TREE_CODE (TREE_TYPE (field)) == METHOD_TYPE),
+ 179);
+
+ TREE_TYPE (rhs) = lhstype;
+ /* First look for an exact match */
+
+ while (field && TREE_TYPE (field) != lhstype)
+ field = DECL_CHAIN (field);
+ if (field)
+ {
+ TREE_OPERAND (rhs, 1) = field;
+ return rhs;
+ }
+
+ /* No exact match found, look for a compatible function. */
+ field = TREE_OPERAND (rhs, 1);
+ while (field && ! comptypes (lhstype, TREE_TYPE (field), 0))
+ field = DECL_CHAIN (field);
+ if (field)
+ {
+ TREE_OPERAND (rhs, 1) = field;
+ field = DECL_CHAIN (field);
+ while (field && ! comptypes (lhstype, TREE_TYPE (field), 0))
+ field = DECL_CHAIN (field);
+ if (field)
+ {
+ if (complain)
+ error ("ambiguous overload for COMPONENT_REF requested");
+ return error_mark_node;
+ }
+ }
+ else
+ {
+ if (complain)
+ error ("no appropriate overload exists for COMPONENT_REF");
+ return error_mark_node;
+ }
+ return rhs;
+ }
+
+ case TREE_LIST:
+ {
+ tree elem, baselink, name;
+ int globals = overloaded_globals_p (rhs);
+
+#if 0 /* obsolete */
+ /* If there's only one function we know about, return that. */
+ if (globals > 0 && TREE_CHAIN (rhs) == NULL_TREE)
+ return TREE_VALUE (rhs);
+#endif
+
+ /* First look for an exact match. Search either overloaded
+ functions or member functions. May have to undo what
+ `default_conversion' might do to lhstype. */
+
+ if (TYPE_PTRMEMFUNC_P (lhstype))
+ lhstype = TYPE_PTRMEMFUNC_FN_TYPE (lhstype);
+
+ if (TREE_CODE (lhstype) == POINTER_TYPE)
+ if (TREE_CODE (TREE_TYPE (lhstype)) == FUNCTION_TYPE
+ || TREE_CODE (TREE_TYPE (lhstype)) == METHOD_TYPE)
+ lhstype = TREE_TYPE (lhstype);
+ else
+ {
+ if (complain)
+ error ("invalid type combination for overload");
+ return error_mark_node;
+ }
+
+ if (TREE_CODE (lhstype) != FUNCTION_TYPE && globals > 0)
+ {
+ if (complain)
+ cp_error ("cannot resolve overloaded function `%D' based on non-function type",
+ TREE_PURPOSE (rhs));
+ return error_mark_node;
+ }
+
+ if (globals > 0)
+ {
+ elem = get_first_fn (rhs);
+ while (elem)
+ if (! comptypes (lhstype, TREE_TYPE (elem), 1))
+ elem = DECL_CHAIN (elem);
+ else
+ return elem;
+
+ /* No exact match found, look for a compatible template. */
+ {
+ tree save_elem = 0;
+ for (elem = get_first_fn (rhs); elem; elem = DECL_CHAIN (elem))
+ if (TREE_CODE (elem) == TEMPLATE_DECL)
+ {
+ int n = TREE_VEC_LENGTH (DECL_TEMPLATE_PARMS (elem));
+ tree *t = (tree *) alloca (sizeof (tree) * n);
+ int i, d = 0;
+ i = type_unification (DECL_TEMPLATE_PARMS (elem), t,
+ TYPE_ARG_TYPES (TREE_TYPE (elem)),
+ TYPE_ARG_TYPES (lhstype), &d, 0);
+ if (i == 0)
+ {
+ if (save_elem)
+ {
+ cp_error ("ambiguous template instantiation converting to `%#T'", lhstype);
+ return error_mark_node;
+ }
+ save_elem = instantiate_template (elem, t);
+ /* Check the return type. */
+ if (! comptypes (TREE_TYPE (lhstype),
+ TREE_TYPE (TREE_TYPE (save_elem)), 1))
+ save_elem = 0;
+ }
+ }
+ if (save_elem)
+ return save_elem;
+ }
+
+ /* No match found, look for a compatible function. */
+ elem = get_first_fn (rhs);
+ while (elem && comp_target_types (lhstype,
+ TREE_TYPE (elem), 1) <= 0)
+ elem = DECL_CHAIN (elem);
+ if (elem)
+ {
+ tree save_elem = elem;
+ elem = DECL_CHAIN (elem);
+ while (elem && comp_target_types (lhstype,
+ TREE_TYPE (elem), 0) <= 0)
+ elem = DECL_CHAIN (elem);
+ if (elem)
+ {
+ if (complain)
+ {
+ cp_error ("cannot resolve overload to target type `%#T'",
+ lhstype);
+ cp_error_at (" ambiguity between `%#D'", save_elem);
+ cp_error_at (" and `%#D', at least", elem);
+ }
+ return error_mark_node;
+ }
+ return save_elem;
+ }
+ if (complain)
+ {
+ cp_error ("cannot resolve overload to target type `%#T'",
+ lhstype);
+ cp_error (" because no suitable overload of function `%D' exists",
+ TREE_PURPOSE (rhs));
+ }
+ return error_mark_node;
+ }
+
+ if (TREE_NONLOCAL_FLAG (rhs))
+ {
+ /* Got to get it as a baselink. */
+ rhs = lookup_fnfields (TYPE_BINFO (current_class_type),
+ TREE_PURPOSE (rhs), 0);
+ }
+ else
+ {
+ my_friendly_assert (TREE_CHAIN (rhs) == NULL_TREE, 181);
+ if (TREE_CODE (TREE_VALUE (rhs)) == TREE_LIST)
+ rhs = TREE_VALUE (rhs);
+ my_friendly_assert (TREE_CODE (TREE_VALUE (rhs)) == FUNCTION_DECL,
+ 182);
+ }
+
+ for (baselink = rhs; baselink;
+ baselink = next_baselink (baselink))
+ {
+ elem = TREE_VALUE (baselink);
+ while (elem)
+ if (comptypes (lhstype, TREE_TYPE (elem), 1))
+ return elem;
+ else
+ elem = DECL_CHAIN (elem);
+ }
+
+ /* No exact match found, look for a compatible method. */
+ for (baselink = rhs; baselink;
+ baselink = next_baselink (baselink))
+ {
+ elem = TREE_VALUE (baselink);
+ while (elem && comp_target_types (lhstype,
+ TREE_TYPE (elem), 1) <= 0)
+ elem = DECL_CHAIN (elem);
+ if (elem)
+ {
+ tree save_elem = elem;
+ elem = DECL_CHAIN (elem);
+ while (elem && comp_target_types (lhstype,
+ TREE_TYPE (elem), 0) <= 0)
+ elem = DECL_CHAIN (elem);
+ if (elem)
+ {
+ if (complain)
+ error ("ambiguous overload for overloaded method requested");
+ return error_mark_node;
+ }
+ return save_elem;
+ }
+ name = DECL_NAME (TREE_VALUE (rhs));
+#if 0
+ if (TREE_CODE (lhstype) == FUNCTION_TYPE && globals < 0)
+ {
+ /* Try to instantiate from non-member functions. */
+ rhs = lookup_name_nonclass (name);
+ if (rhs && TREE_CODE (rhs) == TREE_LIST)
+ {
+ /* This code seems to be missing a `return'. */
+ my_friendly_abort (4);
+ instantiate_type (lhstype, rhs, complain);
+ }
+ }
+#endif
+ }
+ if (complain)
+ cp_error ("no compatible member functions named `%D'", name);
+ return error_mark_node;
+ }
+
+ case CALL_EXPR:
+ /* This is too hard for now. */
+ my_friendly_abort (183);
+ return error_mark_node;
+
+ case PLUS_EXPR:
+ case MINUS_EXPR:
+ case COMPOUND_EXPR:
+ TREE_OPERAND (rhs, 0)
+ = instantiate_type (lhstype, TREE_OPERAND (rhs, 0), complain);
+ if (TREE_OPERAND (rhs, 0) == error_mark_node)
+ return error_mark_node;
+ TREE_OPERAND (rhs, 1)
+ = instantiate_type (lhstype, TREE_OPERAND (rhs, 1), complain);
+ if (TREE_OPERAND (rhs, 1) == error_mark_node)
+ return error_mark_node;
+
+ TREE_TYPE (rhs) = lhstype;
+ return rhs;
+
+ case MULT_EXPR:
+ case TRUNC_DIV_EXPR:
+ case FLOOR_DIV_EXPR:
+ case CEIL_DIV_EXPR:
+ case ROUND_DIV_EXPR:
+ case RDIV_EXPR:
+ case TRUNC_MOD_EXPR:
+ case FLOOR_MOD_EXPR:
+ case CEIL_MOD_EXPR:
+ case ROUND_MOD_EXPR:
+ case FIX_ROUND_EXPR:
+ case FIX_FLOOR_EXPR:
+ case FIX_CEIL_EXPR:
+ case FIX_TRUNC_EXPR:
+ case FLOAT_EXPR:
+ case NEGATE_EXPR:
+ case ABS_EXPR:
+ case MAX_EXPR:
+ case MIN_EXPR:
+ case FFS_EXPR:
+
+ case BIT_AND_EXPR:
+ case BIT_IOR_EXPR:
+ case BIT_XOR_EXPR:
+ case LSHIFT_EXPR:
+ case RSHIFT_EXPR:
+ case LROTATE_EXPR:
+ case RROTATE_EXPR:
+
+ case PREINCREMENT_EXPR:
+ case PREDECREMENT_EXPR:
+ case POSTINCREMENT_EXPR:
+ case POSTDECREMENT_EXPR:
+ if (complain)
+ error ("invalid operation on uninstantiated type");
+ return error_mark_node;
+
+ case TRUTH_AND_EXPR:
+ case TRUTH_OR_EXPR:
+ case TRUTH_XOR_EXPR:
+ case LT_EXPR:
+ case LE_EXPR:
+ case GT_EXPR:
+ case GE_EXPR:
+ case EQ_EXPR:
+ case NE_EXPR:
+ case TRUTH_ANDIF_EXPR:
+ case TRUTH_ORIF_EXPR:
+ case TRUTH_NOT_EXPR:
+ if (complain)
+ error ("not enough type information");
+ return error_mark_node;
+
+ case COND_EXPR:
+ if (type_unknown_p (TREE_OPERAND (rhs, 0)))
+ {
+ if (complain)
+ error ("not enough type information");
+ return error_mark_node;
+ }
+ TREE_OPERAND (rhs, 1)
+ = instantiate_type (lhstype, TREE_OPERAND (rhs, 1), complain);
+ if (TREE_OPERAND (rhs, 1) == error_mark_node)
+ return error_mark_node;
+ TREE_OPERAND (rhs, 2)
+ = instantiate_type (lhstype, TREE_OPERAND (rhs, 2), complain);
+ if (TREE_OPERAND (rhs, 2) == error_mark_node)
+ return error_mark_node;
+
+ TREE_TYPE (rhs) = lhstype;
+ return rhs;
+
+ case MODIFY_EXPR:
+ TREE_OPERAND (rhs, 1)
+ = instantiate_type (lhstype, TREE_OPERAND (rhs, 1), complain);
+ if (TREE_OPERAND (rhs, 1) == error_mark_node)
+ return error_mark_node;
+
+ TREE_TYPE (rhs) = lhstype;
+ return rhs;
+
+ case ADDR_EXPR:
+ if (TYPE_PTRMEMFUNC_P (lhstype))
+ lhstype = TYPE_PTRMEMFUNC_FN_TYPE (lhstype);
+ else if (TREE_CODE (lhstype) != POINTER_TYPE)
+ {
+ if (complain)
+ error ("type for resolving address of overloaded function must be pointer type");
+ return error_mark_node;
+ }
+ TREE_TYPE (rhs) = lhstype;
+ lhstype = TREE_TYPE (lhstype);
+ {
+ tree fn = instantiate_type (lhstype, TREE_OPERAND (rhs, 0), complain);
+ if (fn == error_mark_node)
+ return error_mark_node;
+ mark_addressable (fn);
+ TREE_OPERAND (rhs, 0) = fn;
+ TREE_CONSTANT (rhs) = staticp (fn);
+ }
+ return rhs;
+
+ case ENTRY_VALUE_EXPR:
+ my_friendly_abort (184);
+ return error_mark_node;
+
+ case ERROR_MARK:
+ return error_mark_node;
+
+ default:
+ my_friendly_abort (185);
+ return error_mark_node;
+ }
+}
+
+/* Return the name of the virtual function pointer field
+ (as an IDENTIFIER_NODE) for the given TYPE. Note that
+ this may have to look back through base types to find the
+ ultimate field name. (For single inheritance, these could
+ all be the same name. Who knows for multiple inheritance). */
+static tree
+get_vfield_name (type)
+ tree type;
+{
+ tree binfo = TYPE_BINFO (type);
+ char *buf;
+
+ while (BINFO_BASETYPES (binfo)
+ && TYPE_VIRTUAL_P (BINFO_TYPE (BINFO_BASETYPE (binfo, 0)))
+ && ! TREE_VIA_VIRTUAL (BINFO_BASETYPE (binfo, 0)))
+ binfo = BINFO_BASETYPE (binfo, 0);
+
+ type = BINFO_TYPE (binfo);
+ buf = (char *)alloca (sizeof (VFIELD_NAME_FORMAT)
+ + TYPE_NAME_LENGTH (type) + 2);
+ sprintf (buf, VFIELD_NAME_FORMAT, TYPE_NAME_STRING (type));
+ return get_identifier (buf);
+}
+
+void
+print_class_statistics ()
+{
+#ifdef GATHER_STATISTICS
+ fprintf (stderr, "convert_harshness = %d\n", n_convert_harshness);
+ fprintf (stderr, "compute_conversion_costs = %d\n", n_compute_conversion_costs);
+ fprintf (stderr, "build_method_call = %d (inner = %d)\n",
+ n_build_method_call, n_inner_fields_searched);
+ if (n_vtables)
+ {
+ fprintf (stderr, "vtables = %d; vtable searches = %d\n",
+ n_vtables, n_vtable_searches);
+ fprintf (stderr, "vtable entries = %d; vtable elems = %d\n",
+ n_vtable_entries, n_vtable_elems);
+ }
+#endif
+}
+
+/* Push an obstack which is sufficiently long-lived to hold such class
+ decls that may be cached in the previous_class_values list. For now, let's
+ use the permanent obstack, later we may create a dedicated obstack just
+ for this purpose. The effect is undone by pop_obstacks. */
+void
+maybe_push_cache_obstack ()
+{
+ push_obstacks_nochange ();
+ if (current_class_depth == 1)
+ current_obstack = &permanent_obstack;
+}
diff --git a/contrib/gcc/cp/class.h b/contrib/gcc/cp/class.h
new file mode 100644
index 0000000..f2c2173
--- /dev/null
+++ b/contrib/gcc/cp/class.h
@@ -0,0 +1,117 @@
+/* Variables and structures for overloading rules.
+ Copyright (C) 1993 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+/* The following structure is used when comparing various alternatives
+ for overloading. The unsigned quantity `strikes.i' is used
+ for fast comparison of two possibilities. This number is an
+ aggregate of four constituents:
+
+ EVIL: if this is non-zero, then the candidate should not be considered
+ ELLIPSIS: if this is non-zero, then some actual argument has been matched
+ against an ellipsis
+ USER: if this is non-zero, then a user-defined type conversion is needed
+ B_OR_D: if this is non-zero, then use a base pointer instead of the
+ type of the pointer we started with.
+ EASY: if this is non-zero, then we have a builtin conversion
+ (such as int to long, int to float, etc) to do.
+
+ If two candidates require user-defined type conversions, and the
+ type conversions are not identical, then an ambiguity error
+ is reported.
+
+ If two candidates agree on user-defined type conversions,
+ and one uses pointers of strictly higher type (derived where
+ another uses base), then that alternative is silently chosen.
+
+ Note that this technique really only works for 255 arguments. Perhaps
+ this is not enough. */
+
+/* These macros and harshness_code are used by the NEW METHOD. */
+#define EVIL_CODE (1<<7)
+#define CONST_CODE (1<<6)
+#define ELLIPSIS_CODE (1<<5)
+#define USER_CODE (1<<4)
+#define STD_CODE (1<<3)
+#define PROMO_CODE (1<<2)
+#define QUAL_CODE (1<<1)
+#define TRIVIAL_CODE (1<<0)
+
+struct harshness_code
+{
+ /* What kind of conversion is involved. */
+ unsigned short code;
+
+ /* The inheritance distance. */
+ short distance;
+
+ /* For a PROMO_CODE, Any special penalties involved in integral conversions.
+ This exists because $4.1 of the ARM states that something like
+ `short unsigned int' should promote to `int', not `unsigned int'.
+ If, for example, it tries to match two fns, f(int) and f(unsigned),
+ f(int) should be a better match than f(unsigned) by this rule. Without
+ this extra metric, they both only appear as "integral promotions", which
+ will lead to an ambiguity.
+ For a TRIVIAL_CODE, This is also used by build_overload_call_real and
+ convert_harshness to keep track of other information we need. */
+ unsigned short int_penalty;
+};
+
+struct candidate
+{
+ struct harshness_code h; /* Used for single-argument conversions. */
+
+ int h_len; /* The length of the harshness vector. */
+
+ tree function; /* A FUNCTION_DECL */
+ tree basetypes; /* The path to function. */
+ tree arg; /* first parm to function. */
+
+ /* Indexed by argument number, encodes evil, user, d_to_b, and easy
+ strikes for that argument. At end of array, we store the index+1
+ of where we started using default parameters, or 0 if there are
+ none. */
+ struct harshness_code *harshness;
+
+ union
+ {
+ tree field; /* If no evil strikes, the FUNCTION_DECL of
+ the function (if a member function). */
+ int bad_arg; /* the index of the first bad argument:
+ 0 if no bad arguments
+ > 0 is first bad argument
+ -1 if extra actual arguments
+ -2 if too few actual arguments.
+ -3 if const/non const method mismatch.
+ -4 if type unification failed.
+ -5 if contravariance violation. */
+ } u;
+};
+int rank_for_overload ();
+
+/* Variables shared between class.c and call.c. */
+
+extern int n_vtables;
+extern int n_vtable_entries;
+extern int n_vtable_searches;
+extern int n_vtable_elems;
+extern int n_convert_harshness;
+extern int n_compute_conversion_costs;
+extern int n_build_method_call;
+extern int n_inner_fields_searched;
diff --git a/contrib/gcc/cp/config-lang.in b/contrib/gcc/cp/config-lang.in
new file mode 100644
index 0000000..7a9a5c5
--- /dev/null
+++ b/contrib/gcc/cp/config-lang.in
@@ -0,0 +1,35 @@
+# Top level configure fragment for GNU C++.
+# Copyright (C) 1994, 1995 Free Software Foundation, Inc.
+
+#This file is part of GNU CC.
+
+#GNU CC is free software; you can redistribute it and/or modify
+#it under the terms of the GNU General Public License as published by
+#the Free Software Foundation; either version 2, or (at your option)
+#any later version.
+
+#GNU CC is distributed in the hope that it will be useful,
+#but WITHOUT ANY WARRANTY; without even the implied warranty of
+#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+#GNU General Public License for more details.
+
+#You should have received a copy of the GNU General Public License
+#along with GNU CC; see the file COPYING. If not, write to
+#the Free Software Foundation, 59 Temple Place - Suite 330,
+#Boston, MA 02111-1307, USA.
+
+# Configure looks for the existence of this file to auto-config each language.
+# We define several parameters used by configure:
+#
+# language - name of language as it would appear in $(LANGUAGES)
+# compilers - value to add to $(COMPILERS)
+# stagestuff - files to add to $(STAGESTUFF)
+# diff_excludes - files to ignore when building diffs between two versions.
+
+language="c++"
+
+compilers="cc1plus\$(exeext)"
+
+stagestuff="g++\$(exeext) g++-cross\$(exeext) cc1plus\$(exeext)"
+
+diff_excludes="-x cp/parse.c -x cp/parse.h"
diff --git a/contrib/gcc/cp/cp-tree.h b/contrib/gcc/cp/cp-tree.h
new file mode 100644
index 0000000..fe9855d
--- /dev/null
+++ b/contrib/gcc/cp/cp-tree.h
@@ -0,0 +1,2496 @@
+/* Definitions for C++ parsing and type checking.
+ Copyright (C) 1987, 1993, 1994, 1995 Free Software Foundation, Inc.
+ Hacked by Michael Tiemann (tiemann@cygnus.com)
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#ifndef _CP_TREE_H
+#define _CP_TREE_H
+
+/* Borrow everything that is C from c-tree.h,
+ but do so by copy, not by inclusion, since c-tree.h defines
+ lang_identifier. */
+
+#ifndef STDIO_PROTO
+#ifdef BUFSIZ
+#define STDIO_PROTO(ARGS) PROTO(ARGS)
+#else
+#define STDIO_PROTO(ARGS) ()
+#endif
+#endif
+
+/* Language-dependent contents of an identifier. */
+
+struct lang_identifier
+{
+ struct tree_identifier ignore;
+ tree global_value, local_value;
+ tree class_value;
+ tree class_template_info;
+ struct lang_id2 *x;
+};
+
+struct lang_id2
+{
+ tree label_value, implicit_decl;
+ tree type_desc, as_list, error_locus;
+};
+
+/* To identify to the debug emitters if it should pay attention to the
+ flag `-Wtemplate-debugging'. */
+#define HAVE_TEMPLATES 1
+
+/* Macros for access to language-specific slots in an identifier. */
+
+#define IDENTIFIER_GLOBAL_VALUE(NODE) \
+ (((struct lang_identifier *)(NODE))->global_value)
+#define IDENTIFIER_CLASS_VALUE(NODE) \
+ (((struct lang_identifier *)(NODE))->class_value)
+#define IDENTIFIER_LOCAL_VALUE(NODE) \
+ (((struct lang_identifier *)(NODE))->local_value)
+#define IDENTIFIER_TEMPLATE(NODE) \
+ (((struct lang_identifier *)(NODE))->class_template_info)
+
+#define IDENTIFIER_TYPE_VALUE(NODE) (TREE_TYPE (NODE))
+#define SET_IDENTIFIER_TYPE_VALUE(NODE,TYPE) (TREE_TYPE (NODE) = TYPE)
+#define IDENTIFIER_HAS_TYPE_VALUE(NODE) (TREE_TYPE (NODE) ? 1 : 0)
+
+#define LANG_ID_FIELD(NAME,NODE) \
+ (((struct lang_identifier *)(NODE))->x \
+ ? ((struct lang_identifier *)(NODE))->x->NAME : 0)
+#define SET_LANG_ID(NODE,VALUE,NAME) \
+ (((struct lang_identifier *)(NODE))->x == 0 \
+ ? ((struct lang_identifier *)(NODE))->x \
+ = (struct lang_id2 *)perm_calloc (1, sizeof (struct lang_id2)) : 0, \
+ ((struct lang_identifier *)(NODE))->x->NAME = (VALUE))
+
+#define IDENTIFIER_LABEL_VALUE(NODE) LANG_ID_FIELD(label_value, NODE)
+#define SET_IDENTIFIER_LABEL_VALUE(NODE,VALUE) \
+ SET_LANG_ID(NODE, VALUE, label_value)
+
+#define IDENTIFIER_IMPLICIT_DECL(NODE) LANG_ID_FIELD(implicit_decl, NODE)
+#define SET_IDENTIFIER_IMPLICIT_DECL(NODE,VALUE) \
+ SET_LANG_ID(NODE, VALUE, implicit_decl)
+
+#define IDENTIFIER_AS_DESC(NODE) LANG_ID_FIELD(type_desc, NODE)
+#define SET_IDENTIFIER_AS_DESC(NODE,DESC) \
+ SET_LANG_ID(NODE, DESC, type_desc)
+
+#define IDENTIFIER_AS_LIST(NODE) LANG_ID_FIELD(as_list, NODE)
+#define SET_IDENTIFIER_AS_LIST(NODE,LIST) \
+ SET_LANG_ID(NODE, LIST, as_list)
+
+#define IDENTIFIER_ERROR_LOCUS(NODE) LANG_ID_FIELD(error_locus, NODE)
+#define SET_IDENTIFIER_ERROR_LOCUS(NODE,VALUE) \
+ SET_LANG_ID(NODE, VALUE, error_locus)
+
+
+#define IDENTIFIER_VIRTUAL_P(NODE) TREE_LANG_FLAG_1(NODE)
+
+/* Nonzero if this identifier is the prefix for a mangled C++ operator name. */
+#define IDENTIFIER_OPNAME_P(NODE) TREE_LANG_FLAG_2(NODE)
+
+#define IDENTIFIER_TYPENAME_P(NODE) \
+ (! strncmp (IDENTIFIER_POINTER (NODE), \
+ IDENTIFIER_POINTER (ansi_opname[(int) TYPE_EXPR]), \
+ IDENTIFIER_LENGTH (ansi_opname[(int) TYPE_EXPR])))
+
+/* Nonzero means reject anything that ANSI standard C forbids. */
+extern int pedantic;
+
+/* In a RECORD_TYPE or UNION_TYPE, nonzero if any component is read-only. */
+#define C_TYPE_FIELDS_READONLY(type) TYPE_LANG_FLAG_0 (type)
+
+/* Record in each node resulting from a binary operator
+ what operator was specified for it. */
+#define C_EXP_ORIGINAL_CODE(exp) ((enum tree_code) TREE_COMPLEXITY (exp))
+
+/* Store a value in that field. */
+#define C_SET_EXP_ORIGINAL_CODE(exp, code) \
+ (TREE_COMPLEXITY (exp) = (int)(code))
+
+/* If non-zero, a VAR_DECL whose cleanup will cause a throw to the
+ next exception handler. */
+extern tree exception_throw_decl;
+
+extern tree double_type_node, long_double_type_node, float_type_node;
+extern tree char_type_node, unsigned_char_type_node, signed_char_type_node;
+extern tree ptrdiff_type_node;
+
+extern tree short_integer_type_node, short_unsigned_type_node;
+extern tree long_integer_type_node, long_unsigned_type_node;
+extern tree long_long_integer_type_node, long_long_unsigned_type_node;
+extern tree unsigned_type_node;
+extern tree string_type_node, char_array_type_node, int_array_type_node;
+extern tree wchar_array_type_node;
+extern tree wchar_type_node, signed_wchar_type_node, unsigned_wchar_type_node;
+extern tree intQI_type_node, unsigned_intQI_type_node;
+extern tree intHI_type_node, unsigned_intHI_type_node;
+extern tree intSI_type_node, unsigned_intSI_type_node;
+extern tree intDI_type_node, unsigned_intDI_type_node;
+
+extern int current_function_returns_value;
+extern int current_function_returns_null;
+extern tree current_function_return_value;
+
+extern tree ridpointers[];
+extern tree ansi_opname[];
+extern tree ansi_assopname[];
+
+/* Nonzero means `$' can be in an identifier. */
+
+extern int dollars_in_ident;
+
+/* Nonzero means allow type mismatches in conditional expressions;
+ just make their values `void'. */
+
+extern int flag_cond_mismatch;
+
+/* Nonzero means don't recognize the keyword `asm'. */
+
+extern int flag_no_asm;
+
+/* For cross referencing. */
+
+extern int flag_gnu_xref;
+
+/* For environments where you can use GNU binutils (as, ld in particular). */
+
+extern int flag_gnu_binutils;
+
+/* Nonzero means ignore `#ident' directives. */
+
+extern int flag_no_ident;
+
+/* Nonzero means warn about implicit declarations. */
+
+extern int warn_implicit;
+
+/* Nonzero means warn when all ctors or dtors are private, and the class
+ has no friends. */
+
+extern int warn_ctor_dtor_privacy;
+
+/* Nonzero means warn about function definitions that default the return type
+ or that use a null return and have a return-type other than void. */
+
+extern int warn_return_type;
+
+/* Nonzero means give string constants the type `const char *'
+ to get extra warnings from them. These warnings will be too numerous
+ to be useful, except in thoroughly ANSIfied programs. */
+
+extern int warn_write_strings;
+
+/* Nonzero means warn about sizeof(function) or addition/subtraction
+ of function pointers. */
+
+extern int warn_pointer_arith;
+
+/* Nonzero means warn for all old-style non-prototype function decls. */
+
+extern int warn_strict_prototypes;
+
+/* Nonzero means warn about suggesting putting in ()'s. */
+
+extern int warn_parentheses;
+
+/* Nonzero means warn about multiple (redundant) decls for the same single
+ variable or function. */
+
+extern int warn_redundant_decls;
+
+/* Warn if initializer is not completely bracketed. */
+
+extern int warn_missing_braces;
+
+/* Warn about a subscript that has type char. */
+
+extern int warn_char_subscripts;
+
+/* Nonzero means warn about pointer casts that can drop a type qualifier
+ from the pointer target type. */
+
+extern int warn_cast_qual;
+
+/* Warn about traditional constructs whose meanings changed in ANSI C. */
+
+extern int warn_traditional;
+
+/* Warn about *printf or *scanf format/argument anomalies. */
+
+extern int warn_format;
+
+/* Nonzero means warn about non virtual destructors in classes that have
+ virtual functions. */
+
+extern int warn_nonvdtor;
+
+/* Non-zero means warn when a function is declared extern and later inline. */
+extern int warn_extern_inline;
+
+/* Nonzero means do some things the same way PCC does. */
+
+extern int flag_traditional;
+
+/* Nonzero means to treat bitfields as unsigned unless they say `signed'. */
+
+extern int flag_signed_bitfields;
+
+/* 3 means write out only virtuals function tables `defined'
+ in this implementation file.
+ 2 means write out only specific virtual function tables
+ and give them (C) public access.
+ 1 means write out virtual function tables and give them
+ (C) public access.
+ 0 means write out virtual function tables and give them
+ (C) static access (default).
+ -1 means declare virtual function tables extern. */
+
+extern int write_virtuals;
+
+/* True for more efficient but incompatible (not not fully tested)
+ vtable implementation (using thunks).
+ 0 is old behavior; 1 is new behavior. */
+extern int flag_vtable_thunks;
+
+/* INTERFACE_ONLY nonzero means that we are in an "interface"
+ section of the compiler. INTERFACE_UNKNOWN nonzero means
+ we cannot trust the value of INTERFACE_ONLY. If INTERFACE_UNKNOWN
+ is zero and INTERFACE_ONLY is zero, it means that we are responsible
+ for exporting definitions that others might need. */
+extern int interface_only, interface_unknown;
+
+/* Nonzero means we should attempt to elide constructors when possible. */
+
+extern int flag_elide_constructors;
+
+/* Nonzero means enable obscure ANSI features and disable GNU extensions
+ that might cause ANSI-compliant code to be miscompiled. */
+
+extern int flag_ansi;
+
+/* Nonzero means recognize and handle ansi-style exception handling
+ constructs. */
+
+extern int flag_handle_exceptions;
+
+/* Nonzero means recognize and handle signature language constructs. */
+
+extern int flag_handle_signatures;
+
+/* Nonzero means that member functions defined in class scope are
+ inline by default. */
+
+extern int flag_default_inline;
+
+/* Nonzero means emit cadillac protocol. */
+
+extern int flag_cadillac;
+
+/* C++ language-specific tree codes. */
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) SYM,
+enum cplus_tree_code {
+ __DUMMY = LAST_AND_UNUSED_TREE_CODE,
+#include "tree.def"
+ LAST_CPLUS_TREE_CODE
+};
+#undef DEFTREECODE
+
+/* Override OFFSET_REFs from the back-end, as we want our very own. */
+/* Allow complex pointer to members to work correctly. */
+#define OFFSET_REF CP_OFFSET_REF
+
+enum languages { lang_c, lang_cplusplus };
+
+/* Macros to make error reporting functions' lives easier. */
+#define TYPE_IDENTIFIER(NODE) (DECL_NAME (TYPE_NAME (NODE)))
+#define TYPE_NAME_STRING(NODE) (IDENTIFIER_POINTER (TYPE_IDENTIFIER (NODE)))
+#define TYPE_NAME_LENGTH(NODE) (IDENTIFIER_LENGTH (TYPE_IDENTIFIER (NODE)))
+
+#define TYPE_ASSEMBLER_NAME_STRING(NODE) (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (TYPE_NAME (NODE))))
+#define TYPE_ASSEMBLER_NAME_LENGTH(NODE) (IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (TYPE_NAME (NODE))))
+
+/* The _DECL for this _TYPE. */
+#define TYPE_MAIN_DECL(NODE) (TYPE_NAME (NODE))
+
+#define IS_AGGR_TYPE(t) (TYPE_LANG_FLAG_5 (t))
+#define IS_AGGR_TYPE_CODE(t) (t == RECORD_TYPE || t == UNION_TYPE || t == UNINSTANTIATED_P_TYPE)
+#define IS_AGGR_TYPE_2(TYPE1,TYPE2) \
+ (TREE_CODE (TYPE1) == TREE_CODE (TYPE2) \
+ && IS_AGGR_TYPE (TYPE1)&IS_AGGR_TYPE (TYPE2))
+#define IS_OVERLOAD_TYPE_CODE(t) (IS_AGGR_TYPE_CODE (t) || t == ENUMERAL_TYPE)
+#define IS_OVERLOAD_TYPE(t) (IS_OVERLOAD_TYPE_CODE (TREE_CODE (t)))
+
+/* In a *_TYPE, nonzero means a built-in type. */
+#define TYPE_BUILT_IN(NODE) TYPE_LANG_FLAG_6(NODE)
+
+/* Macros which might want to be replaced by function calls. */
+
+#define DELTA_FROM_VTABLE_ENTRY(ENTRY) \
+ (!flag_vtable_thunks ? \
+ TREE_VALUE (CONSTRUCTOR_ELTS (ENTRY)) \
+ : TREE_CODE (TREE_OPERAND ((ENTRY), 0)) != THUNK_DECL ? integer_zero_node \
+ : build_int_2 (THUNK_DELTA (TREE_OPERAND ((ENTRY), 0)), 0))
+#if 1
+/* Virtual function addresses can be gotten from a virtual function
+ table entry using this macro. */
+#define FNADDR_FROM_VTABLE_ENTRY(ENTRY) \
+ (!flag_vtable_thunks ? \
+ TREE_VALUE (TREE_CHAIN (TREE_CHAIN (CONSTRUCTOR_ELTS (ENTRY)))) \
+ : TREE_CODE (TREE_OPERAND ((ENTRY), 0)) != THUNK_DECL ? (ENTRY) \
+ : DECL_INITIAL (TREE_OPERAND ((ENTRY), 0)))
+#define SET_FNADDR_FROM_VTABLE_ENTRY(ENTRY,VALUE) \
+ (TREE_VALUE (TREE_CHAIN (TREE_CHAIN (CONSTRUCTOR_ELTS (ENTRY)))) = (VALUE))
+#define FUNCTION_ARG_CHAIN(NODE) (TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (NODE))))
+#define PROMOTES_TO_AGGR_TYPE(NODE,CODE) \
+ (((CODE) == TREE_CODE (NODE) \
+ && IS_AGGR_TYPE (TREE_TYPE (NODE))) \
+ || IS_AGGR_TYPE (NODE))
+
+#else
+#define FNADDR_FROM_VTABLE_ENTRY(ENTRY) (fnaddr_from_vtable_entry (ENTRY))
+#define SET_FNADDR_FROM_VTABLE_ENTRY(ENTRY,VALUE) \
+ (set_fnaddr_from_vtable_entry (ENTRY, VALUE))
+/* #define TYPE_NAME_STRING(NODE) (type_name_string (NODE)) */
+#define FUNCTION_ARG_CHAIN(NODE) (function_arg_chain (NODE))
+#define PROMOTES_TO_AGGR_TYPE(NODE,CODE) (promotes_to_aggr_type (NODE, CODE))
+/* #define IS_AGGR_TYPE_2(TYPE1, TYPE2) (is_aggr_type_2 (TYPE1, TYPE2)) */
+#endif
+/* Nonzero iff TYPE is uniquely derived from PARENT. Under MI, PARENT can
+ be an ambiguous base class of TYPE, and this macro will be false. */
+#define UNIQUELY_DERIVED_FROM_P(PARENT, TYPE) (get_base_distance (PARENT, TYPE, 0, (tree *)0) >= 0)
+#define ACCESSIBLY_DERIVED_FROM_P(PARENT, TYPE) (get_base_distance (PARENT, TYPE, -1, (tree *)0) >= 0)
+#define ACCESSIBLY_UNIQUELY_DERIVED_P(PARENT, TYPE) (get_base_distance (PARENT, TYPE, 1, (tree *)0) >= 0)
+#define DERIVED_FROM_P(PARENT, TYPE) (get_base_distance (PARENT, TYPE, 0, (tree *)0) != -1)
+
+/* Statistics show that while the GNU C++ compiler may generate
+ thousands of different types during a compilation run, it
+ generates relatively few (tens) of classtypes. Because of this,
+ it is not costly to store a generous amount of information
+ in classtype nodes. This struct must fill out to a multiple of 4 bytes. */
+struct lang_type
+{
+ struct
+ {
+ unsigned has_type_conversion : 1;
+ unsigned has_int_conversion : 1;
+ unsigned has_float_conversion : 1;
+ unsigned has_init_ref : 1;
+ unsigned gets_init_aggr : 1;
+ unsigned has_assignment : 1;
+ unsigned has_default_ctor : 1;
+ unsigned uses_multiple_inheritance : 1;
+
+ unsigned has_nonpublic_ctor : 2;
+ unsigned has_nonpublic_assign_ref : 2;
+ unsigned const_needs_init : 1;
+ unsigned ref_needs_init : 1;
+ unsigned has_const_assign_ref : 1;
+ unsigned vtable_needs_writing : 1;
+
+ unsigned has_assign_ref : 1;
+ unsigned gets_new : 2;
+ unsigned gets_delete : 2;
+ unsigned has_call_overloaded : 1;
+ unsigned has_array_ref_overloaded : 1;
+ unsigned has_arrow_overloaded : 1;
+
+ unsigned local_typedecls : 1;
+ unsigned interface_only : 1;
+ unsigned interface_unknown : 1;
+ unsigned needs_virtual_reinit : 1;
+ unsigned vec_delete_takes_size : 1;
+ unsigned declared_class : 1;
+ unsigned being_defined : 1;
+ unsigned redefined : 1;
+
+ unsigned no_globalize : 1;
+ unsigned marked : 1;
+ unsigned marked2 : 1;
+ unsigned marked3 : 1;
+ unsigned marked4 : 1;
+ unsigned marked5 : 1;
+ unsigned marked6 : 1;
+
+ unsigned use_template : 2;
+ unsigned debug_requested : 1;
+ unsigned has_method_call_overloaded : 1;
+ unsigned private_attr : 1;
+ unsigned got_semicolon : 1;
+ unsigned ptrmemfunc_flag : 1;
+ unsigned is_signature : 1;
+ unsigned is_signature_pointer : 1;
+
+ unsigned is_signature_reference : 1;
+ unsigned has_default_implementation : 1;
+ unsigned grokking_typedef : 1;
+ unsigned has_opaque_typedecls : 1;
+ unsigned sigtable_has_been_generated : 1;
+ unsigned was_anonymous : 1;
+ unsigned has_real_assignment : 1;
+ unsigned has_real_assign_ref : 1;
+
+ unsigned has_const_init_ref : 1;
+ unsigned has_complex_init_ref : 1;
+ unsigned has_complex_assign_ref : 1;
+ unsigned has_abstract_assign_ref : 1;
+ unsigned non_aggregate : 1;
+
+ /* The MIPS compiler gets it wrong if this struct also
+ does not fill out to a multiple of 4 bytes. Add a
+ member `dummy' with new bits if you go over the edge. */
+ unsigned dummy : 19;
+
+ unsigned n_vancestors : 16;
+ } type_flags;
+
+ int cid;
+ int n_ancestors;
+ int vsize;
+ int max_depth;
+ int vfield_parent;
+
+ union tree_node *vbinfo[2];
+ union tree_node *baselink_vec;
+ union tree_node *vfields;
+ union tree_node *vbases;
+ union tree_node *vbase_size;
+
+ union tree_node *tags;
+ char *memoized_table_entry;
+
+ char *search_slot;
+
+#ifdef ONLY_INT_FIELDS
+ unsigned int mode : 8;
+#else
+ enum machine_mode mode : 8;
+#endif
+
+ unsigned char size_unit;
+ unsigned char align;
+ unsigned char sep_unit;
+
+ union tree_node *sep;
+ union tree_node *size;
+
+ union tree_node *base_init_list;
+ union tree_node *abstract_virtuals;
+ union tree_node *as_list;
+ union tree_node *id_as_list;
+ union tree_node *binfo_as_list;
+ union tree_node *friend_classes;
+
+ char *mi_matrix;
+
+ union tree_node *rtti;
+
+ union tree_node *methods;
+
+ union tree_node *signature;
+ union tree_node *signature_pointer_to;
+ union tree_node *signature_reference_to;
+
+ int linenum;
+};
+
+#define CLASSTYPE_SOURCE_LINE(NODE) (TYPE_LANG_SPECIFIC(NODE)->linenum)
+
+/* Indicates whether or not (and how) a template was expanded for this class.
+ 0=no information yet/non-template class
+ 1=implicit template instantiation
+ 2=explicit template specialization
+ 3=explicit template instantiation */
+#define CLASSTYPE_USE_TEMPLATE(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.use_template)
+
+/* Fields used for storing information before the class is defined.
+ After the class is defined, these fields hold other information. */
+
+/* List of friends which were defined inline in this class definition. */
+#define CLASSTYPE_INLINE_FRIENDS(NODE) (TYPE_NONCOPIED_PARTS (NODE))
+
+/* Nonzero for _CLASSTYPE means that the _CLASSTYPE either has
+ a special meaning for the assignment operator ("operator="),
+ or one of its fields (or base members) has a special meaning
+ defined. */
+#define TYPE_HAS_ASSIGNMENT(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_assignment)
+#define TYPE_HAS_REAL_ASSIGNMENT(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_real_assignment)
+
+/* Nonzero for _CLASSTYPE means that operator new and delete are defined,
+ respectively. */
+#define TYPE_GETS_NEW(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.gets_new)
+#define TYPE_GETS_DELETE(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.gets_delete)
+#define TYPE_GETS_REG_DELETE(NODE) (TYPE_GETS_DELETE (NODE) & 1)
+
+/* Nonzero for _CLASSTYPE means that operator vec delete is defined and
+ takes the optional size_t argument. */
+#define TYPE_VEC_DELETE_TAKES_SIZE(NODE) \
+ (TYPE_LANG_SPECIFIC(NODE)->type_flags.vec_delete_takes_size)
+#define TYPE_VEC_NEW_USES_COOKIE(NODE) \
+ (TYPE_NEEDS_DESTRUCTOR (NODE) \
+ || (TYPE_LANG_SPECIFIC (NODE) && TYPE_VEC_DELETE_TAKES_SIZE (NODE)))
+
+/* Nonzero for TREE_LIST or _TYPE node means that this node is class-local. */
+#define TREE_NONLOCAL_FLAG(NODE) (TREE_LANG_FLAG_0 (NODE))
+
+/* Nonzero for a _CLASSTYPE node which we know to be private. */
+#define TYPE_PRIVATE_P(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.private_attr)
+
+/* Nonzero means that this _CLASSTYPE node defines ways of converting
+ itself to other types. */
+#define TYPE_HAS_CONVERSION(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_type_conversion)
+
+/* Nonzero means that this _CLASSTYPE node can convert itself to an
+ INTEGER_TYPE. */
+#define TYPE_HAS_INT_CONVERSION(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_int_conversion)
+
+/* Nonzero means that this _CLASSTYPE node can convert itself to an
+ REAL_TYPE. */
+#define TYPE_HAS_REAL_CONVERSION(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_float_conversion)
+
+/* Nonzero means that this _CLASSTYPE node overloads operator=(X&). */
+#define TYPE_HAS_ASSIGN_REF(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_assign_ref)
+#define TYPE_HAS_CONST_ASSIGN_REF(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_const_assign_ref)
+
+/* Nonzero means that this _CLASSTYPE node has an X(X&) constructor. */
+#define TYPE_HAS_INIT_REF(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_init_ref)
+#define TYPE_HAS_CONST_INIT_REF(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_const_init_ref)
+
+/* Nonzero means that this _CLASSTYPE node has an X(X ...) constructor.
+ Note that there must be other arguments, or this constructor is flagged
+ as being erroneous. */
+#define TYPE_GETS_INIT_AGGR(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.gets_init_aggr)
+
+/* Nonzero means that this type is being defined. I.e., the left brace
+ starting the definition of this type has been seen. */
+#define TYPE_BEING_DEFINED(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.being_defined)
+/* Nonzero means that this type has been redefined. In this case, if
+ convenient, don't reprocess any methods that appear in its redefinition. */
+#define TYPE_REDEFINED(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.redefined)
+
+/* Nonzero means that this _CLASSTYPE node overloads the method call
+ operator. In this case, all method calls go through `operator->()(...). */
+#define TYPE_OVERLOADS_METHOD_CALL_EXPR(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_method_call_overloaded)
+
+/* Nonzero means that this type is a signature. */
+# define IS_SIGNATURE(NODE) (TYPE_LANG_SPECIFIC(NODE)?TYPE_LANG_SPECIFIC(NODE)->type_flags.is_signature:0)
+# define SET_SIGNATURE(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.is_signature=1)
+# define CLEAR_SIGNATURE(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.is_signature=0)
+
+/* Nonzero means that this type is a signature pointer type. */
+# define IS_SIGNATURE_POINTER(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.is_signature_pointer)
+
+/* Nonzero means that this type is a signature reference type. */
+# define IS_SIGNATURE_REFERENCE(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.is_signature_reference)
+
+/* Nonzero means that this signature type has a default implementation. */
+# define HAS_DEFAULT_IMPLEMENTATION(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_default_implementation)
+
+/* Nonzero means that grokdeclarator works on a signature-local typedef. */
+#define SIGNATURE_GROKKING_TYPEDEF(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.grokking_typedef)
+
+/* Nonzero means that this signature contains opaque type declarations. */
+#define SIGNATURE_HAS_OPAQUE_TYPEDECLS(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_opaque_typedecls)
+
+/* Nonzero means that a signature table has been generated
+ for this signature. */
+#define SIGTABLE_HAS_BEEN_GENERATED(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.sigtable_has_been_generated)
+
+/* If NODE is a class, this is the signature type that contains NODE's
+ signature after it has been computed using sigof(). */
+#define CLASSTYPE_SIGNATURE(NODE) (TYPE_LANG_SPECIFIC(NODE)->signature)
+
+/* If NODE is a signature pointer or signature reference, this is the
+ signature type the pointer/reference points to. */
+#define SIGNATURE_TYPE(NODE) (TYPE_LANG_SPECIFIC(NODE)->signature)
+
+/* If NODE is a signature, this is a vector of all methods defined
+ in the signature or in its base types together with their default
+ implementations. */
+#define SIGNATURE_METHOD_VEC(NODE) (TYPE_LANG_SPECIFIC(NODE)->signature)
+
+/* If NODE is a signature, this is the _TYPE node that contains NODE's
+ signature pointer type. */
+#define SIGNATURE_POINTER_TO(NODE) (TYPE_LANG_SPECIFIC(NODE)->signature_pointer_to)
+
+/* If NODE is a signature, this is the _TYPE node that contains NODE's
+ signature reference type. */
+#define SIGNATURE_REFERENCE_TO(NODE) (TYPE_LANG_SPECIFIC(NODE)->signature_reference_to)
+
+/* The is the VAR_DECL that contains NODE's rtti. */
+#define CLASSTYPE_RTTI(NODE) (TYPE_LANG_SPECIFIC(NODE)->rtti)
+
+/* List of all explicit methods (chained using DECL_NEXT_METHOD),
+ in order they were parsed. */
+#define CLASSTYPE_METHODS(NODE) (TYPE_LANG_SPECIFIC(NODE)->methods)
+
+/* Nonzero means that this _CLASSTYPE node overloads operator(). */
+#define TYPE_OVERLOADS_CALL_EXPR(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_call_overloaded)
+
+/* Nonzero means that this _CLASSTYPE node overloads operator[]. */
+#define TYPE_OVERLOADS_ARRAY_REF(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_array_ref_overloaded)
+
+/* Nonzero means that this _CLASSTYPE node overloads operator->. */
+#define TYPE_OVERLOADS_ARROW(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_arrow_overloaded)
+
+/* Nonzero means that this _CLASSTYPE (or one of its ancestors) uses
+ multiple inheritance. If this is 0 for the root of a type
+ hierarchy, then we can use more efficient search techniques. */
+#define TYPE_USES_MULTIPLE_INHERITANCE(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.uses_multiple_inheritance)
+
+/* Nonzero means that this _CLASSTYPE (or one of its ancestors) uses
+ virtual base classes. If this is 0 for the root of a type
+ hierarchy, then we can use more efficient search techniques. */
+#define TYPE_USES_VIRTUAL_BASECLASSES(NODE) (TREE_LANG_FLAG_3(NODE))
+
+/* List of lists of member functions defined in this class. */
+#define CLASSTYPE_METHOD_VEC(NODE) TYPE_METHODS(NODE)
+
+/* The first type conversion operator in the class (the others can be
+ searched with TREE_CHAIN), or the first non-constructor function if
+ there are no type conversion operators. */
+#define CLASSTYPE_FIRST_CONVERSION(NODE) \
+ TREE_VEC_LENGTH (CLASSTYPE_METHOD_VEC (NODE)) > 1 \
+ ? TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (NODE), 1) \
+ : NULL_TREE;
+
+/* Pointer from any member function to the head of the list of
+ member functions of the type that member function belongs to. */
+#define CLASSTYPE_BASELINK_VEC(NODE) (TYPE_LANG_SPECIFIC(NODE)->baselink_vec)
+
+/* Mark bits for depth-first and breath-first searches. */
+#define CLASSTYPE_MARKED(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.marked)
+#define CLASSTYPE_MARKED2(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.marked2)
+#define CLASSTYPE_MARKED3(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.marked3)
+#define CLASSTYPE_MARKED4(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.marked4)
+#define CLASSTYPE_MARKED5(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.marked5)
+#define CLASSTYPE_MARKED6(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.marked6)
+/* Macros to modify the above flags */
+#define SET_CLASSTYPE_MARKED(NODE) (CLASSTYPE_MARKED(NODE) = 1)
+#define CLEAR_CLASSTYPE_MARKED(NODE) (CLASSTYPE_MARKED(NODE) = 0)
+#define SET_CLASSTYPE_MARKED2(NODE) (CLASSTYPE_MARKED2(NODE) = 1)
+#define CLEAR_CLASSTYPE_MARKED2(NODE) (CLASSTYPE_MARKED2(NODE) = 0)
+#define SET_CLASSTYPE_MARKED3(NODE) (CLASSTYPE_MARKED3(NODE) = 1)
+#define CLEAR_CLASSTYPE_MARKED3(NODE) (CLASSTYPE_MARKED3(NODE) = 0)
+#define SET_CLASSTYPE_MARKED4(NODE) (CLASSTYPE_MARKED4(NODE) = 1)
+#define CLEAR_CLASSTYPE_MARKED4(NODE) (CLASSTYPE_MARKED4(NODE) = 0)
+#define SET_CLASSTYPE_MARKED5(NODE) (CLASSTYPE_MARKED5(NODE) = 1)
+#define CLEAR_CLASSTYPE_MARKED5(NODE) (CLASSTYPE_MARKED5(NODE) = 0)
+#define SET_CLASSTYPE_MARKED6(NODE) (CLASSTYPE_MARKED6(NODE) = 1)
+#define CLEAR_CLASSTYPE_MARKED6(NODE) (CLASSTYPE_MARKED6(NODE) = 0)
+
+#define CLASSTYPE_TAGS(NODE) (TYPE_LANG_SPECIFIC(NODE)->tags)
+
+/* If this class has any bases, this is the number of the base class from
+ which our VFIELD is based, -1 otherwise. If this class has no base
+ classes, this is not used.
+ In D : B1, B2, PARENT would be 0, if D's vtable came from B1,
+ 1, if D's vtable came from B2. */
+#define CLASSTYPE_VFIELD_PARENT(NODE) (TYPE_LANG_SPECIFIC(NODE)->vfield_parent)
+
+/* Remove when done merging. */
+#define CLASSTYPE_VFIELD(NODE) TYPE_VFIELD(NODE)
+
+/* The number of virtual functions defined for this
+ _CLASSTYPE node. */
+#define CLASSTYPE_VSIZE(NODE) (TYPE_LANG_SPECIFIC(NODE)->vsize)
+/* The virtual base classes that this type uses. */
+#define CLASSTYPE_VBASECLASSES(NODE) (TYPE_LANG_SPECIFIC(NODE)->vbases)
+/* The virtual function pointer fields that this type contains. */
+#define CLASSTYPE_VFIELDS(NODE) (TYPE_LANG_SPECIFIC(NODE)->vfields)
+
+/* Number of baseclasses defined for this type.
+ 0 means no base classes. */
+#define CLASSTYPE_N_BASECLASSES(NODE) \
+ (TYPE_BINFO_BASETYPES (NODE) ? TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES(NODE)) : 0)
+
+/* Memoize the number of super classes (base classes) tha this node
+ has. That way we can know immediately (albeit conservatively how
+ large a multiple-inheritance matrix we need to build to find
+ derivation information. */
+#define CLASSTYPE_N_SUPERCLASSES(NODE) (TYPE_LANG_SPECIFIC(NODE)->n_ancestors)
+#define CLASSTYPE_N_VBASECLASSES(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.n_vancestors)
+
+/* Record how deep the inheritance is for this class so `void*' conversions
+ are less favorable than a conversion to the most base type. */
+#define CLASSTYPE_MAX_DEPTH(NODE) (TYPE_LANG_SPECIFIC(NODE)->max_depth)
+
+/* Used for keeping search-specific information. Any search routine
+ which uses this must define what exactly this slot is used for. */
+#define CLASSTYPE_SEARCH_SLOT(NODE) (TYPE_LANG_SPECIFIC(NODE)->search_slot)
+
+/* Entry for keeping memoization tables for this type to
+ hopefully speed up search routines. Since it is a pointer,
+ it can mean almost anything. */
+#define CLASSTYPE_MTABLE_ENTRY(NODE) (TYPE_LANG_SPECIFIC(NODE)->memoized_table_entry)
+
+/* This is the total size of the baseclasses defined for this type.
+ Needed because it is desirable to layout such information
+ before beginning to process the class itself, and we
+ don't want to compute it second time when actually laying
+ out the type for real. */
+#define CLASSTYPE_SIZE(NODE) (TYPE_LANG_SPECIFIC(NODE)->size)
+#define CLASSTYPE_SIZE_UNIT(NODE) (TYPE_LANG_SPECIFIC(NODE)->size_unit)
+#define CLASSTYPE_MODE(NODE) (TYPE_LANG_SPECIFIC(NODE)->mode)
+#define CLASSTYPE_ALIGN(NODE) (TYPE_LANG_SPECIFIC(NODE)->align)
+
+/* This is the space needed for virtual base classes. NULL if
+ there are no virtual basetypes. */
+#define CLASSTYPE_VBASE_SIZE(NODE) (TYPE_LANG_SPECIFIC(NODE)->vbase_size)
+
+/* A cons list of structure elements which either have constructors
+ to be called, or virtual function table pointers which
+ need initializing. Depending on what is being initialized,
+ the TREE_PURPOSE and TREE_VALUE fields have different meanings:
+
+ Member initialization: <FIELD_DECL, TYPE>
+ Base class construction: <NULL_TREE, BASETYPE>
+ Base class initialization: <BASE_INITIALIZATION, THESE_INITIALIZATIONS>
+ Whole type: <MEMBER_INIT, BASE_INIT>. */
+#define CLASSTYPE_BASE_INIT_LIST(NODE) (TYPE_LANG_SPECIFIC(NODE)->base_init_list)
+
+/* A cons list of virtual functions which cannot be inherited by
+ derived classes. When deriving from this type, the derived
+ class must provide its own definition for each of these functions. */
+#define CLASSTYPE_ABSTRACT_VIRTUALS(NODE) (TYPE_LANG_SPECIFIC(NODE)->abstract_virtuals)
+
+/* Nonzero means that this aggr type has been `closed' by a semicolon. */
+#define CLASSTYPE_GOT_SEMICOLON(NODE) (TYPE_LANG_SPECIFIC (NODE)->type_flags.got_semicolon)
+
+/* Nonzero means that the main virtual function table pointer needs to be
+ set because base constructors have placed the wrong value there.
+ If this is zero, it means that they placed the right value there,
+ and there is no need to change it. */
+#define CLASSTYPE_NEEDS_VIRTUAL_REINIT(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.needs_virtual_reinit)
+
+/* Nonzero means that if this type has virtual functions, that
+ the virtual function table will be written out. */
+#define CLASSTYPE_VTABLE_NEEDS_WRITING(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.vtable_needs_writing)
+
+/* Nonzero means that this type defines its own local type declarations. */
+#define CLASSTYPE_LOCAL_TYPEDECLS(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.local_typedecls)
+
+/* Nonzero means that this type has an X() constructor. */
+#define TYPE_HAS_DEFAULT_CONSTRUCTOR(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_default_ctor)
+
+/* Nonzero means the type declared a ctor as private or protected. We
+ use this to make sure we don't try to generate a copy ctor for a
+ class that has a member of type NODE. */
+#define TYPE_HAS_NONPUBLIC_CTOR(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_nonpublic_ctor)
+
+/* Ditto, for operator=. */
+#define TYPE_HAS_NONPUBLIC_ASSIGN_REF(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_nonpublic_assign_ref)
+
+/* Many routines need to cons up a list of basetypes for access
+ checking. This field contains a TREE_LIST node whose TREE_VALUE
+ is the main variant of the type, and whose TREE_VIA_PUBLIC
+ and TREE_VIA_VIRTUAL bits are correctly set. */
+#define CLASSTYPE_AS_LIST(NODE) (TYPE_LANG_SPECIFIC(NODE)->as_list)
+/* Same, but cache a list whose value is the name of this type. */
+#define CLASSTYPE_ID_AS_LIST(NODE) (TYPE_LANG_SPECIFIC(NODE)->id_as_list)
+/* Same, but cache a list whose value is the binfo of this type. */
+#define CLASSTYPE_BINFO_AS_LIST(NODE) (TYPE_LANG_SPECIFIC(NODE)->binfo_as_list)
+
+/* A list of class types with which this type is a friend. */
+#define CLASSTYPE_FRIEND_CLASSES(NODE) (TYPE_LANG_SPECIFIC(NODE)->friend_classes)
+
+/* Keep an inheritance lattice around so we can quickly tell whether
+ a type is derived from another or not. */
+#define CLASSTYPE_MI_MATRIX(NODE) (TYPE_LANG_SPECIFIC(NODE)->mi_matrix)
+
+/* Say whether this node was declared as a "class" or a "struct". */
+#define CLASSTYPE_DECLARED_CLASS(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.declared_class)
+/* whether this can be globalized. */
+#define CLASSTYPE_NO_GLOBALIZE(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.no_globalize)
+
+/* Nonzero if this class has const members which have no specified initialization. */
+#define CLASSTYPE_READONLY_FIELDS_NEED_INIT(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.const_needs_init)
+
+/* Nonzero if this class has ref members which have no specified initialization. */
+#define CLASSTYPE_REF_FIELDS_NEED_INIT(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.ref_needs_init)
+
+/* Nonzero if this class is included from a header file which employs
+ `#pragma interface', and it is not included in its implementation file. */
+#define CLASSTYPE_INTERFACE_ONLY(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.interface_only)
+
+/* Same as above, but for classes whose purpose we do not know. */
+#define CLASSTYPE_INTERFACE_UNKNOWN(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.interface_unknown)
+#define CLASSTYPE_INTERFACE_KNOWN(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.interface_unknown == 0)
+#define SET_CLASSTYPE_INTERFACE_UNKNOWN_X(NODE,X) (TYPE_LANG_SPECIFIC(NODE)->type_flags.interface_unknown = !!(X))
+#define SET_CLASSTYPE_INTERFACE_UNKNOWN(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.interface_unknown = 1)
+#define SET_CLASSTYPE_INTERFACE_KNOWN(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.interface_unknown = 0)
+
+/* Nonzero if a _DECL node requires us to output debug info for this class. */
+#define CLASSTYPE_DEBUG_REQUESTED(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.debug_requested)
+
+#define TYPE_INCOMPLETE(NODE) \
+ (TYPE_SIZE (NODE) == NULL_TREE && TREE_CODE (NODE) != TEMPLATE_TYPE_PARM)
+
+/* Additional macros for inheritance information. */
+
+#define CLASSTYPE_VBINFO(NODE,VIA_PUBLIC) \
+ (TYPE_LANG_SPECIFIC (NODE)->vbinfo[VIA_PUBLIC])
+
+/* When following an binfo-specific chain, this is the cumulative
+ via-public flag. */
+#define BINFO_VIA_PUBLIC(NODE) TREE_LANG_FLAG_5 (NODE)
+
+/* When building a matrix to determine by a single lookup
+ whether one class is derived from another or not,
+ this field is the index of the class in the table. */
+#define CLASSTYPE_CID(NODE) (TYPE_LANG_SPECIFIC(NODE)->cid)
+#define BINFO_CID(NODE) CLASSTYPE_CID(BINFO_TYPE(NODE))
+
+/* Nonzero means marked by DFS or BFS search, including searches
+ by `get_binfo' and `get_base_distance'. */
+#define BINFO_MARKED(NODE) (TREE_VIA_VIRTUAL(NODE)?CLASSTYPE_MARKED(BINFO_TYPE(NODE)):TREE_LANG_FLAG_0(NODE))
+/* Macros needed because of C compilers that don't allow conditional
+ expressions to be lvalues. Grr! */
+#define SET_BINFO_MARKED(NODE) (TREE_VIA_VIRTUAL(NODE)?SET_CLASSTYPE_MARKED(BINFO_TYPE(NODE)):(TREE_LANG_FLAG_0(NODE)=1))
+#define CLEAR_BINFO_MARKED(NODE) (TREE_VIA_VIRTUAL(NODE)?CLEAR_CLASSTYPE_MARKED(BINFO_TYPE(NODE)):(TREE_LANG_FLAG_0(NODE)=0))
+
+/* Nonzero means marked in building initialization list. */
+#define BINFO_BASEINIT_MARKED(NODE) CLASSTYPE_MARKED2 (BINFO_TYPE (NODE))
+/* Modifier macros */
+#define SET_BINFO_BASEINIT_MARKED(NODE) SET_CLASSTYPE_MARKED2 (BINFO_TYPE (NODE))
+#define CLEAR_BINFO_BASEINIT_MARKED(NODE) CLEAR_CLASSTYPE_MARKED2 (BINFO_TYPE (NODE))
+
+/* Nonzero means marked in search through virtual inheritance hierarchy. */
+#define BINFO_VBASE_MARKED(NODE) CLASSTYPE_MARKED2 (BINFO_TYPE (NODE))
+/* Modifier macros */
+#define SET_BINFO_VBASE_MARKED(NODE) SET_CLASSTYPE_MARKED2 (BINFO_TYPE (NODE))
+#define CLEAR_BINFO_VBASE_MARKED(NODE) CLEAR_CLASSTYPE_MARKED2 (BINFO_TYPE (NODE))
+
+/* Nonzero means marked in search for members or member functions. */
+#define BINFO_FIELDS_MARKED(NODE) \
+ (TREE_VIA_VIRTUAL(NODE)?CLASSTYPE_MARKED2 (BINFO_TYPE (NODE)):TREE_LANG_FLAG_2(NODE))
+#define SET_BINFO_FIELDS_MARKED(NODE) (TREE_VIA_VIRTUAL(NODE)?SET_CLASSTYPE_MARKED2(BINFO_TYPE(NODE)):(TREE_LANG_FLAG_2(NODE)=1))
+#define CLEAR_BINFO_FIELDS_MARKED(NODE) (TREE_VIA_VIRTUAL(NODE)?CLEAR_CLASSTYPE_MARKED2(BINFO_TYPE(NODE)):(TREE_LANG_FLAG_2(NODE)=0))
+
+/* Nonzero means that this class is on a path leading to a new vtable. */
+#define BINFO_VTABLE_PATH_MARKED(NODE) \
+ (TREE_VIA_VIRTUAL(NODE)?CLASSTYPE_MARKED3(BINFO_TYPE(NODE)):TREE_LANG_FLAG_3(NODE))
+#define SET_BINFO_VTABLE_PATH_MARKED(NODE) (TREE_VIA_VIRTUAL(NODE)?SET_CLASSTYPE_MARKED3(BINFO_TYPE(NODE)):(TREE_LANG_FLAG_3(NODE)=1))
+#define CLEAR_BINFO_VTABLE_PATH_MARKED(NODE) (TREE_VIA_VIRTUAL(NODE)?CLEAR_CLASSTYPE_MARKED3(BINFO_TYPE(NODE)):(TREE_LANG_FLAG_3(NODE)=0))
+
+/* Nonzero means that this class has a new vtable. */
+#define BINFO_NEW_VTABLE_MARKED(NODE) \
+ (TREE_VIA_VIRTUAL(NODE)?CLASSTYPE_MARKED4(BINFO_TYPE(NODE)):TREE_LANG_FLAG_4(NODE))
+#define SET_BINFO_NEW_VTABLE_MARKED(NODE) (TREE_VIA_VIRTUAL(NODE)?SET_CLASSTYPE_MARKED4(BINFO_TYPE(NODE)):(TREE_LANG_FLAG_4(NODE)=1))
+#define CLEAR_BINFO_NEW_VTABLE_MARKED(NODE) (TREE_VIA_VIRTUAL(NODE)?CLEAR_CLASSTYPE_MARKED4(BINFO_TYPE(NODE)):(TREE_LANG_FLAG_4(NODE)=0))
+
+/* Nonzero means this class has initialized its virtual baseclasses. */
+#define BINFO_VBASE_INIT_MARKED(NODE) \
+ (TREE_VIA_VIRTUAL(NODE)?CLASSTYPE_MARKED5(BINFO_TYPE(NODE)):TREE_LANG_FLAG_5(NODE))
+#define SET_BINFO_VBASE_INIT_MARKED(NODE) (TREE_VIA_VIRTUAL(NODE)?SET_CLASSTYPE_MARKED5(BINFO_TYPE(NODE)):(TREE_LANG_FLAG_5(NODE)=1))
+#define CLEAR_BINFO_VBASE_INIT_MARKED(NODE) (TREE_VIA_VIRTUAL(NODE)?CLEAR_CLASSTYPE_MARKED5(BINFO_TYPE(NODE)):(TREE_LANG_FLAG_5(NODE)=0))
+
+/* Accessor macros for the vfield slots in structures. */
+
+/* Get the assoc info that caused this vfield to exist. */
+#define VF_BINFO_VALUE(NODE) TREE_PURPOSE (NODE)
+
+/* Get that same information as a _TYPE. */
+#define VF_BASETYPE_VALUE(NODE) TREE_VALUE (NODE)
+
+/* Get the value of the top-most type dominating the non-`normal' vfields. */
+#define VF_DERIVED_VALUE(NODE) (VF_BINFO_VALUE (NODE) ? BINFO_TYPE (VF_BINFO_VALUE (NODE)) : NULL_TREE)
+
+/* Get the value of the top-most type that's `normal' for the vfield. */
+#define VF_NORMAL_VALUE(NODE) TREE_TYPE (NODE)
+
+/* Nonzero for TREE_LIST node means that this list of things
+ is a list of parameters, as opposed to a list of expressions. */
+#define TREE_PARMLIST(NODE) ((NODE)->common.unsigned_flag) /* overloaded! */
+
+/* For FUNCTION_TYPE or METHOD_TYPE, a list of the exceptions that
+ this type can raise. */
+#define TYPE_RAISES_EXCEPTIONS(NODE) TYPE_NONCOPIED_PARTS (NODE)
+
+/* The binding level associated with the namespace. */
+#define NAMESPACE_LEVEL(NODE) ((NODE)->decl.arguments)
+
+struct lang_decl_flags
+{
+#ifdef ONLY_INT_FIELDS
+ int language : 8;
+#else
+ enum languages language : 8;
+#endif
+
+ unsigned operator_attr : 1;
+ unsigned constructor_attr : 1;
+ unsigned returns_first_arg : 1;
+ unsigned preserves_first_arg : 1;
+ unsigned friend_attr : 1;
+ unsigned static_function : 1;
+ unsigned const_memfunc : 1;
+ unsigned volatile_memfunc : 1;
+
+ unsigned abstract_virtual : 1;
+ unsigned permanent_attr : 1 ;
+ unsigned constructor_for_vbase_attr : 1;
+ unsigned mutable_flag : 1;
+ unsigned is_default_implementation : 1;
+ unsigned saved_inline : 1;
+ unsigned use_template : 2;
+
+ unsigned c_static : 1;
+ unsigned nonconverting : 1;
+ unsigned declared_inline : 1;
+ unsigned not_really_extern : 1;
+ unsigned dummy : 4;
+
+ tree access;
+ tree context;
+ tree memfunc_pointer_to;
+};
+
+struct lang_decl
+{
+ struct lang_decl_flags decl_flags;
+
+ struct template_info *template_info;
+ tree main_decl_variant;
+ struct pending_inline *pending_inline_info;
+ tree next_method;
+ tree chain;
+};
+
+/* Non-zero if NODE is a _DECL with TREE_READONLY set. */
+#define TREE_READONLY_DECL_P(NODE) \
+ (TREE_READONLY (NODE) && TREE_CODE_CLASS (TREE_CODE (NODE)) == 'd')
+
+/* For FUNCTION_DECLs: return the language in which this decl
+ was declared. */
+#define DECL_LANGUAGE(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.language)
+
+/* For FUNCTION_DECLs: nonzero means that this function is a constructor. */
+#define DECL_CONSTRUCTOR_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.constructor_attr)
+/* For FUNCTION_DECLs: nonzero means that this function is a constructor
+ for an object with virtual baseclasses. */
+#define DECL_CONSTRUCTOR_FOR_VBASE_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.constructor_for_vbase_attr)
+
+/* For FUNCTION_DECLs: nonzero means that this function is a default
+ implementation of a signature method. */
+#define IS_DEFAULT_IMPLEMENTATION(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.is_default_implementation)
+
+/* For FUNCTION_DECLs: nonzero means that the constructor
+ is known to return a non-zero `this' unchanged. */
+#define DECL_RETURNS_FIRST_ARG(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.returns_first_arg)
+
+/* Nonzero for FUNCTION_DECL means that this constructor is known to
+ not make any assignment to `this', and therefore can be trusted
+ to return it unchanged. Otherwise, we must re-assign `current_class_decl'
+ after performing base initializations. */
+#define DECL_PRESERVES_THIS(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.preserves_first_arg)
+
+/* Nonzero for _DECL means that this decl appears in (or will appear
+ in) as a member in a RECORD_TYPE or UNION_TYPE node. It is also for
+ detecting circularity in case members are multiply defined. In the
+ case of a VAR_DECL, it is also used to determine how program storage
+ should be allocated. */
+#define DECL_IN_AGGR_P(NODE) (DECL_LANG_FLAG_3(NODE))
+
+/* Nonzero for FUNCTION_DECL means that this decl is just a
+ friend declaration, and should not be added to the list of
+ member functions for this class. */
+#define DECL_FRIEND_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.friend_attr)
+
+/* Nonzero for FUNCTION_DECL means that this decl is a static
+ member function. */
+#define DECL_STATIC_FUNCTION_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.static_function)
+
+/* Nonzero for a class member means that it is shared between all objects
+ of that class. */
+#define SHARED_MEMBER_P(NODE) \
+ (TREE_CODE (NODE) == VAR_DECL || TREE_CODE (NODE) == TYPE_DECL \
+ || TREE_CODE (NODE) == CONST_DECL)
+
+/* Nonzero for FUNCTION_DECL means that this decl is a member function
+ (static or non-static). */
+#define DECL_FUNCTION_MEMBER_P(NODE) \
+ (TREE_CODE (TREE_TYPE (NODE)) == METHOD_TYPE || DECL_STATIC_FUNCTION_P (NODE))
+
+/* Nonzero for FUNCTION_DECL means that this member function
+ has `this' as const X *const. */
+#define DECL_CONST_MEMFUNC_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.const_memfunc)
+
+/* Nonzero for FUNCTION_DECL means that this member function
+ has `this' as volatile X *const. */
+#define DECL_VOLATILE_MEMFUNC_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.volatile_memfunc)
+
+/* Nonzero for _DECL means that this member object type
+ is mutable. */
+#define DECL_MUTABLE_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.mutable_flag)
+
+/* Nonzero for _DECL means that this constructor is a non-converting
+ constructor. */
+#define DECL_NONCONVERTING_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.nonconverting)
+
+/* Nonzero for FUNCTION_DECL means that this member function
+ exists as part of an abstract class's interface. */
+#define DECL_ABSTRACT_VIRTUAL_P(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.abstract_virtual)
+
+/* Nonzero if allocated on permanent_obstack. */
+#define LANG_DECL_PERMANENT(LANGDECL) ((LANGDECL)->decl_flags.permanent_attr)
+
+/* The _TYPE context in which this _DECL appears. This field holds the
+ class where a virtual function instance is actually defined, and the
+ lexical scope of a friend function defined in a class body. */
+#define DECL_CLASS_CONTEXT(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.context)
+#define DECL_REAL_CONTEXT(NODE) \
+ ((TREE_CODE (NODE) == FUNCTION_DECL && DECL_FUNCTION_MEMBER_P (NODE)) \
+ ? DECL_CLASS_CONTEXT (NODE) : DECL_CONTEXT (NODE))
+
+/* For a FUNCTION_DECL: the chain through which the next method
+ in the method chain is found. We now use TREE_CHAIN to
+ link into the FIELD_DECL chain. */
+#if 1
+#define DECL_CHAIN(NODE) (DECL_LANG_SPECIFIC(NODE)->chain)
+#else
+#define DECL_CHAIN(NODE) (TREE_CHAIN (NODE))
+#endif
+
+/* Next method in CLASSTYPE_METHODS list. */
+#define DECL_NEXT_METHOD(NODE) (DECL_LANG_SPECIFIC(NODE)->next_method)
+
+/* In a VAR_DECL for a variable declared in a for statement,
+ this is the shadowed variable. */
+#define DECL_SHADOWED_FOR_VAR(NODE) DECL_RESULT(NODE)
+
+/* Points back to the decl which caused this lang_decl to be allocated. */
+#define DECL_MAIN_VARIANT(NODE) (DECL_LANG_SPECIFIC(NODE)->main_decl_variant)
+
+/* For a FUNCTION_DECL: if this function was declared inline inside of
+ a class declaration, this is where the text for the function is
+ squirreled away. */
+#define DECL_PENDING_INLINE_INFO(NODE) (DECL_LANG_SPECIFIC(NODE)->pending_inline_info)
+
+/* True if on the saved_inlines (see decl2.c) list. */
+#define DECL_SAVED_INLINE(DECL) \
+ (DECL_LANG_SPECIFIC(DECL)->decl_flags.saved_inline)
+
+/* For a FUNCTION_DECL: if this function was declared inside a signature
+ declaration, this is the corresponding member function pointer that was
+ created for it. */
+#define DECL_MEMFUNC_POINTER_TO(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.memfunc_pointer_to)
+
+/* For a FIELD_DECL: this points to the signature member function from
+ which this signature member function pointer was created. */
+#define DECL_MEMFUNC_POINTING_TO(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.memfunc_pointer_to)
+
+/* For a TEMPLATE_DECL: template-specific information. */
+#define DECL_TEMPLATE_INFO(NODE) (DECL_LANG_SPECIFIC(NODE)->template_info)
+
+/* Nonzero in INT_CST means that this int is negative by dint of
+ using a twos-complement negated operand. */
+#define TREE_NEGATED_INT(NODE) (TREE_LANG_FLAG_0 (NODE))
+
+/* Nonzero in any kind of _EXPR or _REF node means that it is a call
+ to a storage allocation routine. If, later, alternate storage
+ is found to hold the object, this call can be ignored. */
+#define TREE_CALLS_NEW(NODE) (TREE_LANG_FLAG_1 (NODE))
+
+/* Nonzero in any kind of _TYPE that uses multiple inheritance
+ or virtual baseclasses. */
+#define TYPE_USES_COMPLEX_INHERITANCE(NODE) (TREE_LANG_FLAG_1 (NODE))
+
+/* Nonzero in IDENTIFIER_NODE means that this name is not the name the user
+ gave; it's a DECL_NESTED_TYPENAME. Someone may want to set this on
+ mangled function names, too, but it isn't currently. */
+#define TREE_MANGLED(NODE) (TREE_LANG_FLAG_0 (NODE))
+
+#if 0 /* UNUSED */
+/* Nonzero in IDENTIFIER_NODE means that this name is overloaded, and
+ should be looked up in a non-standard way. */
+#define DECL_OVERLOADED(NODE) (DECL_LANG_FLAG_4 (NODE))
+#endif
+
+/* Nonzero if this (non-TYPE)_DECL has its virtual attribute set.
+ For a FUNCTION_DECL, this is when the function is a virtual function.
+ For a VAR_DECL, this is when the variable is a virtual function table.
+ For a FIELD_DECL, when the field is the field for the virtual function table.
+ For an IDENTIFIER_NODE, nonzero if any function with this name
+ has been declared virtual.
+
+ For a _TYPE if it uses virtual functions (or is derived from
+ one that does). */
+#define TYPE_VIRTUAL_P(NODE) (TREE_LANG_FLAG_2 (NODE))
+
+#if 0
+/* Same, but tells if this field is private in current context. */
+#define DECL_PRIVATE(NODE) (FOO)
+
+/* Same, but tells if this field is private in current context. */
+#define DECL_PROTECTED(NODE) (DECL_LANG_FLAG_6 (NODE))
+
+#define DECL_PUBLIC(NODE) (DECL_LANG_FLAG_7 (NODE))
+#endif
+
+extern int flag_new_for_scope;
+
+/* This flag is true of a local VAR_DECL if it was declared in a for
+ statement, but we are no longer in the scope of the for. */
+#define DECL_DEAD_FOR_LOCAL(NODE) DECL_LANG_FLAG_7 (NODE)
+
+/* This flag is set on a VAR_DECL that is a DECL_DEAD_FOR_LOCAL
+ if we already emitted a warning about using it. */
+#define DECL_ERROR_REPORTED(NODE) DECL_LANG_FLAG_0 (NODE)
+
+/* This _DECL represents a compiler-generated entity. */
+#define SET_DECL_ARTIFICIAL(NODE) (DECL_ARTIFICIAL (NODE) = 1)
+
+/* Record whether a typedef for type `int' was actually `signed int'. */
+#define C_TYPEDEF_EXPLICITLY_SIGNED(exp) DECL_LANG_FLAG_1 ((exp))
+
+/* Nonzero if the type T promotes to itself.
+ ANSI C states explicitly the list of types that promote;
+ in particular, short promotes to int even if they have the same width. */
+#define C_PROMOTING_INTEGER_TYPE_P(t) \
+ (TREE_CODE ((t)) == INTEGER_TYPE \
+ && (TYPE_MAIN_VARIANT (t) == char_type_node \
+ || TYPE_MAIN_VARIANT (t) == signed_char_type_node \
+ || TYPE_MAIN_VARIANT (t) == unsigned_char_type_node \
+ || TYPE_MAIN_VARIANT (t) == short_integer_type_node \
+ || TYPE_MAIN_VARIANT (t) == short_unsigned_type_node))
+
+#define INTEGRAL_CODE_P(CODE) \
+ (CODE == INTEGER_TYPE || CODE == ENUMERAL_TYPE || CODE == BOOLEAN_TYPE)
+#define ARITHMETIC_TYPE_P(TYPE) (INTEGRAL_TYPE_P (TYPE) || FLOAT_TYPE_P (TYPE))
+
+/* Mark which labels are explicitly declared.
+ These may be shadowed, and may be referenced from nested functions. */
+#define C_DECLARED_LABEL_FLAG(label) TREE_LANG_FLAG_1 (label)
+
+/* Record whether a type or decl was written with nonconstant size.
+ Note that TYPE_SIZE may have simplified to a constant. */
+#define C_TYPE_VARIABLE_SIZE(type) TREE_LANG_FLAG_4 (type)
+#define C_DECL_VARIABLE_SIZE(type) DECL_LANG_FLAG_8 (type)
+
+/* Nonzero for _TYPE means that the _TYPE defines
+ at least one constructor. */
+#define TYPE_HAS_CONSTRUCTOR(NODE) (TYPE_LANG_FLAG_1(NODE))
+
+/* When appearing in an INDIRECT_REF, it means that the tree structure
+ underneath is actually a call to a constructor. This is needed
+ when the constructor must initialize local storage (which can
+ be automatically destroyed), rather than allowing it to allocate
+ space from the heap.
+
+ When appearing in a SAVE_EXPR, it means that underneath
+ is a call to a constructor.
+
+ When appearing in a CONSTRUCTOR, it means that it was
+ a GNU C constructor expression.
+
+ When appearing in a FIELD_DECL, it means that this field
+ has been duly initialized in its constructor. */
+#define TREE_HAS_CONSTRUCTOR(NODE) (TREE_LANG_FLAG_4(NODE))
+
+#define EMPTY_CONSTRUCTOR_P(NODE) (TREE_CODE (NODE) == CONSTRUCTOR \
+ && CONSTRUCTOR_ELTS (NODE) == NULL_TREE)
+
+/* Indicates that a NON_LVALUE_EXPR came from a C++ reference.
+ Used to generate more helpful error message in case somebody
+ tries to take its address. */
+#define TREE_REFERENCE_EXPR(NODE) (TREE_LANG_FLAG_3(NODE))
+
+/* Nonzero for _TYPE means that the _TYPE defines a destructor. */
+#define TYPE_HAS_DESTRUCTOR(NODE) (TYPE_LANG_FLAG_2(NODE))
+
+#if 0
+/* Nonzero for _TYPE node means that creating an object of this type
+ will involve a call to a constructor. This can apply to objects
+ of ARRAY_TYPE if the type of the elements needs a constructor. */
+#define TYPE_NEEDS_CONSTRUCTING(NODE) (TYPE_LANG_FLAG_3(NODE))
+#endif
+
+/* Nonzero means that an object of this type can not be initialized using
+ an initializer list. */
+#define CLASSTYPE_NON_AGGREGATE(NODE) \
+ (TYPE_LANG_SPECIFIC (NODE)->type_flags.non_aggregate)
+#define TYPE_NON_AGGREGATE_CLASS(NODE) \
+ (IS_AGGR_TYPE (NODE) && CLASSTYPE_NON_AGGREGATE (NODE))
+
+/* Nonzero if there is a user-defined X::op=(x&) for this class. */
+#define TYPE_HAS_REAL_ASSIGN_REF(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_real_assign_ref)
+#define TYPE_HAS_COMPLEX_ASSIGN_REF(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_complex_assign_ref)
+#define TYPE_HAS_ABSTRACT_ASSIGN_REF(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_abstract_assign_ref)
+#define TYPE_HAS_COMPLEX_INIT_REF(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.has_complex_init_ref)
+
+/* Nonzero for _TYPE node means that destroying an object of this type
+ will involve a call to a destructor. This can apply to objects
+ of ARRAY_TYPE is the type of the elements needs a destructor. */
+#define TYPE_NEEDS_DESTRUCTOR(NODE) (TYPE_LANG_FLAG_4(NODE))
+
+/* Nonzero for class type means that initialization of this type can use
+ a bitwise copy. */
+#define TYPE_HAS_TRIVIAL_INIT_REF(NODE) \
+ (TYPE_HAS_INIT_REF (NODE) && ! TYPE_HAS_COMPLEX_INIT_REF (NODE))
+
+/* Nonzero for class type means that assignment of this type can use
+ a bitwise copy. */
+#define TYPE_HAS_TRIVIAL_ASSIGN_REF(NODE) \
+ (TYPE_HAS_ASSIGN_REF (NODE) && ! TYPE_HAS_COMPLEX_ASSIGN_REF (NODE))
+
+/* Nonzero for _TYPE node means that this type is a pointer to member
+ function type. */
+#define TYPE_PTRMEMFUNC_P(NODE) (TREE_CODE(NODE) == RECORD_TYPE && TYPE_LANG_SPECIFIC(NODE)->type_flags.ptrmemfunc_flag)
+#define TYPE_PTRMEMFUNC_FLAG(NODE) (TYPE_LANG_SPECIFIC(NODE)->type_flags.ptrmemfunc_flag)
+/* Get the POINTER_TYPE to the METHOD_TYPE associated with this
+ pointer to member function. TYPE_PTRMEMFUNC_P _must_ be true,
+ before using this macro. */
+#define TYPE_PTRMEMFUNC_FN_TYPE(NODE) (TREE_TYPE (TYPE_FIELDS (TREE_TYPE (TREE_CHAIN (TREE_CHAIN (TYPE_FIELDS (NODE)))))))
+/* These are use to manipulate the the canonical RECORD_TYPE from the
+ hashed POINTER_TYPE, and can only be used on the POINTER_TYPE. */
+#define TYPE_GET_PTRMEMFUNC_TYPE(NODE) ((tree)TYPE_LANG_SPECIFIC(NODE))
+#define TYPE_SET_PTRMEMFUNC_TYPE(NODE, VALUE) (TYPE_LANG_SPECIFIC(NODE) = ((struct lang_type *)(void*)(VALUE)))
+/* These are to get the delta2 and pfn fields from a TYPE_PTRMEMFUNC_P. */
+#define DELTA2_FROM_PTRMEMFUNC(NODE) (build_component_ref (build_component_ref ((NODE), pfn_or_delta2_identifier, 0, 0), delta2_identifier, 0, 0))
+#define PFN_FROM_PTRMEMFUNC(NODE) (build_component_ref (build_component_ref ((NODE), pfn_or_delta2_identifier, 0, 0), pfn_identifier, 0, 0))
+
+/* Nonzero for VAR_DECL and FUNCTION_DECL node means that `extern' was
+ specified in its declaration. */
+#define DECL_THIS_EXTERN(NODE) (DECL_LANG_FLAG_2(NODE))
+
+/* Nonzero for VAR_DECL and FUNCTION_DECL node means that `static' was
+ specified in its declaration. */
+#define DECL_THIS_STATIC(NODE) (DECL_LANG_FLAG_6(NODE))
+
+/* Nonzero for SAVE_EXPR if used to initialize a PARM_DECL. */
+#define PARM_DECL_EXPR(NODE) (TREE_LANG_FLAG_2(NODE))
+
+/* Nonzero in FUNCTION_DECL means it is really an operator.
+ Just used to communicate formatting information to dbxout.c. */
+#define DECL_OPERATOR(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.operator_attr)
+
+#define ANON_UNION_P(NODE) (DECL_NAME (NODE) == 0)
+
+#define UNKNOWN_TYPE LANG_TYPE
+
+/* Define fields and accessors for nodes representing declared names. */
+
+#if 0
+/* C++: A derived class may be able to directly use the virtual
+ function table of a base class. When it does so, it may
+ still have a decl node used to access the virtual function
+ table (so that variables of this type can initialize their
+ virtual function table pointers by name). When such thievery
+ is committed, know exactly which base class's virtual function
+ table is the one being stolen. This effectively computes the
+ transitive closure. */
+#define DECL_VPARENT(NODE) ((NODE)->decl.arguments)
+#endif
+
+/* Make a slot so we can implement nested types. This slot holds
+ the IDENTIFIER_NODE that uniquely names the nested type. This
+ is for TYPE_DECLs only. */
+#define DECL_NESTED_TYPENAME(NODE) ((NODE)->decl.arguments)
+#define TYPE_NESTED_NAME(NODE) (DECL_NESTED_TYPENAME (TYPE_NAME (NODE)))
+
+#define TYPE_WAS_ANONYMOUS(NODE) (TYPE_LANG_SPECIFIC (NODE)->type_flags.was_anonymous)
+
+/* C++: all of these are overloaded! These apply only to TYPE_DECLs. */
+#define DECL_FRIENDLIST(NODE) (DECL_INITIAL (NODE))
+#if 0
+#define DECL_UNDEFINED_FRIENDS(NODE) ((NODE)->decl.result)
+#endif
+#define DECL_WAITING_FRIENDS(NODE) ((tree)(NODE)->decl.rtl)
+#define SET_DECL_WAITING_FRIENDS(NODE,VALUE) \
+ ((NODE)->decl.rtl=(struct rtx_def*)VALUE)
+
+/* The DECL_ACCESS is used to record under which context
+ special access rules apply. */
+#define DECL_ACCESS(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.access)
+
+/* C++: all of these are overloaded!
+ These apply to PARM_DECLs and VAR_DECLs. */
+#define DECL_REFERENCE_SLOT(NODE) ((tree)(NODE)->decl.arguments)
+#define SET_DECL_REFERENCE_SLOT(NODE,VAL) ((NODE)->decl.arguments=VAL)
+
+/* For local VAR_DECLs, holds index into gc-protected obstack. */
+#define DECL_GC_OFFSET(NODE) ((NODE)->decl.result)
+
+/* Accessor macros for C++ template decl nodes. */
+#define DECL_TEMPLATE_IS_CLASS(NODE) (DECL_RESULT(NODE) == NULL_TREE)
+#define DECL_TEMPLATE_PARMS(NODE) DECL_ARGUMENTS(NODE)
+/* For class templates. */
+#define DECL_TEMPLATE_MEMBERS(NODE) DECL_SIZE(NODE)
+/* For function, method, class-data templates. */
+#define DECL_TEMPLATE_RESULT(NODE) DECL_RESULT(NODE)
+#define DECL_TEMPLATE_INSTANTIATIONS(NODE) DECL_VINDEX(NODE)
+
+/* Indicates whether or not (and how) a template was expanded for this
+ FUNCTION_DECL or VAR_DECL.
+ 0=normal declaration, e.g. int min (int, int);
+ 1=implicit template instantiation
+ 2=explicit template specialization, e.g. int min<int> (int, int);
+ 3=explicit template instantiation, e.g. template int min<int> (int, int);
+ */
+#define DECL_USE_TEMPLATE(NODE) (DECL_LANG_SPECIFIC(NODE)->decl_flags.use_template)
+
+#define DECL_TEMPLATE_INSTANTIATION(NODE) (DECL_USE_TEMPLATE (NODE) & 1)
+#define CLASSTYPE_TEMPLATE_INSTANTIATION(NODE) \
+ (CLASSTYPE_USE_TEMPLATE (NODE) & 1)
+
+#define DECL_TEMPLATE_SPECIALIZATION(NODE) (DECL_USE_TEMPLATE (NODE) == 2)
+#define SET_DECL_TEMPLATE_SPECIALIZATION(NODE) (DECL_USE_TEMPLATE (NODE) = 2)
+#define CLASSTYPE_TEMPLATE_SPECIALIZATION(NODE) \
+ (CLASSTYPE_USE_TEMPLATE (NODE) == 2)
+#define SET_CLASSTYPE_TEMPLATE_SPECIALIZATION(NODE) \
+ (CLASSTYPE_USE_TEMPLATE (NODE) = 2)
+
+#define DECL_IMPLICIT_INSTANTIATION(NODE) (DECL_USE_TEMPLATE (NODE) == 1)
+#define SET_DECL_IMPLICIT_INSTANTIATION(NODE) (DECL_USE_TEMPLATE (NODE) = 1)
+#define CLASSTYPE_IMPLICIT_INSTANTIATION(NODE) \
+ (CLASSTYPE_USE_TEMPLATE(NODE) == 1)
+#define SET_CLASSTYPE_IMPLICIT_INSTANTIATION(NODE) \
+ (CLASSTYPE_USE_TEMPLATE(NODE) = 1)
+
+#define DECL_EXPLICIT_INSTANTIATION(NODE) (DECL_USE_TEMPLATE (NODE) == 3)
+#define SET_DECL_EXPLICIT_INSTANTIATION(NODE) (DECL_USE_TEMPLATE (NODE) = 3)
+#define CLASSTYPE_EXPLICIT_INSTANTIATION(NODE) \
+ (CLASSTYPE_USE_TEMPLATE(NODE) == 3)
+#define SET_CLASSTYPE_EXPLICIT_INSTANTIATION(NODE) \
+ (CLASSTYPE_USE_TEMPLATE(NODE) = 3)
+
+/* We know what we're doing with this decl now. */
+#define DECL_INTERFACE_KNOWN(NODE) DECL_LANG_FLAG_5 (NODE)
+
+/* This decl was declared or deduced to have internal linkage. This is
+ only meaningful if TREE_PUBLIC is set. */
+#define DECL_C_STATIC(NODE) \
+ (DECL_LANG_SPECIFIC (NODE)->decl_flags.c_static)
+
+/* This function was declared inline. This flag controls the linkage
+ semantics of 'inline'; whether or not the function is inlined is
+ controlled by DECL_INLINE. */
+#define DECL_THIS_INLINE(NODE) \
+ (DECL_LANG_SPECIFIC (NODE)->decl_flags.declared_inline)
+
+/* DECL_EXTERNAL must be set on a decl until the decl is actually emitted,
+ so that assemble_external will work properly. So we have this flag to
+ tell us whether the decl is really not external. */
+#define DECL_NOT_REALLY_EXTERN(NODE) \
+ (DECL_LANG_SPECIFIC (NODE)->decl_flags.not_really_extern)
+
+#define DECL_PUBLIC(NODE) \
+ (TREE_CODE (NODE) == FUNCTION_DECL \
+ ? ! DECL_C_STATIC (NODE) : TREE_PUBLIC (NODE))
+
+#define THUNK_DELTA(DECL) ((DECL)->decl.frame_size.i)
+
+/* ...and for unexpanded-parameterized-type nodes. */
+#define UPT_TEMPLATE(NODE) TREE_PURPOSE(TYPE_VALUES(NODE))
+#define UPT_PARMS(NODE) TREE_VALUE(TYPE_VALUES(NODE))
+
+/* An enumeration of the kind of tags that C++ accepts. */
+enum tag_types { record_type, class_type, union_type, enum_type,
+ signature_type };
+
+/* Zero means prototype weakly, as in ANSI C (no args means nothing).
+ Each language context defines how this variable should be set. */
+extern int strict_prototype;
+extern int strict_prototypes_lang_c, strict_prototypes_lang_cplusplus;
+
+/* Non-zero means that if a label exists, and no other identifier
+ applies, use the value of the label. */
+extern int flag_labels_ok;
+
+/* Non-zero means to collect statistics which might be expensive
+ and to print them when we are done. */
+extern int flag_detailed_statistics;
+
+/* Non-zero means warn in function declared in derived class has the
+ same name as a virtual in the base class, but fails to match the
+ type signature of any virtual function in the base class. */
+extern int warn_overloaded_virtual;
+
+/* in c-common.c */
+extern void declare_function_name PROTO((void));
+extern void decl_attributes PROTO((tree, tree, tree));
+extern void init_function_format_info PROTO((void));
+extern void record_function_format PROTO((tree, tree, int, int, int));
+extern void check_function_format PROTO((tree, tree, tree));
+/* Print an error message for invalid operands to arith operation CODE.
+ NOP_EXPR is used as a special case (see truthvalue_conversion). */
+extern void binary_op_error PROTO((enum tree_code));
+extern tree cp_build_type_variant PROTO((tree, int, int));
+extern void c_expand_expr_stmt PROTO((tree));
+/* Validate the expression after `case' and apply default promotions. */
+extern tree check_case_value PROTO((tree));
+/* Concatenate a list of STRING_CST nodes into one STRING_CST. */
+extern tree combine_strings PROTO((tree));
+extern void constant_expression_warning PROTO((tree));
+extern tree convert_and_check PROTO((tree, tree));
+extern void overflow_warning PROTO((tree));
+extern void unsigned_conversion_warning PROTO((tree, tree));
+/* Read the rest of the current #-directive line. */
+extern char *get_directive_line STDIO_PROTO((FILE *));
+/* Subroutine of build_binary_op, used for comparison operations.
+ See if the operands have both been converted from subword integer types
+ and, if so, perhaps change them both back to their original type. */
+extern tree shorten_compare PROTO((tree *, tree *, tree *, enum tree_code *));
+/* Prepare expr to be an argument of a TRUTH_NOT_EXPR,
+ or validate its data type for an `if' or `while' statement or ?..: exp. */
+extern tree truthvalue_conversion PROTO((tree));
+extern tree type_for_mode PROTO((enum machine_mode, int));
+extern tree type_for_size PROTO((unsigned, int));
+
+/* in decl{2}.c */
+extern tree void_list_node;
+extern tree void_zero_node;
+extern tree default_function_type;
+extern tree vtable_entry_type;
+extern tree sigtable_entry_type;
+extern tree __t_desc_type_node;
+extern tree __tp_desc_type_node;
+extern tree __access_mode_type_node;
+extern tree __bltn_desc_type_node, __user_desc_type_node;
+extern tree __class_desc_type_node, __attr_desc_type_node;
+extern tree __ptr_desc_type_node, __func_desc_type_node;
+extern tree __ptmf_desc_type_node, __ptmd_desc_type_node;
+extern tree type_info_type_node;
+extern tree class_star_type_node;
+extern tree this_identifier;
+extern tree pfn_identifier;
+extern tree index_identifier;
+extern tree delta_identifier;
+extern tree delta2_identifier;
+extern tree pfn_or_delta2_identifier;
+extern tree tag_identifier;
+extern tree vb_off_identifier;
+extern tree vt_off_identifier;
+
+/* A node that is a list (length 1) of error_mark_nodes. */
+extern tree error_mark_list;
+
+extern tree ptr_type_node, const_ptr_type_node;
+extern tree class_type_node, record_type_node, union_type_node, enum_type_node;
+extern tree unknown_type_node;
+extern tree opaque_type_node, signature_type_node;
+
+/* Node for "pointer to (virtual) function".
+ This may be distinct from ptr_type_node so gdb can distinguish them. */
+#define vfunc_ptr_type_node \
+ (flag_vtable_thunks ? vtable_entry_type : ptr_type_node)
+
+/* Array type `(void *)[]' */
+extern tree vtbl_type_node;
+extern tree delta_type_node;
+
+extern tree long_long_integer_type_node, long_long_unsigned_type_node;
+/* For building calls to `delete'. */
+extern tree integer_two_node, integer_three_node;
+extern tree boolean_type_node, boolean_true_node, boolean_false_node;
+
+/* in pt.c */
+/* PARM_VEC is a vector of template parameters, either IDENTIFIER_NODEs or
+ PARM_DECLs. BINDINGS, if non-null, is a vector of bindings for those
+ parameters. */
+struct template_info {
+ /* Vector of template parameters, either PARM_DECLs or IDENTIFIER_NODEs. */
+ tree parm_vec;
+ /* If non-null, a vector of bindings for the template parms. */
+ tree bindings;
+
+ /* Text of template, and length. */
+ char *text;
+ int length;
+ /* Where it came from. */
+ char *filename;
+ int lineno;
+
+ /* What kind of aggregate -- struct, class, or null. */
+ tree aggr;
+};
+extern int processing_template_decl, processing_template_defn;
+
+/* The template currently being instantiated, and where the instantiation
+ was triggered. */
+struct tinst_level
+{
+ tree classname;
+ int line;
+ char *file;
+ struct tinst_level *next;
+};
+
+/* in class.c */
+extern tree current_class_name;
+extern tree current_class_type;
+extern tree previous_class_type;
+
+extern tree current_lang_name, lang_name_cplusplus, lang_name_c;
+
+/* Points to the name of that function. May not be the DECL_NAME
+ of CURRENT_FUNCTION_DECL due to overloading */
+extern tree original_function_name;
+
+extern tree current_class_name, current_class_type, current_class_decl, C_C_D;
+
+/* in init.c */
+extern tree global_base_init_list;
+extern tree current_base_init_list, current_member_init_list;
+
+extern int current_function_assigns_this;
+extern int current_function_just_assigned_this;
+extern int current_function_parms_stored;
+
+/* Here's where we control how name mangling takes place. */
+
+#define OPERATOR_ASSIGN_FORMAT "__a%s"
+#define OPERATOR_FORMAT "__%s"
+#define OPERATOR_TYPENAME_FORMAT "__op"
+#define OPERATOR_TYPENAME_P(ID_NODE) \
+ (IDENTIFIER_POINTER (ID_NODE)[0] == '_' \
+ && IDENTIFIER_POINTER (ID_NODE)[1] == '_' \
+ && IDENTIFIER_POINTER (ID_NODE)[2] == 'o' \
+ && IDENTIFIER_POINTER (ID_NODE)[3] == 'p')
+
+
+/* Cannot use '$' up front, because this confuses gdb
+ (names beginning with '$' are gdb-local identifiers).
+
+ Note that all forms in which the '$' is significant are long enough
+ for direct indexing (meaning that if we know there is a '$'
+ at a particular location, we can index into the string at
+ any other location that provides distinguishing characters). */
+
+/* Define NO_DOLLAR_IN_LABEL in your favorite tm file if your assembler
+ doesn't allow '$' in symbol names. */
+#ifndef NO_DOLLAR_IN_LABEL
+
+#define JOINER '$'
+
+#define VPTR_NAME "$v"
+#define THROW_NAME "$eh_throw"
+#define DESTRUCTOR_DECL_PREFIX "_$_"
+#define AUTO_VTABLE_NAME "__vtbl$me__"
+#define AUTO_TEMP_NAME "_$tmp_"
+#define AUTO_TEMP_FORMAT "_$tmp_%d"
+#define VTABLE_BASE "$vb"
+#define VTABLE_NAME_FORMAT (flag_vtable_thunks ? "__vt_%s" : "_vt$%s")
+#define VFIELD_BASE "$vf"
+#define VFIELD_NAME "_vptr$"
+#define VFIELD_NAME_FORMAT "_vptr$%s"
+#define VBASE_NAME "_vb$"
+#define VBASE_NAME_FORMAT "_vb$%s"
+#define STATIC_NAME_FORMAT "_%s$%s"
+#define ANON_AGGRNAME_FORMAT "$_%d"
+
+#else /* NO_DOLLAR_IN_LABEL */
+
+#ifndef NO_DOT_IN_LABEL
+
+#define JOINER '.'
+
+#define VPTR_NAME ".v"
+#define THROW_NAME ".eh_throw"
+#define DESTRUCTOR_DECL_PREFIX "_._"
+#define AUTO_VTABLE_NAME "__vtbl.me__"
+#define AUTO_TEMP_NAME "_.tmp_"
+#define AUTO_TEMP_FORMAT "_.tmp_%d"
+#define VTABLE_BASE ".vb"
+#define VTABLE_NAME_FORMAT (flag_vtable_thunks ? "__vt_%s" : "_vt.%s")
+#define VFIELD_BASE ".vf"
+#define VFIELD_NAME "_vptr."
+#define VFIELD_NAME_FORMAT "_vptr.%s"
+#define VBASE_NAME "_vb."
+#define VBASE_NAME_FORMAT "_vb.%s"
+#define STATIC_NAME_FORMAT "_%s.%s"
+
+#define ANON_AGGRNAME_FORMAT "._%d"
+
+#else /* NO_DOT_IN_LABEL */
+
+#define VPTR_NAME "__vptr"
+#define VPTR_NAME_P(ID_NODE) \
+ (!strncmp (IDENTIFIER_POINTER (ID_NODE), VPTR_NAME, sizeof (VPTR_NAME) - 1))
+#define THROW_NAME "__eh_throw"
+#define DESTRUCTOR_DECL_PREFIX "__destr_"
+#define DESTRUCTOR_NAME_P(ID_NODE) \
+ (!strncmp (IDENTIFIER_POINTER (ID_NODE), DESTRUCTOR_DECL_PREFIX, \
+ sizeof (DESTRUCTOR_DECL_PREFIX) - 1))
+#define IN_CHARGE_NAME "__in_chrg"
+#define AUTO_VTABLE_NAME "__vtbl_me__"
+#define AUTO_TEMP_NAME "__tmp_"
+#define TEMP_NAME_P(ID_NODE) \
+ (!strncmp (IDENTIFIER_POINTER (ID_NODE), AUTO_TEMP_NAME, \
+ sizeof (AUTO_TEMP_NAME) - 1))
+#define AUTO_TEMP_FORMAT "__tmp_%d"
+#define VTABLE_BASE "__vtb"
+#define VTABLE_NAME "__vt_"
+#define VTABLE_NAME_FORMAT (flag_vtable_thunks ? "__vt_%s" : "_vt_%s")
+#define VTABLE_NAME_P(ID_NODE) \
+ (!strncmp (IDENTIFIER_POINTER (ID_NODE), VTABLE_NAME, \
+ sizeof (VTABLE_NAME) - 1))
+#define VFIELD_BASE "__vfb"
+#define VFIELD_NAME "__vptr_"
+#define VFIELD_NAME_P(ID_NODE) \
+ (!strncmp (IDENTIFIER_POINTER (ID_NODE), VFIELD_NAME, \
+ sizeof (VFIELD_NAME) - 1))
+#define VFIELD_NAME_FORMAT "_vptr_%s"
+#define VBASE_NAME "__vb_"
+#define VBASE_NAME_P(ID_NODE) \
+ (!strncmp (IDENTIFIER_POINTER (ID_NODE), VBASE_NAME, \
+ sizeof (VBASE_NAME) - 1))
+#define VBASE_NAME_FORMAT "__vb_%s"
+#define STATIC_NAME_FORMAT "__static_%s_%s"
+
+#define ANON_AGGRNAME_PREFIX "__anon_"
+#define ANON_AGGRNAME_P(ID_NODE) \
+ (!strncmp (IDENTIFIER_POINTER (ID_NODE), ANON_AGGRNAME_PREFIX, \
+ sizeof (ANON_AGGRNAME_PREFIX) - 1))
+#define ANON_AGGRNAME_FORMAT "__anon_%d"
+#define ANON_PARMNAME_FORMAT "__%d"
+#define ANON_PARMNAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[0] == '_' \
+ && IDENTIFIER_POINTER (ID_NODE)[1] == '_' \
+ && IDENTIFIER_POINTER (ID_NODE)[2] <= '9')
+
+#endif /* NO_DOT_IN_LABEL */
+#endif /* NO_DOLLAR_IN_LABEL */
+
+#define THIS_NAME "this"
+#define DESTRUCTOR_NAME_FORMAT "~%s"
+#define FILE_FUNCTION_PREFIX_LEN 9
+
+#define IN_CHARGE_NAME "__in_chrg"
+
+#define VTBL_PTR_TYPE "__vtbl_ptr_type"
+#define VTABLE_DELTA_NAME "__delta"
+#define VTABLE_INDEX_NAME "__index"
+#define VTABLE_PFN_NAME "__pfn"
+#define VTABLE_DELTA2_NAME "__delta2"
+
+#define SIGNATURE_FIELD_NAME "__s_"
+#define SIGNATURE_FIELD_NAME_FORMAT "__s_%s"
+#define SIGNATURE_OPTR_NAME "__optr"
+#define SIGNATURE_SPTR_NAME "__sptr"
+#define SIGNATURE_POINTER_NAME "__sp_"
+#define SIGNATURE_POINTER_NAME_FORMAT "__%s%ssp_%s"
+#define SIGNATURE_REFERENCE_NAME "__sr_"
+#define SIGNATURE_REFERENCE_NAME_FORMAT "__%s%ssr_%s"
+
+#define SIGTABLE_PTR_TYPE "__sigtbl_ptr_type"
+#define SIGTABLE_NAME_FORMAT "__st_%s_%s"
+#define SIGTABLE_NAME_FORMAT_LONG "__st_%s_%s_%d"
+#define SIGTABLE_TAG_NAME "__tag"
+#define SIGTABLE_VB_OFF_NAME "__vb_off"
+#define SIGTABLE_VT_OFF_NAME "__vt_off"
+#define EXCEPTION_CLEANUP_NAME "exception cleanup"
+
+#define THIS_NAME_P(ID_NODE) (strcmp(IDENTIFIER_POINTER (ID_NODE), "this") == 0)
+
+#if !defined(NO_DOLLAR_IN_LABEL) || !defined(NO_DOT_IN_LABEL)
+
+#define VPTR_NAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[0] == JOINER \
+ && IDENTIFIER_POINTER (ID_NODE)[1] == 'v')
+#define DESTRUCTOR_NAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[1] == JOINER \
+ && IDENTIFIER_POINTER (ID_NODE)[2] == '_')
+
+#define VTABLE_NAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[1] == 'v' \
+ && IDENTIFIER_POINTER (ID_NODE)[2] == 't' \
+ && IDENTIFIER_POINTER (ID_NODE)[3] == JOINER)
+
+#define VBASE_NAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[1] == 'v' \
+ && IDENTIFIER_POINTER (ID_NODE)[2] == 'b' \
+ && IDENTIFIER_POINTER (ID_NODE)[3] == JOINER)
+
+#define TEMP_NAME_P(ID_NODE) (!strncmp (IDENTIFIER_POINTER (ID_NODE), AUTO_TEMP_NAME, sizeof (AUTO_TEMP_NAME)-1))
+#define VFIELD_NAME_P(ID_NODE) (!strncmp (IDENTIFIER_POINTER (ID_NODE), VFIELD_NAME, sizeof(VFIELD_NAME)-1))
+
+/* For anonymous aggregate types, we need some sort of name to
+ hold on to. In practice, this should not appear, but it should
+ not be harmful if it does. */
+#define ANON_AGGRNAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[0] == JOINER \
+ && IDENTIFIER_POINTER (ID_NODE)[1] == '_')
+#define ANON_PARMNAME_FORMAT "_%d"
+#define ANON_PARMNAME_P(ID_NODE) (IDENTIFIER_POINTER (ID_NODE)[0] == '_' \
+ && IDENTIFIER_POINTER (ID_NODE)[1] <= '9')
+#endif /* !defined(NO_DOLLAR_IN_LABEL) || !defined(NO_DOT_IN_LABEL) */
+
+/* Define the sets of attributes that member functions and baseclasses
+ can have. These are sensible combinations of {public,private,protected}
+ cross {virtual,non-virtual}. */
+
+enum access_type {
+ access_default,
+ access_public,
+ access_protected,
+ access_private,
+ access_default_virtual,
+ access_public_virtual,
+ access_private_virtual
+};
+
+/* in lex.c */
+extern tree current_unit_name, current_unit_language;
+
+/* Things for handling inline functions. */
+
+struct pending_inline
+{
+ struct pending_inline *next; /* pointer to next in chain */
+ int lineno; /* line number we got the text from */
+ char *filename; /* name of file we were processing */
+ tree fndecl; /* FUNCTION_DECL that brought us here */
+ int token; /* token we were scanning */
+ int token_value; /* value of token we were scanning (YYSTYPE) */
+
+ char *buf; /* pointer to character stream */
+ int len; /* length of stream */
+ tree parm_vec, bindings; /* in case this is derived from a template */
+ unsigned int can_free : 1; /* free this after we're done with it? */
+ unsigned int deja_vu : 1; /* set iff we don't want to see it again. */
+ unsigned int interface : 2; /* 0=interface 1=unknown 2=implementation */
+};
+
+/* in method.c */
+extern struct pending_inline *pending_inlines;
+
+/* 1 for -fall-virtual: make every member function (except
+ constructors) lay down in the virtual function table.
+ Calls can then either go through the virtual function table or not,
+ depending on whether we know what function will actually be called. */
+
+extern int flag_all_virtual;
+
+/* Positive values means that we cannot make optimizing assumptions about
+ `this'. Negative values means we know `this' to be of static type. */
+
+extern int flag_this_is_variable;
+
+/* Controls whether enums and ints freely convert.
+ 1 means with complete freedom.
+ 0 means enums can convert to ints, but not vice-versa. */
+
+extern int flag_int_enum_equivalence;
+
+/* Nonzero means layout structures so that we can do garbage collection. */
+
+extern int flag_gc;
+
+/* Nonzero means generate 'rtti' that give run-time type information. */
+
+extern int flag_rtti;
+
+/* Nonzero means do emit exported implementations of functions even if
+ they can be inlined. */
+
+extern int flag_implement_inlines;
+
+/* Nonzero means templates obey #pragma interface and implementation. */
+
+extern int flag_external_templates;
+
+/* Nonzero means templates are emitted where they are instantiated. */
+
+extern int flag_alt_external_templates;
+
+/* Nonzero means implicit template instantiations are emitted. */
+
+extern int flag_implicit_templates;
+
+/* Current end of entries in the gc obstack for stack pointer variables. */
+
+extern int current_function_obstack_index;
+
+/* Flag saying whether we have used the obstack in this function or not. */
+
+extern int current_function_obstack_usage;
+
+enum overload_flags { NO_SPECIAL = 0, DTOR_FLAG, OP_FLAG, TYPENAME_FLAG };
+
+extern tree current_class_decl, C_C_D; /* PARM_DECL: the class instance variable */
+
+/* The following two can be derived from the previous one */
+extern tree current_class_name; /* IDENTIFIER_NODE: name of current class */
+extern tree current_class_type; /* _TYPE: the type of the current class */
+
+/* Some macros for char-based bitfields. */
+#define B_SET(a,x) (a[x>>3] |= (1 << (x&7)))
+#define B_CLR(a,x) (a[x>>3] &= ~(1 << (x&7)))
+#define B_TST(a,x) (a[x>>3] & (1 << (x&7)))
+
+/* These are uses as bits in flags passed to build_method_call
+ to control its error reporting behavior.
+
+ LOOKUP_PROTECT means flag access violations.
+ LOOKUP_COMPLAIN mean complain if no suitable member function
+ matching the arguments is found.
+ LOOKUP_NORMAL is just a combination of these two.
+ LOOKUP_AGGR requires the instance to be of aggregate type.
+ LOOKUP_NONVIRTUAL means make a direct call to the member function found
+ LOOKUP_GLOBAL means search through the space of overloaded functions,
+ as well as the space of member functions.
+ LOOKUP_HAS_IN_CHARGE means that the "in charge" variable is already
+ in the parameter list.
+ LOOKUP_ONLYCONVERTING means that non-conversion constructors are not tried.
+ LOOKUP_SPECULATIVELY means return NULL_TREE if we cannot find what we are
+ after. Note, LOOKUP_COMPLAIN is checked and error messages printed
+ before LOOKUP_SPECULATIVELY is checked.
+ LOOKUP_NO_CONVERSION means that user-defined conversions are not
+ permitted. Built-in conversions are permitted.
+ LOOKUP_DESTRUCTOR means explicit call to destructor. */
+
+#define LOOKUP_PROTECT (1)
+#define LOOKUP_COMPLAIN (2)
+#define LOOKUP_NORMAL (3)
+#define LOOKUP_AGGR (4)
+#define LOOKUP_NONVIRTUAL (8)
+#define LOOKUP_GLOBAL (16)
+#define LOOKUP_HAS_IN_CHARGE (32)
+#define LOOKUP_SPECULATIVELY (64)
+#define LOOKUP_ONLYCONVERTING (128)
+/* 256 is free */
+#define LOOKUP_NO_CONVERSION (512)
+#define LOOKUP_DESTRUCTOR (512)
+
+/* These flags are used by the conversion code.
+ CONV_IMPLICIT : Perform implicit conversions (standard and user-defined).
+ CONV_STATIC : Perform the explicit conversions for static_cast.
+ CONV_CONST : Perform the explicit conversions for const_cast.
+ CONV_REINTERPRET: Perform the explicit conversions for reinterpret_cast.
+ CONV_PRIVATE : Perform upcasts to private bases.
+ CONV_NONCONVERTING : Allow non-converting constructors to be used.
+ CONV_FORCE_TEMP : Require a new temporary when converting to the same
+ aggregate type. */
+
+#define CONV_IMPLICIT 1
+#define CONV_STATIC 2
+#define CONV_CONST 4
+#define CONV_REINTERPRET 8
+#define CONV_PRIVATE 16
+#define CONV_NONCONVERTING 32
+#define CONV_FORCE_TEMP 64
+#define CONV_STATIC_CAST (CONV_IMPLICIT | CONV_STATIC | CONV_FORCE_TEMP)
+#define CONV_OLD_CONVERT (CONV_IMPLICIT | CONV_STATIC | CONV_CONST \
+ | CONV_REINTERPRET)
+#define CONV_C_CAST (CONV_IMPLICIT | CONV_STATIC | CONV_CONST \
+ | CONV_REINTERPRET | CONV_PRIVATE | CONV_FORCE_TEMP)
+
+/* Used by build_expr_type_conversion to indicate which types are
+ acceptable as arguments to the expression under consideration. */
+
+#define WANT_INT 1 /* integer types, including bool */
+#define WANT_FLOAT 2 /* floating point types */
+#define WANT_ENUM 4 /* enumerated types */
+#define WANT_POINTER 8 /* pointer types */
+#define WANT_NULL 16 /* null pointer constant */
+
+#define WANT_ARITH (WANT_INT | WANT_FLOAT)
+
+/* Anatomy of a DECL_FRIENDLIST (which is a TREE_LIST):
+ purpose = friend name (IDENTIFIER_NODE);
+ value = TREE_LIST of FUNCTION_DECLS;
+ chain, type = EMPTY; */
+#define FRIEND_NAME(LIST) (TREE_PURPOSE (LIST))
+#define FRIEND_DECLS(LIST) (TREE_VALUE (LIST))
+
+/* These macros are for accessing the fields of TEMPLATE...PARM nodes. */
+#define TEMPLATE_TYPE_TPARMLIST(NODE) TREE_PURPOSE (TYPE_FIELDS (NODE))
+#define TEMPLATE_TYPE_IDX(NODE) TREE_INT_CST_LOW (TREE_VALUE (TYPE_FIELDS (NODE)))
+#define TEMPLATE_TYPE_SET_INFO(NODE,P,I) \
+ (TYPE_FIELDS (NODE) = build_tree_list (P, build_int_2 (I, 0)))
+#define TEMPLATE_CONST_TPARMLIST(NODE) (*(tree*)&TREE_INT_CST_LOW(NODE))
+#define TEMPLATE_CONST_IDX(NODE) (TREE_INT_CST_HIGH(NODE))
+#define TEMPLATE_CONST_SET_INFO(NODE,P,I) \
+ (TEMPLATE_CONST_TPARMLIST (NODE) = saved_parmlist, \
+ TEMPLATE_CONST_IDX (NODE) = I)
+
+/* in lex.c */
+/* Indexed by TREE_CODE, these tables give C-looking names to
+ operators represented by TREE_CODES. For example,
+ opname_tab[(int) MINUS_EXPR] == "-". */
+extern char **opname_tab, **assignop_tab;
+
+/* in c-common.c */
+extern tree convert_and_check PROTO((tree, tree));
+extern void overflow_warning PROTO((tree));
+extern void unsigned_conversion_warning PROTO((tree, tree));
+
+/* in call.c */
+extern struct candidate *ansi_c_bullshit;
+
+extern int rank_for_overload PROTO((struct candidate *, struct candidate *));
+extern void compute_conversion_costs PROTO((tree, tree, struct candidate *, int));
+extern int get_arglist_len_in_bytes PROTO((tree));
+extern tree build_vfield_ref PROTO((tree, tree));
+extern tree find_scoped_type PROTO((tree, tree, tree));
+extern tree resolve_scope_to_name PROTO((tree, tree));
+extern tree build_scoped_method_call PROTO((tree, tree, tree, tree));
+extern tree build_method_call PROTO((tree, tree, tree, tree, int));
+extern tree build_overload_call_real PROTO((tree, tree, int, struct candidate *, int));
+extern tree build_overload_call PROTO((tree, tree, int, struct candidate *));
+extern tree build_overload_call_maybe PROTO((tree, tree, int, struct candidate *));
+
+/* in class.c */
+extern char *dont_allow_type_definitions;
+extern tree build_vbase_pointer PROTO((tree, tree));
+extern tree build_vbase_path PROTO((enum tree_code, tree, tree, tree, int));
+extern tree build_vtable_entry PROTO((tree, tree));
+extern tree build_vfn_ref PROTO((tree *, tree, tree));
+extern void add_method PROTO((tree, tree *, tree));
+extern tree get_vfield_offset PROTO((tree));
+extern void duplicate_tag_error PROTO((tree));
+extern tree finish_struct PROTO((tree, tree, int));
+extern int resolves_to_fixed_type_p PROTO((tree, int *));
+extern void init_class_processing PROTO((void));
+extern void pushclass PROTO((tree, int));
+extern void popclass PROTO((int));
+extern void push_nested_class PROTO((tree, int));
+extern void pop_nested_class PROTO((int));
+extern void push_lang_context PROTO((tree));
+extern void pop_lang_context PROTO((void));
+extern int root_lang_context_p PROTO((void));
+extern tree instantiate_type PROTO((tree, tree, int));
+extern void print_class_statistics PROTO((void));
+extern void maybe_push_cache_obstack PROTO((void));
+extern unsigned HOST_WIDE_INT skip_rtti_stuff PROTO((tree *));
+
+/* in cvt.c */
+extern tree convert_to_reference PROTO((tree, tree, int, int, tree));
+extern tree convert_from_reference PROTO((tree));
+extern tree convert_to_aggr PROTO((tree, tree, char **, int));
+extern tree convert_pointer_to PROTO((tree, tree));
+extern tree convert_pointer_to_real PROTO((tree, tree));
+extern tree convert_pointer_to_vbase PROTO((tree, tree));
+extern tree convert PROTO((tree, tree));
+extern tree cp_convert PROTO((tree, tree, int, int));
+extern tree convert_force PROTO((tree, tree, int));
+extern tree build_type_conversion PROTO((enum tree_code, tree, tree, int));
+extern tree build_expr_type_conversion PROTO((int, tree, int));
+extern int build_default_binary_type_conversion PROTO((enum tree_code, tree *, tree *));
+extern tree type_promotes_to PROTO((tree));
+
+/* decl.c */
+extern int global_bindings_p PROTO((void));
+extern int toplevel_bindings_p PROTO((void));
+extern void keep_next_level PROTO((void));
+extern int kept_level_p PROTO((void));
+extern void declare_parm_level PROTO((void));
+extern void declare_implicit_exception PROTO((void));
+extern int have_exceptions_p PROTO((void));
+extern void declare_uninstantiated_type_level PROTO((void));
+extern int uninstantiated_type_level_p PROTO((void));
+extern void declare_pseudo_global_level PROTO((void));
+extern int pseudo_global_level_p PROTO((void));
+extern void pushlevel PROTO((int));
+extern void pushlevel_temporary PROTO((int));
+extern tree poplevel PROTO((int, int, int));
+extern void delete_block PROTO((tree));
+extern void insert_block PROTO((tree));
+extern void add_block_current_level PROTO((tree));
+extern void set_block PROTO((tree));
+extern void pushlevel_class PROTO((void));
+extern tree poplevel_class PROTO((int));
+/* skip print_other_binding_stack and print_binding_level */
+extern void print_binding_stack PROTO((void));
+extern void push_to_top_level PROTO((void));
+extern void pop_from_top_level PROTO((void));
+extern void set_identifier_type_value PROTO((tree, tree));
+extern void pop_everything PROTO((void));
+extern tree make_type_decl PROTO((tree, tree));
+extern void pushtag PROTO((tree, tree, int));
+extern tree make_anon_name PROTO((void));
+extern void clear_anon_tags PROTO((void));
+extern tree pushdecl PROTO((tree));
+extern tree pushdecl_top_level PROTO((tree));
+extern void push_class_level_binding PROTO((tree, tree));
+extern void push_overloaded_decl_top_level PROTO((tree, int));
+extern tree pushdecl_class_level PROTO((tree));
+extern tree pushdecl_nonclass_level PROTO((tree));
+extern int overloaded_globals_p PROTO((tree));
+extern tree push_overloaded_decl PROTO((tree, int));
+extern tree implicitly_declare PROTO((tree));
+extern tree lookup_label PROTO((tree));
+extern tree shadow_label PROTO((tree));
+extern tree define_label PROTO((char *, int, tree));
+extern void define_case_label PROTO((tree));
+extern tree getdecls PROTO((void));
+extern tree gettags PROTO((void));
+extern void set_current_level_tags_transparency PROTO((int));
+extern tree typedecl_for_tag PROTO((tree));
+extern tree lookup_name PROTO((tree, int));
+extern tree lookup_namespace_name PROTO((tree, tree));
+extern tree lookup_name_current_level PROTO((tree));
+extern void init_decl_processing PROTO((void));
+/* skipped define_function */
+extern void shadow_tag PROTO((tree));
+extern int grok_ctor_properties PROTO((tree, tree));
+extern tree groktypename PROTO((tree));
+extern tree start_decl PROTO((tree, tree, int, tree));
+extern void cp_finish_decl PROTO((tree, tree, tree, int, int));
+extern void expand_static_init PROTO((tree, tree));
+extern int complete_array_type PROTO((tree, tree, int));
+extern tree build_ptrmemfunc_type PROTO((tree));
+/* the grokdeclarator prototype is in decl.h */
+extern int parmlist_is_exprlist PROTO((tree));
+extern tree xref_tag PROTO((tree, tree, tree, int));
+extern void xref_basetypes PROTO((tree, tree, tree, tree));
+extern tree start_enum PROTO((tree));
+extern tree finish_enum PROTO((tree, tree));
+extern tree build_enumerator PROTO((tree, tree));
+extern tree grok_enum_decls PROTO((tree, tree));
+extern int start_function PROTO((tree, tree, tree, tree, int));
+extern void store_parm_decls PROTO((void));
+extern void expand_start_early_try_stmts PROTO((void));
+extern void store_in_parms PROTO((struct rtx_def *));
+extern void store_return_init PROTO((tree, tree));
+extern void finish_function PROTO((int, int, int));
+extern tree start_method PROTO((tree, tree, tree));
+extern tree finish_method PROTO((tree));
+extern void hack_incomplete_structures PROTO((tree));
+extern tree maybe_build_cleanup PROTO((tree));
+extern void cplus_expand_expr_stmt PROTO((tree));
+extern void finish_stmt PROTO((void));
+extern void pop_implicit_try_blocks PROTO((tree));
+extern void push_exception_cleanup PROTO((tree));
+extern void revert_static_member_fn PROTO((tree *, tree *, tree *));
+
+/* in decl2.c */
+extern int lang_decode_option PROTO((char *));
+extern tree grok_method_quals PROTO((tree, tree, tree));
+extern void grokclassfn PROTO((tree, tree, tree, enum overload_flags, tree));
+extern tree grok_alignof PROTO((tree));
+extern tree grok_array_decl PROTO((tree, tree));
+extern tree delete_sanity PROTO((tree, tree, int, int));
+extern tree check_classfn PROTO((tree, tree, tree));
+extern tree grokfield PROTO((tree, tree, tree, tree, tree, tree));
+extern tree grokbitfield PROTO((tree, tree, tree));
+extern tree groktypefield PROTO((tree, tree));
+extern tree grokoptypename PROTO((tree, tree));
+extern tree build_push_scope PROTO((tree, tree));
+extern void cplus_decl_attributes PROTO((tree, tree, tree));
+extern tree constructor_name_full PROTO((tree));
+extern tree constructor_name PROTO((tree));
+extern void setup_vtbl_ptr PROTO((void));
+extern void mark_inline_for_output PROTO((tree));
+extern void clear_temp_name PROTO((void));
+extern tree get_temp_name PROTO((tree, int));
+extern tree get_temp_regvar PROTO((tree, tree));
+extern void finish_anon_union PROTO((tree));
+extern tree finish_table PROTO((tree, tree, tree, int));
+extern void finish_builtin_type PROTO((tree, char *, tree *, int, tree));
+extern tree coerce_new_type PROTO((tree));
+extern tree coerce_delete_type PROTO((tree));
+extern void walk_vtables PROTO((void (*)(), void (*)()));
+extern void walk_sigtables PROTO((void (*)(), void (*)()));
+extern void finish_file PROTO((void));
+extern void warn_if_unknown_interface PROTO((tree));
+extern tree grok_x_components PROTO((tree, tree));
+extern tree reparse_absdcl_as_expr PROTO((tree, tree));
+extern tree reparse_absdcl_as_casts PROTO((tree, tree));
+extern tree reparse_decl_as_expr PROTO((tree, tree));
+extern tree finish_decl_parsing PROTO((tree));
+extern tree lookup_name_nonclass PROTO((tree));
+extern tree check_cp_case_value PROTO((tree));
+extern tree do_toplevel_using_decl PROTO((tree));
+extern tree do_class_using_decl PROTO((tree));
+extern tree current_namespace_id PROTO((tree));
+extern tree get_namespace_id PROTO((void));
+extern void check_default_args PROTO((tree));
+
+/* in edsel.c */
+
+/* in except.c */
+extern tree protect_list;
+extern void start_protect PROTO((void));
+extern void end_protect PROTO((tree));
+extern void end_protect_partials ();
+extern void expand_exception_blocks PROTO((void));
+extern void expand_start_try_stmts PROTO((void));
+extern void expand_end_try_stmts PROTO((void));
+extern void expand_start_all_catch PROTO((void));
+extern void expand_end_all_catch PROTO((void));
+extern void start_catch_block PROTO((tree, tree));
+extern void end_catch_block PROTO((void));
+extern void expand_throw PROTO((tree));
+extern int might_have_exceptions_p PROTO((void));
+extern void emit_exception_table PROTO((void));
+extern tree build_throw PROTO((tree));
+extern void init_exception_processing PROTO((void));
+extern void expand_builtin_throw PROTO((void));
+extern void expand_start_eh_spec PROTO((void));
+extern void expand_end_eh_spec PROTO((tree));
+
+/* in expr.c */
+/* skip cplus_expand_expr */
+extern void init_cplus_expand PROTO((void));
+extern void fixup_result_decl PROTO((tree, struct rtx_def *));
+extern int decl_in_memory_p PROTO((tree));
+extern tree unsave_expr_now PROTO((tree));
+
+/* in gc.c */
+extern int type_needs_gc_entry PROTO((tree));
+extern int value_safe_from_gc PROTO((tree, tree));
+extern void build_static_gc_entry PROTO((tree, tree));
+extern tree protect_value_from_gc PROTO((tree, tree));
+extern tree build_headof PROTO((tree));
+extern tree build_classof PROTO((tree));
+extern tree build_t_desc PROTO((tree, int));
+extern tree build_i_desc PROTO((tree));
+extern tree build_m_desc PROTO((tree));
+extern void expand_gc_prologue_and_epilogue PROTO((void));
+extern void lang_expand_end_bindings PROTO((struct rtx_def *, struct rtx_def *));
+extern void init_gc_processing PROTO((void));
+extern tree build_typeid PROTO((tree));
+extern tree get_typeid PROTO((tree));
+extern tree build_dynamic_cast PROTO((tree, tree));
+
+/* in init.c */
+extern void emit_base_init PROTO((tree, int));
+extern void check_base_init PROTO((tree));
+extern void expand_direct_vtbls_init PROTO((tree, tree, int, int, tree));
+extern void do_member_init PROTO((tree, tree, tree));
+extern void expand_member_init PROTO((tree, tree, tree));
+extern void expand_aggr_init PROTO((tree, tree, int, int));
+extern int is_aggr_typedef PROTO((tree, int));
+extern tree get_aggr_from_typedef PROTO((tree, int));
+extern tree get_type_value PROTO((tree));
+extern tree build_member_call PROTO((tree, tree, tree));
+extern tree build_offset_ref PROTO((tree, tree));
+extern tree get_member_function PROTO((tree *, tree, tree));
+extern tree get_member_function_from_ptrfunc PROTO((tree *, tree));
+extern tree resolve_offset_ref PROTO((tree));
+extern tree decl_constant_value PROTO((tree));
+extern int is_friend_type PROTO((tree, tree));
+extern int is_friend PROTO((tree, tree));
+extern void make_friend_class PROTO((tree, tree));
+extern tree do_friend PROTO((tree, tree, tree, tree, enum overload_flags, tree));
+extern void embrace_waiting_friends PROTO((tree));
+extern tree build_builtin_call PROTO((tree, tree, tree));
+extern tree build_new PROTO((tree, tree, tree, int));
+extern tree expand_vec_init PROTO((tree, tree, tree, tree, int));
+extern tree build_x_delete PROTO((tree, tree, int, tree));
+extern tree build_delete PROTO((tree, tree, tree, int, int));
+extern tree build_vbase_delete PROTO((tree, tree));
+extern tree build_vec_delete PROTO((tree, tree, tree, tree, tree, int));
+
+/* in input.c */
+
+/* in lex.c */
+extern tree make_pointer_declarator PROTO((tree, tree));
+extern tree make_reference_declarator PROTO((tree, tree));
+extern char *operator_name_string PROTO((tree));
+extern void lang_init PROTO((void));
+extern void lang_finish PROTO((void));
+extern void init_filename_times PROTO((void));
+extern void reinit_lang_specific PROTO((void));
+extern void init_lex PROTO((void));
+extern void reinit_parse_for_function PROTO((void));
+extern int *init_parse PROTO((void));
+extern void print_parse_statistics PROTO((void));
+extern void extract_interface_info PROTO((void));
+extern void set_vardecl_interface_info PROTO((tree, tree));
+extern void do_pending_inlines PROTO((void));
+extern void process_next_inline PROTO((tree));
+/* skip restore_pending_input */
+extern void yyungetc PROTO((int, int));
+extern void reinit_parse_for_method PROTO((int, tree));
+#if 0
+extern void reinit_parse_for_block PROTO((int, struct obstack *, int));
+#endif
+extern tree cons_up_default_function PROTO((tree, tree, int));
+extern void check_for_missing_semicolon PROTO((tree));
+extern void note_got_semicolon PROTO((tree));
+extern void note_list_got_semicolon PROTO((tree));
+extern int check_newline PROTO((void));
+extern void dont_see_typename PROTO((void));
+extern int identifier_type PROTO((tree));
+extern void see_typename PROTO((void));
+extern tree do_identifier PROTO((tree));
+extern tree identifier_typedecl_value PROTO((tree));
+extern int real_yylex PROTO((void));
+extern tree build_lang_decl PROTO((enum tree_code, tree, tree));
+extern tree build_lang_field_decl PROTO((enum tree_code, tree, tree));
+extern void copy_lang_decl PROTO((tree));
+extern tree make_lang_type PROTO((enum tree_code));
+extern void copy_decl_lang_specific PROTO((tree));
+extern void dump_time_statistics PROTO((void));
+/* extern void compiler_error PROTO((char *, HOST_WIDE_INT, HOST_WIDE_INT)); */
+extern void compiler_error_with_decl PROTO((tree, char *));
+extern void yyerror PROTO((char *));
+
+/* in errfn.c */
+extern void cp_error ();
+extern void cp_error_at ();
+extern void cp_warning ();
+extern void cp_warning_at ();
+extern void cp_pedwarn ();
+extern void cp_pedwarn_at ();
+extern void cp_compiler_error ();
+extern void cp_sprintf ();
+
+/* in error.c */
+extern void init_error PROTO((void));
+extern char *fndecl_as_string PROTO((tree, tree, int));
+extern char *type_as_string PROTO((tree, int));
+extern char *args_as_string PROTO((tree, int));
+extern char *decl_as_string PROTO((tree, int));
+extern char *expr_as_string PROTO((tree, int));
+extern char *code_as_string PROTO((enum tree_code, int));
+extern char *language_as_string PROTO((enum languages, int));
+extern char *parm_as_string PROTO((int, int));
+extern char *op_as_string PROTO((enum tree_code, int));
+extern char *cv_as_string PROTO((tree, int));
+
+/* in method.c */
+extern void init_method PROTO((void));
+extern tree make_anon_parm_name PROTO((void));
+extern void clear_anon_parm_name PROTO((void));
+extern void do_inline_function_hair PROTO((tree, tree));
+/* skip report_type_mismatch */
+extern char *build_overload_name PROTO((tree, int, int));
+extern tree build_static_name PROTO((tree, tree));
+extern tree cplus_exception_name PROTO((tree));
+extern tree build_decl_overload PROTO((tree, tree, int));
+extern tree build_typename_overload PROTO((tree));
+extern tree build_t_desc_overload PROTO((tree));
+extern void declare_overloaded PROTO((tree));
+#ifdef NO_AUTO_OVERLOAD
+extern int is_overloaded PROTO((tree));
+#endif
+extern tree build_opfncall PROTO((enum tree_code, int, tree, tree, tree));
+extern tree hack_identifier PROTO((tree, tree, int));
+extern tree build_component_type_expr PROTO((tree, tree, tree, int));
+
+/* in pt.c */
+extern tree tsubst PROTO ((tree, tree*, int, tree));
+extern void begin_template_parm_list PROTO((void));
+extern tree process_template_parm PROTO((tree, tree));
+extern tree end_template_parm_list PROTO((tree));
+extern void end_template_decl PROTO((tree, tree, tree, int));
+extern tree lookup_template_class PROTO((tree, tree, tree));
+extern void push_template_decls PROTO((tree, tree, int));
+extern void pop_template_decls PROTO((tree, tree, int));
+extern int uses_template_parms PROTO((tree));
+extern void instantiate_member_templates PROTO((tree));
+extern tree instantiate_class_template PROTO((tree, int));
+extern tree instantiate_template PROTO((tree, tree *));
+extern void undo_template_name_overload PROTO((tree, int));
+extern void overload_template_name PROTO((tree, int));
+extern void end_template_instantiation PROTO((tree));
+extern void reinit_parse_for_template PROTO((int, tree, tree));
+extern int type_unification PROTO((tree, tree *, tree, tree, int *, int));
+extern int do_pending_expansions PROTO((void));
+extern void do_pending_templates PROTO((void));
+struct tinst_level *tinst_for_decl PROTO((void));
+extern void do_function_instantiation PROTO((tree, tree, tree));
+extern void do_type_instantiation PROTO((tree, tree));
+extern tree create_nested_upt PROTO((tree, tree));
+
+/* in search.c */
+extern tree make_memoized_table_entry PROTO((tree, tree, int));
+extern void push_memoized_context PROTO((tree, int));
+extern void pop_memoized_context PROTO((int));
+extern tree get_binfo PROTO((tree, tree, int));
+extern int get_base_distance PROTO((tree, tree, int, tree *));
+extern enum access_type compute_access PROTO((tree, tree));
+extern tree lookup_field PROTO((tree, tree, int, int));
+extern tree lookup_nested_field PROTO((tree, int));
+extern tree lookup_fnfields PROTO((tree, tree, int));
+extern tree lookup_nested_tag PROTO((tree, tree));
+extern HOST_WIDE_INT breadth_first_search PROTO((tree, int (*)(), int (*)()));
+extern int tree_needs_constructor_p PROTO((tree, int));
+extern int tree_has_any_destructor_p PROTO((tree, int));
+extern tree get_matching_virtual PROTO((tree, tree, int));
+extern tree get_abstract_virtuals PROTO((tree));
+extern tree get_baselinks PROTO((tree, tree, tree));
+extern tree next_baselink PROTO((tree));
+extern tree init_vbase_pointers PROTO((tree, tree));
+extern void expand_indirect_vtbls_init PROTO((tree, tree, tree, int));
+extern void clear_search_slots PROTO((tree));
+extern tree get_vbase_types PROTO((tree));
+extern void build_mi_matrix PROTO((tree));
+extern void free_mi_matrix PROTO((void));
+extern void build_mi_virtuals PROTO((int, int));
+extern void add_mi_virtuals PROTO((int, tree));
+extern void report_ambiguous_mi_virtuals PROTO((int, tree));
+extern void note_debug_info_needed PROTO((tree));
+extern void push_class_decls PROTO((tree));
+extern void pop_class_decls PROTO((tree));
+extern void unuse_fields PROTO((tree));
+extern void unmark_finished_struct PROTO((tree));
+extern void print_search_statistics PROTO((void));
+extern void init_search_processing PROTO((void));
+extern void reinit_search_statistics PROTO((void));
+extern tree current_scope PROTO((void));
+extern tree lookup_conversions PROTO((tree));
+
+/* in sig.c */
+extern tree build_signature_pointer_type PROTO((tree, int, int));
+extern tree build_signature_reference_type PROTO((tree, int, int));
+extern tree build_signature_pointer_constructor PROTO((tree, tree));
+extern tree build_signature_method_call PROTO((tree, tree, tree, tree));
+extern tree build_optr_ref PROTO((tree));
+extern tree build_sptr_ref PROTO((tree));
+
+/* in spew.c */
+extern void init_spew PROTO((void));
+extern int yylex PROTO((void));
+extern tree arbitrate_lookup PROTO((tree, tree, tree));
+
+/* in tree.c */
+extern int lvalue_p PROTO((tree));
+extern int lvalue_or_else PROTO((tree, char *));
+extern tree build_cplus_new PROTO((tree, tree, int));
+extern tree break_out_cleanups PROTO((tree));
+extern tree break_out_calls PROTO((tree));
+extern tree build_cplus_method_type PROTO((tree, tree, tree));
+extern tree build_cplus_staticfn_type PROTO((tree, tree, tree));
+extern tree build_cplus_array_type PROTO((tree, tree));
+extern void propagate_binfo_offsets PROTO((tree, tree));
+extern int layout_vbasetypes PROTO((tree, int));
+extern tree layout_basetypes PROTO((tree, tree));
+extern int list_hash PROTO((tree));
+extern tree list_hash_lookup PROTO((int, tree));
+extern void list_hash_add PROTO((int, tree));
+extern tree list_hash_canon PROTO((int, tree));
+extern tree hash_tree_cons PROTO((int, int, int, tree, tree, tree));
+extern tree hash_tree_chain PROTO((tree, tree));
+extern tree hash_chainon PROTO((tree, tree));
+extern tree get_decl_list PROTO((tree));
+extern tree list_hash_lookup_or_cons PROTO((tree));
+extern tree make_binfo PROTO((tree, tree, tree, tree, tree));
+extern tree binfo_value PROTO((tree, tree));
+extern tree reverse_path PROTO((tree));
+extern tree virtual_member PROTO((tree, tree));
+extern void debug_binfo PROTO((tree));
+extern int decl_list_length PROTO((tree));
+extern int count_functions PROTO((tree));
+extern tree decl_value_member PROTO((tree, tree));
+extern int is_overloaded_fn PROTO((tree));
+extern tree get_first_fn PROTO((tree));
+extern tree fnaddr_from_vtable_entry PROTO((tree));
+extern void set_fnaddr_from_vtable_entry PROTO((tree, tree));
+extern tree function_arg_chain PROTO((tree));
+extern int promotes_to_aggr_type PROTO((tree, enum tree_code));
+extern int is_aggr_type_2 PROTO((tree, tree));
+extern void message_2_types PROTO((void (*)(), char *, tree, tree));
+extern char *lang_printable_name PROTO((tree));
+extern tree build_exception_variant PROTO((tree, tree));
+extern tree copy_to_permanent PROTO((tree));
+extern void print_lang_statistics PROTO((void));
+/* skip __eprintf */
+extern tree array_type_nelts_total PROTO((tree));
+extern tree array_type_nelts_top PROTO((tree));
+extern tree break_out_target_exprs PROTO((tree));
+extern tree build_unsave_expr PROTO((tree));
+extern int cp_expand_decl_cleanup PROTO((tree, tree));
+
+/* in typeck.c */
+extern tree condition_conversion PROTO((tree));
+extern tree target_type PROTO((tree));
+extern tree require_complete_type PROTO((tree));
+extern int type_unknown_p PROTO((tree));
+extern int fntype_p PROTO((tree));
+extern tree require_instantiated_type PROTO((tree, tree, tree));
+extern tree commonparms PROTO((tree, tree));
+extern tree common_type PROTO((tree, tree));
+extern int compexcepttypes PROTO((tree, tree, int));
+extern int comptypes PROTO((tree, tree, int));
+extern int comp_target_types PROTO((tree, tree, int));
+extern tree common_base_types PROTO((tree, tree));
+extern int compparms PROTO((tree, tree, int));
+extern int comp_target_types PROTO((tree, tree, int));
+extern int self_promoting_args_p PROTO((tree));
+extern tree unsigned_type PROTO((tree));
+extern tree signed_type PROTO((tree));
+extern tree signed_or_unsigned_type PROTO((int, tree));
+extern tree c_sizeof PROTO((tree));
+extern tree c_sizeof_nowarn PROTO((tree));
+extern tree c_alignof PROTO((tree));
+extern tree decay_conversion PROTO((tree));
+extern tree default_conversion PROTO((tree));
+extern tree build_object_ref PROTO((tree, tree, tree));
+extern tree build_component_ref_1 PROTO((tree, tree, int));
+extern tree build_component_ref PROTO((tree, tree, tree, int));
+extern tree build_x_indirect_ref PROTO((tree, char *));
+extern tree build_indirect_ref PROTO((tree, char *));
+extern tree build_x_array_ref PROTO((tree, tree));
+extern tree build_array_ref PROTO((tree, tree));
+extern tree build_x_function_call PROTO((tree, tree, tree));
+extern tree build_function_call_real PROTO((tree, tree, int, int));
+extern tree build_function_call PROTO((tree, tree));
+extern tree build_function_call_maybe PROTO((tree, tree));
+extern tree convert_arguments PROTO((tree, tree, tree, tree, int));
+extern tree build_x_binary_op PROTO((enum tree_code, tree, tree));
+extern tree build_binary_op PROTO((enum tree_code, tree, tree, int));
+extern tree build_binary_op_nodefault PROTO((enum tree_code, tree, tree, enum tree_code));
+extern tree build_component_addr PROTO((tree, tree, char *));
+extern tree build_x_unary_op PROTO((enum tree_code, tree));
+extern tree build_unary_op PROTO((enum tree_code, tree, int));
+extern tree unary_complex_lvalue PROTO((enum tree_code, tree));
+extern int mark_addressable PROTO((tree));
+extern tree build_x_conditional_expr PROTO((tree, tree, tree));
+extern tree build_conditional_expr PROTO((tree, tree, tree));
+extern tree build_x_compound_expr PROTO((tree));
+extern tree build_compound_expr PROTO((tree));
+extern tree build_static_cast PROTO((tree, tree));
+extern tree build_reinterpret_cast PROTO((tree, tree));
+extern tree build_const_cast PROTO((tree, tree));
+extern tree build_c_cast PROTO((tree, tree, int));
+extern tree build_modify_expr PROTO((tree, enum tree_code, tree));
+extern int language_lvalue_valid PROTO((tree));
+extern void warn_for_assignment PROTO((char *, char *, char *, tree, int, int));
+extern tree convert_for_initialization PROTO((tree, tree, tree, int, char *, tree, int));
+extern void c_expand_asm_operands PROTO((tree, tree, tree, tree, int, char *, int));
+extern void c_expand_return PROTO((tree));
+extern tree c_expand_start_case PROTO((tree));
+extern tree build_component_ref PROTO((tree, tree, tree, int));
+extern tree build_ptrmemfunc PROTO((tree, tree, int));
+
+/* in typeck2.c */
+extern tree error_not_base_type PROTO((tree, tree));
+extern tree binfo_or_else PROTO((tree, tree));
+extern void error_with_aggr_type (); /* PROTO((tree, char *, HOST_WIDE_INT)); */
+extern void readonly_error PROTO((tree, char *, int));
+extern void abstract_virtuals_error PROTO((tree, tree));
+extern void incomplete_type_error PROTO((tree, tree));
+extern void my_friendly_abort PROTO((int));
+extern void my_friendly_assert PROTO((int, int));
+extern tree store_init_value PROTO((tree, tree));
+extern tree digest_init PROTO((tree, tree, tree *));
+extern tree build_scoped_ref PROTO((tree, tree));
+extern tree build_x_arrow PROTO((tree));
+extern tree build_m_component_ref PROTO((tree, tree));
+extern tree build_functional_cast PROTO((tree, tree));
+extern char *enum_name_string PROTO((tree, tree));
+extern void report_case_error PROTO((int, tree, tree, tree));
+
+/* in xref.c */
+extern void GNU_xref_begin PROTO((char *));
+extern void GNU_xref_end PROTO((int));
+extern void GNU_xref_file PROTO((char *));
+extern void GNU_xref_start_scope PROTO((HOST_WIDE_INT));
+extern void GNU_xref_end_scope PROTO((HOST_WIDE_INT, HOST_WIDE_INT, int, int, int));
+extern void GNU_xref_ref PROTO((tree, char *));
+extern void GNU_xref_decl PROTO((tree, tree));
+extern void GNU_xref_call PROTO((tree, char *));
+extern void GNU_xref_function PROTO((tree, tree));
+extern void GNU_xref_assign PROTO((tree));
+extern void GNU_xref_hier PROTO((char *, char *, int, int, int));
+extern void GNU_xref_member PROTO((tree, tree));
+
+/* -- end of C++ */
+
+#endif /* not _CP_TREE_H */
diff --git a/contrib/gcc/cp/cvt.c b/contrib/gcc/cp/cvt.c
new file mode 100644
index 0000000..56508c1
--- /dev/null
+++ b/contrib/gcc/cp/cvt.c
@@ -0,0 +1,1820 @@
+/* Language-level data type conversion for GNU C++.
+ Copyright (C) 1987, 88, 92, 93, 94, 1995 Free Software Foundation, Inc.
+ Hacked by Michael Tiemann (tiemann@cygnus.com)
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+/* This file contains the functions for converting C expressions
+ to different data types. The only entry point is `convert'.
+ Every language front end must have a `convert' function
+ but what kind of conversions it does will depend on the language. */
+
+#include "config.h"
+#include "tree.h"
+#include "flags.h"
+#include "cp-tree.h"
+#include "class.h"
+#include "convert.h"
+
+#undef NULL
+#define NULL (char *)0
+
+/* Change of width--truncation and extension of integers or reals--
+ is represented with NOP_EXPR. Proper functioning of many things
+ assumes that no other conversions can be NOP_EXPRs.
+
+ Conversion between integer and pointer is represented with CONVERT_EXPR.
+ Converting integer to real uses FLOAT_EXPR
+ and real to integer uses FIX_TRUNC_EXPR.
+
+ Here is a list of all the functions that assume that widening and
+ narrowing is always done with a NOP_EXPR:
+ In convert.c, convert_to_integer.
+ In c-typeck.c, build_binary_op_nodefault (boolean ops),
+ and truthvalue_conversion.
+ In expr.c: expand_expr, for operands of a MULT_EXPR.
+ In fold-const.c: fold.
+ In tree.c: get_narrower and get_unwidened.
+
+ C++: in multiple-inheritance, converting between pointers may involve
+ adjusting them by a delta stored within the class definition. */
+
+/* Subroutines of `convert'. */
+
+/* Build a thunk. What it is, is an entry point that when called will
+ adjust the this pointer (the first argument) by offset, and then
+ goto the real address of the function given by REAL_ADDR that we
+ would like called. What we return is the address of the thunk. */
+static tree
+build_thunk (offset, real_addr)
+ tree offset, real_addr;
+{
+ if (TREE_CODE (real_addr) != ADDR_EXPR
+ || TREE_CODE (TREE_OPERAND (real_addr, 0)) != FUNCTION_DECL)
+ {
+ sorry ("MI pointer to member conversion too complex");
+ return error_mark_node;
+ }
+ sorry ("MI pointer to member conversion too complex");
+ return error_mark_node;
+}
+
+/* Convert a `pointer to member' (POINTER_TYPE to METHOD_TYPE) into
+ another `pointer to method'. This may involved the creation of
+ a thunk to handle the this offset calculation. */
+static tree
+convert_fn_ptr (type, expr)
+ tree type, expr;
+{
+ if (flag_vtable_thunks)
+ {
+ tree intype = TREE_TYPE (expr);
+ tree binfo = get_binfo (TYPE_METHOD_BASETYPE (TREE_TYPE (intype)),
+ TYPE_METHOD_BASETYPE (TREE_TYPE (type)), 1);
+ if (binfo == error_mark_node)
+ {
+ error (" in pointer to member conversion");
+ return error_mark_node;
+ }
+ if (binfo == NULL_TREE)
+ {
+ /* ARM 4.8 restriction. */
+ error ("invalid pointer to member conversion");
+ return error_mark_node;
+ }
+
+ if (BINFO_OFFSET_ZEROP (binfo))
+ return build1 (NOP_EXPR, type, expr);
+ return build1 (NOP_EXPR, type, build_thunk (BINFO_OFFSET (binfo), expr));
+ }
+ else
+ return build_ptrmemfunc (type, expr, 1);
+}
+
+/* if converting pointer to pointer
+ if dealing with classes, check for derived->base or vice versa
+ else if dealing with method pointers, delegate
+ else convert blindly
+ else if converting class, pass off to build_type_conversion
+ else try C-style pointer conversion */
+static tree
+cp_convert_to_pointer (type, expr)
+ tree type, expr;
+{
+ register tree intype = TREE_TYPE (expr);
+ register enum tree_code form;
+
+ if (TYPE_PTRMEMFUNC_P (type))
+ type = TYPE_PTRMEMFUNC_FN_TYPE (type);
+ if (TYPE_PTRMEMFUNC_P (intype))
+ intype = TYPE_PTRMEMFUNC_FN_TYPE (intype);
+
+ form = TREE_CODE (intype);
+
+ if (form == POINTER_TYPE || form == REFERENCE_TYPE)
+ {
+ intype = TYPE_MAIN_VARIANT (intype);
+
+ if (TYPE_MAIN_VARIANT (type) != intype
+ && TREE_CODE (TREE_TYPE (type)) == RECORD_TYPE
+ && TREE_CODE (TREE_TYPE (intype)) == RECORD_TYPE)
+ {
+ enum tree_code code = PLUS_EXPR;
+ tree binfo = get_binfo (TREE_TYPE (type), TREE_TYPE (intype), 1);
+ if (binfo == error_mark_node)
+ return error_mark_node;
+ if (binfo == NULL_TREE)
+ {
+ binfo = get_binfo (TREE_TYPE (intype), TREE_TYPE (type), 1);
+ if (binfo == error_mark_node)
+ return error_mark_node;
+ code = MINUS_EXPR;
+ }
+ if (binfo)
+ {
+ if (TYPE_USES_VIRTUAL_BASECLASSES (TREE_TYPE (type))
+ || TYPE_USES_VIRTUAL_BASECLASSES (TREE_TYPE (intype))
+ || ! BINFO_OFFSET_ZEROP (binfo))
+ {
+ /* Need to get the path we took. */
+ tree path;
+
+ if (code == PLUS_EXPR)
+ get_base_distance (TREE_TYPE (type), TREE_TYPE (intype), 0, &path);
+ else
+ get_base_distance (TREE_TYPE (intype), TREE_TYPE (type), 0, &path);
+ return build_vbase_path (code, type, expr, path, 0);
+ }
+ }
+ }
+ if (TREE_CODE (TREE_TYPE (intype)) == METHOD_TYPE
+ && TREE_CODE (type) == POINTER_TYPE
+ && TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE)
+ return convert_fn_ptr (type, expr);
+
+ if (TREE_CODE (TREE_TYPE (type)) == OFFSET_TYPE
+ && TREE_CODE (TREE_TYPE (intype)) == OFFSET_TYPE)
+ {
+ tree b1 = TYPE_OFFSET_BASETYPE (TREE_TYPE (type));
+ tree b2 = TYPE_OFFSET_BASETYPE (TREE_TYPE (intype));
+ tree binfo = get_binfo (b1, b2, 1);
+ if (binfo == NULL_TREE)
+ binfo = get_binfo (b2, b1, 1);
+ if (binfo == error_mark_node)
+ return error_mark_node;
+ }
+
+ if (TREE_CODE (TREE_TYPE (intype)) == METHOD_TYPE
+ || (TREE_CODE (type) == POINTER_TYPE
+ && TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE))
+ {
+ cp_error ("cannot convert `%E' from type `%T' to type `%T'",
+ expr, intype, type);
+ return error_mark_node;
+ }
+
+ return build1 (NOP_EXPR, type, expr);
+ }
+
+ my_friendly_assert (form != OFFSET_TYPE, 186);
+
+ if (TYPE_LANG_SPECIFIC (intype)
+ && (IS_SIGNATURE_POINTER (intype) || IS_SIGNATURE_REFERENCE (intype)))
+ return convert_to_pointer (type, build_optr_ref (expr));
+
+ if (IS_AGGR_TYPE (intype))
+ {
+ tree rval;
+ rval = build_type_conversion (CONVERT_EXPR, type, expr, 1);
+ if (rval)
+ {
+ if (rval == error_mark_node)
+ cp_error ("conversion of `%E' from `%T' to `%T' is ambiguous",
+ expr, intype, type);
+ return rval;
+ }
+ }
+
+ if (integer_zerop (expr))
+ {
+ if (type == TREE_TYPE (null_pointer_node))
+ return null_pointer_node;
+ expr = build_int_2 (0, 0);
+ TREE_TYPE (expr) = type;
+ return expr;
+ }
+
+ if (INTEGRAL_CODE_P (form))
+ {
+ if (type_precision (intype) == POINTER_SIZE)
+ return build1 (CONVERT_EXPR, type, expr);
+ expr = convert (type_for_size (POINTER_SIZE, 0), expr);
+ /* Modes may be different but sizes should be the same. */
+ if (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (expr)))
+ != GET_MODE_SIZE (TYPE_MODE (type)))
+ /* There is supposed to be some integral type
+ that is the same width as a pointer. */
+ abort ();
+ return convert_to_pointer (type, expr);
+ }
+
+ cp_error ("cannot convert `%E' from type `%T' to type `%T'",
+ expr, intype, type);
+ return error_mark_node;
+}
+
+/* Like convert, except permit conversions to take place which
+ are not normally allowed due to access restrictions
+ (such as conversion from sub-type to private super-type). */
+static tree
+convert_to_pointer_force (type, expr)
+ tree type, expr;
+{
+ register tree intype = TREE_TYPE (expr);
+ register enum tree_code form = TREE_CODE (intype);
+
+ if (integer_zerop (expr))
+ {
+ if (type == TREE_TYPE (null_pointer_node))
+ return null_pointer_node;
+ expr = build_int_2 (0, 0);
+ TREE_TYPE (expr) = type;
+ return expr;
+ }
+
+ /* Convert signature pointer/reference to `void *' first. */
+ if (form == RECORD_TYPE
+ && (IS_SIGNATURE_POINTER (intype) || IS_SIGNATURE_REFERENCE (intype)))
+ {
+ expr = build_optr_ref (expr);
+ intype = TREE_TYPE (expr);
+ form = TREE_CODE (intype);
+ }
+
+ if (form == POINTER_TYPE)
+ {
+ intype = TYPE_MAIN_VARIANT (intype);
+
+ if (TYPE_MAIN_VARIANT (type) != intype
+ && TREE_CODE (TREE_TYPE (type)) == RECORD_TYPE
+ && TREE_CODE (TREE_TYPE (intype)) == RECORD_TYPE)
+ {
+ enum tree_code code = PLUS_EXPR;
+ tree path;
+ int distance = get_base_distance (TREE_TYPE (type),
+ TREE_TYPE (intype), 0, &path);
+ if (distance == -2)
+ {
+ ambig:
+ cp_error ("type `%T' is ambiguous baseclass of `%s'", TREE_TYPE (type),
+ TYPE_NAME_STRING (TREE_TYPE (intype)));
+ return error_mark_node;
+ }
+ if (distance == -1)
+ {
+ distance = get_base_distance (TREE_TYPE (intype),
+ TREE_TYPE (type), 0, &path);
+ if (distance == -2)
+ goto ambig;
+ if (distance < 0)
+ /* Doesn't need any special help from us. */
+ return build1 (NOP_EXPR, type, expr);
+
+ code = MINUS_EXPR;
+ }
+ return build_vbase_path (code, type, expr, path, 0);
+ }
+ return build1 (NOP_EXPR, type, expr);
+ }
+
+ return cp_convert_to_pointer (type, expr);
+}
+
+/* We are passing something to a function which requires a reference.
+ The type we are interested in is in TYPE. The initial
+ value we have to begin with is in ARG.
+
+ FLAGS controls how we manage access checking.
+ CHECKCONST controls if we report error messages on const subversion. */
+static tree
+build_up_reference (type, arg, flags, checkconst)
+ tree type, arg;
+ int flags, checkconst;
+{
+ tree rval, targ;
+ int literal_flag = 0;
+ tree argtype = TREE_TYPE (arg);
+ tree target_type = TREE_TYPE (type);
+ tree binfo = NULL_TREE;
+
+ my_friendly_assert (TREE_CODE (type) == REFERENCE_TYPE, 187);
+ if ((flags & LOOKUP_PROTECT)
+ && TYPE_MAIN_VARIANT (argtype) != TYPE_MAIN_VARIANT (target_type)
+ && IS_AGGR_TYPE (argtype)
+ && IS_AGGR_TYPE (target_type))
+ {
+ binfo = get_binfo (target_type, argtype, 1);
+ if (binfo == error_mark_node)
+ return error_mark_node;
+ if (binfo == NULL_TREE)
+ return error_not_base_type (target_type, argtype);
+ }
+
+ /* Pass along const and volatile down into the type. */
+ if (TYPE_READONLY (type) || TYPE_VOLATILE (type))
+ target_type = cp_build_type_variant (target_type, TYPE_READONLY (type),
+ TYPE_VOLATILE (type));
+ targ = arg;
+ if (TREE_CODE (targ) == SAVE_EXPR)
+ targ = TREE_OPERAND (targ, 0);
+ while (TREE_CODE (targ) == NOP_EXPR
+ && (TYPE_MAIN_VARIANT (argtype)
+ == TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (targ, 0)))))
+ targ = TREE_OPERAND (targ, 0);
+
+ switch (TREE_CODE (targ))
+ {
+ case INDIRECT_REF:
+ /* This is a call to a constructor which did not know what it was
+ initializing until now: it needs to initialize a temporary. */
+ if (TREE_HAS_CONSTRUCTOR (targ))
+ {
+ tree temp = build_cplus_new (argtype, TREE_OPERAND (targ, 0), 1);
+ TREE_HAS_CONSTRUCTOR (targ) = 0;
+ return build_up_reference (type, temp, flags, 1);
+ }
+ /* Let &* cancel out to simplify resulting code.
+ Also, throw away intervening NOP_EXPRs. */
+ arg = TREE_OPERAND (targ, 0);
+ if (TREE_CODE (arg) == NOP_EXPR || TREE_CODE (arg) == NON_LVALUE_EXPR
+ || (TREE_CODE (arg) == CONVERT_EXPR && TREE_REFERENCE_EXPR (arg)))
+ arg = TREE_OPERAND (arg, 0);
+
+ /* in doing a &*, we have to get rid of the const'ness on the pointer
+ value. Haven't thought about volatile here. Pointers come to mind
+ here. */
+ if (TREE_READONLY (arg))
+ {
+ arg = copy_node (arg);
+ TREE_READONLY (arg) = 0;
+ }
+
+ rval = build1 (CONVERT_EXPR, type, arg);
+ TREE_REFERENCE_EXPR (rval) = 1;
+
+ /* propagate the const flag on something like:
+
+ class Base {
+ public:
+ int foo;
+ };
+
+ class Derived : public Base {
+ public:
+ int bar;
+ };
+
+ void func(Base&);
+
+ void func2(const Derived& d) {
+ func(d);
+ }
+
+ on the d parameter. The below could have been avoided, if the flags
+ were down in the tree, not sure why they are not. (mrs) */
+ /* The below code may have to be propagated to other parts of this
+ switch. */
+ if (TREE_READONLY (targ) && !TREE_READONLY (arg)
+ && (TREE_CODE (arg) == PARM_DECL || TREE_CODE (arg) == VAR_DECL)
+ && TREE_CODE (TREE_TYPE (arg)) == REFERENCE_TYPE
+ && (TYPE_READONLY (target_type) && checkconst))
+ {
+ arg = copy_node (arg);
+ TREE_READONLY (arg) = TREE_READONLY (targ);
+ }
+ literal_flag = TREE_CONSTANT (arg);
+
+ goto done;
+
+ /* Get this out of a register if we happened to be in one by accident.
+ Also, build up references to non-lvalues it we must. */
+ /* For &x[y], return (&) x+y */
+ case ARRAY_REF:
+ if (mark_addressable (TREE_OPERAND (targ, 0)) == 0)
+ return error_mark_node;
+ rval = build_binary_op (PLUS_EXPR, TREE_OPERAND (targ, 0),
+ TREE_OPERAND (targ, 1), 1);
+ TREE_TYPE (rval) = type;
+ if (TREE_CONSTANT (TREE_OPERAND (targ, 1))
+ && staticp (TREE_OPERAND (targ, 0)))
+ TREE_CONSTANT (rval) = 1;
+ goto done;
+
+ case SCOPE_REF:
+ /* Could be a reference to a static member. */
+ {
+ tree field = TREE_OPERAND (targ, 1);
+ if (TREE_STATIC (field))
+ {
+ rval = build1 (ADDR_EXPR, type, field);
+ literal_flag = 1;
+ goto done;
+ }
+ }
+
+ /* We should have farmed out member pointers above. */
+ my_friendly_abort (188);
+
+ case COMPONENT_REF:
+ rval = build_component_addr (targ, build_pointer_type (argtype),
+ "attempt to make a reference to bit-field structure member `%s'");
+ TREE_TYPE (rval) = type;
+ literal_flag = staticp (TREE_OPERAND (targ, 0));
+
+ goto done;
+
+ /* Anything not already handled and not a true memory reference
+ needs to have a reference built up. Do so silently for
+ things like integers and return values from function,
+ but complain if we need a reference to something declared
+ as `register'. */
+
+ case RESULT_DECL:
+ if (staticp (targ))
+ literal_flag = 1;
+ TREE_ADDRESSABLE (targ) = 1;
+ put_var_into_stack (targ);
+ break;
+
+ case PARM_DECL:
+#if 0
+ if (targ == current_class_decl)
+ {
+ error ("address of `this' not available");
+/* #if 0 */
+ /* This code makes the following core dump the compiler on a sun4,
+ if the code below is used.
+
+ class e_decl;
+ class a_decl;
+ typedef a_decl* a_ref;
+
+ class a_s {
+ public:
+ a_s();
+ void* append(a_ref& item);
+ };
+ class a_decl {
+ public:
+ a_decl (e_decl *parent);
+ a_s generic_s;
+ a_s decls;
+ e_decl* parent;
+ };
+
+ class e_decl {
+ public:
+ e_decl();
+ a_s implementations;
+ };
+
+ void foobar(void *);
+
+ a_decl::a_decl(e_decl *parent) {
+ parent->implementations.append(this);
+ }
+ */
+
+ TREE_ADDRESSABLE (targ) = 1; /* so compiler doesn't die later */
+ put_var_into_stack (targ);
+ break;
+/* #else */
+ return error_mark_node;
+/* #endif */
+ }
+#endif
+ /* Fall through. */
+ case VAR_DECL:
+ case CONST_DECL:
+ if (DECL_REGISTER (targ) && !TREE_ADDRESSABLE (targ)
+ && !DECL_ARTIFICIAL (targ))
+ cp_warning ("address needed to build reference for `%D', which is declared `register'",
+ targ);
+ else if (staticp (targ))
+ literal_flag = 1;
+
+ TREE_ADDRESSABLE (targ) = 1;
+ put_var_into_stack (targ);
+ break;
+
+ case COMPOUND_EXPR:
+ {
+ tree real_reference = build_up_reference (type, TREE_OPERAND (targ, 1),
+ LOOKUP_PROTECT, checkconst);
+ rval = build (COMPOUND_EXPR, type, TREE_OPERAND (targ, 0), real_reference);
+ TREE_CONSTANT (rval) = staticp (TREE_OPERAND (targ, 1));
+ return rval;
+ }
+
+ case PREINCREMENT_EXPR:
+ case PREDECREMENT_EXPR:
+ case MODIFY_EXPR:
+ case INIT_EXPR:
+ {
+ tree real_reference = build_up_reference (type, TREE_OPERAND (targ, 0),
+ LOOKUP_PROTECT, checkconst);
+ rval = build (COMPOUND_EXPR, type, arg, real_reference);
+ TREE_CONSTANT (rval) = staticp (TREE_OPERAND (targ, 0));
+ return rval;
+ }
+
+ case COND_EXPR:
+ return build (COND_EXPR, type,
+ TREE_OPERAND (targ, 0),
+ build_up_reference (type, TREE_OPERAND (targ, 1),
+ LOOKUP_PROTECT, checkconst),
+ build_up_reference (type, TREE_OPERAND (targ, 2),
+ LOOKUP_PROTECT, checkconst));
+
+ /* Undo the folding... */
+ case MIN_EXPR:
+ case MAX_EXPR:
+ return build (COND_EXPR, type,
+ build (TREE_CODE (targ) == MIN_EXPR ? LT_EXPR : GT_EXPR,
+ boolean_type_node, TREE_OPERAND (targ, 0),
+ TREE_OPERAND (targ, 1)),
+ build_up_reference (type, TREE_OPERAND (targ, 0),
+ LOOKUP_PROTECT, checkconst),
+ build_up_reference (type, TREE_OPERAND (targ, 1),
+ LOOKUP_PROTECT, checkconst));
+
+ case WITH_CLEANUP_EXPR:
+ return build (WITH_CLEANUP_EXPR, type,
+ build_up_reference (type, TREE_OPERAND (targ, 0),
+ LOOKUP_PROTECT, checkconst),
+ 0, TREE_OPERAND (targ, 2));
+
+ case BIND_EXPR:
+ arg = TREE_OPERAND (targ, 1);
+ if (arg == NULL_TREE)
+ {
+ compiler_error ("({ ... }) expression not expanded when needed for reference");
+ return error_mark_node;
+ }
+ rval = build1 (ADDR_EXPR, type, arg);
+ TREE_REFERENCE_EXPR (rval) = 1;
+ return rval;
+
+ default:
+ break;
+ }
+
+ if (TREE_ADDRESSABLE (targ) == 0)
+ {
+ tree temp;
+
+ if (TREE_CODE (targ) == CALL_EXPR && IS_AGGR_TYPE (argtype))
+ {
+ temp = build_cplus_new (argtype, targ, 1);
+ if (TREE_CODE (temp) == WITH_CLEANUP_EXPR)
+ rval = build (WITH_CLEANUP_EXPR, type,
+ build1 (ADDR_EXPR, type, TREE_OPERAND (temp, 0)),
+ 0, TREE_OPERAND (temp, 2));
+ else
+ rval = build1 (ADDR_EXPR, type, temp);
+ goto done;
+ }
+ else
+ {
+ temp = get_temp_name (argtype, 0);
+ if (toplevel_bindings_p ())
+ {
+ /* Give this new temp some rtl and initialize it. */
+ DECL_INITIAL (temp) = targ;
+ TREE_STATIC (temp) = 1;
+ cp_finish_decl (temp, targ, NULL_TREE, 0, LOOKUP_ONLYCONVERTING);
+ /* Do this after declaring it static. */
+ rval = build_unary_op (ADDR_EXPR, temp, 0);
+ TREE_TYPE (rval) = type;
+ literal_flag = TREE_CONSTANT (rval);
+ goto done;
+ }
+ else
+ {
+ rval = build_unary_op (ADDR_EXPR, temp, 0);
+ if (binfo && !BINFO_OFFSET_ZEROP (binfo))
+ rval = convert_pointer_to (target_type, rval);
+ else
+ TREE_TYPE (rval) = type;
+
+ temp = build (MODIFY_EXPR, argtype, temp, arg);
+ TREE_SIDE_EFFECTS (temp) = 1;
+ return build (COMPOUND_EXPR, type, temp, rval);
+ }
+ }
+ }
+ else
+ rval = build1 (ADDR_EXPR, type, arg);
+
+ done:
+ if (TYPE_USES_COMPLEX_INHERITANCE (argtype)
+ || TYPE_USES_COMPLEX_INHERITANCE (target_type))
+ {
+ TREE_TYPE (rval) = build_pointer_type (argtype);
+ if (flags & LOOKUP_PROTECT)
+ rval = convert_pointer_to (target_type, rval);
+ else
+ rval
+ = convert_to_pointer_force (build_pointer_type (target_type), rval);
+ TREE_TYPE (rval) = type;
+ if (TREE_CODE (rval) == PLUS_EXPR || TREE_CODE (rval) == MINUS_EXPR)
+ TREE_TYPE (TREE_OPERAND (rval, 0))
+ = TREE_TYPE (TREE_OPERAND (rval, 1)) = type;
+ }
+ TREE_CONSTANT (rval) = literal_flag;
+ return rval;
+}
+
+/* For C++: Only need to do one-level references, but cannot
+ get tripped up on signed/unsigned differences.
+
+ DECL is either NULL_TREE or the _DECL node for a reference that is being
+ initialized. It can be error_mark_node if we don't know the _DECL but
+ we know it's an initialization. */
+
+tree
+convert_to_reference (reftype, expr, convtype, flags, decl)
+ tree reftype, expr;
+ int convtype, flags;
+ tree decl;
+{
+ register tree type = TYPE_MAIN_VARIANT (TREE_TYPE (reftype));
+ register tree intype = TREE_TYPE (expr);
+ tree rval = NULL_TREE;
+ tree rval_as_conversion = NULL_TREE;
+ int i;
+
+ if (TREE_CODE (intype) == REFERENCE_TYPE)
+ my_friendly_abort (364);
+
+ intype = TYPE_MAIN_VARIANT (intype);
+
+ i = comp_target_types (type, intype, 0);
+
+ if (i <= 0 && (convtype & CONV_IMPLICIT) && IS_AGGR_TYPE (intype)
+ && ! (flags & LOOKUP_NO_CONVERSION))
+ {
+ /* Look for a user-defined conversion to lvalue that we can use. */
+
+ rval_as_conversion = build_type_conversion (CONVERT_EXPR, type, expr, 1);
+
+ if (rval_as_conversion && rval_as_conversion != error_mark_node
+ && real_lvalue_p (rval_as_conversion))
+ {
+ expr = rval_as_conversion;
+ rval_as_conversion = NULL_TREE;
+ intype = type;
+ i = 1;
+ }
+ }
+
+ if (((convtype & CONV_STATIC) && i == -1)
+ || ((convtype & CONV_IMPLICIT) && i == 1))
+ {
+ if (flags & LOOKUP_COMPLAIN)
+ {
+ tree ttl = TREE_TYPE (reftype);
+ tree ttr;
+
+ {
+ int r = TREE_READONLY (expr);
+ int v = TREE_THIS_VOLATILE (expr);
+ ttr = cp_build_type_variant (TREE_TYPE (expr), r, v);
+ }
+
+ if (! real_lvalue_p (expr) &&
+ (decl == NULL_TREE || ! TYPE_READONLY (ttl)))
+ {
+ if (decl)
+ /* Ensure semantics of [dcl.init.ref] */
+ cp_pedwarn ("initialization of non-const `%T' from rvalue `%T'",
+ reftype, intype);
+ else
+ cp_pedwarn ("conversion to `%T' from rvalue `%T'",
+ reftype, intype);
+ }
+ else if (! (convtype & CONV_CONST))
+ {
+ if (! TYPE_READONLY (ttl) && TYPE_READONLY (ttr))
+ cp_pedwarn ("conversion from `%T' to `%T' discards const",
+ ttr, reftype);
+ else if (! TYPE_VOLATILE (ttl) && TYPE_VOLATILE (ttr))
+ cp_pedwarn ("conversion from `%T' to `%T' discards volatile",
+ ttr, reftype);
+ }
+ }
+
+ return build_up_reference (reftype, expr, flags,
+ ! (convtype & CONV_CONST));
+ }
+ else if ((convtype & CONV_REINTERPRET) && lvalue_p (expr))
+ {
+ /* When casting an lvalue to a reference type, just convert into
+ a pointer to the new type and deference it. This is allowed
+ by San Diego WP section 5.2.9 paragraph 12, though perhaps it
+ should be done directly (jason). (int &)ri ---> *(int*)&ri */
+
+ /* B* bp; A& ar = (A&)bp; is valid, but it's probably not what they
+ meant. */
+ if (TREE_CODE (intype) == POINTER_TYPE
+ && (comptypes (TREE_TYPE (intype), type, -1)))
+ cp_warning ("casting `%T' to `%T' does not dereference pointer",
+ intype, reftype);
+
+ rval = build_unary_op (ADDR_EXPR, expr, 0);
+ if (rval != error_mark_node)
+ rval = convert_force (build_pointer_type (TREE_TYPE (reftype)), rval, 0);
+ if (rval != error_mark_node)
+ rval = build1 (NOP_EXPR, reftype, rval);
+ }
+ else if (decl)
+ {
+ tree rval_as_ctor = NULL_TREE;
+
+ if (rval_as_conversion)
+ {
+ if (rval_as_conversion == error_mark_node)
+ {
+ cp_error ("conversion from `%T' to `%T' is ambiguous",
+ intype, reftype);
+ return error_mark_node;
+ }
+ rval_as_conversion = build_up_reference (reftype, rval_as_conversion,
+ flags, 1);
+ }
+
+ /* Definitely need to go through a constructor here. */
+ if (TYPE_HAS_CONSTRUCTOR (type)
+ && ! CLASSTYPE_ABSTRACT_VIRTUALS (type)
+ && (rval = build_method_call
+ (NULL_TREE, constructor_name_full (type),
+ build_tree_list (NULL_TREE, expr), TYPE_BINFO (type),
+ LOOKUP_NO_CONVERSION|LOOKUP_SPECULATIVELY
+ | LOOKUP_ONLYCONVERTING)))
+ {
+ tree init;
+
+ if (toplevel_bindings_p ())
+ {
+ extern tree static_aggregates;
+ tree t = get_temp_name (type, toplevel_bindings_p ());
+ init = build_method_call (t, constructor_name_full (type),
+ build_tree_list (NULL_TREE, expr),
+ TYPE_BINFO (type),
+ LOOKUP_NORMAL|LOOKUP_NO_CONVERSION
+ | LOOKUP_ONLYCONVERTING);
+
+ if (init == error_mark_node)
+ return error_mark_node;
+
+ make_decl_rtl (t, NULL_PTR, 1);
+ static_aggregates = perm_tree_cons (expr, t, static_aggregates);
+ rval = build_unary_op (ADDR_EXPR, t, 0);
+ }
+ else
+ {
+ init = build_method_call (NULL_TREE, constructor_name_full (type),
+ build_tree_list (NULL_TREE, expr),
+ TYPE_BINFO (type),
+ LOOKUP_NORMAL|LOOKUP_NO_CONVERSION
+ |LOOKUP_ONLYCONVERTING);
+
+ if (init == error_mark_node)
+ return error_mark_node;
+
+ rval = build_cplus_new (type, init, 1);
+ rval = build_up_reference (reftype, rval, flags, 1);
+ }
+ rval_as_ctor = rval;
+ }
+
+ if (rval_as_ctor && rval_as_conversion)
+ {
+ cp_error ("ambiguous conversion from `%T' to `%T'; both user-defined conversion and constructor apply",
+ intype, reftype);
+ return error_mark_node;
+ }
+ else if (rval_as_ctor)
+ rval = rval_as_ctor;
+ else if (rval_as_conversion)
+ rval = rval_as_conversion;
+ else if (! IS_AGGR_TYPE (type) && ! IS_AGGR_TYPE (intype))
+ {
+ rval = convert (type, expr);
+ if (rval == error_mark_node)
+ return error_mark_node;
+
+ rval = build_up_reference (reftype, rval, flags, 1);
+ }
+
+ if (rval && ! TYPE_READONLY (TREE_TYPE (reftype)))
+ cp_pedwarn ("initializing non-const `%T' with `%T' will use a temporary",
+ reftype, intype);
+ }
+
+ if (rval)
+ {
+ /* If we found a way to convert earlier, then use it. */
+ return rval;
+ }
+
+ my_friendly_assert (TREE_CODE (intype) != OFFSET_TYPE, 189);
+
+ if (flags & LOOKUP_COMPLAIN)
+ cp_error ("cannot convert type `%T' to type `%T'", intype, reftype);
+
+ if (flags & LOOKUP_SPECULATIVELY)
+ return NULL_TREE;
+
+ return error_mark_node;
+}
+
+/* We are using a reference VAL for its value. Bash that reference all the
+ way down to its lowest form. */
+tree
+convert_from_reference (val)
+ tree val;
+{
+ tree type = TREE_TYPE (val);
+
+ if (TREE_CODE (type) == OFFSET_TYPE)
+ type = TREE_TYPE (type);
+ if (TREE_CODE (type) == REFERENCE_TYPE)
+ return build_indirect_ref (val, NULL_PTR);
+ return val;
+}
+
+/* See if there is a constructor of type TYPE which will convert
+ EXPR. The reference manual seems to suggest (8.5.6) that we need
+ not worry about finding constructors for base classes, then converting
+ to the derived class.
+
+ MSGP is a pointer to a message that would be an appropriate error
+ string. If MSGP is NULL, then we are not interested in reporting
+ errors. */
+tree
+convert_to_aggr (type, expr, msgp, protect)
+ tree type, expr;
+ char **msgp;
+ int protect;
+{
+ tree basetype = type;
+ tree name = TYPE_IDENTIFIER (basetype);
+ tree function, fndecl, fntype, parmtypes, parmlist, result;
+ tree method_name;
+ enum access_type access;
+ int can_be_private, can_be_protected;
+
+ if (! TYPE_HAS_CONSTRUCTOR (basetype))
+ {
+ if (msgp)
+ *msgp = "type `%s' does not have a constructor";
+ return error_mark_node;
+ }
+
+ access = access_public;
+ can_be_private = 0;
+ can_be_protected = IDENTIFIER_CLASS_VALUE (name) || name == current_class_name;
+
+ parmlist = build_tree_list (NULL_TREE, expr);
+ parmtypes = tree_cons (NULL_TREE, TREE_TYPE (expr), void_list_node);
+
+ if (TYPE_USES_VIRTUAL_BASECLASSES (basetype))
+ {
+ parmtypes = tree_cons (NULL_TREE, integer_type_node, parmtypes);
+ parmlist = tree_cons (NULL_TREE, integer_one_node, parmlist);
+ }
+
+ /* The type of the first argument will be filled in inside the loop. */
+ parmlist = tree_cons (NULL_TREE, integer_zero_node, parmlist);
+ parmtypes = tree_cons (NULL_TREE, build_pointer_type (basetype), parmtypes);
+
+#if 0
+ method_name = build_decl_overload (name, parmtypes, 1);
+
+ /* constructors are up front. */
+ fndecl = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (basetype), 0);
+ if (TYPE_HAS_DESTRUCTOR (basetype))
+ fndecl = DECL_CHAIN (fndecl);
+
+ while (fndecl)
+ {
+ if (DECL_ASSEMBLER_NAME (fndecl) == method_name)
+ {
+ function = fndecl;
+ if (protect)
+ {
+ if (TREE_PRIVATE (fndecl))
+ {
+ can_be_private =
+ (basetype == current_class_type
+ || is_friend (basetype, current_function_decl)
+ || purpose_member (basetype, DECL_ACCESS (fndecl)));
+ if (! can_be_private)
+ goto found;
+ }
+ else if (TREE_PROTECTED (fndecl))
+ {
+ if (! can_be_protected)
+ goto found;
+ }
+ }
+ goto found_and_ok;
+ }
+ fndecl = DECL_CHAIN (fndecl);
+ }
+#endif
+
+ /* No exact conversion was found. See if an approximate
+ one will do. */
+ fndecl = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (basetype), 0);
+ if (TYPE_HAS_DESTRUCTOR (basetype))
+ fndecl = DECL_CHAIN (fndecl);
+
+ {
+ int saw_private = 0;
+ int saw_protected = 0;
+ struct candidate *candidates =
+ (struct candidate *) alloca ((decl_list_length (fndecl)+1) * sizeof (struct candidate));
+ struct candidate *cp = candidates;
+
+ while (fndecl)
+ {
+ function = fndecl;
+ cp->h_len = 2;
+ cp->harshness = (struct harshness_code *)
+ alloca (3 * sizeof (struct harshness_code));
+
+ compute_conversion_costs (fndecl, parmlist, cp, 2);
+ if ((cp->h.code & EVIL_CODE) == 0)
+ {
+ cp->u.field = fndecl;
+ if (protect)
+ {
+ if (TREE_PRIVATE (fndecl))
+ access = access_private;
+ else if (TREE_PROTECTED (fndecl))
+ access = access_protected;
+ else
+ access = access_public;
+ }
+ else
+ access = access_public;
+
+ if (access == access_private
+ ? (basetype == current_class_type
+ || is_friend (basetype, cp->function)
+ || purpose_member (basetype, DECL_ACCESS (fndecl)))
+ : access == access_protected
+ ? (can_be_protected
+ || purpose_member (basetype, DECL_ACCESS (fndecl)))
+ : 1)
+ {
+ if (cp->h.code <= TRIVIAL_CODE)
+ goto found_and_ok;
+ cp++;
+ }
+ else
+ {
+ if (access == access_private)
+ saw_private = 1;
+ else
+ saw_protected = 1;
+ }
+ }
+ fndecl = DECL_CHAIN (fndecl);
+ }
+ if (cp - candidates)
+ {
+ /* Rank from worst to best. Then cp will point to best one.
+ Private fields have their bits flipped. For unsigned
+ numbers, this should make them look very large.
+ If the best alternate has a (signed) negative value,
+ then all we ever saw were private members. */
+ if (cp - candidates > 1)
+ qsort (candidates, /* char *base */
+ cp - candidates, /* int nel */
+ sizeof (struct candidate), /* int width */
+ rank_for_overload); /* int (*compar)() */
+
+ --cp;
+ if (cp->h.code & EVIL_CODE)
+ {
+ if (msgp)
+ *msgp = "ambiguous type conversion possible for `%s'";
+ return error_mark_node;
+ }
+
+ function = cp->function;
+ fndecl = cp->u.field;
+ goto found_and_ok;
+ }
+ else if (msgp)
+ {
+ if (saw_private)
+ if (saw_protected)
+ *msgp = "only private and protected conversions apply";
+ else
+ *msgp = "only private conversions apply";
+ else if (saw_protected)
+ *msgp = "only protected conversions apply";
+ else
+ *msgp = "no appropriate conversion to type `%s'";
+ }
+ return error_mark_node;
+ }
+ /* NOTREACHED */
+
+ found:
+ if (access == access_private)
+ if (! can_be_private)
+ {
+ if (msgp)
+ *msgp = TREE_PRIVATE (fndecl)
+ ? "conversion to type `%s' is private"
+ : "conversion to type `%s' is from private base class";
+ return error_mark_node;
+ }
+ if (access == access_protected)
+ if (! can_be_protected)
+ {
+ if (msgp)
+ *msgp = TREE_PRIVATE (fndecl)
+ ? "conversion to type `%s' is protected"
+ : "conversion to type `%s' is from protected base class";
+ return error_mark_node;
+ }
+ function = fndecl;
+ found_and_ok:
+
+ /* It will convert, but we don't do anything about it yet. */
+ if (msgp == 0)
+ return NULL_TREE;
+
+ fntype = TREE_TYPE (function);
+ function = default_conversion (function);
+
+ result = build_nt (CALL_EXPR, function,
+ convert_arguments (NULL_TREE, TYPE_ARG_TYPES (fntype),
+ parmlist, NULL_TREE, LOOKUP_NORMAL),
+ NULL_TREE);
+ TREE_TYPE (result) = TREE_TYPE (fntype);
+ TREE_SIDE_EFFECTS (result) = 1;
+ return result;
+}
+
+/* Call this when we know (for any reason) that expr is not, in fact,
+ zero. This routine is like convert_pointer_to, but it pays
+ attention to which specific instance of what type we want to
+ convert to. This routine should eventually become
+ convert_to_pointer after all references to convert_to_pointer
+ are removed. */
+tree
+convert_pointer_to_real (binfo, expr)
+ tree binfo, expr;
+{
+ register tree intype = TREE_TYPE (expr);
+ tree ptr_type;
+ tree type, rval;
+
+ if (TREE_CODE (binfo) == TREE_VEC)
+ type = BINFO_TYPE (binfo);
+ else if (IS_AGGR_TYPE (binfo))
+ {
+ type = binfo;
+ }
+ else
+ {
+ type = binfo;
+ binfo = NULL_TREE;
+ }
+
+ ptr_type = build_pointer_type (type);
+ if (ptr_type == TYPE_MAIN_VARIANT (intype))
+ return expr;
+
+ if (intype == error_mark_node)
+ return error_mark_node;
+
+ my_friendly_assert (!integer_zerop (expr), 191);
+
+ if (TREE_CODE (type) == RECORD_TYPE
+ && TREE_CODE (TREE_TYPE (intype)) == RECORD_TYPE
+ && type != TYPE_MAIN_VARIANT (TREE_TYPE (intype)))
+ {
+ tree path;
+ int distance
+ = get_base_distance (binfo, TYPE_MAIN_VARIANT (TREE_TYPE (intype)),
+ 0, &path);
+
+ /* This function shouldn't be called with unqualified arguments
+ but if it is, give them an error message that they can read. */
+ if (distance < 0)
+ {
+ cp_error ("cannot convert a pointer of type `%T' to a pointer of type `%T'",
+ TREE_TYPE (intype), type);
+
+ if (distance == -2)
+ cp_error ("because `%T' is an ambiguous base class", type);
+ return error_mark_node;
+ }
+
+ return build_vbase_path (PLUS_EXPR, ptr_type, expr, path, 1);
+ }
+ rval = build1 (NOP_EXPR, ptr_type,
+ TREE_CODE (expr) == NOP_EXPR ? TREE_OPERAND (expr, 0) : expr);
+ TREE_CONSTANT (rval) = TREE_CONSTANT (expr);
+ return rval;
+}
+
+/* Call this when we know (for any reason) that expr is
+ not, in fact, zero. This routine gets a type out of the first
+ argument and uses it to search for the type to convert to. If there
+ is more than one instance of that type in the expr, the conversion is
+ ambiguous. This routine should eventually go away, and all
+ callers should use convert_to_pointer_real. */
+tree
+convert_pointer_to (binfo, expr)
+ tree binfo, expr;
+{
+ tree type;
+
+ if (TREE_CODE (binfo) == TREE_VEC)
+ type = BINFO_TYPE (binfo);
+ else if (IS_AGGR_TYPE (binfo))
+ type = binfo;
+ else
+ type = binfo;
+ return convert_pointer_to_real (type, expr);
+}
+
+/* Conversion...
+
+ FLAGS indicates how we should behave. */
+
+tree
+cp_convert (type, expr, convtype, flags)
+ tree type, expr;
+ int convtype, flags;
+{
+ register tree e = expr;
+ register enum tree_code code = TREE_CODE (type);
+
+ if (TREE_CODE (e) == ERROR_MARK
+ || TREE_CODE (TREE_TYPE (e)) == ERROR_MARK)
+ return error_mark_node;
+
+ if (IS_AGGR_TYPE (type) && (convtype & CONV_FORCE_TEMP))
+ /* We need a new temporary; don't take this shortcut. */;
+ else if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (e)))
+ /* Trivial conversion: cv-qualifiers do not matter on rvalues. */
+ return fold (build1 (NOP_EXPR, type, e));
+
+ if (code == VOID_TYPE && (convtype & CONV_STATIC))
+ return build1 (CONVERT_EXPR, type, e);
+
+#if 0
+ /* This is incorrect. A truncation can't be stripped this way.
+ Extensions will be stripped by the use of get_unwidened. */
+ if (TREE_CODE (e) == NOP_EXPR)
+ return convert (type, TREE_OPERAND (e, 0));
+#endif
+
+ /* Just convert to the type of the member. */
+ if (code == OFFSET_TYPE)
+ {
+ type = TREE_TYPE (type);
+ code = TREE_CODE (type);
+ }
+
+#if 0
+ if (code == REFERENCE_TYPE)
+ return fold (convert_to_reference (type, e, convtype, flags, NULL_TREE));
+ else if (TREE_CODE (TREE_TYPE (e)) == REFERENCE_TYPE)
+ e = convert_from_reference (e);
+#endif
+
+ if (TREE_CODE (e) == OFFSET_REF)
+ e = resolve_offset_ref (e);
+
+ if (TREE_READONLY_DECL_P (e))
+ e = decl_constant_value (e);
+
+ if (INTEGRAL_CODE_P (code))
+ {
+ tree intype = TREE_TYPE (e);
+ enum tree_code form = TREE_CODE (intype);
+ /* enum = enum, enum = int, enum = float are all errors. */
+ if (flag_int_enum_equivalence == 0
+ && TREE_CODE (type) == ENUMERAL_TYPE
+ && ARITHMETIC_TYPE_P (intype)
+ && ! (convtype & CONV_STATIC))
+ {
+ cp_pedwarn ("conversion from `%#T' to `%#T'", intype, type);
+
+ if (flag_pedantic_errors)
+ return error_mark_node;
+ }
+ if (IS_AGGR_TYPE (intype))
+ {
+ tree rval;
+ rval = build_type_conversion (CONVERT_EXPR, type, e, 1);
+ if (rval)
+ return rval;
+ if (flags & LOOKUP_COMPLAIN)
+ cp_error ("`%#T' used where a `%T' was expected", intype, type);
+ if (flags & LOOKUP_SPECULATIVELY)
+ return NULL_TREE;
+ return error_mark_node;
+ }
+ if (code == BOOLEAN_TYPE)
+ return truthvalue_conversion (e);
+ return fold (convert_to_integer (type, e));
+ }
+ if (code == POINTER_TYPE || code == REFERENCE_TYPE
+ || TYPE_PTRMEMFUNC_P (type))
+ return fold (cp_convert_to_pointer (type, e));
+ if (code == REAL_TYPE)
+ {
+ if (IS_AGGR_TYPE (TREE_TYPE (e)))
+ {
+ tree rval;
+ rval = build_type_conversion (CONVERT_EXPR, type, e, 1);
+ if (rval)
+ return rval;
+ else
+ if (flags & LOOKUP_COMPLAIN)
+ cp_error ("`%#T' used where a floating point value was expected",
+ TREE_TYPE (e));
+ }
+ return fold (convert_to_real (type, e));
+ }
+
+ /* New C++ semantics: since assignment is now based on
+ memberwise copying, if the rhs type is derived from the
+ lhs type, then we may still do a conversion. */
+ if (IS_AGGR_TYPE_CODE (code))
+ {
+ tree dtype = TREE_TYPE (e);
+ tree ctor = NULL_TREE;
+ tree conversion = NULL_TREE;
+
+ dtype = TYPE_MAIN_VARIANT (dtype);
+
+ /* Conversion of object pointers or signature pointers/references
+ to signature pointers/references. */
+
+ if (TYPE_LANG_SPECIFIC (type)
+ && (IS_SIGNATURE_POINTER (type) || IS_SIGNATURE_REFERENCE (type)))
+ {
+ tree constructor = build_signature_pointer_constructor (type, expr);
+ tree sig_ty = SIGNATURE_TYPE (type);
+ tree sig_ptr;
+
+ if (constructor == error_mark_node)
+ return error_mark_node;
+
+ sig_ptr = get_temp_name (type, 1);
+ DECL_INITIAL (sig_ptr) = constructor;
+ CLEAR_SIGNATURE (sig_ty);
+ cp_finish_decl (sig_ptr, constructor, NULL_TREE, 0, 0);
+ SET_SIGNATURE (sig_ty);
+ TREE_READONLY (sig_ptr) = 1;
+
+ return sig_ptr;
+ }
+
+ /* Conversion between aggregate types. New C++ semantics allow
+ objects of derived type to be cast to objects of base type.
+ Old semantics only allowed this between pointers.
+
+ There may be some ambiguity between using a constructor
+ vs. using a type conversion operator when both apply. */
+
+ if (IS_AGGR_TYPE (dtype) && ! DERIVED_FROM_P (type, dtype)
+ && TYPE_HAS_CONVERSION (dtype))
+ conversion = build_type_conversion (CONVERT_EXPR, type, e, 1);
+
+ if (conversion == error_mark_node)
+ {
+ if (flags & LOOKUP_COMPLAIN)
+ error ("ambiguous pointer conversion");
+ return conversion;
+ }
+
+ if (TYPE_HAS_CONSTRUCTOR (type))
+ ctor = build_method_call (NULL_TREE, constructor_name_full (type),
+ build_tree_list (NULL_TREE, e),
+ TYPE_BINFO (type),
+ (flags & LOOKUP_NORMAL) | LOOKUP_SPECULATIVELY
+ | (convtype&CONV_NONCONVERTING ? 0 : LOOKUP_ONLYCONVERTING)
+ | (conversion ? LOOKUP_NO_CONVERSION : 0));
+
+ if (ctor == error_mark_node)
+ {
+ if (flags & LOOKUP_COMPLAIN)
+ cp_error ("in conversion to type `%T'", type);
+ if (flags & LOOKUP_SPECULATIVELY)
+ return NULL_TREE;
+ return error_mark_node;
+ }
+
+ if (conversion && ctor)
+ {
+ if (flags & LOOKUP_COMPLAIN)
+ error ("both constructor and type conversion operator apply");
+ if (flags & LOOKUP_SPECULATIVELY)
+ return NULL_TREE;
+ return error_mark_node;
+ }
+ else if (conversion)
+ return conversion;
+ else if (ctor)
+ {
+ ctor = build_cplus_new (type, ctor, 0);
+ return ctor;
+ }
+ }
+
+ /* If TYPE or TREE_TYPE (E) is not on the permanent_obstack,
+ then the it won't be hashed and hence compare as not equal,
+ even when it is. */
+ if (code == ARRAY_TYPE
+ && TREE_TYPE (TREE_TYPE (e)) == TREE_TYPE (type)
+ && index_type_equal (TYPE_DOMAIN (TREE_TYPE (e)), TYPE_DOMAIN (type)))
+ return e;
+
+ if (flags & LOOKUP_COMPLAIN)
+ cp_error ("conversion from `%T' to non-scalar type `%T' requested",
+ TREE_TYPE (expr), type);
+ if (flags & LOOKUP_SPECULATIVELY)
+ return NULL_TREE;
+ return error_mark_node;
+}
+
+/* Create an expression whose value is that of EXPR,
+ converted to type TYPE. The TREE_TYPE of the value
+ is always TYPE. This function implements all reasonable
+ conversions; callers should filter out those that are
+ not permitted by the language being compiled. */
+
+tree
+convert (type, expr)
+ tree type, expr;
+{
+ return cp_convert (type, expr, CONV_OLD_CONVERT, LOOKUP_NORMAL);
+}
+
+/* Like convert, except permit conversions to take place which
+ are not normally allowed due to access restrictions
+ (such as conversion from sub-type to private super-type). */
+tree
+convert_force (type, expr, convtype)
+ tree type;
+ tree expr;
+ int convtype;
+{
+ register tree e = expr;
+ register enum tree_code code = TREE_CODE (type);
+
+ if (code == REFERENCE_TYPE)
+ return fold (convert_to_reference (type, e, CONV_C_CAST, LOOKUP_COMPLAIN,
+ NULL_TREE));
+ else if (TREE_CODE (TREE_TYPE (e)) == REFERENCE_TYPE)
+ e = convert_from_reference (e);
+
+ if (code == POINTER_TYPE)
+ return fold (convert_to_pointer_force (type, e));
+
+ /* From typeck.c convert_for_assignment */
+ if (((TREE_CODE (TREE_TYPE (e)) == POINTER_TYPE && TREE_CODE (e) == ADDR_EXPR
+ && TREE_CODE (TREE_TYPE (e)) == POINTER_TYPE
+ && TREE_CODE (TREE_TYPE (TREE_TYPE (e))) == METHOD_TYPE)
+ || integer_zerop (e)
+ || TYPE_PTRMEMFUNC_P (TREE_TYPE (e)))
+ && TYPE_PTRMEMFUNC_P (type))
+ {
+ /* compatible pointer to member functions. */
+ return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), e, 1);
+ }
+
+ return cp_convert (type, e, CONV_C_CAST|convtype, LOOKUP_NORMAL);
+}
+
+/* Subroutine of build_type_conversion. */
+static tree
+build_type_conversion_1 (xtype, basetype, expr, typename, for_sure)
+ tree xtype, basetype;
+ tree expr;
+ tree typename;
+ int for_sure;
+{
+ tree rval;
+ int flags;
+
+ if (for_sure == 0)
+ flags = LOOKUP_PROTECT|LOOKUP_ONLYCONVERTING;
+ else
+ flags = LOOKUP_NORMAL|LOOKUP_ONLYCONVERTING;
+
+ rval = build_method_call (expr, typename, NULL_TREE, NULL_TREE, flags);
+ if (rval == error_mark_node)
+ {
+ if (for_sure == 0)
+ return NULL_TREE;
+ return error_mark_node;
+ }
+
+ if (IS_AGGR_TYPE (TREE_TYPE (rval)))
+ return rval;
+
+ if (warn_cast_qual
+ && TREE_TYPE (xtype)
+ && (TREE_READONLY (TREE_TYPE (TREE_TYPE (rval)))
+ > TREE_READONLY (TREE_TYPE (xtype))))
+ warning ("user-defined conversion casting away `const'");
+ return convert (xtype, rval);
+}
+
+/* Convert an aggregate EXPR to type XTYPE. If a conversion
+ exists, return the attempted conversion. This may
+ return ERROR_MARK_NODE if the conversion is not
+ allowed (references private members, etc).
+ If no conversion exists, NULL_TREE is returned.
+
+ If (FOR_SURE & 1) is non-zero, then we allow this type conversion
+ to take place immediately. Otherwise, we build a SAVE_EXPR
+ which can be evaluated if the results are ever needed.
+
+ Changes to this functions should be mirrored in user_harshness.
+
+ FIXME: Ambiguity checking is wrong. Should choose one by the implicit
+ object parameter, or by the second standard conversion sequence if
+ that doesn't do it. This will probably wait for an overloading rewrite.
+ (jason 8/9/95) */
+
+tree
+build_type_conversion (code, xtype, expr, for_sure)
+ enum tree_code code;
+ tree xtype, expr;
+ int for_sure;
+{
+ /* C++: check to see if we can convert this aggregate type
+ into the required type. */
+ tree basetype;
+ tree conv;
+ tree winner = NULL_TREE;
+
+ if (expr == error_mark_node)
+ return error_mark_node;
+
+ basetype = TREE_TYPE (expr);
+ if (TREE_CODE (basetype) == REFERENCE_TYPE)
+ basetype = TREE_TYPE (basetype);
+
+ basetype = TYPE_MAIN_VARIANT (basetype);
+ if (! TYPE_LANG_SPECIFIC (basetype) || ! TYPE_HAS_CONVERSION (basetype))
+ return NULL_TREE;
+
+ /* Do we have an exact match? */
+ {
+ tree typename = build_typename_overload (xtype);
+ if (lookup_fnfields (TYPE_BINFO (basetype), typename, 0))
+ return build_type_conversion_1 (xtype, basetype, expr, typename,
+ for_sure);
+ }
+
+ /* Nope; try looking for others. */
+ for (conv = lookup_conversions (basetype); conv; conv = TREE_CHAIN (conv))
+ {
+ if (winner && TREE_PURPOSE (winner) == TREE_PURPOSE (conv))
+ continue;
+
+ if (can_convert (xtype, TREE_VALUE (conv)))
+ {
+ if (winner)
+ {
+ if (for_sure)
+ {
+ cp_error ("ambiguous conversion from `%T' to `%T'", basetype,
+ xtype);
+ cp_error (" candidate conversions include `%T' and `%T'",
+ TREE_VALUE (winner), TREE_VALUE (conv));
+ }
+ return NULL_TREE;
+ }
+ else
+ winner = conv;
+ }
+ }
+
+ if (winner)
+ return build_type_conversion_1 (xtype, basetype, expr,
+ TREE_PURPOSE (winner), for_sure);
+
+ return NULL_TREE;
+}
+
+/* Convert the given EXPR to one of a group of types suitable for use in an
+ expression. DESIRES is a combination of various WANT_* flags (q.v.)
+ which indicates which types are suitable. If COMPLAIN is 1, complain
+ about ambiguity; otherwise, the caller will deal with it. */
+
+tree
+build_expr_type_conversion (desires, expr, complain)
+ int desires;
+ tree expr;
+ int complain;
+{
+ tree basetype = TREE_TYPE (expr);
+ tree conv;
+ tree winner = NULL_TREE;
+
+ if (TREE_CODE (basetype) == OFFSET_TYPE)
+ expr = resolve_offset_ref (expr);
+ expr = convert_from_reference (expr);
+ basetype = TREE_TYPE (expr);
+
+ if (! IS_AGGR_TYPE (basetype))
+ switch (TREE_CODE (basetype))
+ {
+ case INTEGER_TYPE:
+ if ((desires & WANT_NULL) && TREE_CODE (expr) == INTEGER_CST
+ && integer_zerop (expr))
+ return expr;
+ /* else fall through... */
+
+ case BOOLEAN_TYPE:
+ return (desires & WANT_INT) ? expr : NULL_TREE;
+ case ENUMERAL_TYPE:
+ return (desires & WANT_ENUM) ? expr : NULL_TREE;
+ case REAL_TYPE:
+ return (desires & WANT_FLOAT) ? expr : NULL_TREE;
+ case POINTER_TYPE:
+ return (desires & WANT_POINTER) ? expr : NULL_TREE;
+
+ case FUNCTION_TYPE:
+ case ARRAY_TYPE:
+ return (desires & WANT_POINTER) ? default_conversion (expr)
+ : NULL_TREE;
+ default:
+ return NULL_TREE;
+ }
+
+ if (! TYPE_HAS_CONVERSION (basetype))
+ return NULL_TREE;
+
+ for (conv = lookup_conversions (basetype); conv; conv = TREE_CHAIN (conv))
+ {
+ int win = 0;
+ tree candidate;
+
+ if (winner && TREE_PURPOSE (winner) == TREE_PURPOSE (conv))
+ continue;
+
+ candidate = TREE_VALUE (conv);
+ if (TREE_CODE (candidate) == REFERENCE_TYPE)
+ candidate = TREE_TYPE (candidate);
+
+ switch (TREE_CODE (candidate))
+ {
+ case BOOLEAN_TYPE:
+ case INTEGER_TYPE:
+ win = (desires & WANT_INT); break;
+ case ENUMERAL_TYPE:
+ win = (desires & WANT_ENUM); break;
+ case REAL_TYPE:
+ win = (desires & WANT_FLOAT); break;
+ case POINTER_TYPE:
+ win = (desires & WANT_POINTER); break;
+ }
+
+ if (win)
+ {
+ if (winner)
+ {
+ if (complain)
+ {
+ cp_error ("ambiguous default type conversion from `%T'",
+ basetype);
+ cp_error (" candidate conversions include `%T' and `%T'",
+ TREE_VALUE (winner), TREE_VALUE (conv));
+ }
+ return error_mark_node;
+ }
+ else
+ winner = conv;
+ }
+ }
+
+ if (winner)
+ return build_type_conversion_1 (TREE_VALUE (winner), basetype, expr,
+ TREE_PURPOSE (winner), 1);
+
+ return NULL_TREE;
+}
+
+/* Must convert two aggregate types to non-aggregate type.
+ Attempts to find a non-ambiguous, "best" type conversion.
+
+ Return 1 on success, 0 on failure.
+
+ @@ What are the real semantics of this supposed to be??? */
+int
+build_default_binary_type_conversion (code, arg1, arg2)
+ enum tree_code code;
+ tree *arg1, *arg2;
+{
+ switch (code)
+ {
+ case MULT_EXPR:
+ case TRUNC_DIV_EXPR:
+ case CEIL_DIV_EXPR:
+ case FLOOR_DIV_EXPR:
+ case ROUND_DIV_EXPR:
+ case EXACT_DIV_EXPR:
+ *arg1 = build_expr_type_conversion (WANT_ARITH | WANT_ENUM, *arg1, 0);
+ *arg2 = build_expr_type_conversion (WANT_ARITH | WANT_ENUM, *arg2, 0);
+ break;
+
+ case TRUNC_MOD_EXPR:
+ case FLOOR_MOD_EXPR:
+ case LSHIFT_EXPR:
+ case RSHIFT_EXPR:
+ case BIT_AND_EXPR:
+ case BIT_XOR_EXPR:
+ case BIT_IOR_EXPR:
+ *arg1 = build_expr_type_conversion (WANT_INT | WANT_ENUM, *arg1, 0);
+ *arg2 = build_expr_type_conversion (WANT_INT | WANT_ENUM, *arg2, 0);
+ break;
+
+ case PLUS_EXPR:
+ {
+ tree a1, a2, p1, p2;
+ int wins;
+
+ a1 = build_expr_type_conversion (WANT_ARITH | WANT_ENUM, *arg1, 0);
+ a2 = build_expr_type_conversion (WANT_ARITH | WANT_ENUM, *arg2, 0);
+ p1 = build_expr_type_conversion (WANT_POINTER, *arg1, 0);
+ p2 = build_expr_type_conversion (WANT_POINTER, *arg2, 0);
+
+ wins = (a1 && a2) + (a1 && p2) + (p1 && a2);
+
+ if (wins > 1)
+ error ("ambiguous default type conversion for `operator +'");
+
+ if (a1 && a2)
+ *arg1 = a1, *arg2 = a2;
+ else if (a1 && p2)
+ *arg1 = a1, *arg2 = p2;
+ else
+ *arg1 = p1, *arg2 = a2;
+ break;
+ }
+
+ case MINUS_EXPR:
+ {
+ tree a1, a2, p1, p2;
+ int wins;
+
+ a1 = build_expr_type_conversion (WANT_ARITH | WANT_ENUM, *arg1, 0);
+ a2 = build_expr_type_conversion (WANT_ARITH | WANT_ENUM, *arg2, 0);
+ p1 = build_expr_type_conversion (WANT_POINTER, *arg1, 0);
+ p2 = build_expr_type_conversion (WANT_POINTER, *arg2, 0);
+
+ wins = (a1 && a2) + (p1 && p2) + (p1 && a2);
+
+ if (wins > 1)
+ error ("ambiguous default type conversion for `operator -'");
+
+ if (a1 && a2)
+ *arg1 = a1, *arg2 = a2;
+ else if (p1 && p2)
+ *arg1 = p1, *arg2 = p2;
+ else
+ *arg1 = p1, *arg2 = a2;
+ break;
+ }
+
+ case GT_EXPR:
+ case LT_EXPR:
+ case GE_EXPR:
+ case LE_EXPR:
+ case EQ_EXPR:
+ case NE_EXPR:
+ {
+ tree a1, a2, p1, p2;
+ int wins;
+
+ a1 = build_expr_type_conversion (WANT_ARITH | WANT_ENUM, *arg1, 0);
+ a2 = build_expr_type_conversion (WANT_ARITH | WANT_ENUM, *arg2, 0);
+ p1 = build_expr_type_conversion (WANT_POINTER | WANT_NULL, *arg1, 0);
+ p2 = build_expr_type_conversion (WANT_POINTER | WANT_NULL, *arg2, 0);
+
+ wins = (a1 && a2) + (p1 && p2);
+
+ if (wins > 1)
+ cp_error ("ambiguous default type conversion for `%O'", code);
+
+ if (a1 && a2)
+ *arg1 = a1, *arg2 = a2;
+ else
+ *arg1 = p1, *arg2 = p2;
+ break;
+ }
+
+ case TRUTH_ANDIF_EXPR:
+ case TRUTH_ORIF_EXPR:
+ *arg1 = convert (boolean_type_node, *arg1);
+ *arg2 = convert (boolean_type_node, *arg2);
+ break;
+
+ default:
+ *arg1 = NULL_TREE;
+ *arg2 = NULL_TREE;
+ }
+
+ if (*arg1 == error_mark_node || *arg2 == error_mark_node)
+ cp_error ("ambiguous default type conversion for `%O'", code);
+
+ if (*arg1 && *arg2)
+ return 1;
+
+ return 0;
+}
+
+/* Implements integral promotion (4.1) and float->double promotion. */
+tree
+type_promotes_to (type)
+ tree type;
+{
+ int constp, volatilep;
+
+ if (type == error_mark_node)
+ return error_mark_node;
+
+ constp = TYPE_READONLY (type);
+ volatilep = TYPE_VOLATILE (type);
+ type = TYPE_MAIN_VARIANT (type);
+
+ /* bool always promotes to int (not unsigned), even if it's the same
+ size. */
+ if (type == boolean_type_node)
+ type = integer_type_node;
+
+ /* Normally convert enums to int, but convert wide enums to something
+ wider. */
+ else if (TREE_CODE (type) == ENUMERAL_TYPE
+ || type == wchar_type_node)
+ {
+ int precision = MAX (TYPE_PRECISION (type),
+ TYPE_PRECISION (integer_type_node));
+ tree totype = type_for_size (precision, 0);
+ if (TREE_UNSIGNED (type)
+ && ! int_fits_type_p (TYPE_MAX_VALUE (type), totype))
+ type = type_for_size (precision, 1);
+ else
+ type = totype;
+ }
+ else if (C_PROMOTING_INTEGER_TYPE_P (type))
+ {
+ /* Traditionally, unsignedness is preserved in default promotions.
+ Otherwise, retain unsignedness if really not getting bigger. */
+ if (TREE_UNSIGNED (type)
+ && (flag_traditional
+ || TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node)))
+ type = unsigned_type_node;
+ else
+ type = integer_type_node;
+ }
+ else if (type == float_type_node)
+ type = double_type_node;
+
+ return cp_build_type_variant (type, constp, volatilep);
+}
diff --git a/contrib/gcc/cp/decl.c b/contrib/gcc/cp/decl.c
new file mode 100644
index 0000000..103cb0d
--- /dev/null
+++ b/contrib/gcc/cp/decl.c
@@ -0,0 +1,12878 @@
+/* Process declarations and variables for C compiler.
+ Copyright (C) 1988, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+ Hacked by Michael Tiemann (tiemann@cygnus.com)
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+/* Process declarations and symbol lookup for C front end.
+ Also constructs types; the standard scalar types at initialization,
+ and structure, union, array and enum types when they are declared. */
+
+/* ??? not all decl nodes are given the most useful possible
+ line numbers. For example, the CONST_DECLs for enum values. */
+
+#include <stdio.h>
+#include "config.h"
+#include "tree.h"
+#include "rtl.h"
+#include "flags.h"
+#include "cp-tree.h"
+#include "decl.h"
+#include "lex.h"
+#include <sys/types.h>
+#include <signal.h>
+#include "obstack.h"
+
+#define obstack_chunk_alloc xmalloc
+#define obstack_chunk_free free
+
+extern tree builtin_return_address_fndecl;
+
+extern struct obstack permanent_obstack;
+
+extern int current_class_depth;
+
+extern tree cleanups_this_call;
+
+extern tree static_ctors, static_dtors;
+
+/* Stack of places to restore the search obstack back to. */
+
+/* Obstack used for remembering local class declarations (like
+ enums and static (const) members. */
+#include "stack.h"
+static struct obstack decl_obstack;
+static struct stack_level *decl_stack;
+
+#ifndef CHAR_TYPE_SIZE
+#define CHAR_TYPE_SIZE BITS_PER_UNIT
+#endif
+
+#ifndef SHORT_TYPE_SIZE
+#define SHORT_TYPE_SIZE (BITS_PER_UNIT * MIN ((UNITS_PER_WORD + 1) / 2, 2))
+#endif
+
+#ifndef INT_TYPE_SIZE
+#define INT_TYPE_SIZE BITS_PER_WORD
+#endif
+
+#ifndef LONG_TYPE_SIZE
+#define LONG_TYPE_SIZE BITS_PER_WORD
+#endif
+
+#ifndef LONG_LONG_TYPE_SIZE
+#define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
+#endif
+
+#ifndef WCHAR_UNSIGNED
+#define WCHAR_UNSIGNED 0
+#endif
+
+#ifndef FLOAT_TYPE_SIZE
+#define FLOAT_TYPE_SIZE BITS_PER_WORD
+#endif
+
+#ifndef DOUBLE_TYPE_SIZE
+#define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
+#endif
+
+#ifndef LONG_DOUBLE_TYPE_SIZE
+#define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
+#endif
+
+#ifndef BOOL_TYPE_SIZE
+#ifdef SLOW_BYTE_ACCESS
+#define BOOL_TYPE_SIZE ((SLOW_BYTE_ACCESS) ? (BITS_PER_WORD) : (BITS_PER_UNIT))
+#else
+#define BOOL_TYPE_SIZE BITS_PER_UNIT
+#endif
+#endif
+
+/* We let tm.h override the types used here, to handle trivial differences
+ such as the choice of unsigned int or long unsigned int for size_t.
+ When machines start needing nontrivial differences in the size type,
+ it would be best to do something here to figure out automatically
+ from other information what type to use. */
+
+#ifndef SIZE_TYPE
+#define SIZE_TYPE "long unsigned int"
+#endif
+
+#ifndef PTRDIFF_TYPE
+#define PTRDIFF_TYPE "long int"
+#endif
+
+#ifndef WCHAR_TYPE
+#define WCHAR_TYPE "int"
+#endif
+
+static tree grokparms PROTO((tree, int));
+static tree lookup_nested_type PROTO((tree, tree));
+static char *redeclaration_error_message PROTO((tree, tree));
+static void grok_op_properties PROTO((tree, int, int));
+
+tree define_function
+ PROTO((char *, tree, enum built_in_function, void (*)(), char *));
+
+/* a node which has tree code ERROR_MARK, and whose type is itself.
+ All erroneous expressions are replaced with this node. All functions
+ that accept nodes as arguments should avoid generating error messages
+ if this node is one of the arguments, since it is undesirable to get
+ multiple error messages from one error in the input. */
+
+tree error_mark_node;
+
+/* Erroneous argument lists can use this *IFF* they do not modify it. */
+tree error_mark_list;
+
+/* INTEGER_TYPE and REAL_TYPE nodes for the standard data types */
+
+tree short_integer_type_node;
+tree integer_type_node;
+tree long_integer_type_node;
+tree long_long_integer_type_node;
+
+tree short_unsigned_type_node;
+tree unsigned_type_node;
+tree long_unsigned_type_node;
+tree long_long_unsigned_type_node;
+
+tree ptrdiff_type_node;
+
+tree unsigned_char_type_node;
+tree signed_char_type_node;
+tree char_type_node;
+tree wchar_type_node;
+tree signed_wchar_type_node;
+tree unsigned_wchar_type_node;
+
+tree wchar_decl_node;
+
+tree float_type_node;
+tree double_type_node;
+tree long_double_type_node;
+
+tree intQI_type_node;
+tree intHI_type_node;
+tree intSI_type_node;
+tree intDI_type_node;
+
+tree unsigned_intQI_type_node;
+tree unsigned_intHI_type_node;
+tree unsigned_intSI_type_node;
+tree unsigned_intDI_type_node;
+
+/* a VOID_TYPE node, and the same, packaged in a TREE_LIST. */
+
+tree void_type_node, void_list_node;
+tree void_zero_node;
+
+/* Nodes for types `void *' and `const void *'. */
+
+tree ptr_type_node, const_ptr_type_node;
+
+/* Nodes for types `char *' and `const char *'. */
+
+tree string_type_node, const_string_type_node;
+
+/* Type `char[256]' or something like it.
+ Used when an array of char is needed and the size is irrelevant. */
+
+tree char_array_type_node;
+
+/* Type `int[256]' or something like it.
+ Used when an array of int needed and the size is irrelevant. */
+
+tree int_array_type_node;
+
+/* Type `wchar_t[256]' or something like it.
+ Used when a wide string literal is created. */
+
+tree wchar_array_type_node;
+
+/* The bool data type, and constants */
+tree boolean_type_node, boolean_true_node, boolean_false_node;
+
+/* type `int ()' -- used for implicit declaration of functions. */
+
+tree default_function_type;
+
+/* function types `double (double)' and `double (double, double)', etc. */
+
+tree double_ftype_double, double_ftype_double_double;
+tree int_ftype_int, long_ftype_long;
+
+/* Function type `void (void *, void *, int)' and similar ones. */
+
+tree void_ftype_ptr_ptr_int, int_ftype_ptr_ptr_int, void_ftype_ptr_int_int;
+
+/* Function type `char *(char *, char *)' and similar ones */
+tree string_ftype_ptr_ptr, int_ftype_string_string;
+
+/* Function type `size_t (const char *)' */
+tree sizet_ftype_string;
+
+/* Function type `int (const void *, const void *, size_t)' */
+tree int_ftype_cptr_cptr_sizet;
+
+/* C++ extensions */
+tree vtable_entry_type;
+tree delta_type_node;
+#if 0
+/* Old rtti stuff. */
+tree __baselist_desc_type_node;
+tree __i_desc_type_node, __m_desc_type_node;
+tree __t_desc_array_type, __i_desc_array_type, __m_desc_array_type;
+#endif
+tree __t_desc_type_node, __tp_desc_type_node;
+tree __access_mode_type_node;
+tree __bltn_desc_type_node, __user_desc_type_node, __class_desc_type_node;
+tree __ptr_desc_type_node, __attr_desc_type_node, __func_desc_type_node;
+tree __ptmf_desc_type_node, __ptmd_desc_type_node;
+#if 0
+/* Not needed yet? May be needed one day? */
+tree __bltn_desc_array_type, __user_desc_array_type, __class_desc_array_type;
+tree __ptr_desc_array_type, __attr_dec_array_type, __func_desc_array_type;
+tree __ptmf_desc_array_type, __ptmd_desc_array_type;
+#endif
+
+tree class_star_type_node;
+tree class_type_node, record_type_node, union_type_node, enum_type_node;
+tree unknown_type_node;
+tree opaque_type_node, signature_type_node;
+tree sigtable_entry_type;
+tree maybe_gc_cleanup;
+
+/* Array type `vtable_entry_type[]' */
+tree vtbl_type_node;
+
+/* In a destructor, the point at which all derived class destroying
+ has been done, just before any base class destroying will be done. */
+
+tree dtor_label;
+
+/* In a constructor, the point at which we are ready to return
+ the pointer to the initialized object. */
+
+tree ctor_label;
+
+/* A FUNCTION_DECL which can call `abort'. Not necessarily the
+ one that the user will declare, but sufficient to be called
+ by routines that want to abort the program. */
+
+tree abort_fndecl;
+
+extern rtx cleanup_label, return_label;
+
+/* If original DECL_RESULT of current function was a register,
+ but due to being an addressable named return value, would up
+ on the stack, this variable holds the named return value's
+ original location. */
+rtx original_result_rtx;
+
+/* Sequence of insns which represents base initialization. */
+tree base_init_expr;
+
+/* C++: Keep these around to reduce calls to `get_identifier'.
+ Identifiers for `this' in member functions and the auto-delete
+ parameter for destructors. */
+tree this_identifier, in_charge_identifier;
+/* Used in pointer to member functions, in vtables, and in sigtables. */
+tree pfn_identifier, index_identifier, delta_identifier, delta2_identifier;
+tree pfn_or_delta2_identifier, tag_identifier;
+tree vb_off_identifier, vt_off_identifier;
+
+/* A list (chain of TREE_LIST nodes) of named label uses.
+ The TREE_PURPOSE field is the list of variables defined
+ the the label's scope defined at the point of use.
+ The TREE_VALUE field is the LABEL_DECL used.
+ The TREE_TYPE field holds `current_binding_level' at the
+ point of the label's use.
+
+ Used only for jumps to as-yet undefined labels, since
+ jumps to defined labels can have their validity checked
+ by stmt.c. */
+
+static tree named_label_uses;
+
+/* A list of objects which have constructors or destructors
+ which reside in the global scope. The decl is stored in
+ the TREE_VALUE slot and the initializer is stored
+ in the TREE_PURPOSE slot. */
+tree static_aggregates;
+
+/* -- end of C++ */
+
+/* Two expressions that are constants with value zero.
+ The first is of type `int', the second of type `void *'. */
+
+tree integer_zero_node;
+tree null_pointer_node;
+
+/* A node for the integer constants 1, 2, and 3. */
+
+tree integer_one_node, integer_two_node, integer_three_node;
+
+/* Nonzero if we have seen an invalid cross reference
+ to a struct, union, or enum, but not yet printed the message. */
+
+tree pending_invalid_xref;
+/* File and line to appear in the eventual error message. */
+char *pending_invalid_xref_file;
+int pending_invalid_xref_line;
+
+/* While defining an enum type, this is 1 plus the last enumerator
+ constant value. */
+
+static tree enum_next_value;
+
+/* Nonzero means that there was overflow computing enum_next_value. */
+
+static int enum_overflow;
+
+/* Parsing a function declarator leaves a list of parameter names
+ or a chain or parameter decls here. */
+
+tree last_function_parms;
+
+/* Parsing a function declarator leaves here a chain of structure
+ and enum types declared in the parmlist. */
+
+static tree last_function_parm_tags;
+
+/* After parsing the declarator that starts a function definition,
+ `start_function' puts here the list of parameter names or chain of decls.
+ `store_parm_decls' finds it here. */
+
+static tree current_function_parms;
+
+/* Similar, for last_function_parm_tags. */
+static tree current_function_parm_tags;
+
+/* A list (chain of TREE_LIST nodes) of all LABEL_DECLs in the function
+ that have names. Here so we can clear out their names' definitions
+ at the end of the function. */
+
+static tree named_labels;
+
+/* A list of LABEL_DECLs from outer contexts that are currently shadowed. */
+
+static tree shadowed_labels;
+
+#if 0 /* Not needed by C++ */
+/* Nonzero when store_parm_decls is called indicates a varargs function.
+ Value not meaningful after store_parm_decls. */
+
+static int c_function_varargs;
+#endif
+
+/* The FUNCTION_DECL for the function currently being compiled,
+ or 0 if between functions. */
+tree current_function_decl;
+
+/* Set to 0 at beginning of a function definition, set to 1 if
+ a return statement that specifies a return value is seen. */
+
+int current_function_returns_value;
+
+/* Set to 0 at beginning of a function definition, set to 1 if
+ a return statement with no argument is seen. */
+
+int current_function_returns_null;
+
+/* Set to 0 at beginning of a function definition, and whenever
+ a label (case or named) is defined. Set to value of expression
+ returned from function when that value can be transformed into
+ a named return value. */
+
+tree current_function_return_value;
+
+/* Set to nonzero by `grokdeclarator' for a function
+ whose return type is defaulted, if warnings for this are desired. */
+
+static int warn_about_return_type;
+
+/* Nonzero means give `double' the same size as `float'. */
+
+extern int flag_short_double;
+
+/* Nonzero means don't recognize any builtin functions. */
+
+extern int flag_no_builtin;
+
+/* Nonzero means don't recognize the non-ANSI builtin functions.
+ -ansi sets this. */
+
+extern int flag_no_nonansi_builtin;
+
+/* Nonzero means enable obscure ANSI features and disable GNU extensions
+ that might cause ANSI-compliant code to be miscompiled. */
+
+extern int flag_ansi;
+
+/* Nonzero if we want to support huge (> 2^(sizeof(short)*8-1) bytes)
+ objects. */
+extern int flag_huge_objects;
+
+/* Nonzero if we want to conserve space in the .o files. We do this
+ by putting uninitialized data and runtime initialized data into
+ .common instead of .data at the expense of not flagging multiple
+ definitions. */
+extern int flag_conserve_space;
+
+/* Pointers to the base and current top of the language name stack. */
+
+extern tree *current_lang_base, *current_lang_stack;
+
+/* C and C++ flags are in decl2.c. */
+
+/* Set to 0 at beginning of a constructor, set to 1
+ if that function does an allocation before referencing its
+ instance variable. */
+int current_function_assigns_this;
+int current_function_just_assigned_this;
+
+/* Set to 0 at beginning of a function. Set non-zero when
+ store_parm_decls is called. Don't call store_parm_decls
+ if this flag is non-zero! */
+int current_function_parms_stored;
+
+/* Current end of entries in the gc obstack for stack pointer variables. */
+
+int current_function_obstack_index;
+
+/* Flag saying whether we have used the obstack in this function or not. */
+
+int current_function_obstack_usage;
+
+/* Flag used when debugging spew.c */
+
+extern int spew_debug;
+
+/* This is a copy of the class_shadowed list of the previous class binding
+ contour when at global scope. It's used to reset IDENTIFIER_CLASS_VALUEs
+ when entering another class scope (i.e. a cache miss). */
+extern tree previous_class_values;
+
+
+/* Allocate a level of searching. */
+struct stack_level *
+push_decl_level (stack, obstack)
+ struct stack_level *stack;
+ struct obstack *obstack;
+{
+ struct stack_level tem;
+ tem.prev = stack;
+
+ return push_stack_level (obstack, (char *)&tem, sizeof (tem));
+}
+
+/* For each binding contour we allocate a binding_level structure
+ * which records the names defined in that contour.
+ * Contours include:
+ * 0) the global one
+ * 1) one for each function definition,
+ * where internal declarations of the parameters appear.
+ * 2) one for each compound statement,
+ * to record its declarations.
+ *
+ * The current meaning of a name can be found by searching the levels from
+ * the current one out to the global one.
+ *
+ * Off to the side, may be the class_binding_level. This exists
+ * only to catch class-local declarations. It is otherwise
+ * nonexistent.
+ *
+ * Also there may be binding levels that catch cleanups that
+ * must be run when exceptions occur.
+ */
+
+/* Note that the information in the `names' component of the global contour
+ is duplicated in the IDENTIFIER_GLOBAL_VALUEs of all identifiers. */
+
+struct binding_level
+ {
+ /* A chain of _DECL nodes for all variables, constants, functions,
+ * and typedef types. These are in the reverse of the order supplied.
+ */
+ tree names;
+
+ /* A list of structure, union and enum definitions,
+ * for looking up tag names.
+ * It is a chain of TREE_LIST nodes, each of whose TREE_PURPOSE is a name,
+ * or NULL_TREE; and whose TREE_VALUE is a RECORD_TYPE, UNION_TYPE,
+ * or ENUMERAL_TYPE node.
+ *
+ * C++: the TREE_VALUE nodes can be simple types for component_bindings.
+ *
+ */
+ tree tags;
+
+ /* For each level, a list of shadowed outer-level local definitions
+ to be restored when this level is popped.
+ Each link is a TREE_LIST whose TREE_PURPOSE is an identifier and
+ whose TREE_VALUE is its old definition (a kind of ..._DECL node). */
+ tree shadowed;
+
+ /* Same, for IDENTIFIER_CLASS_VALUE. */
+ tree class_shadowed;
+
+ /* Same, for IDENTIFIER_TYPE_VALUE. */
+ tree type_shadowed;
+
+ /* For each level (except not the global one),
+ a chain of BLOCK nodes for all the levels
+ that were entered and exited one level down. */
+ tree blocks;
+
+ /* The BLOCK node for this level, if one has been preallocated.
+ If 0, the BLOCK is allocated (if needed) when the level is popped. */
+ tree this_block;
+
+ /* The binding level which this one is contained in (inherits from). */
+ struct binding_level *level_chain;
+
+ /* List of decls in `names' that have incomplete
+ structure or union types. */
+ tree incomplete;
+
+ /* List of VAR_DECLS saved from a previous for statement.
+ These would be dead in ANSI-conforming code, but might
+ be referenced in traditional code. */
+ tree dead_vars_from_for;
+
+ /* 1 for the level that holds the parameters of a function.
+ 2 for the level that holds a class declaration.
+ 3 for levels that hold parameter declarations. */
+ unsigned parm_flag : 4;
+
+ /* 1 means make a BLOCK for this level regardless of all else.
+ 2 for temporary binding contours created by the compiler. */
+ unsigned keep : 3;
+
+ /* Nonzero if this level "doesn't exist" for tags. */
+ unsigned tag_transparent : 1;
+
+ /* Nonzero if this level can safely have additional
+ cleanup-needing variables added to it. */
+ unsigned more_cleanups_ok : 1;
+ unsigned have_cleanups : 1;
+
+ /* Nonzero if we should accept any name as an identifier in
+ this scope. This happens in some template definitions. */
+ unsigned accept_any : 1;
+
+ /* Nonzero if this level is for completing a template class definition
+ inside a binding level that temporarily binds the parameters. This
+ means that definitions here should not be popped off when unwinding
+ this binding level. (Not actually implemented this way,
+ unfortunately.) */
+ unsigned pseudo_global : 1;
+
+ /* This is set for a namespace binding level. */
+ unsigned namespace_p : 1;
+
+ /* True if this level is that of a for-statement. */
+ unsigned is_for_scope : 1;
+
+ /* One bit left for this word. */
+
+#if defined(DEBUG_CP_BINDING_LEVELS)
+ /* Binding depth at which this level began. */
+ unsigned binding_depth;
+#endif /* defined(DEBUG_CP_BINDING_LEVELS) */
+ };
+
+#define NULL_BINDING_LEVEL ((struct binding_level *) NULL)
+
+/* The (non-class) binding level currently in effect. */
+
+static struct binding_level *current_binding_level;
+
+/* The binding level of the current class, if any. */
+
+static struct binding_level *class_binding_level;
+
+/* The current (class or non-class) binding level currently in effect. */
+
+#define inner_binding_level \
+ (class_binding_level ? class_binding_level : current_binding_level)
+
+/* A chain of binding_level structures awaiting reuse. */
+
+static struct binding_level *free_binding_level;
+
+/* The outermost binding level, for names of file scope.
+ This is created when the compiler is started and exists
+ through the entire run. */
+
+static struct binding_level *global_binding_level;
+
+/* Binding level structures are initialized by copying this one. */
+
+static struct binding_level clear_binding_level;
+
+/* Nonzero means unconditionally make a BLOCK for the next level pushed. */
+
+static int keep_next_level_flag;
+
+#if defined(DEBUG_CP_BINDING_LEVELS)
+static int binding_depth = 0;
+static int is_class_level = 0;
+
+static void
+indent ()
+{
+ register unsigned i;
+
+ for (i = 0; i < binding_depth*2; i++)
+ putc (' ', stderr);
+}
+#endif /* defined(DEBUG_CP_BINDING_LEVELS) */
+
+static tree pushdecl_with_scope PROTO((tree, struct binding_level *));
+
+static void
+push_binding_level (newlevel, tag_transparent, keep)
+ struct binding_level *newlevel;
+ int tag_transparent, keep;
+{
+ /* Add this level to the front of the chain (stack) of levels that
+ are active. */
+ *newlevel = clear_binding_level;
+ if (class_binding_level)
+ {
+ newlevel->level_chain = class_binding_level;
+ class_binding_level = (struct binding_level *)0;
+ }
+ else
+ {
+ newlevel->level_chain = current_binding_level;
+ }
+ current_binding_level = newlevel;
+ newlevel->tag_transparent = tag_transparent;
+ newlevel->more_cleanups_ok = 1;
+ newlevel->keep = keep;
+#if defined(DEBUG_CP_BINDING_LEVELS)
+ newlevel->binding_depth = binding_depth;
+ indent ();
+ fprintf (stderr, "push %s level 0x%08x line %d\n",
+ (is_class_level) ? "class" : "block", newlevel, lineno);
+ is_class_level = 0;
+ binding_depth++;
+#endif /* defined(DEBUG_CP_BINDING_LEVELS) */
+}
+
+static void
+pop_binding_level ()
+{
+ if (class_binding_level)
+ current_binding_level = class_binding_level;
+
+ if (global_binding_level)
+ {
+ /* cannot pop a level, if there are none left to pop. */
+ if (current_binding_level == global_binding_level)
+ my_friendly_abort (123);
+ }
+ /* Pop the current level, and free the structure for reuse. */
+#if defined(DEBUG_CP_BINDING_LEVELS)
+ binding_depth--;
+ indent ();
+ fprintf (stderr, "pop %s level 0x%08x line %d\n",
+ (is_class_level) ? "class" : "block",
+ current_binding_level, lineno);
+ if (is_class_level != (current_binding_level == class_binding_level))
+#if 0 /* XXX Don't abort when we're watching how things are being managed. */
+ abort ();
+#else
+ {
+ indent ();
+ fprintf (stderr, "XXX is_class_level != (current_binding_level == class_binding_level)\n");
+ }
+#endif
+ is_class_level = 0;
+#endif /* defined(DEBUG_CP_BINDING_LEVELS) */
+ {
+ register struct binding_level *level = current_binding_level;
+ current_binding_level = current_binding_level->level_chain;
+ level->level_chain = free_binding_level;
+#if 0 /* defined(DEBUG_CP_BINDING_LEVELS) */
+ if (level->binding_depth != binding_depth)
+ abort ();
+#endif /* defined(DEBUG_CP_BINDING_LEVELS) */
+ free_binding_level = level;
+
+ class_binding_level = current_binding_level;
+ if (class_binding_level->parm_flag != 2)
+ class_binding_level = 0;
+ while (current_binding_level->parm_flag == 2)
+ current_binding_level = current_binding_level->level_chain;
+ }
+}
+
+static void
+suspend_binding_level ()
+{
+ if (class_binding_level)
+ current_binding_level = class_binding_level;
+
+ if (global_binding_level)
+ {
+ /* cannot suspend a level, if there are none left to suspend. */
+ if (current_binding_level == global_binding_level)
+ my_friendly_abort (123);
+ }
+ /* Suspend the current level. */
+#if defined(DEBUG_CP_BINDING_LEVELS)
+ binding_depth--;
+ indent ();
+ fprintf (stderr, "suspend %s level 0x%08x line %d\n",
+ (is_class_level) ? "class" : "block",
+ current_binding_level, lineno);
+ if (is_class_level != (current_binding_level == class_binding_level))
+#if 0 /* XXX Don't abort when we're watching how things are being managed. */
+ abort ();
+#else
+ {
+ indent ();
+ fprintf (stderr, "XXX is_class_level != (current_binding_level == class_binding_level)\n");
+ }
+#endif
+ is_class_level = 0;
+#endif /* defined(DEBUG_CP_BINDING_LEVELS) */
+ {
+ register struct binding_level *level = current_binding_level;
+ current_binding_level = current_binding_level->level_chain;
+#if 0 /* defined(DEBUG_CP_BINDING_LEVELS) */
+ if (level->binding_depth != binding_depth)
+ abort ();
+#endif /* defined(DEBUG_CP_BINDING_LEVELS) */
+
+ class_binding_level = current_binding_level;
+ if (class_binding_level->parm_flag != 2)
+ class_binding_level = 0;
+ while (current_binding_level->parm_flag == 2)
+ current_binding_level = current_binding_level->level_chain;
+ }
+}
+
+void
+resume_binding_level (b)
+ struct binding_level *b;
+{
+ if (class_binding_level)
+ {
+#if 1
+ /* These are here because we cannot deal with shadows yet. */
+ sorry ("cannot resume a namespace inside class");
+ return;
+#else
+ b->level_chain = class_binding_level;
+ class_binding_level = (struct binding_level *)0;
+#endif
+ }
+ else
+ {
+#if 1
+ /* These are here because we cannot deal with shadows yet. */
+ if (b->level_chain != current_binding_level)
+ {
+ sorry ("cannot resume a namespace inside a different namespace");
+ return;
+ }
+#endif
+ b->level_chain = current_binding_level;
+ }
+ current_binding_level = b;
+#if defined(DEBUG_CP_BINDING_LEVELS)
+ b->binding_depth = binding_depth;
+ indent ();
+ fprintf (stderr, "resume %s level 0x%08x line %d\n",
+ (is_class_level) ? "class" : "block", b, lineno);
+ is_class_level = 0;
+ binding_depth++;
+#endif /* defined(DEBUG_CP_BINDING_LEVELS) */
+}
+
+/* Nonzero if we are currently in the global binding level. */
+
+int
+global_bindings_p ()
+{
+ return current_binding_level == global_binding_level;
+}
+
+/* Nonzero if we are currently in a toplevel binding level. This
+ means either the global binding level or a namespace in a toplevel
+ binding level. */
+
+int
+toplevel_bindings_p ()
+{
+ struct binding_level *b = current_binding_level;
+
+ while (1)
+ {
+ if (b == global_binding_level)
+ return 1;
+ if (! b->namespace_p)
+ return 0;
+ b=b->level_chain;
+ }
+}
+
+/* Nonzero if this is a namespace scope. */
+
+int
+namespace_bindings_p ()
+{
+ return current_binding_level->namespace_p;
+}
+
+void
+keep_next_level ()
+{
+ keep_next_level_flag = 1;
+}
+
+/* Nonzero if the current level needs to have a BLOCK made. */
+
+int
+kept_level_p ()
+{
+ return (current_binding_level->blocks != NULL_TREE
+ || current_binding_level->keep
+ || current_binding_level->names != NULL_TREE
+ || (current_binding_level->tags != NULL_TREE
+ && !current_binding_level->tag_transparent));
+}
+
+/* Identify this binding level as a level of parameters. */
+
+void
+declare_parm_level ()
+{
+ current_binding_level->parm_flag = 1;
+}
+
+void
+declare_uninstantiated_type_level ()
+{
+ current_binding_level->accept_any = 1;
+}
+
+int
+uninstantiated_type_level_p ()
+{
+ return current_binding_level->accept_any;
+}
+
+void
+declare_pseudo_global_level ()
+{
+ current_binding_level->pseudo_global = 1;
+}
+
+void
+declare_namespace_level ()
+{
+ current_binding_level->namespace_p = 1;
+}
+
+int
+pseudo_global_level_p ()
+{
+ return current_binding_level->pseudo_global;
+}
+
+void
+set_class_shadows (shadows)
+ tree shadows;
+{
+ class_binding_level->class_shadowed = shadows;
+}
+
+/* Enter a new binding level.
+ If TAG_TRANSPARENT is nonzero, do so only for the name space of variables,
+ not for that of tags. */
+
+void
+pushlevel (tag_transparent)
+ int tag_transparent;
+{
+ register struct binding_level *newlevel = NULL_BINDING_LEVEL;
+
+ /* If this is the top level of a function,
+ just make sure that NAMED_LABELS is 0.
+ They should have been set to 0 at the end of the previous function. */
+
+ if (current_binding_level == global_binding_level)
+ my_friendly_assert (named_labels == NULL_TREE, 134);
+
+ /* Reuse or create a struct for this binding level. */
+
+#if defined(DEBUG_CP_BINDING_LEVELS)
+ if (0)
+#else /* !defined(DEBUG_CP_BINDING_LEVELS) */
+ if (free_binding_level)
+#endif /* !defined(DEBUG_CP_BINDING_LEVELS) */
+ {
+ newlevel = free_binding_level;
+ free_binding_level = free_binding_level->level_chain;
+ }
+ else
+ {
+ /* Create a new `struct binding_level'. */
+ newlevel = (struct binding_level *) xmalloc (sizeof (struct binding_level));
+ }
+ push_binding_level (newlevel, tag_transparent, keep_next_level_flag);
+ GNU_xref_start_scope ((HOST_WIDE_INT) newlevel);
+ keep_next_level_flag = 0;
+}
+
+int
+note_level_for_for ()
+{
+ current_binding_level->is_for_scope = 1;
+}
+
+void
+pushlevel_temporary (tag_transparent)
+ int tag_transparent;
+{
+ pushlevel (tag_transparent);
+ current_binding_level->keep = 2;
+ clear_last_expr ();
+
+ /* Note we don't call push_momentary() here. Otherwise, it would cause
+ cleanups to be allocated on the momentary obstack, and they will be
+ overwritten by the next statement. */
+
+ expand_start_bindings (0);
+}
+
+/* Exit a binding level.
+ Pop the level off, and restore the state of the identifier-decl mappings
+ that were in effect when this level was entered.
+
+ If KEEP == 1, this level had explicit declarations, so
+ and create a "block" (a BLOCK node) for the level
+ to record its declarations and subblocks for symbol table output.
+
+ If KEEP == 2, this level's subblocks go to the front,
+ not the back of the current binding level. This happens,
+ for instance, when code for constructors and destructors
+ need to generate code at the end of a function which must
+ be moved up to the front of the function.
+
+ If FUNCTIONBODY is nonzero, this level is the body of a function,
+ so create a block as if KEEP were set and also clear out all
+ label names.
+
+ If REVERSE is nonzero, reverse the order of decls before putting
+ them into the BLOCK. */
+
+tree
+poplevel (keep, reverse, functionbody)
+ int keep;
+ int reverse;
+ int functionbody;
+{
+ register tree link;
+ /* The chain of decls was accumulated in reverse order.
+ Put it into forward order, just for cleanliness. */
+ tree decls;
+ int tmp = functionbody;
+ int implicit_try_block = current_binding_level->parm_flag == 3;
+ int real_functionbody = current_binding_level->keep == 2
+ ? ((functionbody = 0), tmp) : functionbody;
+ tree tags = functionbody >= 0 ? current_binding_level->tags : 0;
+ tree subblocks = functionbody >= 0 ? current_binding_level->blocks : 0;
+ tree block = NULL_TREE;
+ tree decl;
+ int block_previously_created;
+
+ GNU_xref_end_scope ((HOST_WIDE_INT) current_binding_level,
+ (HOST_WIDE_INT) current_binding_level->level_chain,
+ current_binding_level->parm_flag,
+ current_binding_level->keep,
+ current_binding_level->tag_transparent);
+
+ if (current_binding_level->keep == 1)
+ keep = 1;
+
+ /* This warning is turned off because it causes warnings for
+ declarations like `extern struct foo *x'. */
+#if 0
+ /* Warn about incomplete structure types in this level. */
+ for (link = tags; link; link = TREE_CHAIN (link))
+ if (TYPE_SIZE (TREE_VALUE (link)) == NULL_TREE)
+ {
+ tree type = TREE_VALUE (link);
+ char *errmsg;
+ switch (TREE_CODE (type))
+ {
+ case RECORD_TYPE:
+ errmsg = "`struct %s' incomplete in scope ending here";
+ break;
+ case UNION_TYPE:
+ errmsg = "`union %s' incomplete in scope ending here";
+ break;
+ case ENUMERAL_TYPE:
+ errmsg = "`enum %s' incomplete in scope ending here";
+ break;
+ }
+ if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
+ error (errmsg, IDENTIFIER_POINTER (TYPE_NAME (type)));
+ else
+ /* If this type has a typedef-name, the TYPE_NAME is a TYPE_DECL. */
+ error (errmsg, TYPE_NAME_STRING (type));
+ }
+#endif /* 0 */
+
+ /* Get the decls in the order they were written.
+ Usually current_binding_level->names is in reverse order.
+ But parameter decls were previously put in forward order. */
+
+ if (reverse)
+ current_binding_level->names
+ = decls = nreverse (current_binding_level->names);
+ else
+ decls = current_binding_level->names;
+
+ /* Output any nested inline functions within this block
+ if they weren't already output. */
+
+ for (decl = decls; decl; decl = TREE_CHAIN (decl))
+ if (TREE_CODE (decl) == FUNCTION_DECL
+ && ! TREE_ASM_WRITTEN (decl)
+ && DECL_INITIAL (decl) != NULL_TREE
+ && TREE_ADDRESSABLE (decl)
+ && decl_function_context (decl) == current_function_decl)
+ {
+ /* If this decl was copied from a file-scope decl
+ on account of a block-scope extern decl,
+ propagate TREE_ADDRESSABLE to the file-scope decl. */
+ if (DECL_ABSTRACT_ORIGIN (decl) != NULL_TREE)
+ TREE_ADDRESSABLE (DECL_ABSTRACT_ORIGIN (decl)) = 1;
+ else
+ {
+ push_function_context ();
+ output_inline_function (decl);
+ pop_function_context ();
+ }
+ }
+
+ /* If there were any declarations or structure tags in that level,
+ or if this level is a function body,
+ create a BLOCK to record them for the life of this function. */
+
+ block = NULL_TREE;
+ block_previously_created = (current_binding_level->this_block != NULL_TREE);
+ if (block_previously_created)
+ block = current_binding_level->this_block;
+ else if (keep == 1 || functionbody)
+ block = make_node (BLOCK);
+ if (block != NULL_TREE)
+ {
+ BLOCK_VARS (block) = decls;
+ BLOCK_TYPE_TAGS (block) = tags;
+ BLOCK_SUBBLOCKS (block) = subblocks;
+ /* If we created the block earlier on, and we are just diddling it now,
+ then it already should have a proper BLOCK_END_NOTE value associated
+ with it, so avoid trashing that. Otherwise, for a new block, install
+ a new BLOCK_END_NOTE value. */
+ if (! block_previously_created)
+ remember_end_note (block);
+ }
+
+ /* In each subblock, record that this is its superior. */
+
+ if (keep >= 0)
+ for (link = subblocks; link; link = TREE_CHAIN (link))
+ BLOCK_SUPERCONTEXT (link) = block;
+
+ /* Clear out the meanings of the local variables of this level. */
+
+ for (link = current_binding_level->dead_vars_from_for;
+ link != NULL_TREE; link = TREE_CHAIN (link))
+ {
+ if (DECL_DEAD_FOR_LOCAL (link))
+ {
+ tree id = DECL_NAME (link);
+ if (IDENTIFIER_LOCAL_VALUE (id) == link)
+ IDENTIFIER_LOCAL_VALUE (id) = DECL_SHADOWED_FOR_VAR (link);
+ }
+ }
+
+ if (current_binding_level->is_for_scope && flag_new_for_scope == 1)
+ {
+ for (link = decls; link; link = TREE_CHAIN (link))
+ {
+ if (TREE_CODE (link) == VAR_DECL)
+ DECL_DEAD_FOR_LOCAL (link) = 1;
+ }
+ }
+ else
+ {
+ for (link = decls; link; link = TREE_CHAIN (link))
+ {
+ if (DECL_NAME (link) != NULL_TREE)
+ {
+ /* If the ident. was used or addressed via a local extern decl,
+ don't forget that fact. */
+ if (DECL_EXTERNAL (link))
+ {
+ if (TREE_USED (link))
+ TREE_USED (DECL_ASSEMBLER_NAME (link)) = 1;
+ if (TREE_ADDRESSABLE (link))
+ TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (link)) = 1;
+ }
+ IDENTIFIER_LOCAL_VALUE (DECL_NAME (link)) = NULL_TREE;
+ }
+ }
+ }
+
+ /* Restore all name-meanings of the outer levels
+ that were shadowed by this level. */
+
+ if (current_binding_level->is_for_scope && flag_new_for_scope == 1)
+ {
+ struct binding_level *outer = current_binding_level->level_chain;
+ for (link = current_binding_level->shadowed; link; link = TREE_CHAIN (link))
+ {
+ tree id = TREE_PURPOSE (link);
+ tree decl = IDENTIFIER_LOCAL_VALUE (id);
+ if (DECL_DEAD_FOR_LOCAL (decl))
+ DECL_SHADOWED_FOR_VAR (decl) = TREE_VALUE (link);
+ else
+ IDENTIFIER_LOCAL_VALUE (id) = TREE_VALUE (link);
+ }
+
+ /* Save declarations made in a 'for' statement so we can support pre-ANSI
+ 'for' scoping semantics. */
+
+ /* We append the current names of for-variables to those from previous
+ declarations, so that when we get around to do an poplevel
+ on the OUTER level, we restore the any shadowed readl bindings.
+ Note that the new names are put first on the combined list,
+ so they get to be restored first. This is important if there are
+ two for-loops using the same for-variable in the same block.
+ The binding we really want restored is whatever binding was shadowed
+ by the *first* for-variable, not the binding shadowed by the
+ second for-variable (which would be the first for-variable). */
+ outer->dead_vars_from_for
+ = chainon (current_binding_level->names, outer->dead_vars_from_for);
+ }
+ else
+ {
+ for (link = current_binding_level->shadowed; link; link = TREE_CHAIN (link))
+ IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
+ }
+ for (link = current_binding_level->class_shadowed;
+ link; link = TREE_CHAIN (link))
+ IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
+ for (link = current_binding_level->type_shadowed;
+ link; link = TREE_CHAIN (link))
+ IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
+
+ /* If the level being exited is the top level of a function,
+ check over all the labels. */
+
+ if (functionbody)
+ {
+ /* If this is the top level block of a function,
+ the vars are the function's parameters.
+ Don't leave them in the BLOCK because they are
+ found in the FUNCTION_DECL instead. */
+
+ BLOCK_VARS (block) = 0;
+
+ /* Clear out the definitions of all label names,
+ since their scopes end here. */
+
+ for (link = named_labels; link; link = TREE_CHAIN (link))
+ {
+ register tree label = TREE_VALUE (link);
+
+ if (DECL_INITIAL (label) == NULL_TREE)
+ {
+ cp_error_at ("label `%D' used but not defined", label);
+ /* Avoid crashing later. */
+ define_label (input_filename, 1, DECL_NAME (label));
+ }
+ else if (warn_unused && !TREE_USED (label))
+ cp_warning_at ("label `%D' defined but not used", label);
+ SET_IDENTIFIER_LABEL_VALUE (DECL_NAME (label), NULL_TREE);
+
+ /* Put the labels into the "variables" of the
+ top-level block, so debugger can see them. */
+ TREE_CHAIN (label) = BLOCK_VARS (block);
+ BLOCK_VARS (block) = label;
+ }
+
+ named_labels = NULL_TREE;
+ }
+
+ /* Any uses of undefined labels now operate under constraints
+ of next binding contour. */
+ {
+ struct binding_level *level_chain;
+ level_chain = current_binding_level->level_chain;
+ if (level_chain)
+ {
+ tree labels;
+ for (labels = named_label_uses; labels; labels = TREE_CHAIN (labels))
+ if (TREE_TYPE (labels) == (tree)current_binding_level)
+ {
+ TREE_TYPE (labels) = (tree)level_chain;
+ TREE_PURPOSE (labels) = level_chain->names;
+ }
+ }
+ }
+
+ tmp = current_binding_level->keep;
+
+ pop_binding_level ();
+ if (functionbody)
+ DECL_INITIAL (current_function_decl) = block;
+ else if (block)
+ {
+ if (!block_previously_created)
+ current_binding_level->blocks
+ = chainon (current_binding_level->blocks, block);
+ }
+ /* If we did not make a block for the level just exited,
+ any blocks made for inner levels
+ (since they cannot be recorded as subblocks in that level)
+ must be carried forward so they will later become subblocks
+ of something else. */
+ else if (subblocks)
+ {
+ if (keep == 2)
+ current_binding_level->blocks
+ = chainon (subblocks, current_binding_level->blocks);
+ else
+ current_binding_level->blocks
+ = chainon (current_binding_level->blocks, subblocks);
+ }
+
+ /* Take care of compiler's internal binding structures. */
+ if (tmp == 2)
+ {
+#if 0
+ /* We did not call push_momentary for this
+ binding contour, so there is nothing to pop. */
+ pop_momentary ();
+#endif
+ expand_end_bindings (getdecls (), keep, 1);
+ /* Each and every BLOCK node created here in `poplevel' is important
+ (e.g. for proper debugging information) so if we created one
+ earlier, mark it as "used". */
+ if (block)
+ TREE_USED (block) = 1;
+ block = poplevel (keep, reverse, real_functionbody);
+ }
+
+ /* Each and every BLOCK node created here in `poplevel' is important
+ (e.g. for proper debugging information) so if we created one
+ earlier, mark it as "used". */
+ if (block)
+ TREE_USED (block) = 1;
+ return block;
+}
+
+/* Resume a binding level for a namespace. */
+void
+resume_level (b)
+ struct binding_level *b;
+{
+ tree decls, link;
+
+ resume_binding_level (b);
+
+ /* Resume the variable caches. */
+ decls = current_binding_level->names;
+
+ /* Restore the meanings of the local variables of this level. */
+
+ for (link = decls; link; link = TREE_CHAIN (link))
+ {
+ if (DECL_NAME (link) != NULL_TREE)
+ IDENTIFIER_LOCAL_VALUE (DECL_NAME (link)) = link;
+
+ /* If this is a TYPE_DECL, push it into the type value slot. */
+ if (TREE_CODE (link) == TYPE_DECL)
+ SET_IDENTIFIER_TYPE_VALUE (DECL_NAME (link), TREE_TYPE (link));
+ }
+}
+
+/* Delete the node BLOCK from the current binding level.
+ This is used for the block inside a stmt expr ({...})
+ so that the block can be reinserted where appropriate. */
+
+void
+delete_block (block)
+ tree block;
+{
+ tree t;
+ if (current_binding_level->blocks == block)
+ current_binding_level->blocks = TREE_CHAIN (block);
+ for (t = current_binding_level->blocks; t;)
+ {
+ if (TREE_CHAIN (t) == block)
+ TREE_CHAIN (t) = TREE_CHAIN (block);
+ else
+ t = TREE_CHAIN (t);
+ }
+ TREE_CHAIN (block) = NULL_TREE;
+ /* Clear TREE_USED which is always set by poplevel.
+ The flag is set again if insert_block is called. */
+ TREE_USED (block) = 0;
+}
+
+/* Insert BLOCK at the end of the list of subblocks of the
+ current binding level. This is used when a BIND_EXPR is expanded,
+ to handle the BLOCK node inside the BIND_EXPR. */
+
+void
+insert_block (block)
+ tree block;
+{
+ TREE_USED (block) = 1;
+ current_binding_level->blocks
+ = chainon (current_binding_level->blocks, block);
+}
+
+/* Add BLOCK to the current list of blocks for this binding contour. */
+void
+add_block_current_level (block)
+ tree block;
+{
+ current_binding_level->blocks
+ = chainon (current_binding_level->blocks, block);
+}
+
+/* Set the BLOCK node for the innermost scope
+ (the one we are currently in). */
+
+void
+set_block (block)
+ register tree block;
+{
+ current_binding_level->this_block = block;
+}
+
+/* Do a pushlevel for class declarations. */
+void
+pushlevel_class ()
+{
+ register struct binding_level *newlevel;
+
+ /* Reuse or create a struct for this binding level. */
+#if defined(DEBUG_CP_BINDING_LEVELS)
+ if (0)
+#else /* !defined(DEBUG_CP_BINDING_LEVELS) */
+ if (free_binding_level)
+#endif /* !defined(DEBUG_CP_BINDING_LEVELS) */
+ {
+ newlevel = free_binding_level;
+ free_binding_level = free_binding_level->level_chain;
+ }
+ else
+ {
+ /* Create a new `struct binding_level'. */
+ newlevel = (struct binding_level *) xmalloc (sizeof (struct binding_level));
+ }
+
+#if defined(DEBUG_CP_BINDING_LEVELS)
+ is_class_level = 1;
+#endif /* defined(DEBUG_CP_BINDING_LEVELS) */
+
+ push_binding_level (newlevel, 0, 0);
+
+ decl_stack = push_decl_level (decl_stack, &decl_obstack);
+ class_binding_level = current_binding_level;
+ class_binding_level->parm_flag = 2;
+ /* We have just pushed into a new binding level. Now, fake out the rest
+ of the compiler. Set the `current_binding_level' back to point to
+ the most closely containing non-class binding level. */
+ do
+ {
+ current_binding_level = current_binding_level->level_chain;
+ }
+ while (current_binding_level->parm_flag == 2);
+}
+
+/* ...and a poplevel for class declarations. FORCE is used to force
+ clearing out of CLASS_VALUEs after a class definition. */
+tree
+poplevel_class (force)
+ int force;
+{
+ register struct binding_level *level = class_binding_level;
+ tree block = NULL_TREE;
+ tree shadowed;
+
+ my_friendly_assert (level != 0, 354);
+
+ decl_stack = pop_stack_level (decl_stack);
+ for (shadowed = level->shadowed; shadowed; shadowed = TREE_CHAIN (shadowed))
+ IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (shadowed)) = TREE_VALUE (shadowed);
+ /* If we're leaving a toplevel class, don't bother to do the setting
+ of IDENTIFIER_CLASS_VALUE to NULL_TREE, since first of all this slot
+ shouldn't even be used when current_class_type isn't set, and second,
+ if we don't touch it here, we're able to use the cache effect if the
+ next time we're entering a class scope, it is the same class. */
+ if (current_class_depth != 1 || force)
+ for (shadowed = level->class_shadowed;
+ shadowed;
+ shadowed = TREE_CHAIN (shadowed))
+ IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (shadowed)) = TREE_VALUE (shadowed);
+ else
+ /* Remember to save what IDENTIFIER's were bound in this scope so we
+ can recover from cache misses. */
+ previous_class_values = class_binding_level->class_shadowed;
+ for (shadowed = level->type_shadowed;
+ shadowed;
+ shadowed = TREE_CHAIN (shadowed))
+ IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (shadowed)) = TREE_VALUE (shadowed);
+
+ GNU_xref_end_scope ((HOST_WIDE_INT) class_binding_level,
+ (HOST_WIDE_INT) class_binding_level->level_chain,
+ class_binding_level->parm_flag,
+ class_binding_level->keep,
+ class_binding_level->tag_transparent);
+
+ if (class_binding_level->parm_flag != 2)
+ class_binding_level = (struct binding_level *)0;
+
+ /* Now, pop out of the the binding level which we created up in the
+ `pushlevel_class' routine. */
+#if defined(DEBUG_CP_BINDING_LEVELS)
+ is_class_level = 1;
+#endif /* defined(DEBUG_CP_BINDING_LEVELS) */
+
+ pop_binding_level ();
+
+ return block;
+}
+
+/* For debugging. */
+int no_print_functions = 0;
+int no_print_builtins = 0;
+
+void
+print_binding_level (lvl)
+ struct binding_level *lvl;
+{
+ tree t;
+ int i = 0, len;
+ fprintf (stderr, " blocks=");
+ fprintf (stderr, HOST_PTR_PRINTF, lvl->blocks);
+ fprintf (stderr, " n_incomplete=%d parm_flag=%d keep=%d",
+ list_length (lvl->incomplete), lvl->parm_flag, lvl->keep);
+ if (lvl->tag_transparent)
+ fprintf (stderr, " tag-transparent");
+ if (lvl->more_cleanups_ok)
+ fprintf (stderr, " more-cleanups-ok");
+ if (lvl->have_cleanups)
+ fprintf (stderr, " have-cleanups");
+ fprintf (stderr, "\n");
+ if (lvl->names)
+ {
+ fprintf (stderr, " names:\t");
+ /* We can probably fit 3 names to a line? */
+ for (t = lvl->names; t; t = TREE_CHAIN (t))
+ {
+ if (no_print_functions && (TREE_CODE(t) == FUNCTION_DECL))
+ continue;
+ if (no_print_builtins
+ && (TREE_CODE(t) == TYPE_DECL)
+ && (!strcmp(DECL_SOURCE_FILE(t),"<built-in>")))
+ continue;
+
+ /* Function decls tend to have longer names. */
+ if (TREE_CODE (t) == FUNCTION_DECL)
+ len = 3;
+ else
+ len = 2;
+ i += len;
+ if (i > 6)
+ {
+ fprintf (stderr, "\n\t");
+ i = len;
+ }
+ print_node_brief (stderr, "", t, 0);
+ if (TREE_CODE (t) == ERROR_MARK)
+ break;
+ }
+ if (i)
+ fprintf (stderr, "\n");
+ }
+ if (lvl->tags)
+ {
+ fprintf (stderr, " tags:\t");
+ i = 0;
+ for (t = lvl->tags; t; t = TREE_CHAIN (t))
+ {
+ if (TREE_PURPOSE (t) == NULL_TREE)
+ len = 3;
+ else if (TREE_PURPOSE (t) == TYPE_IDENTIFIER (TREE_VALUE (t)))
+ len = 2;
+ else
+ len = 4;
+ i += len;
+ if (i > 5)
+ {
+ fprintf (stderr, "\n\t");
+ i = len;
+ }
+ if (TREE_PURPOSE (t) == NULL_TREE)
+ {
+ print_node_brief (stderr, "<unnamed-typedef", TREE_VALUE (t), 0);
+ fprintf (stderr, ">");
+ }
+ else if (TREE_PURPOSE (t) == TYPE_IDENTIFIER (TREE_VALUE (t)))
+ print_node_brief (stderr, "", TREE_VALUE (t), 0);
+ else
+ {
+ print_node_brief (stderr, "<typedef", TREE_PURPOSE (t), 0);
+ print_node_brief (stderr, "", TREE_VALUE (t), 0);
+ fprintf (stderr, ">");
+ }
+ }
+ if (i)
+ fprintf (stderr, "\n");
+ }
+ if (lvl->shadowed)
+ {
+ fprintf (stderr, " shadowed:");
+ for (t = lvl->shadowed; t; t = TREE_CHAIN (t))
+ {
+ fprintf (stderr, " %s ", IDENTIFIER_POINTER (TREE_PURPOSE (t)));
+ }
+ fprintf (stderr, "\n");
+ }
+ if (lvl->class_shadowed)
+ {
+ fprintf (stderr, " class-shadowed:");
+ for (t = lvl->class_shadowed; t; t = TREE_CHAIN (t))
+ {
+ fprintf (stderr, " %s ", IDENTIFIER_POINTER (TREE_PURPOSE (t)));
+ }
+ fprintf (stderr, "\n");
+ }
+ if (lvl->type_shadowed)
+ {
+ fprintf (stderr, " type-shadowed:");
+ for (t = lvl->type_shadowed; t; t = TREE_CHAIN (t))
+ {
+#if 0
+ fprintf (stderr, "\n\t");
+ print_node_brief (stderr, "<", TREE_PURPOSE (t), 0);
+ if (TREE_VALUE (t))
+ print_node_brief (stderr, " ", TREE_VALUE (t), 0);
+ else
+ fprintf (stderr, " (none)");
+ fprintf (stderr, ">");
+#else
+ fprintf (stderr, " %s ", IDENTIFIER_POINTER (TREE_PURPOSE (t)));
+#endif
+ }
+ fprintf (stderr, "\n");
+ }
+}
+
+void
+print_other_binding_stack (stack)
+ struct binding_level *stack;
+{
+ struct binding_level *level;
+ for (level = stack; level != global_binding_level; level = level->level_chain)
+ {
+ fprintf (stderr, "binding level ");
+ fprintf (stderr, HOST_PTR_PRINTF, level);
+ fprintf (stderr, "\n");
+ print_binding_level (level);
+ }
+}
+
+void
+print_binding_stack ()
+{
+ struct binding_level *b;
+ fprintf (stderr, "current_binding_level=");
+ fprintf (stderr, HOST_PTR_PRINTF, current_binding_level);
+ fprintf (stderr, "\nclass_binding_level=");
+ fprintf (stderr, HOST_PTR_PRINTF, class_binding_level);
+ fprintf (stderr, "\nglobal_binding_level=");
+ fprintf (stderr, HOST_PTR_PRINTF, global_binding_level);
+ fprintf (stderr, "\n");
+ if (class_binding_level)
+ {
+ for (b = class_binding_level; b; b = b->level_chain)
+ if (b == current_binding_level)
+ break;
+ if (b)
+ b = class_binding_level;
+ else
+ b = current_binding_level;
+ }
+ else
+ b = current_binding_level;
+ print_other_binding_stack (b);
+ fprintf (stderr, "global:\n");
+ print_binding_level (global_binding_level);
+}
+
+extern char * first_global_object_name;
+
+/* Get a unique name for each call to this routine for unnamed namespaces.
+ Mostly copied from get_file_function_name. */
+static tree
+get_unique_name ()
+{
+ static int temp_name_counter = 0;
+ char *buf;
+ register char *p;
+
+ if (first_global_object_name)
+ p = first_global_object_name;
+ else if (main_input_filename)
+ p = main_input_filename;
+ else
+ p = input_filename;
+
+#define UNNAMED_NAMESPACE_FORMAT "__%s_%d"
+
+ buf = (char *) alloca (sizeof (UNNAMED_NAMESPACE_FORMAT) + strlen (p));
+
+ sprintf (buf, UNNAMED_NAMESPACE_FORMAT, p, temp_name_counter++);
+
+ /* Don't need to pull weird characters out of global names. */
+ if (p != first_global_object_name)
+ {
+ for (p = buf+11; *p; p++)
+ if (! ((*p >= '0' && *p <= '9')
+#if 0 /* we always want labels, which are valid C++ identifiers (+ `$') */
+#ifndef ASM_IDENTIFY_GCC /* this is required if `.' is invalid -- k. raeburn */
+ || *p == '.'
+#endif
+#endif
+#ifndef NO_DOLLAR_IN_LABEL /* this for `$'; unlikely, but... -- kr */
+ || *p == '$'
+#endif
+#ifndef NO_DOT_IN_LABEL /* this for `.'; unlikely, but... */
+ || *p == '.'
+#endif
+ || (*p >= 'A' && *p <= 'Z')
+ || (*p >= 'a' && *p <= 'z')))
+ *p = '_';
+ }
+
+ return get_identifier (buf);
+}
+
+/* Push into the scope of the NAME namespace. If NAME is NULL_TREE, then we
+ select a name that is unique to this compilation unit. */
+void
+push_namespace (name)
+ tree name;
+{
+ extern tree current_namespace;
+ tree old_id = get_namespace_id ();
+ char *buf;
+ tree d = make_node (NAMESPACE_DECL);
+
+ if (! name)
+ {
+ /* Create a truly ugly name! */
+ name = get_unique_name ();
+ }
+
+ DECL_NAME (d) = name;
+ DECL_ASSEMBLER_NAME (d) = name;
+ /* pushdecl wants to check the size of it to see if it is incomplete... */
+ TREE_TYPE (d) = void_type_node;
+ /* Mark them as external, so redeclaration_error_message doesn't think
+ they are duplicates. */
+ DECL_EXTERNAL (d) = 1;
+ d = pushdecl (d);
+
+ if (NAMESPACE_LEVEL (d) == 0)
+ {
+ /* This is new for this compilation unit. */
+ pushlevel (0);
+ declare_namespace_level ();
+ NAMESPACE_LEVEL (d) = (tree)current_binding_level;
+ }
+ else
+ {
+ resume_level ((struct binding_level*)NAMESPACE_LEVEL (d));
+ }
+
+ /* This code is just is bit old now... */
+ current_namespace = tree_cons (NULL_TREE, name, current_namespace);
+ buf = (char *) alloca (4 + (old_id ? IDENTIFIER_LENGTH (old_id) : 0)
+ + IDENTIFIER_LENGTH (name));
+ sprintf (buf, "%s%s", old_id ? IDENTIFIER_POINTER (old_id) : "",
+ IDENTIFIER_POINTER (name));
+ TREE_PURPOSE (current_namespace) = get_identifier (buf);
+}
+
+/* Pop from the scope of the current namespace. */
+void
+pop_namespace ()
+{
+ extern tree current_namespace;
+ tree decls, link;
+ current_namespace = TREE_CHAIN (current_namespace);
+
+ /* Just in case we get out of sync. */
+ if (! namespace_bindings_p ())
+ poplevel (0, 0, 0);
+
+ decls = current_binding_level->names;
+
+ /* Clear out the meanings of the local variables of this level. */
+
+ for (link = decls; link; link = TREE_CHAIN (link))
+ {
+ if (DECL_NAME (link) != NULL_TREE)
+ {
+ /* If the ident. was used or addressed via a local extern decl,
+ don't forget that fact. */
+ if (DECL_EXTERNAL (link))
+ {
+ if (TREE_USED (link))
+ TREE_USED (DECL_ASSEMBLER_NAME (link)) = 1;
+ if (TREE_ADDRESSABLE (link))
+ TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (link)) = 1;
+ }
+ IDENTIFIER_LOCAL_VALUE (DECL_NAME (link)) = NULL_TREE;
+ }
+ }
+
+ /* Restore all name-meanings of the outer levels
+ that were shadowed by this level. */
+
+ for (link = current_binding_level->shadowed; link; link = TREE_CHAIN (link))
+ IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
+ for (link = current_binding_level->class_shadowed;
+ link; link = TREE_CHAIN (link))
+ IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
+ for (link = current_binding_level->type_shadowed;
+ link; link = TREE_CHAIN (link))
+ IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
+
+ /* suspend a level. */
+ suspend_binding_level ();
+}
+
+/* Subroutines for reverting temporarily to top-level for instantiation
+ of templates and such. We actually need to clear out the class- and
+ local-value slots of all identifiers, so that only the global values
+ are at all visible. Simply setting current_binding_level to the global
+ scope isn't enough, because more binding levels may be pushed. */
+struct saved_scope {
+ struct binding_level *old_binding_level;
+ tree old_bindings;
+ struct saved_scope *prev;
+ tree class_name, class_type, function_decl;
+ tree base_init_list, member_init_list;
+ struct binding_level *class_bindings;
+ tree previous_class_type;
+ tree *lang_base, *lang_stack, lang_name;
+ int lang_stacksize;
+ tree named_labels;
+};
+static struct saved_scope *current_saved_scope;
+extern tree prev_class_type;
+
+void
+push_to_top_level ()
+{
+ extern int current_lang_stacksize;
+ struct saved_scope *s =
+ (struct saved_scope *) xmalloc (sizeof (struct saved_scope));
+ struct binding_level *b = current_binding_level;
+ tree old_bindings = NULL_TREE;
+
+ /* Have to include global_binding_level, because class-level decls
+ aren't listed anywhere useful. */
+ for (; b; b = b->level_chain)
+ {
+ tree t;
+
+ if (b == global_binding_level)
+ continue;
+
+ for (t = b->names; t; t = TREE_CHAIN (t))
+ {
+ tree binding, t1, t2 = t;
+ tree id = DECL_ASSEMBLER_NAME (t2);
+
+ if (!id
+ || (!IDENTIFIER_LOCAL_VALUE (id)
+ && !IDENTIFIER_CLASS_VALUE (id)))
+ continue;
+
+ for (t1 = old_bindings; t1; t1 = TREE_CHAIN (t1))
+ if (TREE_VEC_ELT (t1, 0) == id)
+ goto skip_it;
+
+ binding = make_tree_vec (4);
+ if (id)
+ {
+ my_friendly_assert (TREE_CODE (id) == IDENTIFIER_NODE, 135);
+ TREE_VEC_ELT (binding, 0) = id;
+ TREE_VEC_ELT (binding, 1) = IDENTIFIER_TYPE_VALUE (id);
+ TREE_VEC_ELT (binding, 2) = IDENTIFIER_LOCAL_VALUE (id);
+ TREE_VEC_ELT (binding, 3) = IDENTIFIER_CLASS_VALUE (id);
+ IDENTIFIER_LOCAL_VALUE (id) = NULL_TREE;
+ IDENTIFIER_CLASS_VALUE (id) = NULL_TREE;
+ }
+ TREE_CHAIN (binding) = old_bindings;
+ old_bindings = binding;
+ skip_it:
+ ;
+ }
+ /* Unwind type-value slots back to top level. */
+ for (t = b->type_shadowed; t; t = TREE_CHAIN (t))
+ SET_IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (t), TREE_VALUE (t));
+ }
+ /* Clear out class-level bindings cache. */
+ if (current_binding_level == global_binding_level
+ && previous_class_type != NULL_TREE)
+ {
+ popclass (-1);
+ previous_class_type = NULL_TREE;
+ }
+
+ s->old_binding_level = current_binding_level;
+ current_binding_level = global_binding_level;
+
+ s->class_name = current_class_name;
+ s->class_type = current_class_type;
+ s->function_decl = current_function_decl;
+ s->base_init_list = current_base_init_list;
+ s->member_init_list = current_member_init_list;
+ s->class_bindings = class_binding_level;
+ s->previous_class_type = previous_class_type;
+ s->lang_stack = current_lang_stack;
+ s->lang_base = current_lang_base;
+ s->lang_stacksize = current_lang_stacksize;
+ s->lang_name = current_lang_name;
+ s->named_labels = named_labels;
+ current_class_name = current_class_type = NULL_TREE;
+ current_function_decl = NULL_TREE;
+ class_binding_level = (struct binding_level *)0;
+ previous_class_type = NULL_TREE;
+ current_lang_stacksize = 10;
+ current_lang_stack = current_lang_base
+ = (tree *) xmalloc (current_lang_stacksize * sizeof (tree));
+ current_lang_name = lang_name_cplusplus;
+ strict_prototype = strict_prototypes_lang_cplusplus;
+ named_labels = NULL_TREE;
+
+ s->prev = current_saved_scope;
+ s->old_bindings = old_bindings;
+ current_saved_scope = s;
+}
+
+void
+pop_from_top_level ()
+{
+ extern int current_lang_stacksize;
+ struct saved_scope *s = current_saved_scope;
+ tree t;
+
+ if (previous_class_type)
+ previous_class_type = NULL_TREE;
+
+ current_binding_level = s->old_binding_level;
+ current_saved_scope = s->prev;
+ for (t = s->old_bindings; t; t = TREE_CHAIN (t))
+ {
+ tree id = TREE_VEC_ELT (t, 0);
+ if (id)
+ {
+ IDENTIFIER_TYPE_VALUE (id) = TREE_VEC_ELT (t, 1);
+ IDENTIFIER_LOCAL_VALUE (id) = TREE_VEC_ELT (t, 2);
+ IDENTIFIER_CLASS_VALUE (id) = TREE_VEC_ELT (t, 3);
+ }
+ }
+ current_class_name = s->class_name;
+ current_class_type = s->class_type;
+ current_base_init_list = s->base_init_list;
+ current_member_init_list = s->member_init_list;
+ current_function_decl = s->function_decl;
+ class_binding_level = s->class_bindings;
+ previous_class_type = s->previous_class_type;
+ free (current_lang_base);
+ current_lang_base = s->lang_base;
+ current_lang_stack = s->lang_stack;
+ current_lang_name = s->lang_name;
+ current_lang_stacksize = s->lang_stacksize;
+ if (current_lang_name == lang_name_cplusplus)
+ strict_prototype = strict_prototypes_lang_cplusplus;
+ else if (current_lang_name == lang_name_c)
+ strict_prototype = strict_prototypes_lang_c;
+ named_labels = s->named_labels;
+
+ free (s);
+}
+
+/* Push a definition of struct, union or enum tag "name".
+ into binding_level "b". "type" should be the type node,
+ We assume that the tag "name" is not already defined.
+
+ Note that the definition may really be just a forward reference.
+ In that case, the TYPE_SIZE will be a NULL_TREE.
+
+ C++ gratuitously puts all these tags in the name space. */
+
+/* When setting the IDENTIFIER_TYPE_VALUE field of an identifier ID,
+ record the shadowed value for this binding contour. TYPE is
+ the type that ID maps to. */
+
+static void
+set_identifier_type_value_with_scope (id, type, b)
+ tree id;
+ tree type;
+ struct binding_level *b;
+{
+ if (b != global_binding_level)
+ {
+ tree old_type_value = IDENTIFIER_TYPE_VALUE (id);
+ b->type_shadowed
+ = tree_cons (id, old_type_value, b->type_shadowed);
+ }
+ SET_IDENTIFIER_TYPE_VALUE (id, type);
+}
+
+/* As set_identifier_type_value_with_scope, but using inner_binding_level. */
+
+void
+set_identifier_type_value (id, type)
+ tree id;
+ tree type;
+{
+ set_identifier_type_value_with_scope (id, type, inner_binding_level);
+}
+
+/* Subroutine "set_nested_typename" builds the nested-typename of
+ the type decl in question. (Argument CLASSNAME can actually be
+ a function as well, if that's the smallest containing scope.) */
+
+static void
+set_nested_typename (decl, classname, name, type)
+ tree decl, classname, name, type;
+{
+ char *buf;
+ my_friendly_assert (TREE_CODE (decl) == TYPE_DECL, 136);
+
+ /* No need to do this for anonymous names, since they're unique. */
+ if (ANON_AGGRNAME_P (name))
+ {
+ DECL_NESTED_TYPENAME (decl) = name;
+ return;
+ }
+
+ if (classname == NULL_TREE)
+ classname = get_identifier ("");
+
+ my_friendly_assert (TREE_CODE (classname) == IDENTIFIER_NODE, 137);
+ my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE, 138);
+ buf = (char *) alloca (4 + IDENTIFIER_LENGTH (classname)
+ + IDENTIFIER_LENGTH (name));
+ sprintf (buf, "%s::%s", IDENTIFIER_POINTER (classname),
+ IDENTIFIER_POINTER (name));
+ DECL_NESTED_TYPENAME (decl) = get_identifier (buf);
+ TREE_MANGLED (DECL_NESTED_TYPENAME (decl)) = 1;
+
+ /* Create an extra decl so that the nested name will have a type value
+ where appropriate. */
+ {
+ tree nested, type_decl;
+ nested = DECL_NESTED_TYPENAME (decl);
+ type_decl = build_decl (TYPE_DECL, nested, type);
+ DECL_NESTED_TYPENAME (type_decl) = nested;
+ SET_DECL_ARTIFICIAL (type_decl);
+ /* Mark the TYPE_DECL node created just above as a gratuitous one so that
+ dwarfout.c will know not to generate a TAG_typedef DIE for it, and
+ sdbout.c won't try to output a .def for "::foo". */
+ DECL_IGNORED_P (type_decl) = 1;
+
+ /* Remove this when local classes are fixed. */
+ SET_IDENTIFIER_TYPE_VALUE (nested, type);
+
+ pushdecl_nonclass_level (type_decl);
+ }
+}
+
+/* Pop off extraneous binding levels left over due to syntax errors.
+
+ We don't pop past namespaces, as they might be valid. */
+void
+pop_everything ()
+{
+#ifdef DEBUG_CP_BINDING_LEVELS
+ fprintf (stderr, "XXX entering pop_everything ()\n");
+#endif
+ while (! toplevel_bindings_p () && ! pseudo_global_level_p ())
+ {
+ if (class_binding_level)
+ pop_nested_class (1);
+ else
+ poplevel (0, 0, 0);
+ }
+#ifdef DEBUG_CP_BINDING_LEVELS
+ fprintf (stderr, "XXX leaving pop_everything ()\n");
+#endif
+}
+
+#if 0 /* not yet, should get fixed properly later */
+/* Create a TYPE_DECL node with the correct DECL_ASSEMBLER_NAME.
+ Other routines shouldn't use build_decl directly; they'll produce
+ incorrect results with `-g' unless they duplicate this code.
+
+ This is currently needed mainly for dbxout.c, but we can make
+ use of it in method.c later as well. */
+tree
+make_type_decl (name, type)
+ tree name, type;
+{
+ tree decl, id;
+ decl = build_decl (TYPE_DECL, name, type);
+ if (TYPE_NAME (type) == name)
+ /* Class/union/enum definition, or a redundant typedef for same. */
+ {
+ id = get_identifier (build_overload_name (type, 1, 1));
+ DECL_ASSEMBLER_NAME (decl) = id;
+ }
+ else if (TYPE_NAME (type) != NULL_TREE)
+ /* Explicit typedef, or implicit typedef for template expansion. */
+ DECL_ASSEMBLER_NAME (decl) = DECL_ASSEMBLER_NAME (TYPE_NAME (type));
+ else
+ {
+ /* XXX: Typedef for unnamed struct; some other situations.
+ TYPE_NAME is null; what's right here? */
+ }
+ return decl;
+}
+#endif
+
+/* Push a tag name NAME for struct/class/union/enum type TYPE.
+ Normally put into into the inner-most non-tag-transparent scope,
+ but if GLOBALIZE is true, put it in the inner-most non-class scope.
+ The latter is needed for implicit declarations. */
+
+void
+pushtag (name, type, globalize)
+ tree name, type;
+ int globalize;
+{
+ register struct binding_level *b;
+ tree context = 0;
+ tree c_decl = 0;
+
+ b = inner_binding_level;
+ while (b->tag_transparent
+ || (globalize && b->parm_flag == 2))
+ b = b->level_chain;
+
+ if (toplevel_bindings_p ())
+ b->tags = perm_tree_cons (name, type, b->tags);
+ else
+ b->tags = saveable_tree_cons (name, type, b->tags);
+
+ if (name)
+ {
+ context = type ? TYPE_CONTEXT (type) : NULL_TREE;
+ if (! context && ! globalize)
+ context = current_scope ();
+ if (context)
+ c_decl = TREE_CODE (context) == FUNCTION_DECL
+ ? context : TYPE_MAIN_DECL (context);
+
+#if 0
+ /* Record the identifier as the type's name if it has none. */
+ if (TYPE_NAME (type) == NULL_TREE)
+ TYPE_NAME (type) = name;
+#endif
+
+ /* Do C++ gratuitous typedefing. */
+ if (IDENTIFIER_TYPE_VALUE (name) != type)
+ {
+ register tree d;
+ int newdecl = 0;
+
+ if (b->parm_flag != 2
+ || TYPE_SIZE (current_class_type) != NULL_TREE)
+ {
+ d = lookup_nested_type (type, c_decl);
+
+ if (d == NULL_TREE)
+ {
+ newdecl = 1;
+#if 0 /* not yet, should get fixed properly later */
+ d = make_type_decl (name, type);
+#else
+ d = build_decl (TYPE_DECL, name, type);
+ DECL_ASSEMBLER_NAME (d) = current_namespace_id (DECL_ASSEMBLER_NAME (d));
+#endif
+ SET_DECL_ARTIFICIAL (d);
+#ifdef DWARF_DEBUGGING_INFO
+ if (write_symbols == DWARF_DEBUG)
+ {
+ /* Mark the TYPE_DECL node we created just above as an
+ gratuitous one. We need to do this so that dwarfout.c
+ will understand that it is not supposed to output a
+ TAG_typedef DIE for it. */
+ DECL_IGNORED_P (d) = 1;
+ }
+#endif /* DWARF_DEBUGGING_INFO */
+ set_identifier_type_value_with_scope (name, type, b);
+ }
+ else
+ d = TYPE_NAME (d);
+
+ TYPE_NAME (type) = d;
+
+ /* If it is anonymous, then we are called from pushdecl,
+ and we don't want to infinitely recurse. */
+ if (! ANON_AGGRNAME_P (name))
+ {
+ if (b->parm_flag == 2)
+ d = pushdecl_class_level (d);
+ else
+ d = pushdecl_with_scope (d, b);
+ }
+ }
+ else
+ {
+ /* Make nested declarations go into class-level scope. */
+ newdecl = 1;
+ d = build_decl (TYPE_DECL, name, type);
+ SET_DECL_ARTIFICIAL (d);
+#ifdef DWARF_DEBUGGING_INFO
+ if (write_symbols == DWARF_DEBUG)
+ {
+ /* Mark the TYPE_DECL node we created just above as an
+ gratuitous one. We need to do this so that dwarfout.c
+ will understand that it is not supposed to output a
+ TAG_typedef DIE for it. */
+ DECL_IGNORED_P (d) = 1;
+ }
+#endif /* DWARF_DEBUGGING_INFO */
+
+ TYPE_MAIN_DECL (type) = d;
+
+ /* Make sure we're in this type's scope when we push the
+ decl for a template, otherwise class_binding_level will
+ be NULL and we'll end up dying inside of
+ push_class_level_binding. */
+ if (TREE_CODE (type) == UNINSTANTIATED_P_TYPE)
+ pushclass (type, 0);
+ d = pushdecl_class_level (d);
+ if (TREE_CODE (type) == UNINSTANTIATED_P_TYPE)
+ popclass (0);
+ }
+ if (newdecl)
+ {
+ if (write_symbols != DWARF_DEBUG)
+ {
+ if (ANON_AGGRNAME_P (name))
+ DECL_IGNORED_P (d) = 1;
+ }
+
+ if (context == NULL_TREE)
+ /* Non-nested class. */
+ set_nested_typename (d, NULL_TREE, name, type);
+ else if (context && TREE_CODE (context) == FUNCTION_DECL)
+ /* Function-nested class. */
+ set_nested_typename (d, DECL_ASSEMBLER_NAME (c_decl),
+ name, type);
+ else /* if (context && IS_AGGR_TYPE (context)) */
+ /* Class-nested class. */
+ set_nested_typename (d, DECL_NESTED_TYPENAME (c_decl),
+ name, type);
+
+ DECL_CONTEXT (d) = context;
+ TYPE_CONTEXT (type) = DECL_CONTEXT (d);
+ DECL_ASSEMBLER_NAME (d)
+ = get_identifier (build_overload_name (type, 1, 1));
+ }
+ }
+ if (b->parm_flag == 2)
+ {
+ TREE_NONLOCAL_FLAG (type) = 1;
+ if (TYPE_SIZE (current_class_type) == NULL_TREE)
+ CLASSTYPE_TAGS (current_class_type) = b->tags;
+ }
+ }
+
+ if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
+ /* Use the canonical TYPE_DECL for this node. */
+ TYPE_STUB_DECL (type) = TYPE_NAME (type);
+ else
+ {
+ /* Create a fake NULL-named TYPE_DECL node whose TREE_TYPE
+ will be the tagged type we just added to the current
+ binding level. This fake NULL-named TYPE_DECL node helps
+ dwarfout.c to know when it needs to output a
+ representation of a tagged type, and it also gives us a
+ convenient place to record the "scope start" address for
+ the tagged type. */
+
+#if 0 /* not yet, should get fixed properly later */
+ tree d = make_type_decl (NULL_TREE, type);
+#else
+ tree d = build_decl (TYPE_DECL, NULL_TREE, type);
+#endif
+ TYPE_STUB_DECL (type) = pushdecl_with_scope (d, b);
+ }
+}
+
+/* Counter used to create anonymous type names. */
+static int anon_cnt = 0;
+
+/* Return an IDENTIFIER which can be used as a name for
+ anonymous structs and unions. */
+tree
+make_anon_name ()
+{
+ char buf[32];
+
+ sprintf (buf, ANON_AGGRNAME_FORMAT, anon_cnt++);
+ return get_identifier (buf);
+}
+
+/* Clear the TREE_PURPOSE slot of tags which have anonymous typenames.
+ This keeps dbxout from getting confused. */
+void
+clear_anon_tags ()
+{
+ register struct binding_level *b;
+ register tree tags;
+ static int last_cnt = 0;
+
+ /* Fast out if no new anon names were declared. */
+ if (last_cnt == anon_cnt)
+ return;
+
+ b = current_binding_level;
+ while (b->tag_transparent)
+ b = b->level_chain;
+ tags = b->tags;
+ while (tags)
+ {
+ /* A NULL purpose means we have already processed all tags
+ from here to the end of the list. */
+ if (TREE_PURPOSE (tags) == NULL_TREE)
+ break;
+ if (ANON_AGGRNAME_P (TREE_PURPOSE (tags)))
+ TREE_PURPOSE (tags) = NULL_TREE;
+ tags = TREE_CHAIN (tags);
+ }
+ last_cnt = anon_cnt;
+}
+
+/* Subroutine of duplicate_decls: return truthvalue of whether
+ or not types of these decls match.
+
+ For C++, we must compare the parameter list so that `int' can match
+ `int&' in a parameter position, but `int&' is not confused with
+ `const int&'. */
+int
+decls_match (newdecl, olddecl)
+ tree newdecl, olddecl;
+{
+ int types_match;
+
+ if (TREE_CODE (newdecl) == FUNCTION_DECL
+ && TREE_CODE (olddecl) == FUNCTION_DECL)
+ {
+ tree f1 = TREE_TYPE (newdecl);
+ tree f2 = TREE_TYPE (olddecl);
+ tree p1 = TYPE_ARG_TYPES (f1);
+ tree p2 = TYPE_ARG_TYPES (f2);
+
+ /* When we parse a static member function definition,
+ we put together a FUNCTION_DECL which thinks its type
+ is METHOD_TYPE. Change that to FUNCTION_TYPE, and
+ proceed. */
+ if (TREE_CODE (f1) == METHOD_TYPE && DECL_STATIC_FUNCTION_P (olddecl))
+ revert_static_member_fn (&newdecl, &f1, &p1);
+ else if (TREE_CODE (f2) == METHOD_TYPE
+ && DECL_STATIC_FUNCTION_P (newdecl))
+ revert_static_member_fn (&olddecl, &f2, &p2);
+
+ /* Here we must take care of the case where new default
+ parameters are specified. Also, warn if an old
+ declaration becomes ambiguous because default
+ parameters may cause the two to be ambiguous. */
+ if (TREE_CODE (f1) != TREE_CODE (f2))
+ {
+ if (TREE_CODE (f1) == OFFSET_TYPE)
+ cp_compiler_error ("`%D' redeclared as member function", newdecl);
+ else
+ cp_compiler_error ("`%D' redeclared as non-member function", newdecl);
+ return 0;
+ }
+
+ if (comptypes (TREE_TYPE (f1), TREE_TYPE (f2), 1))
+ {
+ if (! strict_prototypes_lang_c && DECL_LANGUAGE (olddecl) == lang_c
+ && p2 == NULL_TREE)
+ {
+ types_match = self_promoting_args_p (p1);
+ if (p1 == void_list_node)
+ TREE_TYPE (newdecl) = TREE_TYPE (olddecl);
+ }
+ else if (!strict_prototypes_lang_c && DECL_LANGUAGE (olddecl)==lang_c
+ && DECL_LANGUAGE (newdecl) == lang_c && p1 == NULL_TREE)
+ {
+ types_match = self_promoting_args_p (p2);
+ TREE_TYPE (newdecl) = TREE_TYPE (olddecl);
+ }
+ else
+ types_match = compparms (p1, p2, 3);
+ }
+ else
+ types_match = 0;
+ }
+ else if (TREE_CODE (newdecl) == TEMPLATE_DECL
+ && TREE_CODE (olddecl) == TEMPLATE_DECL)
+ {
+ tree newargs = DECL_TEMPLATE_PARMS (newdecl);
+ tree oldargs = DECL_TEMPLATE_PARMS (olddecl);
+ int i, len = TREE_VEC_LENGTH (newargs);
+
+ if (TREE_VEC_LENGTH (oldargs) != len)
+ return 0;
+
+ for (i = 0; i < len; i++)
+ {
+ tree newarg = TREE_VALUE (TREE_VEC_ELT (newargs, i));
+ tree oldarg = TREE_VALUE (TREE_VEC_ELT (oldargs, i));
+ if (TREE_CODE (newarg) != TREE_CODE (oldarg))
+ return 0;
+ else if (TREE_CODE (newarg) == TYPE_DECL)
+ /* continue */;
+ else if (! comptypes (TREE_TYPE (newarg), TREE_TYPE (oldarg), 1))
+ return 0;
+ }
+
+ if (DECL_TEMPLATE_IS_CLASS (newdecl)
+ != DECL_TEMPLATE_IS_CLASS (olddecl))
+ types_match = 0;
+ else if (DECL_TEMPLATE_IS_CLASS (newdecl))
+ types_match = 1;
+ else
+ types_match = decls_match (DECL_TEMPLATE_RESULT (olddecl),
+ DECL_TEMPLATE_RESULT (newdecl));
+ }
+ else
+ {
+ if (TREE_TYPE (newdecl) == error_mark_node)
+ types_match = TREE_TYPE (olddecl) == error_mark_node;
+ else if (TREE_TYPE (olddecl) == NULL_TREE)
+ types_match = TREE_TYPE (newdecl) == NULL_TREE;
+ else if (TREE_TYPE (newdecl) == NULL_TREE)
+ types_match = 0;
+ else
+ types_match = comptypes (TREE_TYPE (newdecl), TREE_TYPE (olddecl), 1);
+ }
+
+ return types_match;
+}
+
+/* If NEWDECL is `static' and an `extern' was seen previously,
+ warn about it. (OLDDECL may be NULL_TREE; NAME contains
+ information about previous usage as an `extern'.)
+
+ Note that this does not apply to the C++ case of declaring
+ a variable `extern const' and then later `const'.
+
+ Don't complain if -traditional, since traditional compilers
+ don't complain.
+
+ Don't complain about built-in functions, since they are beyond
+ the user's control. */
+
+static void
+warn_extern_redeclared_static (newdecl, olddecl)
+ tree newdecl, olddecl;
+{
+ tree name;
+
+ static char *explicit_extern_static_warning
+ = "`%D' was declared `extern' and later `static'";
+ static char *implicit_extern_static_warning
+ = "`%D' was declared implicitly `extern' and later `static'";
+
+ if (flag_traditional
+ || TREE_CODE (newdecl) == TYPE_DECL)
+ return;
+
+ name = DECL_ASSEMBLER_NAME (newdecl);
+ if (TREE_PUBLIC (name) && DECL_THIS_STATIC (newdecl))
+ {
+ /* It's okay to redeclare an ANSI built-in function as static,
+ or to declare a non-ANSI built-in function as anything. */
+ if (! (TREE_CODE (newdecl) == FUNCTION_DECL
+ && olddecl != NULL_TREE
+ && TREE_CODE (olddecl) == FUNCTION_DECL
+ && (DECL_BUILT_IN (olddecl)
+ || DECL_BUILT_IN_NONANSI (olddecl))))
+ {
+ cp_pedwarn (IDENTIFIER_IMPLICIT_DECL (name)
+ ? implicit_extern_static_warning
+ : explicit_extern_static_warning, newdecl);
+ if (olddecl != NULL_TREE)
+ cp_pedwarn_at ("previous declaration of `%D'", olddecl);
+ }
+ }
+}
+
+/* Handle when a new declaration NEWDECL has the same name as an old
+ one OLDDECL in the same binding contour. Prints an error message
+ if appropriate.
+
+ If safely possible, alter OLDDECL to look like NEWDECL, and return 1.
+ Otherwise, return 0. */
+
+int
+duplicate_decls (newdecl, olddecl)
+ register tree newdecl, olddecl;
+{
+ extern struct obstack permanent_obstack;
+ unsigned olddecl_uid = DECL_UID (olddecl);
+ int olddecl_friend = 0, types_match = 0;
+ int new_defines_function;
+ tree previous_c_decl = NULL_TREE;
+
+ if (TREE_CODE_CLASS (TREE_CODE (olddecl)) == 'd')
+ DECL_MACHINE_ATTRIBUTES (newdecl) = DECL_MACHINE_ATTRIBUTES (olddecl);
+
+ types_match = decls_match (newdecl, olddecl);
+
+ if (TREE_CODE (olddecl) != TREE_LIST)
+ olddecl_friend = DECL_LANG_SPECIFIC (olddecl) && DECL_FRIEND_P (olddecl);
+
+ /* If either the type of the new decl or the type of the old decl is an
+ error_mark_node, then that implies that we have already issued an
+ error (earlier) for some bogus type specification, and in that case,
+ it is rather pointless to harass the user with yet more error message
+ about the same declaration, so well just pretent the types match here. */
+ if ((TREE_TYPE (newdecl)
+ && TREE_CODE (TREE_TYPE (newdecl)) == ERROR_MARK)
+ || (TREE_TYPE (olddecl)
+ && TREE_CODE (TREE_TYPE (olddecl)) == ERROR_MARK))
+ types_match = 1;
+
+ if (flag_traditional && TREE_CODE (newdecl) == FUNCTION_DECL
+ && IDENTIFIER_IMPLICIT_DECL (DECL_ASSEMBLER_NAME (newdecl)) == olddecl)
+ /* If -traditional, avoid error for redeclaring fcn
+ after implicit decl. */
+ ;
+ else if (TREE_CODE (olddecl) == FUNCTION_DECL
+ && DECL_ARTIFICIAL (olddecl)
+ && (DECL_BUILT_IN (olddecl) || DECL_BUILT_IN_NONANSI (olddecl)))
+ {
+ /* If you declare a built-in or predefined function name as static,
+ the old definition is overridden, but optionally warn this was a
+ bad choice of name. Ditto for overloads. */
+ if (! DECL_PUBLIC (newdecl)
+ || (TREE_CODE (newdecl) == FUNCTION_DECL
+ && DECL_LANGUAGE (newdecl) != DECL_LANGUAGE (olddecl)))
+ {
+ if (warn_shadow)
+ cp_warning ("shadowing %s function `%#D'",
+ DECL_BUILT_IN (olddecl) ? "built-in" : "library",
+ olddecl);
+ /* Discard the old built-in function. */
+ return 0;
+ }
+ else if (! types_match)
+ {
+ if (TREE_CODE (newdecl) != FUNCTION_DECL)
+ {
+ /* If the built-in is not ansi, then programs can override
+ it even globally without an error. */
+ if (! DECL_BUILT_IN (olddecl))
+ cp_warning ("library function `%#D' redeclared as non-function `%#D'",
+ olddecl, newdecl);
+ else
+ {
+ cp_error ("declaration of `%#D'", newdecl);
+ cp_error ("conflicts with built-in declaration `%#D'",
+ olddecl);
+ }
+ return 0;
+ }
+
+ cp_warning ("declaration of `%#D'", newdecl);
+ cp_warning ("conflicts with built-in declaration `%#D'",
+ olddecl);
+ }
+ }
+ else if (TREE_CODE (olddecl) != TREE_CODE (newdecl))
+ {
+ if ((TREE_CODE (newdecl) == FUNCTION_DECL
+ && TREE_CODE (olddecl) == TEMPLATE_DECL
+ && ! DECL_TEMPLATE_IS_CLASS (olddecl))
+ || (TREE_CODE (olddecl) == FUNCTION_DECL
+ && TREE_CODE (newdecl) == TEMPLATE_DECL
+ && ! DECL_TEMPLATE_IS_CLASS (newdecl)))
+ return 0;
+
+ cp_error ("`%#D' redeclared as different kind of symbol", newdecl);
+ if (TREE_CODE (olddecl) == TREE_LIST)
+ olddecl = TREE_VALUE (olddecl);
+ cp_error_at ("previous declaration of `%#D'", olddecl);
+
+ /* New decl is completely inconsistent with the old one =>
+ tell caller to replace the old one. */
+
+ return 0;
+ }
+ else if (!types_match)
+ {
+ if (TREE_CODE (newdecl) == TEMPLATE_DECL)
+ {
+ /* The name of a class template may not be declared to refer to
+ any other template, class, function, object, namespace, value,
+ or type in the same scope. */
+ if (DECL_TEMPLATE_IS_CLASS (olddecl)
+ || DECL_TEMPLATE_IS_CLASS (newdecl))
+ {
+ cp_error ("declaration of template `%#D'", newdecl);
+ cp_error_at ("conflicts with previous declaration `%#D'",
+ olddecl);
+ }
+ return 0;
+ }
+ if (TREE_CODE (newdecl) == FUNCTION_DECL)
+ {
+ if (DECL_LANGUAGE (newdecl) == lang_c
+ && DECL_LANGUAGE (olddecl) == lang_c)
+ {
+ cp_error ("declaration of C function `%#D' conflicts with",
+ newdecl);
+ cp_error_at ("previous declaration `%#D' here", olddecl);
+ }
+ else if (compparms (TYPE_ARG_TYPES (TREE_TYPE (newdecl)),
+ TYPE_ARG_TYPES (TREE_TYPE (olddecl)), 3))
+ {
+ cp_error ("new declaration `%#D'", newdecl);
+ cp_error_at ("ambiguates old declaration `%#D'", olddecl);
+ }
+ else
+ return 0;
+ }
+
+ /* Already complained about this, so don't do so again. */
+ else if (current_class_type == NULL_TREE
+ || IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (newdecl)) != current_class_type)
+ {
+ cp_error ("conflicting types for `%#D'", newdecl);
+ cp_error_at ("previous declaration as `%#D'", olddecl);
+ }
+ }
+ else
+ {
+ char *errmsg = redeclaration_error_message (newdecl, olddecl);
+ if (errmsg)
+ {
+ cp_error (errmsg, newdecl);
+ if (DECL_NAME (olddecl) != NULL_TREE)
+ cp_error_at ((DECL_INITIAL (olddecl)
+ && current_binding_level == global_binding_level)
+ ? "`%#D' previously defined here"
+ : "`%#D' previously declared here", olddecl);
+ }
+ else if (TREE_CODE (olddecl) == FUNCTION_DECL
+ && DECL_INITIAL (olddecl) != NULL_TREE
+ && TYPE_ARG_TYPES (TREE_TYPE (olddecl)) == NULL_TREE
+ && TYPE_ARG_TYPES (TREE_TYPE (newdecl)) != NULL_TREE)
+ {
+ /* Prototype decl follows defn w/o prototype. */
+ cp_warning_at ("prototype for `%#D'", newdecl);
+ cp_warning_at ("follows non-prototype definition here", olddecl);
+ }
+ else if (TREE_CODE (olddecl) == FUNCTION_DECL
+ && DECL_LANGUAGE (newdecl) != DECL_LANGUAGE (olddecl))
+ {
+ /* extern "C" int foo ();
+ int foo () { bar (); }
+ is OK. */
+ if (current_lang_stack == current_lang_base)
+ DECL_LANGUAGE (newdecl) = DECL_LANGUAGE (olddecl);
+ else
+ {
+ cp_error_at ("previous declaration of `%#D' with %L linkage",
+ olddecl, DECL_LANGUAGE (olddecl));
+ cp_error ("conflicts with new declaration with %L linkage",
+ DECL_LANGUAGE (newdecl));
+ }
+ }
+
+ if (TREE_CODE (olddecl) == FUNCTION_DECL)
+ {
+ tree t1 = TYPE_ARG_TYPES (TREE_TYPE (olddecl));
+ tree t2 = TYPE_ARG_TYPES (TREE_TYPE (newdecl));
+ int i = 1;
+
+ if (TREE_CODE (TREE_TYPE (newdecl)) == METHOD_TYPE)
+ t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2);
+
+ for (; t1 && t1 != void_list_node;
+ t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2), i++)
+ if (TREE_PURPOSE (t1) && TREE_PURPOSE (t2))
+ {
+ if (1 == simple_cst_equal (TREE_PURPOSE (t1),
+ TREE_PURPOSE (t2)))
+ {
+ if (pedantic)
+ {
+ cp_pedwarn ("default argument given for parameter %d of `%#D'",
+ i, newdecl);
+ cp_pedwarn_at ("after previous specification in `%#D'",
+ olddecl);
+ }
+ }
+ else
+ {
+ cp_error ("default argument given for parameter %d of `%#D'",
+ i, newdecl);
+ cp_error_at ("conflicts with previous specification in `%#D'",
+ olddecl);
+ }
+ }
+
+ if (DECL_THIS_INLINE (newdecl) && ! DECL_THIS_INLINE (olddecl))
+ {
+#if 0 /* I think this will be correct, but it's really annoying. We should
+ fix the compiler to find vtables by indirection so it isn't
+ necessary. (jason 8/25/95) */
+ if (DECL_VINDEX (olddecl) && ! DECL_ABSTRACT_VIRTUAL_P (olddecl))
+ {
+ cp_pedwarn ("virtual function `%#D' redeclared inline",
+ newdecl);
+ cp_pedwarn_at ("previous non-inline declaration here",
+ olddecl);
+ }
+ else
+#endif
+ if (TREE_ADDRESSABLE (olddecl))
+ {
+ cp_pedwarn ("`%#D' was used before it was declared inline",
+ newdecl);
+ cp_pedwarn_at ("previous non-inline declaration here",
+ olddecl);
+ }
+ }
+ }
+ /* These bits are logically part of the type for non-functions. */
+ else if (TREE_READONLY (newdecl) != TREE_READONLY (olddecl)
+ || TREE_THIS_VOLATILE (newdecl) != TREE_THIS_VOLATILE (olddecl))
+ {
+ cp_pedwarn ("type qualifiers for `%#D'", newdecl);
+ cp_pedwarn_at ("conflict with previous decl `%#D'", olddecl);
+ }
+ }
+
+ /* If new decl is `static' and an `extern' was seen previously,
+ warn about it. */
+ warn_extern_redeclared_static (newdecl, olddecl);
+
+ /* We have committed to returning 1 at this point. */
+ if (TREE_CODE (newdecl) == FUNCTION_DECL)
+ {
+ /* Now that functions must hold information normally held
+ by field decls, there is extra work to do so that
+ declaration information does not get destroyed during
+ definition. */
+ if (DECL_VINDEX (olddecl))
+ DECL_VINDEX (newdecl) = DECL_VINDEX (olddecl);
+ if (DECL_CONTEXT (olddecl))
+ DECL_CONTEXT (newdecl) = DECL_CONTEXT (olddecl);
+ if (DECL_CLASS_CONTEXT (olddecl))
+ DECL_CLASS_CONTEXT (newdecl) = DECL_CLASS_CONTEXT (olddecl);
+ if (DECL_CHAIN (newdecl) == NULL_TREE)
+ DECL_CHAIN (newdecl) = DECL_CHAIN (olddecl);
+ if (DECL_NEXT_METHOD (newdecl) == NULL_TREE)
+ DECL_NEXT_METHOD (newdecl) = DECL_NEXT_METHOD (olddecl);
+ if (DECL_PENDING_INLINE_INFO (newdecl) == (struct pending_inline *)0)
+ DECL_PENDING_INLINE_INFO (newdecl) = DECL_PENDING_INLINE_INFO (olddecl);
+ DECL_STATIC_CONSTRUCTOR (newdecl) |= DECL_STATIC_CONSTRUCTOR (olddecl);
+ DECL_STATIC_DESTRUCTOR (newdecl) |= DECL_STATIC_DESTRUCTOR (olddecl);
+ DECL_ABSTRACT_VIRTUAL_P (newdecl) |= DECL_ABSTRACT_VIRTUAL_P (olddecl);
+ }
+
+ /* Deal with C++: must preserve virtual function table size. */
+ if (TREE_CODE (olddecl) == TYPE_DECL)
+ {
+ register tree newtype = TREE_TYPE (newdecl);
+ register tree oldtype = TREE_TYPE (olddecl);
+
+ DECL_NESTED_TYPENAME (newdecl) = DECL_NESTED_TYPENAME (olddecl);
+
+ if (newtype != error_mark_node && oldtype != error_mark_node
+ && TYPE_LANG_SPECIFIC (newtype) && TYPE_LANG_SPECIFIC (oldtype))
+ {
+ CLASSTYPE_VSIZE (newtype) = CLASSTYPE_VSIZE (oldtype);
+ CLASSTYPE_FRIEND_CLASSES (newtype)
+ = CLASSTYPE_FRIEND_CLASSES (oldtype);
+ }
+#if 0
+ /* why assert here? Just because debugging information is
+ messed up? (mrs) */
+ /* it happens on something like:
+ typedef struct Thing {
+ Thing();
+ int x;
+ } Thing;
+ */
+ my_friendly_assert (DECL_IGNORED_P (olddecl) == DECL_IGNORED_P (newdecl),
+ 139);
+#endif
+ }
+
+ /* Special handling ensues if new decl is a function definition. */
+ new_defines_function = (TREE_CODE (newdecl) == FUNCTION_DECL
+ && DECL_INITIAL (newdecl) != NULL_TREE);
+
+ /* Optionally warn about more than one declaration for the same name,
+ but don't warn about a function declaration followed by a definition. */
+ if (warn_redundant_decls
+ && ! DECL_ARTIFICIAL (olddecl)
+ && !(new_defines_function && DECL_INITIAL (olddecl) == NULL_TREE)
+ /* Don't warn about extern decl followed by (tentative) definition. */
+ && !(DECL_EXTERNAL (olddecl) && ! DECL_EXTERNAL (newdecl)))
+ {
+ cp_warning ("redundant redeclaration of `%D' in same scope", newdecl);
+ cp_warning_at ("previous declaration of `%D'", olddecl);
+ }
+
+ /* Copy all the DECL_... slots specified in the new decl
+ except for any that we copy here from the old type. */
+
+ if (types_match)
+ {
+ /* Automatically handles default parameters. */
+ tree oldtype = TREE_TYPE (olddecl);
+ tree newtype;
+
+ /* Make sure we put the new type in the same obstack as the old one. */
+ if (oldtype)
+ push_obstacks (TYPE_OBSTACK (oldtype), TYPE_OBSTACK (oldtype));
+ else
+ {
+ push_obstacks_nochange ();
+ end_temporary_allocation ();
+ }
+
+ /* Merge the data types specified in the two decls. */
+ newtype = common_type (TREE_TYPE (newdecl), TREE_TYPE (olddecl));
+
+ if (TREE_CODE (newdecl) == VAR_DECL)
+ DECL_THIS_EXTERN (newdecl) |= DECL_THIS_EXTERN (olddecl);
+ /* Do this after calling `common_type' so that default
+ parameters don't confuse us. */
+ else if (TREE_CODE (newdecl) == FUNCTION_DECL
+ && (TYPE_RAISES_EXCEPTIONS (TREE_TYPE (newdecl))
+ != TYPE_RAISES_EXCEPTIONS (TREE_TYPE (olddecl))))
+ {
+ tree ctype = NULL_TREE;
+ ctype = DECL_CLASS_CONTEXT (newdecl);
+ TREE_TYPE (newdecl) = build_exception_variant (newtype,
+ TYPE_RAISES_EXCEPTIONS (TREE_TYPE (newdecl)));
+ TREE_TYPE (olddecl) = build_exception_variant (newtype,
+ TYPE_RAISES_EXCEPTIONS (oldtype));
+
+ if (! compexcepttypes (TREE_TYPE (newdecl), TREE_TYPE (olddecl), 0))
+ {
+ cp_error ("declaration of `%D' throws different exceptions...",
+ newdecl);
+ cp_error_at ("...from previous declaration here", olddecl);
+ }
+ }
+ TREE_TYPE (newdecl) = TREE_TYPE (olddecl) = newtype;
+
+ /* Lay the type out, unless already done. */
+ if (oldtype != TREE_TYPE (newdecl)
+ && TREE_TYPE (newdecl) != error_mark_node)
+ layout_type (TREE_TYPE (newdecl));
+
+ if (TREE_CODE (newdecl) == VAR_DECL
+ || TREE_CODE (newdecl) == PARM_DECL
+ || TREE_CODE (newdecl) == RESULT_DECL
+ || TREE_CODE (newdecl) == FIELD_DECL
+ || TREE_CODE (newdecl) == TYPE_DECL)
+ layout_decl (newdecl, 0);
+
+ /* Merge the type qualifiers. */
+ if (TREE_READONLY (newdecl))
+ TREE_READONLY (olddecl) = 1;
+ if (TREE_THIS_VOLATILE (newdecl))
+ TREE_THIS_VOLATILE (olddecl) = 1;
+
+ /* Merge the initialization information. */
+ if (DECL_INITIAL (newdecl) == NULL_TREE
+ && DECL_INITIAL (olddecl) != NULL_TREE)
+ {
+ DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
+ DECL_SOURCE_FILE (newdecl) = DECL_SOURCE_FILE (olddecl);
+ DECL_SOURCE_LINE (newdecl) = DECL_SOURCE_LINE (olddecl);
+ }
+
+ /* Merge the section attribute.
+ We want to issue an error if the sections conflict but that must be
+ done later in decl_attributes since we are called before attributes
+ are assigned. */
+ if (DECL_SECTION_NAME (newdecl) == NULL_TREE)
+ DECL_SECTION_NAME (newdecl) = DECL_SECTION_NAME (olddecl);
+
+ /* Keep the old rtl since we can safely use it, unless it's the
+ call to abort() used for abstract virtuals. */
+ if ((DECL_LANG_SPECIFIC (olddecl)
+ && !DECL_ABSTRACT_VIRTUAL_P (olddecl))
+ || DECL_RTL (olddecl) != DECL_RTL (abort_fndecl))
+ DECL_RTL (newdecl) = DECL_RTL (olddecl);
+
+ pop_obstacks ();
+ }
+ /* If cannot merge, then use the new type and qualifiers,
+ and don't preserve the old rtl. */
+ else
+ {
+ /* Clean out any memory we had of the old declaration. */
+ tree oldstatic = value_member (olddecl, static_aggregates);
+ if (oldstatic)
+ TREE_VALUE (oldstatic) = error_mark_node;
+
+ TREE_TYPE (olddecl) = TREE_TYPE (newdecl);
+ TREE_READONLY (olddecl) = TREE_READONLY (newdecl);
+ TREE_THIS_VOLATILE (olddecl) = TREE_THIS_VOLATILE (newdecl);
+ TREE_SIDE_EFFECTS (olddecl) = TREE_SIDE_EFFECTS (newdecl);
+ }
+
+ /* Merge the storage class information. */
+ DECL_WEAK (newdecl) |= DECL_WEAK (olddecl);
+ TREE_PUBLIC (newdecl) = TREE_PUBLIC (olddecl);
+ TREE_STATIC (olddecl) = TREE_STATIC (newdecl) |= TREE_STATIC (olddecl);
+ if (! DECL_EXTERNAL (olddecl))
+ DECL_EXTERNAL (newdecl) = 0;
+
+ if (TREE_CODE (newdecl) == FUNCTION_DECL)
+ {
+ DECL_C_STATIC (newdecl) = DECL_C_STATIC (olddecl);
+ DECL_INTERFACE_KNOWN (newdecl) |= DECL_INTERFACE_KNOWN (olddecl);
+ DECL_NOT_REALLY_EXTERN (newdecl) |= DECL_NOT_REALLY_EXTERN (olddecl);
+ }
+
+ if (TREE_CODE (newdecl) == FUNCTION_DECL)
+ {
+ DECL_THIS_INLINE (newdecl) |= DECL_THIS_INLINE (olddecl);
+
+ /* If either decl says `inline', this fn is inline, unless its
+ definition was passed already. */
+ if (DECL_INLINE (newdecl) && DECL_INITIAL (olddecl) == NULL_TREE)
+ DECL_INLINE (olddecl) = 1;
+ DECL_INLINE (newdecl) = DECL_INLINE (olddecl);
+
+ if (! types_match)
+ {
+ DECL_LANGUAGE (olddecl) = DECL_LANGUAGE (newdecl);
+ DECL_ASSEMBLER_NAME (olddecl) = DECL_ASSEMBLER_NAME (newdecl);
+ DECL_ARGUMENTS (olddecl) = DECL_ARGUMENTS (newdecl);
+ DECL_RESULT (olddecl) = DECL_RESULT (newdecl);
+ DECL_RTL (olddecl) = DECL_RTL (newdecl);
+ }
+ if (new_defines_function)
+ /* If defining a function declared with other language
+ linkage, use the previously declared language linkage. */
+ DECL_LANGUAGE (newdecl) = DECL_LANGUAGE (olddecl);
+ else
+ {
+ /* If redeclaring a builtin function, and not a definition,
+ it stays built in. */
+ if (DECL_BUILT_IN (olddecl))
+ {
+ DECL_BUILT_IN (newdecl) = 1;
+ DECL_FUNCTION_CODE (newdecl) = DECL_FUNCTION_CODE (olddecl);
+ /* If we're keeping the built-in definition, keep the rtl,
+ regardless of declaration matches. */
+ DECL_RTL (newdecl) = DECL_RTL (olddecl);
+ }
+ else
+ DECL_FRAME_SIZE (newdecl) = DECL_FRAME_SIZE (olddecl);
+
+ DECL_RESULT (newdecl) = DECL_RESULT (olddecl);
+ if ((DECL_SAVED_INSNS (newdecl) = DECL_SAVED_INSNS (olddecl)))
+ /* Previously saved insns go together with
+ the function's previous definition. */
+ DECL_INITIAL (newdecl) = DECL_INITIAL (olddecl);
+ /* Don't clear out the arguments if we're redefining a function. */
+ if (DECL_ARGUMENTS (olddecl))
+ DECL_ARGUMENTS (newdecl) = DECL_ARGUMENTS (olddecl);
+ }
+ if (DECL_LANG_SPECIFIC (olddecl))
+ DECL_MAIN_VARIANT (newdecl) = DECL_MAIN_VARIANT (olddecl);
+ }
+
+ if (TREE_CODE (newdecl) == NAMESPACE_DECL)
+ {
+ NAMESPACE_LEVEL (newdecl) = NAMESPACE_LEVEL (olddecl);
+ }
+
+ if (TREE_CODE (newdecl) == TEMPLATE_DECL)
+ {
+ if (DECL_TEMPLATE_INFO (olddecl)->length)
+ DECL_TEMPLATE_INFO (newdecl) = DECL_TEMPLATE_INFO (olddecl);
+ DECL_TEMPLATE_MEMBERS (newdecl) = DECL_TEMPLATE_MEMBERS (olddecl);
+ DECL_TEMPLATE_INSTANTIATIONS (newdecl)
+ = DECL_TEMPLATE_INSTANTIATIONS (olddecl);
+ if (DECL_CHAIN (newdecl) == NULL_TREE)
+ DECL_CHAIN (newdecl) = DECL_CHAIN (olddecl);
+ }
+
+ /* Now preserve various other info from the definition. */
+ TREE_ADDRESSABLE (newdecl) = TREE_ADDRESSABLE (olddecl);
+ TREE_ASM_WRITTEN (newdecl) = TREE_ASM_WRITTEN (olddecl);
+ DECL_COMMON (newdecl) = DECL_COMMON (olddecl);
+ DECL_ASSEMBLER_NAME (newdecl) = DECL_ASSEMBLER_NAME (olddecl);
+
+ /* Don't really know how much of the language-specific
+ values we should copy from old to new. */
+ if (DECL_LANG_SPECIFIC (olddecl))
+ {
+ DECL_IN_AGGR_P (newdecl) = DECL_IN_AGGR_P (olddecl);
+ DECL_ACCESS (newdecl) = DECL_ACCESS (olddecl);
+ DECL_NONCONVERTING_P (newdecl) = DECL_NONCONVERTING_P (olddecl);
+ }
+
+ if (TREE_CODE (newdecl) == FUNCTION_DECL)
+ {
+ int function_size;
+ struct lang_decl *ol = DECL_LANG_SPECIFIC (olddecl);
+ struct lang_decl *nl = DECL_LANG_SPECIFIC (newdecl);
+
+ function_size = sizeof (struct tree_decl);
+
+ bcopy ((char *) newdecl + sizeof (struct tree_common),
+ (char *) olddecl + sizeof (struct tree_common),
+ function_size - sizeof (struct tree_common));
+
+ /* Can we safely free the storage used by newdecl? */
+
+#define ROUND(x) ((x + obstack_alignment_mask (&permanent_obstack)) \
+ & ~ obstack_alignment_mask (&permanent_obstack))
+
+ if ((char *)newdecl + ROUND (function_size)
+ + ROUND (sizeof (struct lang_decl))
+ == obstack_next_free (&permanent_obstack))
+ {
+ DECL_MAIN_VARIANT (newdecl) = olddecl;
+ DECL_LANG_SPECIFIC (olddecl) = ol;
+ bcopy ((char *)nl, (char *)ol, sizeof (struct lang_decl));
+
+ obstack_free (&permanent_obstack, newdecl);
+ }
+ else if (LANG_DECL_PERMANENT (ol))
+ {
+ if (DECL_MAIN_VARIANT (olddecl) == olddecl)
+ {
+ /* Save these lang_decls that would otherwise be lost. */
+ extern tree free_lang_decl_chain;
+ tree free_lang_decl = (tree) ol;
+ TREE_CHAIN (free_lang_decl) = free_lang_decl_chain;
+ free_lang_decl_chain = free_lang_decl;
+ }
+ else
+ {
+ /* Storage leak. */
+ }
+ }
+ }
+ else
+ {
+ bcopy ((char *) newdecl + sizeof (struct tree_common),
+ (char *) olddecl + sizeof (struct tree_common),
+ sizeof (struct tree_decl) - sizeof (struct tree_common)
+ + tree_code_length [(int)TREE_CODE (newdecl)] * sizeof (char *));
+ }
+
+ DECL_UID (olddecl) = olddecl_uid;
+ if (olddecl_friend)
+ DECL_FRIEND_P (olddecl) = 1;
+
+ return 1;
+}
+
+/* Record a decl-node X as belonging to the current lexical scope.
+ Check for errors (such as an incompatible declaration for the same
+ name already seen in the same scope).
+
+ Returns either X or an old decl for the same name.
+ If an old decl is returned, it may have been smashed
+ to agree with what X says. */
+
+tree
+pushdecl (x)
+ tree x;
+{
+ register tree t;
+#if 0 /* not yet, should get fixed properly later */
+ register tree name;
+#else
+ register tree name = DECL_ASSEMBLER_NAME (x);
+#endif
+ register struct binding_level *b = current_binding_level;
+
+#if 0
+ static int nglobals; int len;
+
+ len = list_length (global_binding_level->names);
+ if (len < nglobals)
+ my_friendly_abort (8);
+ else if (len > nglobals)
+ nglobals = len;
+#endif
+
+ if (x != current_function_decl
+ /* Don't change DECL_CONTEXT of virtual methods. */
+ && (TREE_CODE (x) != FUNCTION_DECL || !DECL_VIRTUAL_P (x))
+ && ! DECL_CONTEXT (x))
+ DECL_CONTEXT (x) = current_function_decl;
+ /* A local declaration for a function doesn't constitute nesting. */
+ if (TREE_CODE (x) == FUNCTION_DECL && DECL_INITIAL (x) == 0)
+ DECL_CONTEXT (x) = 0;
+
+#if 0 /* not yet, should get fixed properly later */
+ /* For functions and class static data, we currently look up the encoded
+ form of the name. For types, we want the real name. The former will
+ probably be changed soon, according to MDT. */
+ if (TREE_CODE (x) == FUNCTION_DECL || TREE_CODE (x) == VAR_DECL)
+ name = DECL_ASSEMBLER_NAME (x);
+ else
+ name = DECL_NAME (x);
+#else
+ /* Type are looked up using the DECL_NAME, as that is what the rest of the
+ compiler wants to use. */
+ if (TREE_CODE (x) == TYPE_DECL || TREE_CODE (x) == VAR_DECL
+ || TREE_CODE (x) == NAMESPACE_DECL)
+ name = DECL_NAME (x);
+#endif
+
+ if (name)
+ {
+ char *file;
+ int line;
+
+ t = lookup_name_current_level (name);
+ if (t == error_mark_node)
+ {
+ /* error_mark_node is 0 for a while during initialization! */
+ t = NULL_TREE;
+ cp_error_at ("`%#D' used prior to declaration", x);
+ }
+
+ else if (t != NULL_TREE)
+ {
+ file = DECL_SOURCE_FILE (t);
+ line = DECL_SOURCE_LINE (t);
+ if (TREE_CODE (x) == VAR_DECL && DECL_DEAD_FOR_LOCAL (x))
+ ; /* This is OK. */
+ else if (TREE_CODE (t) == PARM_DECL)
+ {
+ if (DECL_CONTEXT (t) == NULL_TREE)
+ fatal ("parse errors have confused me too much");
+ }
+ else if (((TREE_CODE (x) == FUNCTION_DECL && DECL_LANGUAGE (x) == lang_c)
+ || (TREE_CODE (x) == TEMPLATE_DECL
+ && ! DECL_TEMPLATE_IS_CLASS (x)))
+ && is_overloaded_fn (t))
+ /* don't do anything just yet */;
+ else if (t == wchar_decl_node)
+ {
+ if (pedantic && ! DECL_IN_SYSTEM_HEADER (x))
+ cp_pedwarn ("redeclaration of wchar_t as `%T'", TREE_TYPE (x));
+
+ /* Throw away the redeclaration. */
+ return t;
+ }
+ else if (TREE_CODE (t) != TREE_CODE (x))
+ {
+ if ((TREE_CODE (t) == TYPE_DECL && DECL_ARTIFICIAL (t))
+ || (TREE_CODE (x) == TYPE_DECL && DECL_ARTIFICIAL (x)))
+ {
+ /* We do nothing special here, because C++ does such nasty
+ things with TYPE_DECLs. Instead, just let the TYPE_DECL
+ get shadowed, and know that if we need to find a TYPE_DECL
+ for a given name, we can look in the IDENTIFIER_TYPE_VALUE
+ slot of the identifier. */
+ ;
+ }
+ else if (duplicate_decls (x, t))
+ return t;
+ }
+ else if (duplicate_decls (x, t))
+ {
+#if 0
+ /* This is turned off until I have time to do it right (bpk). */
+
+ /* Also warn if they did a prototype with `static' on it, but
+ then later left the `static' off. */
+ if (! TREE_PUBLIC (name) && TREE_PUBLIC (x))
+ {
+ if (DECL_LANG_SPECIFIC (t) && DECL_FRIEND_P (t))
+ return t;
+
+ if (extra_warnings)
+ {
+ cp_warning ("`static' missing from declaration of `%D'",
+ t);
+ warning_with_file_and_line (file, line,
+ "previous declaration of `%s'",
+ decl_as_string (t, 0));
+ }
+
+ /* Now fix things so it'll do what they expect. */
+ if (current_function_decl)
+ TREE_PUBLIC (current_function_decl) = 0;
+ }
+ /* Due to interference in memory reclamation (X may be
+ obstack-deallocated at this point), we must guard against
+ one really special case. [jason: This should be handled
+ by start_function] */
+ if (current_function_decl == x)
+ current_function_decl = t;
+#endif
+ if (TREE_CODE (t) == TYPE_DECL)
+ SET_IDENTIFIER_TYPE_VALUE (name, TREE_TYPE (t));
+ else if (TREE_CODE (t) == FUNCTION_DECL)
+ check_default_args (t);
+
+ return t;
+ }
+ }
+
+ if (TREE_CODE (x) == FUNCTION_DECL && ! DECL_FUNCTION_MEMBER_P (x))
+ {
+ t = push_overloaded_decl (x, 1);
+ if (t != x || DECL_LANGUAGE (x) == lang_c)
+ return t;
+ }
+ else if (TREE_CODE (x) == TEMPLATE_DECL && ! DECL_TEMPLATE_IS_CLASS (x))
+ return push_overloaded_decl (x, 0);
+
+ /* If declaring a type as a typedef, and the type has no known
+ typedef name, install this TYPE_DECL as its typedef name. */
+ if (TREE_CODE (x) == TYPE_DECL)
+ {
+ tree type = TREE_TYPE (x);
+ tree name = (type != error_mark_node) ? TYPE_NAME (type) : x;
+
+ if (name == NULL_TREE || TREE_CODE (name) != TYPE_DECL)
+ {
+ /* If these are different names, and we're at the global
+ binding level, make two equivalent definitions. */
+ name = x;
+ if (global_bindings_p ())
+ TYPE_NAME (type) = x;
+ }
+ else
+ {
+ tree tname = DECL_NAME (name);
+
+ /* This is a disgusting kludge for dealing with UPTs. */
+ if (global_bindings_p () && ANON_AGGRNAME_P (tname))
+ {
+ /* do gratuitous C++ typedefing, and make sure that
+ we access this type either through TREE_TYPE field
+ or via the tags list. */
+ TYPE_NAME (TREE_TYPE (x)) = x;
+ pushtag (tname, TREE_TYPE (x), 0);
+ }
+ }
+ my_friendly_assert (TREE_CODE (name) == TYPE_DECL, 140);
+
+ /* Don't set nested_typename on template type parms, for instance.
+ Any artificial decls that need DECL_NESTED_TYPENAME will have it
+ set in pushtag. */
+ if (! DECL_NESTED_TYPENAME (x) && ! DECL_ARTIFICIAL (x))
+ set_nested_typename (x, current_class_name, DECL_NAME (x), type);
+
+ if (type != error_mark_node
+ && TYPE_NAME (type)
+ && TYPE_IDENTIFIER (type))
+ set_identifier_type_value_with_scope (DECL_NAME (x), type, b);
+ }
+
+ /* Multiple external decls of the same identifier ought to match.
+
+ We get warnings about inline functions where they are defined.
+ We get warnings about other functions from push_overloaded_decl.
+
+ Avoid duplicate warnings where they are used. */
+ if (TREE_PUBLIC (x) && TREE_CODE (x) != FUNCTION_DECL)
+ {
+ tree decl;
+
+ if (IDENTIFIER_GLOBAL_VALUE (name) != NULL_TREE
+ && (DECL_EXTERNAL (IDENTIFIER_GLOBAL_VALUE (name))
+ || TREE_PUBLIC (IDENTIFIER_GLOBAL_VALUE (name))))
+ decl = IDENTIFIER_GLOBAL_VALUE (name);
+ else
+ decl = NULL_TREE;
+
+ if (decl
+ /* If different sort of thing, we already gave an error. */
+ && TREE_CODE (decl) == TREE_CODE (x)
+ && ! comptypes (TREE_TYPE (x), TREE_TYPE (decl), 1))
+ {
+ cp_pedwarn ("type mismatch with previous external decl", x);
+ cp_pedwarn_at ("previous external decl of `%#D'", decl);
+ }
+ }
+
+ /* In PCC-compatibility mode, extern decls of vars with no current decl
+ take effect at top level no matter where they are. */
+ if (flag_traditional && DECL_EXTERNAL (x)
+ && lookup_name (name, 0) == NULL_TREE)
+ b = global_binding_level;
+
+ /* This name is new in its binding level.
+ Install the new declaration and return it. */
+ if (b == global_binding_level)
+ {
+ /* Install a global value. */
+
+ /* If the first global decl has external linkage,
+ warn if we later see static one. */
+ if (IDENTIFIER_GLOBAL_VALUE (name) == NULL_TREE && DECL_PUBLIC (x))
+ TREE_PUBLIC (name) = 1;
+
+ /* Don't install an artificial TYPE_DECL if we already have
+ another _DECL with that name. */
+ if (TREE_CODE (x) != TYPE_DECL
+ || t == NULL_TREE
+ || ! DECL_ARTIFICIAL (x))
+ IDENTIFIER_GLOBAL_VALUE (name) = x;
+
+ /* Don't forget if the function was used via an implicit decl. */
+ if (IDENTIFIER_IMPLICIT_DECL (name)
+ && TREE_USED (IDENTIFIER_IMPLICIT_DECL (name)))
+ TREE_USED (x) = 1;
+
+ /* Don't forget if its address was taken in that way. */
+ if (IDENTIFIER_IMPLICIT_DECL (name)
+ && TREE_ADDRESSABLE (IDENTIFIER_IMPLICIT_DECL (name)))
+ TREE_ADDRESSABLE (x) = 1;
+
+ /* Warn about mismatches against previous implicit decl. */
+ if (IDENTIFIER_IMPLICIT_DECL (name) != NULL_TREE
+ /* If this real decl matches the implicit, don't complain. */
+ && ! (TREE_CODE (x) == FUNCTION_DECL
+ && TREE_TYPE (TREE_TYPE (x)) == integer_type_node))
+ cp_warning
+ ("`%D' was previously implicitly declared to return `int'", x);
+
+ /* If new decl is `static' and an `extern' was seen previously,
+ warn about it. */
+ if (x != NULL_TREE && t != NULL_TREE && decls_match (x, t))
+ warn_extern_redeclared_static (x, t);
+ }
+ else
+ {
+ /* Here to install a non-global value. */
+ tree oldlocal = IDENTIFIER_LOCAL_VALUE (name);
+ tree oldglobal = IDENTIFIER_GLOBAL_VALUE (name);
+
+ /* Don't install an artificial TYPE_DECL if we already have
+ another _DECL with that name. */
+ if (TREE_CODE (x) != TYPE_DECL
+ || t == NULL_TREE
+ || ! DECL_ARTIFICIAL (x))
+ {
+ b->shadowed = tree_cons (name, oldlocal, b->shadowed);
+ IDENTIFIER_LOCAL_VALUE (name) = x;
+ }
+
+ /* If this is a TYPE_DECL, push it into the type value slot. */
+ if (TREE_CODE (x) == TYPE_DECL)
+ set_identifier_type_value_with_scope (name, TREE_TYPE (x), b);
+
+ /* Clear out any TYPE_DECL shadowed by a namespace so that
+ we won't think this is a type. The C struct hack doesn't
+ go through namespaces. */
+ if (TREE_CODE (x) == NAMESPACE_DECL)
+ set_identifier_type_value_with_scope (name, NULL_TREE, b);
+
+ /* If this is an extern function declaration, see if we
+ have a global definition or declaration for the function. */
+ if (oldlocal == NULL_TREE
+ && DECL_EXTERNAL (x)
+ && oldglobal != NULL_TREE
+ && TREE_CODE (x) == FUNCTION_DECL
+ && TREE_CODE (oldglobal) == FUNCTION_DECL)
+ {
+ /* We have one. Their types must agree. */
+ if (decls_match (x, oldglobal))
+ /* OK */;
+ else
+ {
+ cp_warning ("extern declaration of `%#D' doesn't match", x);
+ cp_warning_at ("global declaration `%#D'", oldglobal);
+ }
+ }
+ /* If we have a local external declaration,
+ and no file-scope declaration has yet been seen,
+ then if we later have a file-scope decl it must not be static. */
+ if (oldlocal == NULL_TREE
+ && oldglobal == NULL_TREE
+ && DECL_EXTERNAL (x)
+ && TREE_PUBLIC (x))
+ {
+ TREE_PUBLIC (name) = 1;
+ }
+
+ if (DECL_FROM_INLINE (x))
+ /* Inline decls shadow nothing. */;
+
+ /* Warn if shadowing an argument at the top level of the body. */
+ else if (oldlocal != NULL_TREE && !DECL_EXTERNAL (x)
+ && TREE_CODE (oldlocal) == PARM_DECL
+ && TREE_CODE (x) != PARM_DECL)
+ {
+ /* Go to where the parms should be and see if we
+ find them there. */
+ struct binding_level *b = current_binding_level->level_chain;
+
+ if (cleanup_label)
+ b = b->level_chain;
+
+ /* ARM $8.3 */
+ if (b->parm_flag == 1)
+ cp_error ("declaration of `%#D' shadows a parameter", name);
+ }
+ else if (oldlocal != NULL_TREE && b->is_for_scope
+ && !DECL_DEAD_FOR_LOCAL (oldlocal))
+ {
+ warning ("variable `%s' shadows local",
+ IDENTIFIER_POINTER (name));
+ cp_warning_at (" this is the shadowed declaration", oldlocal);
+ }
+ /* Maybe warn if shadowing something else. */
+ else if (warn_shadow && !DECL_EXTERNAL (x)
+ /* No shadow warnings for internally generated vars. */
+ && ! DECL_ARTIFICIAL (x)
+ /* No shadow warnings for vars made for inlining. */
+ && ! DECL_FROM_INLINE (x))
+ {
+ char *warnstring = NULL;
+
+ if (oldlocal != NULL_TREE && TREE_CODE (oldlocal) == PARM_DECL)
+ warnstring = "declaration of `%s' shadows a parameter";
+ else if (IDENTIFIER_CLASS_VALUE (name) != NULL_TREE
+ && current_class_decl
+ && !TREE_STATIC (name))
+ warnstring = "declaration of `%s' shadows a member of `this'";
+ else if (oldlocal != NULL_TREE)
+ warnstring = "declaration of `%s' shadows previous local";
+ else if (oldglobal != NULL_TREE)
+ warnstring = "declaration of `%s' shadows global declaration";
+
+ if (warnstring)
+ warning (warnstring, IDENTIFIER_POINTER (name));
+ }
+ }
+
+ if (TREE_CODE (x) == FUNCTION_DECL)
+ check_default_args (x);
+
+ /* Keep count of variables in this level with incomplete type. */
+ if (TREE_CODE (x) == VAR_DECL
+ && TREE_TYPE (x) != error_mark_node
+ && ((TYPE_SIZE (TREE_TYPE (x)) == NULL_TREE
+ && PROMOTES_TO_AGGR_TYPE (TREE_TYPE (x), ARRAY_TYPE))
+ /* RTTI TD entries are created while defining the type_info. */
+ || (TYPE_LANG_SPECIFIC (TREE_TYPE (x))
+ && TYPE_BEING_DEFINED (TREE_TYPE (x)))))
+ b->incomplete = tree_cons (NULL_TREE, x, b->incomplete);
+ }
+
+ /* Put decls on list in reverse order.
+ We will reverse them later if necessary. */
+ TREE_CHAIN (x) = b->names;
+ b->names = x;
+ if (! (b != global_binding_level || TREE_PERMANENT (x)))
+ my_friendly_abort (124);
+
+ return x;
+}
+
+/* Same as pushdecl, but define X in binding-level LEVEL. */
+
+static tree
+pushdecl_with_scope (x, level)
+ tree x;
+ struct binding_level *level;
+{
+ register struct binding_level *b = current_binding_level;
+
+ current_binding_level = level;
+ x = pushdecl (x);
+ current_binding_level = b;
+ return x;
+}
+
+/* Like pushdecl, only it places X in GLOBAL_BINDING_LEVEL,
+ if appropriate. */
+tree
+pushdecl_top_level (x)
+ tree x;
+{
+ register struct binding_level *b = inner_binding_level;
+ register tree t = pushdecl_with_scope (x, global_binding_level);
+
+ /* Now, the type_shadowed stack may screw us. Munge it so it does
+ what we want. */
+ if (TREE_CODE (x) == TYPE_DECL)
+ {
+ tree name = DECL_NAME (x);
+ tree newval;
+ tree *ptr = (tree *)0;
+ for (; b != global_binding_level; b = b->level_chain)
+ {
+ tree shadowed = b->type_shadowed;
+ for (; shadowed; shadowed = TREE_CHAIN (shadowed))
+ if (TREE_PURPOSE (shadowed) == name)
+ {
+ ptr = &TREE_VALUE (shadowed);
+ /* Can't break out of the loop here because sometimes
+ a binding level will have duplicate bindings for
+ PT names. It's gross, but I haven't time to fix it. */
+ }
+ }
+ newval = TREE_TYPE (x);
+ if (ptr == (tree *)0)
+ {
+ /* @@ This shouldn't be needed. My test case "zstring.cc" trips
+ up here if this is changed to an assertion. --KR */
+ SET_IDENTIFIER_TYPE_VALUE (name, newval);
+ }
+ else
+ {
+#if 0
+ /* Disabled this 11/10/92, since there are many cases which
+ behave just fine when *ptr doesn't satisfy either of these.
+ For example, nested classes declared as friends of their enclosing
+ class will not meet this criteria. (bpk) */
+ my_friendly_assert (*ptr == NULL_TREE || *ptr == newval, 141);
+#endif
+ *ptr = newval;
+ }
+ }
+ return t;
+}
+
+/* Like push_overloaded_decl, only it places X in GLOBAL_BINDING_LEVEL,
+ if appropriate. */
+void
+push_overloaded_decl_top_level (x, forget)
+ tree x;
+ int forget;
+{
+ struct binding_level *b = current_binding_level;
+
+ current_binding_level = global_binding_level;
+ push_overloaded_decl (x, forget);
+ current_binding_level = b;
+}
+
+/* Make the declaration of X appear in CLASS scope. */
+tree
+pushdecl_class_level (x)
+ tree x;
+{
+ /* Don't use DECL_ASSEMBLER_NAME here! Everything that looks in class
+ scope looks for the pre-mangled name. */
+ register tree name = DECL_NAME (x);
+
+ if (name)
+ {
+ if (TYPE_BEING_DEFINED (current_class_type))
+ {
+ /* Check for inconsistent use of this name in the class body.
+ Types, enums, and static vars are checked here; other
+ members are checked in finish_struct. */
+ tree icv = IDENTIFIER_CLASS_VALUE (name);
+
+ if (icv
+ /* Don't complain about inherited names. */
+ && id_in_current_class (name)
+ /* Or shadowed tags. */
+ && !(TREE_CODE (icv) == TYPE_DECL
+ && DECL_CONTEXT (icv) == current_class_type))
+ {
+ cp_error ("declaration of identifier `%D' as `%#D'", name, x);
+ cp_error_at ("conflicts with previous use in class as `%#D'",
+ icv);
+ }
+ }
+
+ push_class_level_binding (name, x);
+ if (TREE_CODE (x) == TYPE_DECL)
+ {
+ set_identifier_type_value (name, TREE_TYPE (x));
+
+ /* Don't set nested_typename on template type parms, for instance.
+ Any artificial decls that need DECL_NESTED_TYPENAME will have it
+ set in pushtag. */
+ if (! DECL_NESTED_TYPENAME (x) && ! DECL_ARTIFICIAL (x))
+ set_nested_typename (x, current_class_name, name, TREE_TYPE (x));
+ }
+ }
+ return x;
+}
+
+/* This function is used to push the mangled decls for nested types into
+ the appropriate scope. Previously pushdecl_top_level was used, but that
+ is incorrect for members of local classes. */
+tree
+pushdecl_nonclass_level (x)
+ tree x;
+{
+ struct binding_level *b = current_binding_level;
+
+#if 0
+ /* Get out of class scope -- this isn't necessary, because class scope
+ doesn't make it into current_binding_level. */
+ while (b->parm_flag == 2)
+ b = b->level_chain;
+#else
+ my_friendly_assert (b->parm_flag != 2, 180);
+#endif
+
+ /* Get out of template binding levels */
+ while (b->pseudo_global)
+ b = b->level_chain;
+
+ pushdecl_with_scope (x, b);
+}
+
+/* Make the declaration(s) of X appear in CLASS scope
+ under the name NAME. */
+void
+push_class_level_binding (name, x)
+ tree name;
+ tree x;
+{
+ if (TREE_CODE (x) == TYPE_DECL && DECL_ARTIFICIAL (x)
+ && purpose_member (name, class_binding_level->class_shadowed))
+ return;
+
+ maybe_push_cache_obstack ();
+ class_binding_level->class_shadowed
+ = tree_cons (name, IDENTIFIER_CLASS_VALUE (name),
+ class_binding_level->class_shadowed);
+ pop_obstacks ();
+ IDENTIFIER_CLASS_VALUE (name) = x;
+ obstack_ptr_grow (&decl_obstack, x);
+}
+
+/* Tell caller how to interpret a TREE_LIST which contains
+ chains of FUNCTION_DECLS. */
+int
+overloaded_globals_p (list)
+ tree list;
+{
+ my_friendly_assert (TREE_CODE (list) == TREE_LIST, 142);
+
+ /* Don't commit caller to seeing them as globals. */
+ if (TREE_NONLOCAL_FLAG (list))
+ return -1;
+ /* Do commit caller to seeing them as globals. */
+ if (TREE_CODE (TREE_PURPOSE (list)) == IDENTIFIER_NODE)
+ return 1;
+ /* Do commit caller to not seeing them as globals. */
+ return 0;
+}
+
+/* DECL is a FUNCTION_DECL which may have other definitions already in
+ place. We get around this by making the value of the identifier point
+ to a list of all the things that want to be referenced by that name. It
+ is then up to the users of that name to decide what to do with that
+ list.
+
+ DECL may also be a TEMPLATE_DECL, with a FUNCTION_DECL in its DECL_RESULT
+ slot. It is dealt with the same way.
+
+ The value returned may be a previous declaration if we guessed wrong
+ about what language DECL should belong to (C or C++). Otherwise,
+ it's always DECL (and never something that's not a _DECL). */
+tree
+push_overloaded_decl (decl, forgettable)
+ tree decl;
+ int forgettable;
+{
+ tree orig_name = DECL_NAME (decl);
+ tree old;
+ int doing_global = (global_bindings_p () || ! forgettable
+ || flag_traditional || pseudo_global_level_p ());
+
+ if (doing_global)
+ {
+ old = IDENTIFIER_GLOBAL_VALUE (orig_name);
+ if (old && TREE_CODE (old) == FUNCTION_DECL
+ && DECL_ARTIFICIAL (old)
+ && (DECL_BUILT_IN (old) || DECL_BUILT_IN_NONANSI (old)))
+ {
+ if (duplicate_decls (decl, old))
+ return old;
+ old = NULL_TREE;
+ }
+ }
+ else
+ {
+ old = IDENTIFIER_LOCAL_VALUE (orig_name);
+
+ if (! purpose_member (orig_name, current_binding_level->shadowed))
+ {
+ current_binding_level->shadowed
+ = tree_cons (orig_name, old, current_binding_level->shadowed);
+ old = NULL_TREE;
+ }
+ }
+
+ if (old)
+ {
+#if 0
+ /* We cache the value of builtin functions as ADDR_EXPRs
+ in the name space. Convert it to some kind of _DECL after
+ remembering what to forget. */
+ if (TREE_CODE (old) == ADDR_EXPR)
+ old = TREE_OPERAND (old, 0);
+ else
+#endif
+ if (TREE_CODE (old) == TYPE_DECL && DECL_ARTIFICIAL (old))
+ {
+ tree t = TREE_TYPE (old);
+ if (IS_AGGR_TYPE (t) && warn_shadow)
+ cp_warning ("`%#D' hides constructor for `%#T'", decl, t);
+ old = NULL_TREE;
+ }
+ else if (is_overloaded_fn (old))
+ {
+ tree tmp;
+
+ for (tmp = get_first_fn (old); tmp; tmp = DECL_CHAIN (tmp))
+ if (decl == tmp || duplicate_decls (decl, tmp))
+ return tmp;
+ }
+ else
+ {
+ cp_error_at ("previous non-function declaration `%#D'", old);
+ cp_error ("conflicts with function declaration `%#D'", decl);
+ return decl;
+ }
+ }
+
+ if (old || TREE_CODE (decl) == TEMPLATE_DECL)
+ {
+ if (old && is_overloaded_fn (old))
+ DECL_CHAIN (decl) = get_first_fn (old);
+ else
+ DECL_CHAIN (decl) = NULL_TREE;
+ old = tree_cons (orig_name, decl, NULL_TREE);
+ TREE_TYPE (old) = unknown_type_node;
+ }
+ else
+ /* orig_name is not ambiguous. */
+ old = decl;
+
+ if (doing_global)
+ IDENTIFIER_GLOBAL_VALUE (orig_name) = old;
+ else
+ IDENTIFIER_LOCAL_VALUE (orig_name) = old;
+
+ return decl;
+}
+
+/* Generate an implicit declaration for identifier FUNCTIONID
+ as a function of type int (). Print a warning if appropriate. */
+
+tree
+implicitly_declare (functionid)
+ tree functionid;
+{
+ register tree decl;
+ int temp = allocation_temporary_p ();
+
+ push_obstacks_nochange ();
+
+ /* Save the decl permanently so we can warn if definition follows.
+ In ANSI C, warn_implicit is usually false, so the saves little space.
+ But in C++, it's usually true, hence the extra code. */
+ if (temp && (flag_traditional || !warn_implicit || toplevel_bindings_p ()))
+ end_temporary_allocation ();
+
+ /* We used to reuse an old implicit decl here,
+ but this loses with inline functions because it can clobber
+ the saved decl chains. */
+ decl = build_lang_decl (FUNCTION_DECL, functionid, default_function_type);
+
+ DECL_EXTERNAL (decl) = 1;
+ TREE_PUBLIC (decl) = 1;
+
+ /* ANSI standard says implicit declarations are in the innermost block.
+ So we record the decl in the standard fashion.
+ If flag_traditional is set, pushdecl does it top-level. */
+ pushdecl (decl);
+ rest_of_decl_compilation (decl, NULL_PTR, 0, 0);
+
+ if (warn_implicit
+ /* Only one warning per identifier. */
+ && IDENTIFIER_IMPLICIT_DECL (functionid) == NULL_TREE)
+ {
+ cp_pedwarn ("implicit declaration of function `%#D'", decl);
+ }
+
+ SET_IDENTIFIER_IMPLICIT_DECL (functionid, decl);
+
+ pop_obstacks ();
+
+ return decl;
+}
+
+/* Return zero if the declaration NEWDECL is valid
+ when the declaration OLDDECL (assumed to be for the same name)
+ has already been seen.
+ Otherwise return an error message format string with a %s
+ where the identifier should go. */
+
+static char *
+redeclaration_error_message (newdecl, olddecl)
+ tree newdecl, olddecl;
+{
+ if (TREE_CODE (newdecl) == TYPE_DECL)
+ {
+ /* Because C++ can put things into name space for free,
+ constructs like "typedef struct foo { ... } foo"
+ would look like an erroneous redeclaration. */
+ if (comptypes (TREE_TYPE (newdecl), TREE_TYPE (olddecl), 0))
+ return 0;
+ else
+ return "redefinition of `%#D'";
+ }
+ else if (TREE_CODE (newdecl) == FUNCTION_DECL)
+ {
+ /* If this is a pure function, its olddecl will actually be
+ the original initialization to `0' (which we force to call
+ abort()). Don't complain about redefinition in this case. */
+ if (DECL_LANG_SPECIFIC (olddecl) && DECL_ABSTRACT_VIRTUAL_P (olddecl))
+ return 0;
+
+ /* We'll complain about linkage mismatches in
+ warn_extern_redeclared_static. */
+
+ /* defining the same name twice is no good. */
+ if (DECL_INITIAL (olddecl) != NULL_TREE
+ && DECL_INITIAL (newdecl) != NULL_TREE)
+ {
+ if (DECL_NAME (olddecl) == NULL_TREE)
+ return "`%#D' not declared in class";
+ else
+ return "redefinition of `%#D'";
+ }
+ return 0;
+ }
+ else if (TREE_CODE (newdecl) == TEMPLATE_DECL)
+ {
+ if (DECL_INITIAL (olddecl) && DECL_INITIAL (newdecl))
+ return "redefinition of `%#D'";
+ return 0;
+ }
+ else if (current_binding_level == global_binding_level)
+ {
+ /* Objects declared at top level: */
+ /* If at least one is a reference, it's ok. */
+ if (DECL_EXTERNAL (newdecl) || DECL_EXTERNAL (olddecl))
+ return 0;
+ /* Reject two definitions. */
+ return "redefinition of `%#D'";
+ }
+ else
+ {
+ /* Objects declared with block scope: */
+ /* Reject two definitions, and reject a definition
+ together with an external reference. */
+ if (!(DECL_EXTERNAL (newdecl) && DECL_EXTERNAL (olddecl)))
+ return "redeclaration of `%#D'";
+ return 0;
+ }
+}
+
+/* Get the LABEL_DECL corresponding to identifier ID as a label.
+ Create one if none exists so far for the current function.
+ This function is called for both label definitions and label references. */
+
+tree
+lookup_label (id)
+ tree id;
+{
+ register tree decl = IDENTIFIER_LABEL_VALUE (id);
+
+ if (current_function_decl == NULL_TREE)
+ {
+ error ("label `%s' referenced outside of any function",
+ IDENTIFIER_POINTER (id));
+ return NULL_TREE;
+ }
+
+ if ((decl == NULL_TREE
+ || DECL_SOURCE_LINE (decl) == 0)
+ && (named_label_uses == NULL_TREE
+ || TREE_PURPOSE (named_label_uses) != current_binding_level->names
+ || TREE_VALUE (named_label_uses) != decl))
+ {
+ named_label_uses
+ = tree_cons (current_binding_level->names, decl, named_label_uses);
+ TREE_TYPE (named_label_uses) = (tree)current_binding_level;
+ }
+
+ /* Use a label already defined or ref'd with this name. */
+ if (decl != NULL_TREE)
+ {
+ /* But not if it is inherited and wasn't declared to be inheritable. */
+ if (DECL_CONTEXT (decl) != current_function_decl
+ && ! C_DECLARED_LABEL_FLAG (decl))
+ return shadow_label (id);
+ return decl;
+ }
+
+ decl = build_decl (LABEL_DECL, id, void_type_node);
+
+ /* A label not explicitly declared must be local to where it's ref'd. */
+ DECL_CONTEXT (decl) = current_function_decl;
+
+ DECL_MODE (decl) = VOIDmode;
+
+ /* Say where one reference is to the label,
+ for the sake of the error if it is not defined. */
+ DECL_SOURCE_LINE (decl) = lineno;
+ DECL_SOURCE_FILE (decl) = input_filename;
+
+ SET_IDENTIFIER_LABEL_VALUE (id, decl);
+
+ named_labels = tree_cons (NULL_TREE, decl, named_labels);
+ TREE_VALUE (named_label_uses) = decl;
+
+ return decl;
+}
+
+/* Make a label named NAME in the current function,
+ shadowing silently any that may be inherited from containing functions
+ or containing scopes.
+
+ Note that valid use, if the label being shadowed
+ comes from another scope in the same function,
+ requires calling declare_nonlocal_label right away. */
+
+tree
+shadow_label (name)
+ tree name;
+{
+ register tree decl = IDENTIFIER_LABEL_VALUE (name);
+
+ if (decl != NULL_TREE)
+ {
+ shadowed_labels = tree_cons (NULL_TREE, decl, shadowed_labels);
+ SET_IDENTIFIER_LABEL_VALUE (name, NULL_TREE);
+ SET_IDENTIFIER_LABEL_VALUE (decl, NULL_TREE);
+ }
+
+ return lookup_label (name);
+}
+
+/* Define a label, specifying the location in the source file.
+ Return the LABEL_DECL node for the label, if the definition is valid.
+ Otherwise return 0. */
+
+tree
+define_label (filename, line, name)
+ char *filename;
+ int line;
+ tree name;
+{
+ tree decl = lookup_label (name);
+
+ /* After labels, make any new cleanups go into their
+ own new (temporary) binding contour. */
+ current_binding_level->more_cleanups_ok = 0;
+
+ /* If label with this name is known from an outer context, shadow it. */
+ if (decl != NULL_TREE && DECL_CONTEXT (decl) != current_function_decl)
+ {
+ shadowed_labels = tree_cons (NULL_TREE, decl, shadowed_labels);
+ SET_IDENTIFIER_LABEL_VALUE (name, NULL_TREE);
+ decl = lookup_label (name);
+ }
+
+ if (name == get_identifier ("wchar_t"))
+ cp_pedwarn ("label named wchar_t");
+
+ if (DECL_INITIAL (decl) != NULL_TREE)
+ {
+ cp_error ("duplicate label `%D'", decl);
+ return 0;
+ }
+ else
+ {
+ tree uses, prev;
+ int identified = 0;
+
+ /* Mark label as having been defined. */
+ DECL_INITIAL (decl) = error_mark_node;
+ /* Say where in the source. */
+ DECL_SOURCE_FILE (decl) = filename;
+ DECL_SOURCE_LINE (decl) = line;
+
+ for (prev = NULL_TREE, uses = named_label_uses;
+ uses;
+ prev = uses, uses = TREE_CHAIN (uses))
+ if (TREE_VALUE (uses) == decl)
+ {
+ struct binding_level *b = current_binding_level;
+ while (b)
+ {
+ tree new_decls = b->names;
+ tree old_decls = ((tree)b == TREE_TYPE (uses)
+ ? TREE_PURPOSE (uses) : NULL_TREE);
+ while (new_decls != old_decls)
+ {
+ if (TREE_CODE (new_decls) == VAR_DECL
+ /* Don't complain about crossing initialization
+ of internal entities. They can't be accessed,
+ and they should be cleaned up
+ by the time we get to the label. */
+ && ! DECL_ARTIFICIAL (new_decls)
+ && ((DECL_INITIAL (new_decls) != NULL_TREE
+ && DECL_INITIAL (new_decls) != error_mark_node)
+ || TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (new_decls))))
+ {
+ if (! identified)
+ cp_error ("jump to label `%D'", decl);
+ identified = 1;
+ cp_error_at (" crosses initialization of `%#D'",
+ new_decls);
+ }
+ new_decls = TREE_CHAIN (new_decls);
+ }
+ if ((tree)b == TREE_TYPE (uses))
+ break;
+ b = b->level_chain;
+ }
+
+ if (prev)
+ TREE_CHAIN (prev) = TREE_CHAIN (uses);
+ else
+ named_label_uses = TREE_CHAIN (uses);
+ }
+ current_function_return_value = NULL_TREE;
+ return decl;
+ }
+}
+
+struct cp_switch
+{
+ struct binding_level *level;
+ struct cp_switch *next;
+};
+
+static struct cp_switch *switch_stack;
+
+void
+push_switch ()
+{
+ struct cp_switch *p
+ = (struct cp_switch *) oballoc (sizeof (struct cp_switch));
+ p->level = current_binding_level;
+ p->next = switch_stack;
+ switch_stack = p;
+}
+
+void
+pop_switch ()
+{
+ switch_stack = switch_stack->next;
+}
+
+/* Same, but for CASE labels. If DECL is NULL_TREE, it's the default. */
+/* XXX Note decl is never actually used. (bpk) */
+void
+define_case_label (decl)
+ tree decl;
+{
+ tree cleanup = last_cleanup_this_contour ();
+ struct binding_level *b = current_binding_level;
+ int identified = 0;
+
+ if (cleanup)
+ {
+ static int explained = 0;
+ cp_warning_at ("destructor needed for `%#D'", TREE_PURPOSE (cleanup));
+ warning ("where case label appears here");
+ if (!explained)
+ {
+ warning ("(enclose actions of previous case statements requiring");
+ warning ("destructors in their own binding contours.)");
+ explained = 1;
+ }
+ }
+
+ for (; b && b != switch_stack->level; b = b->level_chain)
+ {
+ tree new_decls = b->names;
+ for (; new_decls; new_decls = TREE_CHAIN (new_decls))
+ {
+ if (TREE_CODE (new_decls) == VAR_DECL
+ /* Don't complain about crossing initialization
+ of internal entities. They can't be accessed,
+ and they should be cleaned up
+ by the time we get to the label. */
+ && ! DECL_ARTIFICIAL (new_decls)
+ && ((DECL_INITIAL (new_decls) != NULL_TREE
+ && DECL_INITIAL (new_decls) != error_mark_node)
+ || TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (new_decls))))
+ {
+ if (! identified)
+ error ("jump to case label");
+ identified = 1;
+ cp_error_at (" crosses initialization of `%#D'",
+ new_decls);
+ }
+ }
+ }
+
+ /* After labels, make any new cleanups go into their
+ own new (temporary) binding contour. */
+
+ current_binding_level->more_cleanups_ok = 0;
+ current_function_return_value = NULL_TREE;
+}
+
+/* Return the list of declarations of the current level.
+ Note that this list is in reverse order unless/until
+ you nreverse it; and when you do nreverse it, you must
+ store the result back using `storedecls' or you will lose. */
+
+tree
+getdecls ()
+{
+ return current_binding_level->names;
+}
+
+/* Return the list of type-tags (for structs, etc) of the current level. */
+
+tree
+gettags ()
+{
+ return current_binding_level->tags;
+}
+
+/* Store the list of declarations of the current level.
+ This is done for the parameter declarations of a function being defined,
+ after they are modified in the light of any missing parameters. */
+
+static void
+storedecls (decls)
+ tree decls;
+{
+ current_binding_level->names = decls;
+}
+
+/* Similarly, store the list of tags of the current level. */
+
+static void
+storetags (tags)
+ tree tags;
+{
+ current_binding_level->tags = tags;
+}
+
+/* Given NAME, an IDENTIFIER_NODE,
+ return the structure (or union or enum) definition for that name.
+ Searches binding levels from BINDING_LEVEL up to the global level.
+ If THISLEVEL_ONLY is nonzero, searches only the specified context
+ (but skips any tag-transparent contexts to find one that is
+ meaningful for tags).
+ FORM says which kind of type the caller wants;
+ it is RECORD_TYPE or UNION_TYPE or ENUMERAL_TYPE.
+ If the wrong kind of type is found, and it's not a template, an error is
+ reported. */
+
+static tree
+lookup_tag (form, name, binding_level, thislevel_only)
+ enum tree_code form;
+ struct binding_level *binding_level;
+ tree name;
+ int thislevel_only;
+{
+ register struct binding_level *level;
+
+ for (level = binding_level; level; level = level->level_chain)
+ {
+ register tree tail;
+ if (ANON_AGGRNAME_P (name))
+ for (tail = level->tags; tail; tail = TREE_CHAIN (tail))
+ {
+ /* There's no need for error checking here, because
+ anon names are unique throughout the compilation. */
+ if (TYPE_IDENTIFIER (TREE_VALUE (tail)) == name)
+ return TREE_VALUE (tail);
+ }
+ else
+ for (tail = level->tags; tail; tail = TREE_CHAIN (tail))
+ {
+ if (TREE_PURPOSE (tail) == name)
+ {
+ enum tree_code code = TREE_CODE (TREE_VALUE (tail));
+ /* Should tighten this up; it'll probably permit
+ UNION_TYPE and a struct template, for example. */
+ if (code != form
+ && !(form != ENUMERAL_TYPE
+ && (code == TEMPLATE_DECL
+ || code == UNINSTANTIATED_P_TYPE)))
+
+ {
+ /* Definition isn't the kind we were looking for. */
+ cp_error ("`%#D' redeclared as %C", TREE_VALUE (tail),
+ form);
+ }
+ return TREE_VALUE (tail);
+ }
+ }
+ if (thislevel_only && ! level->tag_transparent)
+ return NULL_TREE;
+ if (current_class_type && level->level_chain == global_binding_level)
+ {
+ /* Try looking in this class's tags before heading into
+ global binding level. */
+ tree context = current_class_type;
+ while (context)
+ {
+ switch (TREE_CODE_CLASS (TREE_CODE (context)))
+ {
+ tree these_tags;
+ case 't':
+ these_tags = CLASSTYPE_TAGS (context);
+ if (ANON_AGGRNAME_P (name))
+ while (these_tags)
+ {
+ if (TYPE_IDENTIFIER (TREE_VALUE (these_tags))
+ == name)
+ return TREE_VALUE (tail);
+ these_tags = TREE_CHAIN (these_tags);
+ }
+ else
+ while (these_tags)
+ {
+ if (TREE_PURPOSE (these_tags) == name)
+ {
+ if (TREE_CODE (TREE_VALUE (these_tags)) != form)
+ {
+ cp_error ("`%#D' redeclared as %C in class scope",
+ TREE_VALUE (tail), form);
+ }
+ return TREE_VALUE (tail);
+ }
+ these_tags = TREE_CHAIN (these_tags);
+ }
+ /* If this type is not yet complete, then don't
+ look at its context. */
+ if (TYPE_SIZE (context) == NULL_TREE)
+ goto no_context;
+ /* Go to next enclosing type, if any. */
+ context = DECL_CONTEXT (TYPE_NAME (context));
+ break;
+ case 'd':
+ context = DECL_CONTEXT (context);
+ break;
+ default:
+ my_friendly_abort (10);
+ }
+ continue;
+ no_context:
+ break;
+ }
+ }
+ }
+ return NULL_TREE;
+}
+
+void
+set_current_level_tags_transparency (tags_transparent)
+ int tags_transparent;
+{
+ current_binding_level->tag_transparent = tags_transparent;
+}
+
+/* Given a type, find the tag that was defined for it and return the tag name.
+ Otherwise return 0. However, the value can never be 0
+ in the cases in which this is used.
+
+ C++: If NAME is non-zero, this is the new name to install. This is
+ done when replacing anonymous tags with real tag names. */
+
+static tree
+lookup_tag_reverse (type, name)
+ tree type;
+ tree name;
+{
+ register struct binding_level *level;
+
+ for (level = current_binding_level; level; level = level->level_chain)
+ {
+ register tree tail;
+ for (tail = level->tags; tail; tail = TREE_CHAIN (tail))
+ {
+ if (TREE_VALUE (tail) == type)
+ {
+ if (name)
+ TREE_PURPOSE (tail) = name;
+ return TREE_PURPOSE (tail);
+ }
+ }
+ }
+ return NULL_TREE;
+}
+
+/* Given type TYPE which was not declared in C++ language context,
+ attempt to find a name by which it is referred. */
+tree
+typedecl_for_tag (tag)
+ tree tag;
+{
+ struct binding_level *b = current_binding_level;
+
+ if (TREE_CODE (TYPE_NAME (tag)) == TYPE_DECL)
+ return TYPE_NAME (tag);
+
+ while (b)
+ {
+ tree decls = b->names;
+ while (decls)
+ {
+ if (TREE_CODE (decls) == TYPE_DECL && TREE_TYPE (decls) == tag)
+ break;
+ decls = TREE_CHAIN (decls);
+ }
+ if (decls)
+ return decls;
+ b = b->level_chain;
+ }
+ return NULL_TREE;
+}
+
+/* Lookup TYPE in CONTEXT (a chain of nested types or a FUNCTION_DECL).
+ Return the type value, or NULL_TREE if not found. */
+static tree
+lookup_nested_type (type, context)
+ tree type;
+ tree context;
+{
+ if (context == NULL_TREE)
+ return NULL_TREE;
+ while (context)
+ {
+ switch (TREE_CODE (context))
+ {
+ case TYPE_DECL:
+ {
+ tree ctype = TREE_TYPE (context);
+ tree match = value_member (type, CLASSTYPE_TAGS (ctype));
+ if (match)
+ return TREE_VALUE (match);
+ context = DECL_CONTEXT (context);
+
+ /* When we have a nested class whose member functions have
+ local types (e.g., a set of enums), we'll arrive here
+ with the DECL_CONTEXT as the actual RECORD_TYPE node for
+ the enclosing class. Instead, we want to make sure we
+ come back in here with the TYPE_DECL, not the RECORD_TYPE. */
+ if (context && TREE_CODE (context) == RECORD_TYPE)
+ context = TREE_CHAIN (context);
+ }
+ break;
+ case FUNCTION_DECL:
+ if (TYPE_NAME (type) && TYPE_IDENTIFIER (type))
+ return lookup_name (TYPE_IDENTIFIER (type), 1);
+ return NULL_TREE;
+ default:
+ my_friendly_abort (12);
+ }
+ }
+ return NULL_TREE;
+}
+
+/* Look up NAME in the NAMESPACE. */
+tree
+lookup_namespace_name (namespace, name)
+ tree namespace, name;
+{
+ struct binding_level *b = (struct binding_level *)NAMESPACE_LEVEL (namespace);
+ tree x;
+
+ for (x = NULL_TREE; b && !x; b = b->level_chain)
+ {
+ for (x = b->names; x; x = TREE_CHAIN (x))
+ if (DECL_NAME (x) == name || DECL_ASSEMBLER_NAME (x) == name)
+ break;
+ /* Must find directly in the namespace. */
+ break;
+ }
+ return x;
+}
+
+/* Look up NAME in the current binding level and its superiors in the
+ namespace of variables, functions and typedefs. Return a ..._DECL
+ node of some kind representing its definition if there is only one
+ such declaration, or return a TREE_LIST with all the overloaded
+ definitions if there are many, or return 0 if it is undefined.
+
+ If PREFER_TYPE is > 0, we prefer TYPE_DECLs.
+ If PREFER_TYPE is -2, we're being called from yylex(). (UGLY)
+ Otherwise we prefer non-TYPE_DECLs. */
+
+tree
+lookup_name_real (name, prefer_type, nonclass)
+ tree name;
+ int prefer_type, nonclass;
+{
+ register tree val;
+ int yylex = 0;
+ tree from_obj = NULL_TREE;
+
+ if (prefer_type == -2)
+ {
+ extern int looking_for_typename;
+ tree type;
+
+ yylex = 1;
+ prefer_type = looking_for_typename;
+
+ if (got_scope)
+ type = got_scope;
+ else if (got_object != error_mark_node)
+ type = got_object;
+
+ if (type)
+ {
+ if (type == error_mark_node)
+ return error_mark_node;
+ else if (type == void_type_node)
+ val = IDENTIFIER_GLOBAL_VALUE (name);
+ else if (TREE_CODE (type) == TEMPLATE_TYPE_PARM
+ /* TFIXME -- don't do this for UPTs in new model. */
+ || TREE_CODE (type) == UNINSTANTIATED_P_TYPE)
+ {
+ if (prefer_type > 0)
+ val = create_nested_upt (type, name);
+ else
+ val = NULL_TREE;
+ }
+ else if (TREE_CODE (type) == NAMESPACE_DECL)
+ {
+ val = lookup_namespace_name (type, name);
+ }
+ else if (! IS_AGGR_TYPE (type))
+ /* Someone else will give an error about this if needed. */
+ val = NULL_TREE;
+ else if (TYPE_BEING_DEFINED (type))
+ {
+ val = IDENTIFIER_CLASS_VALUE (name);
+ if (val && DECL_CONTEXT (val) != type)
+ {
+ struct binding_level *b = class_binding_level;
+ for (val = NULL_TREE; b; b = b->level_chain)
+ {
+ tree t = purpose_member (name, b->class_shadowed);
+ if (t && TREE_VALUE (t)
+ && DECL_CONTEXT (TREE_VALUE (t)) == type)
+ {
+ val = TREE_VALUE (t);
+ break;
+ }
+ }
+ }
+ if (val == NULL_TREE
+ && CLASSTYPE_LOCAL_TYPEDECLS (type))
+ val = lookup_field (type, name, 0, 1);
+ }
+ else if (type == current_class_type)
+ val = IDENTIFIER_CLASS_VALUE (name);
+ else
+ val = lookup_field (type, name, 0, prefer_type);
+ }
+ else
+ val = NULL_TREE;
+
+ if (got_scope)
+ goto done;
+
+ /* This special lookup only applies to types. */
+ else if (got_object && val && TREE_CODE (val) == TYPE_DECL)
+ from_obj = val;
+ }
+
+ if (current_binding_level != global_binding_level
+ && IDENTIFIER_LOCAL_VALUE (name))
+ val = IDENTIFIER_LOCAL_VALUE (name);
+ /* In C++ class fields are between local and global scope,
+ just before the global scope. */
+ else if (current_class_type && ! nonclass)
+ {
+ val = IDENTIFIER_CLASS_VALUE (name);
+ if (val == NULL_TREE
+ && TYPE_BEING_DEFINED (current_class_type)
+ && CLASSTYPE_LOCAL_TYPEDECLS (current_class_type))
+ /* Try to find values from base classes if we are presently
+ defining a type. We are presently only interested in
+ TYPE_DECLs. */
+ val = lookup_field (current_class_type, name, 0, 1);
+
+ /* yylex() calls this with -2, since we should never start digging for
+ the nested name at the point where we haven't even, for example,
+ created the COMPONENT_REF or anything like that. */
+ if (val == NULL_TREE)
+ val = lookup_nested_field (name, ! yylex);
+
+ if (val == NULL_TREE)
+ val = IDENTIFIER_GLOBAL_VALUE (name);
+ }
+ else
+ val = IDENTIFIER_GLOBAL_VALUE (name);
+
+ done:
+ if (val)
+ {
+ if (from_obj && from_obj != val)
+ cp_error ("lookup in the scope of `%#T' does not match lookup in the current scope",
+ got_object);
+
+ if ((TREE_CODE (val) == TEMPLATE_DECL && looking_for_template)
+ || TREE_CODE (val) == TYPE_DECL || prefer_type <= 0)
+ ;
+ else if (IDENTIFIER_HAS_TYPE_VALUE (name))
+ val = TYPE_NAME (IDENTIFIER_TYPE_VALUE (name));
+ else if (TREE_TYPE (val) == error_mark_node)
+ val = error_mark_node;
+ }
+ else if (from_obj)
+ val = from_obj;
+
+ return val;
+}
+
+tree
+lookup_name_nonclass (name)
+ tree name;
+{
+ return lookup_name_real (name, 0, 1);
+}
+
+tree
+lookup_name (name, prefer_type)
+ tree name;
+ int prefer_type;
+{
+ return lookup_name_real (name, prefer_type, 0);
+}
+
+/* Similar to `lookup_name' but look only at current binding level. */
+
+tree
+lookup_name_current_level (name)
+ tree name;
+{
+ register tree t = NULL_TREE;
+
+ if (current_binding_level == global_binding_level)
+ {
+ t = IDENTIFIER_GLOBAL_VALUE (name);
+
+ /* extern "C" function() */
+ if (t != NULL_TREE && TREE_CODE (t) == TREE_LIST)
+ t = TREE_VALUE (t);
+ }
+ else if (IDENTIFIER_LOCAL_VALUE (name) != NULL_TREE)
+ {
+ struct binding_level *b = current_binding_level;
+ while (1)
+ {
+ for (t = b->names; t; t = TREE_CHAIN (t))
+ if (DECL_NAME (t) == name || DECL_ASSEMBLER_NAME (t) == name)
+ goto out;
+ if (b->keep == 2)
+ b = b->level_chain;
+ else
+ break;
+ }
+ out:
+ ;
+ }
+
+ return t;
+}
+
+/* Arrange for the user to get a source line number, even when the
+ compiler is going down in flames, so that she at least has a
+ chance of working around problems in the compiler. We used to
+ call error(), but that let the segmentation fault continue
+ through; now, it's much more passive by asking them to send the
+ maintainers mail about the problem. */
+
+static void
+signal_catch (sig)
+ int sig;
+{
+ signal (SIGSEGV, SIG_DFL);
+#ifdef SIGIOT
+ signal (SIGIOT, SIG_DFL);
+#endif
+#ifdef SIGILL
+ signal (SIGILL, SIG_DFL);
+#endif
+#ifdef SIGABRT
+ signal (SIGABRT, SIG_DFL);
+#endif
+#ifdef SIGBUS
+ signal (SIGBUS, SIG_DFL);
+#endif
+ my_friendly_abort (0);
+}
+
+/* Array for holding types considered "built-in". These types
+ are output in the module in which `main' is defined. */
+static tree *builtin_type_tdescs_arr;
+static int builtin_type_tdescs_len, builtin_type_tdescs_max;
+
+/* Push the declarations of builtin types into the namespace.
+ RID_INDEX, if < RID_MAX is the index of the builtin type
+ in the array RID_POINTERS. NAME is the name used when looking
+ up the builtin type. TYPE is the _TYPE node for the builtin type. */
+
+static void
+record_builtin_type (rid_index, name, type)
+ enum rid rid_index;
+ char *name;
+ tree type;
+{
+ tree rname = NULL_TREE, tname = NULL_TREE;
+ tree tdecl;
+
+ if ((int) rid_index < (int) RID_MAX)
+ rname = ridpointers[(int) rid_index];
+ if (name)
+ tname = get_identifier (name);
+
+ TYPE_BUILT_IN (type) = 1;
+
+ if (tname)
+ {
+#if 0 /* not yet, should get fixed properly later */
+ tdecl = pushdecl (make_type_decl (tname, type));
+#else
+ tdecl = pushdecl (build_decl (TYPE_DECL, tname, type));
+#endif
+ set_identifier_type_value (tname, NULL_TREE);
+ if ((int) rid_index < (int) RID_MAX)
+ IDENTIFIER_GLOBAL_VALUE (tname) = tdecl;
+ }
+ if (rname != NULL_TREE)
+ {
+ if (tname != NULL_TREE)
+ {
+ set_identifier_type_value (rname, NULL_TREE);
+ IDENTIFIER_GLOBAL_VALUE (rname) = tdecl;
+ }
+ else
+ {
+#if 0 /* not yet, should get fixed properly later */
+ tdecl = pushdecl (make_type_decl (rname, type));
+#else
+ tdecl = pushdecl (build_decl (TYPE_DECL, rname, type));
+#endif
+ set_identifier_type_value (rname, NULL_TREE);
+ }
+ }
+
+ if (flag_rtti)
+ {
+ if (builtin_type_tdescs_len+5 >= builtin_type_tdescs_max)
+ {
+ builtin_type_tdescs_max *= 2;
+ builtin_type_tdescs_arr
+ = (tree *)xrealloc (builtin_type_tdescs_arr,
+ builtin_type_tdescs_max * sizeof (tree));
+ }
+ builtin_type_tdescs_arr[builtin_type_tdescs_len++] = type;
+ if (TREE_CODE (type) != POINTER_TYPE)
+ {
+ builtin_type_tdescs_arr[builtin_type_tdescs_len++]
+ = build_pointer_type (type);
+ builtin_type_tdescs_arr[builtin_type_tdescs_len++]
+ = build_pointer_type (build_type_variant (type, 1, 0));
+ }
+ if (TREE_CODE (type) != VOID_TYPE)
+ {
+ builtin_type_tdescs_arr[builtin_type_tdescs_len++]
+ = build_reference_type (type);
+ builtin_type_tdescs_arr[builtin_type_tdescs_len++]
+ = build_reference_type (build_type_variant (type, 1, 0));
+ }
+ }
+}
+
+static void
+output_builtin_tdesc_entries ()
+{
+ extern struct obstack permanent_obstack;
+
+ /* If there's more than one main in this file, don't crash. */
+ if (builtin_type_tdescs_arr == 0)
+ return;
+
+ push_obstacks (&permanent_obstack, &permanent_obstack);
+ while (builtin_type_tdescs_len > 0)
+ {
+ tree type = builtin_type_tdescs_arr[--builtin_type_tdescs_len];
+ tree tdesc = build_t_desc (type, 0);
+ TREE_ASM_WRITTEN (tdesc) = 0;
+ build_t_desc (type, 2);
+ }
+ free (builtin_type_tdescs_arr);
+ builtin_type_tdescs_arr = 0;
+ pop_obstacks ();
+}
+
+/* Push overloaded decl, in global scope, with one argument so it
+ can be used as a callback from define_function. */
+static void
+push_overloaded_decl_1 (x)
+ tree x;
+{
+ push_overloaded_decl (x, 0);
+}
+
+#define builtin_function(NAME, TYPE, CODE, LIBNAME) \
+ define_function (NAME, TYPE, CODE, (void (*)())pushdecl, LIBNAME)
+
+#ifdef __GNUC__
+__inline
+#endif
+tree auto_function (name, type, code)
+ tree name, type;
+ enum built_in_function code;
+{
+ return define_function
+ (IDENTIFIER_POINTER (name), type, code, (void (*)())push_overloaded_decl_1,
+ IDENTIFIER_POINTER (build_decl_overload (name, TYPE_ARG_TYPES (type),
+ 0)));
+}
+
+/* Create the predefined scalar types of C,
+ and some nodes representing standard constants (0, 1, (void *)0).
+ Initialize the global binding level.
+ Make definitions for built-in primitive functions. */
+
+void
+init_decl_processing ()
+{
+ tree decl;
+ register tree endlink, int_endlink, double_endlink, ptr_endlink;
+ tree fields[20];
+ /* Either char* or void*. */
+ tree traditional_ptr_type_node;
+ /* Data type of memcpy. */
+ tree memcpy_ftype;
+#if 0 /* Not yet. */
+ /* Data type of strncpy. */
+ tree strncpy_ftype;
+#endif
+ int wchar_type_size;
+ tree temp;
+ tree array_domain_type;
+ extern int flag_strict_prototype;
+
+ /* Have to make these distinct before we try using them. */
+ lang_name_cplusplus = get_identifier ("C++");
+ lang_name_c = get_identifier ("C");
+
+ if (flag_strict_prototype == 2)
+ {
+ if (pedantic)
+ strict_prototypes_lang_c = strict_prototypes_lang_cplusplus;
+ }
+ else
+ strict_prototypes_lang_c = flag_strict_prototype;
+
+ /* Initially, C. */
+ current_lang_name = lang_name_c;
+
+ current_function_decl = NULL_TREE;
+ named_labels = NULL_TREE;
+ named_label_uses = NULL_TREE;
+ current_binding_level = NULL_BINDING_LEVEL;
+ free_binding_level = NULL_BINDING_LEVEL;
+
+ /* Because most segmentation signals can be traced back into user
+ code, catch them and at least give the user a chance of working
+ around compiler bugs. */
+ signal (SIGSEGV, signal_catch);
+
+ /* We will also catch aborts in the back-end through signal_catch and
+ give the user a chance to see where the error might be, and to defeat
+ aborts in the back-end when there have been errors previously in their
+ code. */
+#ifdef SIGIOT
+ signal (SIGIOT, signal_catch);
+#endif
+#ifdef SIGILL
+ signal (SIGILL, signal_catch);
+#endif
+#ifdef SIGABRT
+ signal (SIGABRT, signal_catch);
+#endif
+#ifdef SIGBUS
+ signal (SIGBUS, signal_catch);
+#endif
+
+ gcc_obstack_init (&decl_obstack);
+ if (flag_rtti)
+ {
+ builtin_type_tdescs_max = 100;
+ builtin_type_tdescs_arr = (tree *)xmalloc (100 * sizeof (tree));
+ }
+
+ /* Must lay these out before anything else gets laid out. */
+ error_mark_node = make_node (ERROR_MARK);
+ TREE_PERMANENT (error_mark_node) = 1;
+ TREE_TYPE (error_mark_node) = error_mark_node;
+ error_mark_list = build_tree_list (error_mark_node, error_mark_node);
+ TREE_TYPE (error_mark_list) = error_mark_node;
+
+ /* Make the binding_level structure for global names. */
+ pushlevel (0);
+ global_binding_level = current_binding_level;
+
+ this_identifier = get_identifier (THIS_NAME);
+ in_charge_identifier = get_identifier (IN_CHARGE_NAME);
+ pfn_identifier = get_identifier (VTABLE_PFN_NAME);
+ index_identifier = get_identifier (VTABLE_INDEX_NAME);
+ delta_identifier = get_identifier (VTABLE_DELTA_NAME);
+ delta2_identifier = get_identifier (VTABLE_DELTA2_NAME);
+ pfn_or_delta2_identifier = get_identifier ("__pfn_or_delta2");
+ if (flag_handle_signatures)
+ {
+ tag_identifier = get_identifier (SIGTABLE_TAG_NAME);
+ vb_off_identifier = get_identifier (SIGTABLE_VB_OFF_NAME);
+ vt_off_identifier = get_identifier (SIGTABLE_VT_OFF_NAME);
+ }
+
+ /* Define `int' and `char' first so that dbx will output them first. */
+
+ integer_type_node = make_signed_type (INT_TYPE_SIZE);
+ record_builtin_type (RID_INT, NULL_PTR, integer_type_node);
+
+ /* Define `char', which is like either `signed char' or `unsigned char'
+ but not the same as either. */
+
+ char_type_node =
+ (flag_signed_char
+ ? make_signed_type (CHAR_TYPE_SIZE)
+ : make_unsigned_type (CHAR_TYPE_SIZE));
+ record_builtin_type (RID_CHAR, "char", char_type_node);
+
+ long_integer_type_node = make_signed_type (LONG_TYPE_SIZE);
+ record_builtin_type (RID_LONG, "long int", long_integer_type_node);
+
+ unsigned_type_node = make_unsigned_type (INT_TYPE_SIZE);
+ record_builtin_type (RID_UNSIGNED, "unsigned int", unsigned_type_node);
+
+ long_unsigned_type_node = make_unsigned_type (LONG_TYPE_SIZE);
+ record_builtin_type (RID_MAX, "long unsigned int", long_unsigned_type_node);
+ record_builtin_type (RID_MAX, "unsigned long", long_unsigned_type_node);
+
+ long_long_integer_type_node = make_signed_type (LONG_LONG_TYPE_SIZE);
+ record_builtin_type (RID_MAX, "long long int", long_long_integer_type_node);
+
+ long_long_unsigned_type_node = make_unsigned_type (LONG_LONG_TYPE_SIZE);
+ record_builtin_type (RID_MAX, "long long unsigned int",
+ long_long_unsigned_type_node);
+ record_builtin_type (RID_MAX, "long long unsigned",
+ long_long_unsigned_type_node);
+
+ /* `unsigned long' is the standard type for sizeof.
+ Traditionally, use a signed type.
+ Note that stddef.h uses `unsigned long',
+ and this must agree, even of long and int are the same size. */
+ sizetype
+ = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (SIZE_TYPE)));
+ if (flag_traditional && TREE_UNSIGNED (sizetype))
+ sizetype = signed_type (sizetype);
+
+ ptrdiff_type_node
+ = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (PTRDIFF_TYPE)));
+
+ TREE_TYPE (TYPE_SIZE (integer_type_node)) = sizetype;
+ TREE_TYPE (TYPE_SIZE (char_type_node)) = sizetype;
+ TREE_TYPE (TYPE_SIZE (unsigned_type_node)) = sizetype;
+ TREE_TYPE (TYPE_SIZE (long_unsigned_type_node)) = sizetype;
+ TREE_TYPE (TYPE_SIZE (long_integer_type_node)) = sizetype;
+ TREE_TYPE (TYPE_SIZE (long_long_integer_type_node)) = sizetype;
+ TREE_TYPE (TYPE_SIZE (long_long_unsigned_type_node)) = sizetype;
+
+ short_integer_type_node = make_signed_type (SHORT_TYPE_SIZE);
+ record_builtin_type (RID_SHORT, "short int", short_integer_type_node);
+ short_unsigned_type_node = make_unsigned_type (SHORT_TYPE_SIZE);
+ record_builtin_type (RID_MAX, "short unsigned int", short_unsigned_type_node);
+ record_builtin_type (RID_MAX, "unsigned short", short_unsigned_type_node);
+
+ /* Define both `signed char' and `unsigned char'. */
+ signed_char_type_node = make_signed_type (CHAR_TYPE_SIZE);
+ record_builtin_type (RID_MAX, "signed char", signed_char_type_node);
+ unsigned_char_type_node = make_unsigned_type (CHAR_TYPE_SIZE);
+ record_builtin_type (RID_MAX, "unsigned char", unsigned_char_type_node);
+
+ /* These are types that type_for_size and type_for_mode use. */
+ intQI_type_node = make_signed_type (GET_MODE_BITSIZE (QImode));
+ pushdecl (build_decl (TYPE_DECL, NULL_TREE, intQI_type_node));
+ intHI_type_node = make_signed_type (GET_MODE_BITSIZE (HImode));
+ pushdecl (build_decl (TYPE_DECL, NULL_TREE, intHI_type_node));
+ intSI_type_node = make_signed_type (GET_MODE_BITSIZE (SImode));
+ pushdecl (build_decl (TYPE_DECL, NULL_TREE, intSI_type_node));
+ intDI_type_node = make_signed_type (GET_MODE_BITSIZE (DImode));
+ pushdecl (build_decl (TYPE_DECL, NULL_TREE, intDI_type_node));
+ unsigned_intQI_type_node = make_unsigned_type (GET_MODE_BITSIZE (QImode));
+ pushdecl (build_decl (TYPE_DECL, NULL_TREE, unsigned_intQI_type_node));
+ unsigned_intHI_type_node = make_unsigned_type (GET_MODE_BITSIZE (HImode));
+ pushdecl (build_decl (TYPE_DECL, NULL_TREE, unsigned_intHI_type_node));
+ unsigned_intSI_type_node = make_unsigned_type (GET_MODE_BITSIZE (SImode));
+ pushdecl (build_decl (TYPE_DECL, NULL_TREE, unsigned_intSI_type_node));
+ unsigned_intDI_type_node = make_unsigned_type (GET_MODE_BITSIZE (DImode));
+ pushdecl (build_decl (TYPE_DECL, NULL_TREE, unsigned_intDI_type_node));
+
+ float_type_node = make_node (REAL_TYPE);
+ TYPE_PRECISION (float_type_node) = FLOAT_TYPE_SIZE;
+ record_builtin_type (RID_FLOAT, NULL_PTR, float_type_node);
+ layout_type (float_type_node);
+
+ double_type_node = make_node (REAL_TYPE);
+ if (flag_short_double)
+ TYPE_PRECISION (double_type_node) = FLOAT_TYPE_SIZE;
+ else
+ TYPE_PRECISION (double_type_node) = DOUBLE_TYPE_SIZE;
+ record_builtin_type (RID_DOUBLE, NULL_PTR, double_type_node);
+ layout_type (double_type_node);
+
+ long_double_type_node = make_node (REAL_TYPE);
+ TYPE_PRECISION (long_double_type_node) = LONG_DOUBLE_TYPE_SIZE;
+ record_builtin_type (RID_MAX, "long double", long_double_type_node);
+ layout_type (long_double_type_node);
+
+ integer_zero_node = build_int_2 (0, 0);
+ TREE_TYPE (integer_zero_node) = integer_type_node;
+ integer_one_node = build_int_2 (1, 0);
+ TREE_TYPE (integer_one_node) = integer_type_node;
+ integer_two_node = build_int_2 (2, 0);
+ TREE_TYPE (integer_two_node) = integer_type_node;
+ integer_three_node = build_int_2 (3, 0);
+ TREE_TYPE (integer_three_node) = integer_type_node;
+
+ boolean_type_node = make_unsigned_type (BOOL_TYPE_SIZE);
+ TREE_SET_CODE (boolean_type_node, BOOLEAN_TYPE);
+ record_builtin_type (RID_BOOL, "bool", boolean_type_node);
+ boolean_false_node = build_int_2 (0, 0);
+ TREE_TYPE (boolean_false_node) = boolean_type_node;
+ boolean_true_node = build_int_2 (1, 0);
+ TREE_TYPE (boolean_true_node) = boolean_type_node;
+
+ /* These are needed by stor-layout.c. */
+ size_zero_node = size_int (0);
+ size_one_node = size_int (1);
+
+ void_type_node = make_node (VOID_TYPE);
+ record_builtin_type (RID_VOID, NULL_PTR, void_type_node);
+ layout_type (void_type_node); /* Uses integer_zero_node. */
+ void_list_node = build_tree_list (NULL_TREE, void_type_node);
+ TREE_PARMLIST (void_list_node) = 1;
+
+ null_pointer_node = build_int_2 (0, 0);
+ TREE_TYPE (null_pointer_node) = build_pointer_type (void_type_node);
+ layout_type (TREE_TYPE (null_pointer_node));
+
+ /* Used for expressions that do nothing, but are not errors. */
+ void_zero_node = build_int_2 (0, 0);
+ TREE_TYPE (void_zero_node) = void_type_node;
+
+ string_type_node = build_pointer_type (char_type_node);
+ const_string_type_node =
+ build_pointer_type (build_type_variant (char_type_node, 1, 0));
+ record_builtin_type (RID_MAX, NULL_PTR, string_type_node);
+
+ /* Make a type to be the domain of a few array types
+ whose domains don't really matter.
+ 200 is small enough that it always fits in size_t
+ and large enough that it can hold most function names for the
+ initializations of __FUNCTION__ and __PRETTY_FUNCTION__. */
+ array_domain_type = build_index_type (build_int_2 (200, 0));
+
+ /* make a type for arrays of characters.
+ With luck nothing will ever really depend on the length of this
+ array type. */
+ char_array_type_node
+ = build_array_type (char_type_node, array_domain_type);
+ /* Likewise for arrays of ints. */
+ int_array_type_node
+ = build_array_type (integer_type_node, array_domain_type);
+
+ /* This is just some anonymous class type. Nobody should ever
+ need to look inside this envelope. */
+ class_star_type_node = build_pointer_type (make_lang_type (RECORD_TYPE));
+
+ default_function_type
+ = build_function_type (integer_type_node, NULL_TREE);
+ build_pointer_type (default_function_type);
+
+ ptr_type_node = build_pointer_type (void_type_node);
+ const_ptr_type_node =
+ build_pointer_type (build_type_variant (void_type_node, 1, 0));
+ record_builtin_type (RID_MAX, NULL_PTR, ptr_type_node);
+ endlink = void_list_node;
+ int_endlink = tree_cons (NULL_TREE, integer_type_node, endlink);
+ double_endlink = tree_cons (NULL_TREE, double_type_node, endlink);
+ ptr_endlink = tree_cons (NULL_TREE, ptr_type_node, endlink);
+
+ double_ftype_double
+ = build_function_type (double_type_node, double_endlink);
+
+ double_ftype_double_double
+ = build_function_type (double_type_node,
+ tree_cons (NULL_TREE, double_type_node,
+ double_endlink));
+
+ int_ftype_int
+ = build_function_type (integer_type_node, int_endlink);
+
+ long_ftype_long
+ = build_function_type (long_integer_type_node,
+ tree_cons (NULL_TREE, long_integer_type_node,
+ endlink));
+
+ void_ftype_ptr_ptr_int
+ = build_function_type (void_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ int_endlink)));
+
+ int_ftype_cptr_cptr_sizet
+ = build_function_type (integer_type_node,
+ tree_cons (NULL_TREE, const_ptr_type_node,
+ tree_cons (NULL_TREE, const_ptr_type_node,
+ tree_cons (NULL_TREE,
+ sizetype,
+ endlink))));
+
+ void_ftype_ptr_int_int
+ = build_function_type (void_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ tree_cons (NULL_TREE, integer_type_node,
+ int_endlink)));
+
+ string_ftype_ptr_ptr /* strcpy prototype */
+ = build_function_type (string_type_node,
+ tree_cons (NULL_TREE, string_type_node,
+ tree_cons (NULL_TREE,
+ const_string_type_node,
+ endlink)));
+
+#if 0
+ /* Not yet. */
+ strncpy_ftype /* strncpy prototype */
+ = build_function_type (string_type_node,
+ tree_cons (NULL_TREE, string_type_node,
+ tree_cons (NULL_TREE, const_string_type_node,
+ tree_cons (NULL_TREE,
+ sizetype,
+ endlink))));
+#endif
+
+ int_ftype_string_string /* strcmp prototype */
+ = build_function_type (integer_type_node,
+ tree_cons (NULL_TREE, const_string_type_node,
+ tree_cons (NULL_TREE,
+ const_string_type_node,
+ endlink)));
+
+ sizet_ftype_string /* strlen prototype */
+ = build_function_type (sizetype,
+ tree_cons (NULL_TREE, const_string_type_node,
+ endlink));
+
+ traditional_ptr_type_node
+ = (flag_traditional ? string_type_node : ptr_type_node);
+
+ memcpy_ftype /* memcpy prototype */
+ = build_function_type (traditional_ptr_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ tree_cons (NULL_TREE, const_ptr_type_node,
+ tree_cons (NULL_TREE,
+ sizetype,
+ endlink))));
+
+ if (flag_huge_objects)
+ delta_type_node = long_integer_type_node;
+ else
+ delta_type_node = short_integer_type_node;
+
+ builtin_function ("__builtin_constant_p", int_ftype_int,
+ BUILT_IN_CONSTANT_P, NULL_PTR);
+
+ builtin_return_address_fndecl =
+ builtin_function ("__builtin_return_address",
+ build_function_type (ptr_type_node,
+ tree_cons (NULL_TREE,
+ unsigned_type_node,
+ endlink)),
+ BUILT_IN_RETURN_ADDRESS, NULL_PTR);
+
+ builtin_function ("__builtin_frame_address",
+ build_function_type (ptr_type_node,
+ tree_cons (NULL_TREE,
+ unsigned_type_node,
+ endlink)),
+ BUILT_IN_FRAME_ADDRESS, NULL_PTR);
+
+
+ builtin_function ("__builtin_alloca",
+ build_function_type (ptr_type_node,
+ tree_cons (NULL_TREE,
+ sizetype,
+ endlink)),
+ BUILT_IN_ALLOCA, "alloca");
+ /* Define alloca, ffs as builtins.
+ Declare _exit just to mark it as volatile. */
+ if (! flag_no_builtin && !flag_no_nonansi_builtin)
+ {
+ temp = builtin_function ("alloca",
+ build_function_type (ptr_type_node,
+ tree_cons (NULL_TREE,
+ sizetype,
+ endlink)),
+ BUILT_IN_ALLOCA, NULL_PTR);
+ /* Suppress error if redefined as a non-function. */
+ DECL_BUILT_IN_NONANSI (temp) = 1;
+ temp = builtin_function ("ffs", int_ftype_int, BUILT_IN_FFS, NULL_PTR);
+ /* Suppress error if redefined as a non-function. */
+ DECL_BUILT_IN_NONANSI (temp) = 1;
+ temp = builtin_function ("_exit", build_function_type (void_type_node,
+ int_endlink),
+ NOT_BUILT_IN, NULL_PTR);
+ TREE_THIS_VOLATILE (temp) = 1;
+ TREE_SIDE_EFFECTS (temp) = 1;
+ /* Suppress error if redefined as a non-function. */
+ DECL_BUILT_IN_NONANSI (temp) = 1;
+ }
+
+ builtin_function ("__builtin_abs", int_ftype_int,
+ BUILT_IN_ABS, NULL_PTR);
+ builtin_function ("__builtin_fabs", double_ftype_double,
+ BUILT_IN_FABS, NULL_PTR);
+ builtin_function ("__builtin_labs", long_ftype_long,
+ BUILT_IN_LABS, NULL_PTR);
+ builtin_function ("__builtin_ffs", int_ftype_int,
+ BUILT_IN_FFS, NULL_PTR);
+ builtin_function ("__builtin_fsqrt", double_ftype_double,
+ BUILT_IN_FSQRT, NULL_PTR);
+ builtin_function ("__builtin_sin", double_ftype_double,
+ BUILT_IN_SIN, "sin");
+ builtin_function ("__builtin_cos", double_ftype_double,
+ BUILT_IN_COS, "cos");
+ builtin_function ("__builtin_saveregs",
+ build_function_type (ptr_type_node, NULL_TREE),
+ BUILT_IN_SAVEREGS, NULL_PTR);
+/* EXPAND_BUILTIN_VARARGS is obsolete. */
+#if 0
+ builtin_function ("__builtin_varargs",
+ build_function_type (ptr_type_node,
+ tree_cons (NULL_TREE,
+ integer_type_node,
+ endlink)),
+ BUILT_IN_VARARGS, NULL_PTR);
+#endif
+ builtin_function ("__builtin_classify_type", default_function_type,
+ BUILT_IN_CLASSIFY_TYPE, NULL_PTR);
+ builtin_function ("__builtin_next_arg",
+ build_function_type (ptr_type_node, NULL_TREE),
+ BUILT_IN_NEXT_ARG, NULL_PTR);
+ builtin_function ("__builtin_args_info",
+ build_function_type (integer_type_node,
+ tree_cons (NULL_TREE,
+ integer_type_node,
+ endlink)),
+ BUILT_IN_ARGS_INFO, NULL_PTR);
+
+ /* Untyped call and return. */
+ builtin_function ("__builtin_apply_args",
+ build_function_type (ptr_type_node, NULL_TREE),
+ BUILT_IN_APPLY_ARGS, NULL_PTR);
+
+ temp = tree_cons (NULL_TREE,
+ build_pointer_type (build_function_type (void_type_node,
+ NULL_TREE)),
+ tree_cons (NULL_TREE,
+ ptr_type_node,
+ tree_cons (NULL_TREE,
+ sizetype,
+ endlink)));
+ builtin_function ("__builtin_apply",
+ build_function_type (ptr_type_node, temp),
+ BUILT_IN_APPLY, NULL_PTR);
+ builtin_function ("__builtin_return",
+ build_function_type (void_type_node,
+ tree_cons (NULL_TREE,
+ ptr_type_node,
+ endlink)),
+ BUILT_IN_RETURN, NULL_PTR);
+
+ /* Currently under experimentation. */
+ builtin_function ("__builtin_memcpy", memcpy_ftype,
+ BUILT_IN_MEMCPY, "memcpy");
+ builtin_function ("__builtin_memcmp", int_ftype_cptr_cptr_sizet,
+ BUILT_IN_MEMCMP, "memcmp");
+ builtin_function ("__builtin_strcmp", int_ftype_string_string,
+ BUILT_IN_STRCMP, "strcmp");
+ builtin_function ("__builtin_strcpy", string_ftype_ptr_ptr,
+ BUILT_IN_STRCPY, "strcpy");
+#if 0
+ /* Not yet. */
+ builtin_function ("__builtin_strncpy", strncpy_ftype,
+ BUILT_IN_STRNCPY, "strncpy");
+#endif
+ builtin_function ("__builtin_strlen", sizet_ftype_string,
+ BUILT_IN_STRLEN, "strlen");
+
+ if (!flag_no_builtin)
+ {
+#if 0 /* These do not work well with libg++. */
+ builtin_function ("abs", int_ftype_int, BUILT_IN_ABS, NULL_PTR);
+ builtin_function ("fabs", double_ftype_double, BUILT_IN_FABS, NULL_PTR);
+ builtin_function ("labs", long_ftype_long, BUILT_IN_LABS, NULL_PTR);
+#endif
+ builtin_function ("memcpy", memcpy_ftype, BUILT_IN_MEMCPY, NULL_PTR);
+ builtin_function ("memcmp", int_ftype_cptr_cptr_sizet, BUILT_IN_MEMCMP,
+ NULL_PTR);
+ builtin_function ("strcmp", int_ftype_string_string, BUILT_IN_STRCMP, NULL_PTR);
+ builtin_function ("strcpy", string_ftype_ptr_ptr, BUILT_IN_STRCPY,
+ NULL_PTR);
+#if 0
+ /* Not yet. */
+ builtin_function ("strncpy", strncpy_ftype, BUILT_IN_STRNCPY, NULL_PTR);
+#endif
+ builtin_function ("strlen", sizet_ftype_string, BUILT_IN_STRLEN, NULL_PTR);
+ builtin_function ("sin", double_ftype_double, BUILT_IN_SIN, NULL_PTR);
+ builtin_function ("cos", double_ftype_double, BUILT_IN_COS, NULL_PTR);
+
+ /* Declare these functions volatile
+ to avoid spurious "control drops through" warnings. */
+ temp = builtin_function ("abort",
+ build_function_type (void_type_node, endlink),
+ NOT_BUILT_IN, NULL_PTR);
+ TREE_THIS_VOLATILE (temp) = 1;
+ TREE_SIDE_EFFECTS (temp) = 1;
+ /* Well, these are actually ANSI, but we can't set DECL_BUILT_IN on
+ them... */
+ DECL_BUILT_IN_NONANSI (temp) = 1;
+ temp = builtin_function ("exit", build_function_type (void_type_node,
+ int_endlink),
+ NOT_BUILT_IN, NULL_PTR);
+ TREE_THIS_VOLATILE (temp) = 1;
+ TREE_SIDE_EFFECTS (temp) = 1;
+ DECL_BUILT_IN_NONANSI (temp) = 1;
+ }
+
+#if 0
+ /* Support for these has not been written in either expand_builtin
+ or build_function_call. */
+ builtin_function ("__builtin_div", default_ftype, BUILT_IN_DIV, 0);
+ builtin_function ("__builtin_ldiv", default_ftype, BUILT_IN_LDIV, 0);
+ builtin_function ("__builtin_ffloor", double_ftype_double, BUILT_IN_FFLOOR,
+ 0);
+ builtin_function ("__builtin_fceil", double_ftype_double, BUILT_IN_FCEIL, 0);
+ builtin_function ("__builtin_fmod", double_ftype_double_double,
+ BUILT_IN_FMOD, 0);
+ builtin_function ("__builtin_frem", double_ftype_double_double,
+ BUILT_IN_FREM, 0);
+ builtin_function ("__builtin_memset", ptr_ftype_ptr_int_int, BUILT_IN_MEMSET,
+ 0);
+ builtin_function ("__builtin_getexp", double_ftype_double, BUILT_IN_GETEXP,
+ 0);
+ builtin_function ("__builtin_getman", double_ftype_double, BUILT_IN_GETMAN,
+ 0);
+#endif
+
+ /* C++ extensions */
+
+ unknown_type_node = make_node (UNKNOWN_TYPE);
+#if 0 /* not yet, should get fixed properly later */
+ pushdecl (make_type_decl (get_identifier ("unknown type"),
+ unknown_type_node));
+#else
+ decl = pushdecl (build_decl (TYPE_DECL, get_identifier ("unknown type"),
+ unknown_type_node));
+ /* Make sure the "unknown type" typedecl gets ignored for debug info. */
+ DECL_IGNORED_P (decl) = 1;
+ TYPE_DECL_SUPPRESS_DEBUG (decl) = 1;
+#endif
+ TYPE_SIZE (unknown_type_node) = TYPE_SIZE (void_type_node);
+ TYPE_ALIGN (unknown_type_node) = 1;
+ TYPE_MODE (unknown_type_node) = TYPE_MODE (void_type_node);
+ /* Indirecting an UNKNOWN_TYPE node yields an UNKNOWN_TYPE node. */
+ TREE_TYPE (unknown_type_node) = unknown_type_node;
+ /* Looking up TYPE_POINTER_TO and TYPE_REFERENCE_TO yield the same result. */
+ TYPE_POINTER_TO (unknown_type_node) = unknown_type_node;
+ TYPE_REFERENCE_TO (unknown_type_node) = unknown_type_node;
+
+ /* This is for handling opaque types in signatures. */
+ opaque_type_node = copy_node (ptr_type_node);
+ TYPE_MAIN_VARIANT (opaque_type_node) = opaque_type_node;
+ record_builtin_type (RID_MAX, 0, opaque_type_node);
+
+ /* This is special for C++ so functions can be overloaded. */
+ wchar_type_node
+ = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (get_identifier (WCHAR_TYPE)));
+ wchar_type_size = TYPE_PRECISION (wchar_type_node);
+ signed_wchar_type_node = make_signed_type (wchar_type_size);
+ unsigned_wchar_type_node = make_unsigned_type (wchar_type_size);
+ wchar_type_node
+ = TREE_UNSIGNED (wchar_type_node)
+ ? unsigned_wchar_type_node
+ : signed_wchar_type_node;
+ record_builtin_type (RID_WCHAR, "__wchar_t", wchar_type_node);
+
+ /* Artificial declaration of wchar_t -- can be bashed */
+ wchar_decl_node = build_decl (TYPE_DECL, get_identifier ("wchar_t"),
+ wchar_type_node);
+ pushdecl (wchar_decl_node);
+
+ /* This is for wide string constants. */
+ wchar_array_type_node
+ = build_array_type (wchar_type_node, array_domain_type);
+
+ /* This is a hack that should go away when we deliver the
+ real gc code. */
+ if (flag_gc)
+ {
+ builtin_function ("__gc_main", default_function_type, NOT_BUILT_IN, 0);
+ pushdecl (lookup_name (get_identifier ("__gc_main"), 0));
+ }
+
+ if (flag_vtable_thunks)
+ {
+ /* Make sure we get a unique function type, so we can give
+ its pointer type a name. (This wins for gdb.) */
+ tree vfunc_type = make_node (FUNCTION_TYPE);
+ TREE_TYPE (vfunc_type) = integer_type_node;
+ TYPE_ARG_TYPES (vfunc_type) = NULL_TREE;
+ layout_type (vfunc_type);
+
+ vtable_entry_type = build_pointer_type (vfunc_type);
+ }
+ else
+ {
+ vtable_entry_type = make_lang_type (RECORD_TYPE);
+ fields[0] = build_lang_field_decl (FIELD_DECL, delta_identifier,
+ delta_type_node);
+ fields[1] = build_lang_field_decl (FIELD_DECL, index_identifier,
+ delta_type_node);
+ fields[2] = build_lang_field_decl (FIELD_DECL, pfn_identifier,
+ ptr_type_node);
+ finish_builtin_type (vtable_entry_type, VTBL_PTR_TYPE, fields, 2,
+ double_type_node);
+
+ /* Make this part of an invisible union. */
+ fields[3] = copy_node (fields[2]);
+ TREE_TYPE (fields[3]) = delta_type_node;
+ DECL_NAME (fields[3]) = delta2_identifier;
+ DECL_MODE (fields[3]) = TYPE_MODE (delta_type_node);
+ DECL_SIZE (fields[3]) = TYPE_SIZE (delta_type_node);
+ TREE_UNSIGNED (fields[3]) = 0;
+ TREE_CHAIN (fields[2]) = fields[3];
+ vtable_entry_type = build_type_variant (vtable_entry_type, 1, 0);
+ }
+ record_builtin_type (RID_MAX, VTBL_PTR_TYPE, vtable_entry_type);
+
+ vtbl_type_node
+ = build_array_type (vtable_entry_type, NULL_TREE);
+ layout_type (vtbl_type_node);
+ vtbl_type_node = cp_build_type_variant (vtbl_type_node, 1, 0);
+ record_builtin_type (RID_MAX, NULL_PTR, vtbl_type_node);
+
+ /* Simplify life by making a "sigtable_entry_type". Give its
+ fields names so that the debugger can use them. */
+
+ if (flag_handle_signatures)
+ {
+ sigtable_entry_type = make_lang_type (RECORD_TYPE);
+ fields[0] = build_lang_field_decl (FIELD_DECL, tag_identifier,
+ delta_type_node);
+ fields[1] = build_lang_field_decl (FIELD_DECL, vb_off_identifier,
+ delta_type_node);
+ fields[2] = build_lang_field_decl (FIELD_DECL, delta_identifier,
+ delta_type_node);
+ fields[3] = build_lang_field_decl (FIELD_DECL, index_identifier,
+ delta_type_node);
+ fields[4] = build_lang_field_decl (FIELD_DECL, pfn_identifier,
+ ptr_type_node);
+
+ /* Set the alignment to the max of the alignment of ptr_type_node and
+ delta_type_node. Double alignment wastes a word on the Sparc. */
+ finish_builtin_type (sigtable_entry_type, SIGTABLE_PTR_TYPE, fields, 4,
+ (TYPE_ALIGN (ptr_type_node) > TYPE_ALIGN (delta_type_node))
+ ? ptr_type_node
+ : delta_type_node);
+
+ /* Make this part of an invisible union. */
+ fields[5] = copy_node (fields[4]);
+ TREE_TYPE (fields[5]) = delta_type_node;
+ DECL_NAME (fields[5]) = vt_off_identifier;
+ DECL_MODE (fields[5]) = TYPE_MODE (delta_type_node);
+ DECL_SIZE (fields[5]) = TYPE_SIZE (delta_type_node);
+ TREE_UNSIGNED (fields[5]) = 0;
+ TREE_CHAIN (fields[4]) = fields[5];
+
+ sigtable_entry_type = build_type_variant (sigtable_entry_type, 1, 0);
+ record_builtin_type (RID_MAX, SIGTABLE_PTR_TYPE, sigtable_entry_type);
+ }
+
+#if 0
+ if (flag_rtti)
+ {
+ /* Must build __t_desc type. Currently, type descriptors look like this:
+
+ struct __t_desc
+ {
+ const char *name;
+ int size;
+ int bits;
+ struct __t_desc *points_to;
+ int ivars_count, meths_count;
+ struct __i_desc *ivars[];
+ struct __m_desc *meths[];
+ struct __t_desc *parents[];
+ struct __t_desc *vbases[];
+ int offsets[];
+ };
+
+ ...as per Linton's paper. */
+
+ __t_desc_type_node = make_lang_type (RECORD_TYPE);
+ __i_desc_type_node = make_lang_type (RECORD_TYPE);
+ __m_desc_type_node = make_lang_type (RECORD_TYPE);
+ __t_desc_array_type =
+ build_array_type (build_pointer_type (__t_desc_type_node), NULL_TREE);
+ __i_desc_array_type =
+ build_array_type (build_pointer_type (__i_desc_type_node), NULL_TREE);
+ __m_desc_array_type =
+ build_array_type (build_pointer_type (__m_desc_type_node), NULL_TREE);
+
+ fields[0] = build_lang_field_decl (FIELD_DECL, get_identifier ("name"),
+ string_type_node);
+ fields[1] = build_lang_field_decl (FIELD_DECL, get_identifier ("size"),
+ unsigned_type_node);
+ fields[2] = build_lang_field_decl (FIELD_DECL, get_identifier ("bits"),
+ unsigned_type_node);
+ fields[3] = build_lang_field_decl (FIELD_DECL,
+ get_identifier ("points_to"),
+ build_pointer_type (__t_desc_type_node));
+ fields[4] = build_lang_field_decl (FIELD_DECL,
+ get_identifier ("ivars_count"),
+ integer_type_node);
+ fields[5] = build_lang_field_decl (FIELD_DECL,
+ get_identifier ("meths_count"),
+ integer_type_node);
+ fields[6] = build_lang_field_decl (FIELD_DECL, get_identifier ("ivars"),
+ build_pointer_type (__i_desc_array_type));
+ fields[7] = build_lang_field_decl (FIELD_DECL, get_identifier ("meths"),
+ build_pointer_type (__m_desc_array_type));
+ fields[8] = build_lang_field_decl (FIELD_DECL, get_identifier ("parents"),
+ build_pointer_type (__t_desc_array_type));
+ fields[9] = build_lang_field_decl (FIELD_DECL, get_identifier ("vbases"),
+ build_pointer_type (__t_desc_array_type));
+ fields[10] = build_lang_field_decl (FIELD_DECL, get_identifier ("offsets"),
+ build_pointer_type (integer_type_node));
+ finish_builtin_type (__t_desc_type_node, "__t_desc", fields, 10, integer_type_node);
+
+ /* ivar descriptors look like this:
+
+ struct __i_desc
+ {
+ const char *name;
+ int offset;
+ struct __t_desc *type;
+ };
+ */
+
+ fields[0] = build_lang_field_decl (FIELD_DECL, get_identifier ("name"),
+ string_type_node);
+ fields[1] = build_lang_field_decl (FIELD_DECL, get_identifier ("offset"),
+ integer_type_node);
+ fields[2] = build_lang_field_decl (FIELD_DECL, get_identifier ("type"),
+ build_pointer_type (__t_desc_type_node));
+ finish_builtin_type (__i_desc_type_node, "__i_desc", fields, 2,
+ integer_type_node);
+
+ /* method descriptors look like this:
+
+ struct __m_desc
+ {
+ const char *name;
+ int vindex;
+ struct __t_desc *vcontext;
+ struct __t_desc *return_type;
+ void (*address)();
+ short parm_count;
+ short required_parms;
+ struct __t_desc *parm_types[];
+ };
+ */
+
+ fields[0] = build_lang_field_decl (FIELD_DECL, get_identifier ("name"),
+ string_type_node);
+ fields[1] = build_lang_field_decl (FIELD_DECL, get_identifier ("vindex"),
+ integer_type_node);
+ fields[2] = build_lang_field_decl (FIELD_DECL, get_identifier ("vcontext"),
+ build_pointer_type (__t_desc_type_node));
+ fields[3] = build_lang_field_decl (FIELD_DECL, get_identifier ("return_type"),
+ build_pointer_type (__t_desc_type_node));
+ fields[4] = build_lang_field_decl (FIELD_DECL, get_identifier ("address"),
+ build_pointer_type (default_function_type));
+ fields[5] = build_lang_field_decl (FIELD_DECL, get_identifier ("parm_count"),
+ short_integer_type_node);
+ fields[6] = build_lang_field_decl (FIELD_DECL, get_identifier ("required_parms"),
+ short_integer_type_node);
+ fields[7] = build_lang_field_decl (FIELD_DECL, get_identifier ("parm_types"),
+ build_pointer_type (build_array_type (build_pointer_type (__t_desc_type_node), NULL_TREE)));
+ finish_builtin_type (__m_desc_type_node, "__m_desc", fields, 7,
+ integer_type_node);
+ }
+
+ if (flag_rtti)
+ {
+ int i = builtin_type_tdescs_len;
+ while (i > 0)
+ {
+ tree tdesc = build_t_desc (builtin_type_tdescs_arr[--i], 0);
+ TREE_ASM_WRITTEN (tdesc) = 1;
+ TREE_PUBLIC (TREE_OPERAND (tdesc, 0)) = 1;
+ }
+ }
+#endif /*flag_rtti*/
+
+ /* Now, C++. */
+ current_lang_name = lang_name_cplusplus;
+
+ auto_function (ansi_opname[(int) NEW_EXPR],
+ build_function_type (ptr_type_node,
+ tree_cons (NULL_TREE, sizetype,
+ void_list_node)),
+ NOT_BUILT_IN);
+ auto_function (ansi_opname[(int) VEC_NEW_EXPR],
+ build_function_type (ptr_type_node,
+ tree_cons (NULL_TREE, sizetype,
+ void_list_node)),
+ NOT_BUILT_IN);
+ auto_function (ansi_opname[(int) DELETE_EXPR],
+ build_function_type (void_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ void_list_node)),
+ NOT_BUILT_IN);
+ auto_function (ansi_opname[(int) VEC_DELETE_EXPR],
+ build_function_type (void_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ void_list_node)),
+ NOT_BUILT_IN);
+
+ abort_fndecl
+ = define_function ("__pure_virtual",
+ build_function_type (void_type_node, void_list_node),
+ NOT_BUILT_IN, 0, 0);
+
+ /* Perform other language dependent initializations. */
+ init_class_processing ();
+ init_init_processing ();
+ init_search_processing ();
+
+ if (flag_handle_exceptions)
+ init_exception_processing ();
+ if (flag_gc)
+ init_gc_processing ();
+ if (flag_no_inline)
+ {
+ flag_inline_functions = 0;
+#if 0
+ /* This causes unnecessary emission of inline functions. */
+ flag_default_inline = 0;
+#endif
+ }
+ if (flag_cadillac)
+ init_cadillac ();
+
+ /* Create the global bindings for __FUNCTION__ and __PRETTY_FUNCTION__. */
+ declare_function_name ();
+
+ /* Prepare to check format strings against argument lists. */
+ init_function_format_info ();
+}
+
+/* initialize type descriptor type node of various rtti type. */
+
+int
+init_type_desc()
+{
+ tree tdecl;
+
+ tdecl = lookup_name (get_identifier ("type_info"), 0);
+ if (tdecl == NULL_TREE)
+ return 0;
+ __t_desc_type_node = TREE_TYPE(tdecl);
+ __tp_desc_type_node = build_pointer_type (__t_desc_type_node);
+
+#if 0
+ tdecl = lookup_name (get_identifier ("__baselist_type_info"), 0);
+ if (tdecl == NULL_TREE)
+ return 0;
+ __baselist_desc_type_node = TREE_TYPE (tdecl);
+#endif
+
+ tdecl = lookup_name (get_identifier ("__builtin_type_info"), 0);
+ if (tdecl == NULL_TREE)
+ return 0;
+ __bltn_desc_type_node = TREE_TYPE (tdecl);
+
+ tdecl = lookup_name (get_identifier ("__user_type_info"), 0);
+ if (tdecl == NULL_TREE)
+ return 0;
+ __user_desc_type_node = TREE_TYPE (tdecl);
+
+ tdecl = lookup_name (get_identifier ("__class_type_info"), 0);
+ if (tdecl == NULL_TREE)
+ return 0;
+ __class_desc_type_node = TREE_TYPE (tdecl);
+
+ tdecl = lookup_field (__class_desc_type_node,
+ get_identifier ("access_mode"), 0, 0);
+ if (tdecl == NULL_TREE)
+ return 0;
+ __access_mode_type_node = TREE_TYPE (tdecl);
+
+ tdecl = lookup_name (get_identifier ("__attr_type_info"), 0);
+ if (tdecl == NULL_TREE)
+ return 0;
+ __attr_desc_type_node = TREE_TYPE (tdecl);
+
+ tdecl = lookup_name (get_identifier ("__pointer_type_info"), 0);
+ if (tdecl == NULL_TREE)
+ return 0;
+ __ptr_desc_type_node = TREE_TYPE (tdecl);
+
+ tdecl = lookup_name (get_identifier ("__func_type_info"), 0);
+ if (tdecl == NULL_TREE)
+ return 0;
+ __func_desc_type_node = TREE_TYPE (tdecl);
+
+ tdecl = lookup_name (get_identifier ("__ptmf_type_info"), 0);
+ if (tdecl == NULL_TREE)
+ return 0;
+ __ptmf_desc_type_node = TREE_TYPE (tdecl);
+
+ tdecl = lookup_name (get_identifier ("__ptmd_type_info"), 0);
+ if (tdecl == NULL_TREE)
+ return 0;
+ __ptmd_desc_type_node = TREE_TYPE (tdecl);
+
+ return 1;
+}
+/* Make a definition for a builtin function named NAME and whose data type
+ is TYPE. TYPE should be a function type with argument types.
+ FUNCTION_CODE tells later passes how to compile calls to this function.
+ See tree.h for its possible values.
+
+ If LIBRARY_NAME is nonzero, use that for DECL_ASSEMBLER_NAME,
+ the name to be called if we can't opencode the function. */
+
+tree
+define_function (name, type, function_code, pfn, library_name)
+ char *name;
+ tree type;
+ enum built_in_function function_code;
+ void (*pfn)();
+ char *library_name;
+{
+ tree decl = build_lang_decl (FUNCTION_DECL, get_identifier (name), type);
+ DECL_EXTERNAL (decl) = 1;
+ TREE_PUBLIC (decl) = 1;
+ DECL_ARTIFICIAL (decl) = 1;
+
+ /* Since `pushdecl' relies on DECL_ASSEMBLER_NAME instead of DECL_NAME,
+ we cannot change DECL_ASSEMBLER_NAME until we have installed this
+ function in the namespace. */
+ if (pfn) (*pfn) (decl);
+ if (library_name)
+ DECL_ASSEMBLER_NAME (decl) = get_identifier (library_name);
+ make_function_rtl (decl);
+ if (function_code != NOT_BUILT_IN)
+ {
+ DECL_BUILT_IN (decl) = 1;
+ DECL_FUNCTION_CODE (decl) = function_code;
+ }
+ return decl;
+}
+
+/* Called when a declaration is seen that contains no names to declare.
+ If its type is a reference to a structure, union or enum inherited
+ from a containing scope, shadow that tag name for the current scope
+ with a forward reference.
+ If its type defines a new named structure or union
+ or defines an enum, it is valid but we need not do anything here.
+ Otherwise, it is an error.
+
+ C++: may have to grok the declspecs to learn about static,
+ complain for anonymous unions. */
+
+void
+shadow_tag (declspecs)
+ tree declspecs;
+{
+ int found_tag = 0;
+ tree ob_modifier = NULL_TREE;
+ register tree link;
+ register enum tree_code code, ok_code = ERROR_MARK;
+ register tree t = NULL_TREE;
+
+ for (link = declspecs; link; link = TREE_CHAIN (link))
+ {
+ register tree value = TREE_VALUE (link);
+
+ code = TREE_CODE (value);
+ if (IS_AGGR_TYPE_CODE (code) || code == ENUMERAL_TYPE)
+ {
+ my_friendly_assert (TYPE_NAME (value) != NULL_TREE, 261);
+
+ if (code == ENUMERAL_TYPE && TYPE_SIZE (value) == 0)
+ cp_error ("forward declaration of `%#T'", value);
+
+ t = value;
+ ok_code = code;
+ found_tag++;
+ }
+ else if (value == ridpointers[(int) RID_STATIC]
+ || value == ridpointers[(int) RID_EXTERN]
+ || value == ridpointers[(int) RID_AUTO]
+ || value == ridpointers[(int) RID_REGISTER]
+ || value == ridpointers[(int) RID_INLINE]
+ || value == ridpointers[(int) RID_VIRTUAL]
+ || value == ridpointers[(int) RID_EXPLICIT])
+ ob_modifier = value;
+ }
+
+ /* This is where the variables in an anonymous union are
+ declared. An anonymous union declaration looks like:
+ union { ... } ;
+ because there is no declarator after the union, the parser
+ sends that declaration here. */
+ if (ok_code == UNION_TYPE
+ && t != NULL_TREE
+ && ((TREE_CODE (TYPE_NAME (t)) == IDENTIFIER_NODE
+ && ANON_AGGRNAME_P (TYPE_NAME (t)))
+ || (TREE_CODE (TYPE_NAME (t)) == TYPE_DECL
+ && ANON_AGGRNAME_P (TYPE_IDENTIFIER (t)))))
+ {
+ /* ANSI C++ June 5 1992 WP 9.5.3. Anonymous unions may not have
+ function members. */
+ if (TYPE_FIELDS (t))
+ {
+ tree decl = grokdeclarator (NULL_TREE, declspecs, NORMAL, 0,
+ NULL_TREE, NULL_TREE);
+ finish_anon_union (decl);
+ }
+ else
+ error ("anonymous union cannot have a function member");
+ }
+ else
+ {
+ /* Anonymous unions are objects, that's why we only check for
+ inappropriate specifiers in this branch. */
+
+ if (ob_modifier)
+ {
+ if (ob_modifier == ridpointers[(int) RID_INLINE]
+ || ob_modifier == ridpointers[(int) RID_VIRTUAL])
+ cp_error ("`%D' can only be specified for functions", ob_modifier);
+ else if (ob_modifier == ridpointers[(int) RID_EXPLICIT])
+ cp_error ("`%D' can only be specified for constructors",
+ ob_modifier);
+ else
+ cp_error ("`%D' can only be specified for objects and functions",
+ ob_modifier);
+ }
+
+ if (found_tag == 0)
+ pedwarn ("abstract declarator used as declaration");
+ else if (found_tag > 1)
+ pedwarn ("multiple types in one declaration");
+ }
+}
+
+/* Decode a "typename", such as "int **", returning a ..._TYPE node. */
+
+tree
+groktypename (typename)
+ tree typename;
+{
+ if (TREE_CODE (typename) != TREE_LIST)
+ return typename;
+ return grokdeclarator (TREE_VALUE (typename),
+ TREE_PURPOSE (typename),
+ TYPENAME, 0, NULL_TREE, NULL_TREE);
+}
+
+/* Decode a declarator in an ordinary declaration or data definition.
+ This is called as soon as the type information and variable name
+ have been parsed, before parsing the initializer if any.
+ Here we create the ..._DECL node, fill in its type,
+ and put it on the list of decls for the current context.
+ The ..._DECL node is returned as the value.
+
+ Exception: for arrays where the length is not specified,
+ the type is left null, to be filled in by `cp_finish_decl'.
+
+ Function definitions do not come here; they go to start_function
+ instead. However, external and forward declarations of functions
+ do go through here. Structure field declarations are done by
+ grokfield and not through here. */
+
+/* Set this to zero to debug not using the temporary obstack
+ to parse initializers. */
+int debug_temp_inits = 1;
+
+tree
+start_decl (declarator, declspecs, initialized, raises)
+ tree declarator, declspecs;
+ int initialized;
+ tree raises;
+{
+ register tree decl;
+ register tree type, tem;
+ tree context;
+ extern int have_extern_spec;
+ extern int used_extern_spec;
+
+ int init_written = initialized;
+
+ /* This should only be done once on the top most decl. */
+ if (have_extern_spec && !used_extern_spec)
+ {
+ declspecs = decl_tree_cons (NULL_TREE, get_identifier ("extern"),
+ declspecs);
+ used_extern_spec = 1;
+ }
+
+ decl = grokdeclarator (declarator, declspecs, NORMAL, initialized, raises,
+ NULL_TREE);
+ if (decl == NULL_TREE || decl == void_type_node)
+ return NULL_TREE;
+
+ type = TREE_TYPE (decl);
+
+ /* Don't lose if destructors must be executed at file-level. */
+ if (TREE_STATIC (decl)
+ && TYPE_NEEDS_DESTRUCTOR (type)
+ && !TREE_PERMANENT (decl))
+ {
+ push_obstacks (&permanent_obstack, &permanent_obstack);
+ decl = copy_node (decl);
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ {
+ tree itype = TYPE_DOMAIN (type);
+ if (itype && ! TREE_PERMANENT (itype))
+ {
+ itype = build_index_type (copy_to_permanent (TYPE_MAX_VALUE (itype)));
+ type = build_cplus_array_type (TREE_TYPE (type), itype);
+ TREE_TYPE (decl) = type;
+ }
+ }
+ pop_obstacks ();
+ }
+
+ /* Corresponding pop_obstacks is done in `cp_finish_decl'. */
+ push_obstacks_nochange ();
+
+ context
+ = (TREE_CODE (decl) == FUNCTION_DECL && DECL_VIRTUAL_P (decl))
+ ? DECL_CLASS_CONTEXT (decl)
+ : DECL_CONTEXT (decl);
+
+ if (processing_template_decl)
+ {
+ tree d;
+ if (TREE_CODE (decl) == FUNCTION_DECL)
+ {
+ /* Declarator is a call_expr; extract arguments from it, since
+ grokdeclarator didn't do it. */
+ tree args;
+ args = copy_to_permanent (last_function_parms);
+ if (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)
+ {
+ tree t = TREE_TYPE (decl);
+
+ t = TYPE_METHOD_BASETYPE (t); /* type method belongs to */
+ if (TREE_CODE (t) != UNINSTANTIATED_P_TYPE)
+ {
+ t = build_pointer_type (t); /* base type of `this' */
+#if 1
+ /* I suspect this is wrong. */
+ t = build_type_variant (t, flag_this_is_variable <= 0,
+ 0); /* type of `this' */
+#else
+ t = build_type_variant (t, 0, 0); /* type of `this' */
+#endif
+ t = build (PARM_DECL, t, this_identifier);
+ TREE_CHAIN (t) = args;
+ args = t;
+ }
+ }
+ DECL_ARGUMENTS (decl) = args;
+ }
+ d = build_lang_decl (TEMPLATE_DECL, DECL_NAME (decl), TREE_TYPE (decl));
+ TREE_PUBLIC (d) = TREE_PUBLIC (decl);
+ TREE_STATIC (d) = TREE_STATIC (decl);
+ DECL_EXTERNAL (d) = (DECL_EXTERNAL (decl)
+ && !(context && !DECL_THIS_EXTERN (decl)));
+ DECL_TEMPLATE_RESULT (d) = decl;
+ decl = d;
+ }
+
+ /* If this type of object needs a cleanup, and control may
+ jump past it, make a new binding level so that it is cleaned
+ up only when it is initialized first. */
+ if (TYPE_NEEDS_DESTRUCTOR (type)
+ && current_binding_level->more_cleanups_ok == 0)
+ pushlevel_temporary (1);
+
+ if (initialized)
+ /* Is it valid for this decl to have an initializer at all?
+ If not, set INITIALIZED to zero, which will indirectly
+ tell `cp_finish_decl' to ignore the initializer once it is parsed. */
+ switch (TREE_CODE (decl))
+ {
+ case TYPE_DECL:
+ /* typedef foo = bar means give foo the same type as bar.
+ We haven't parsed bar yet, so `cp_finish_decl' will fix that up.
+ Any other case of an initialization in a TYPE_DECL is an error. */
+ if (pedantic || list_length (declspecs) > 1)
+ {
+ cp_error ("typedef `%D' is initialized", decl);
+ initialized = 0;
+ }
+ break;
+
+ case FUNCTION_DECL:
+ cp_error ("function `%#D' is initialized like a variable", decl);
+ initialized = 0;
+ break;
+
+ default:
+ /* Don't allow initializations for incomplete types except for
+ arrays which might be completed by the initialization. */
+ if (type == error_mark_node)
+ ; /* Don't complain again. */
+ else if (TYPE_SIZE (type) != NULL_TREE)
+ ; /* A complete type is ok. */
+ else if (TREE_CODE (type) != ARRAY_TYPE)
+ {
+ cp_error ("variable `%#D' has initializer but incomplete type",
+ decl);
+ initialized = 0;
+ }
+ else if (TYPE_SIZE (TREE_TYPE (type)) == NULL_TREE)
+ {
+ cp_error ("elements of array `%#D' have incomplete type", decl);
+ initialized = 0;
+ }
+ }
+
+ if (!initialized
+ && TREE_CODE (decl) != TYPE_DECL
+ && TREE_CODE (decl) != TEMPLATE_DECL
+ && IS_AGGR_TYPE (type) && ! DECL_EXTERNAL (decl))
+ {
+ if (TYPE_SIZE (type) == NULL_TREE)
+ {
+ cp_error ("aggregate `%#D' has incomplete type and cannot be initialized",
+ decl);
+ /* Change the type so that assemble_variable will give
+ DECL an rtl we can live with: (mem (const_int 0)). */
+ TREE_TYPE (decl) = error_mark_node;
+ type = error_mark_node;
+ }
+ else
+ {
+ /* If any base type in the hierarchy of TYPE needs a constructor,
+ then we set initialized to 1. This way any nodes which are
+ created for the purposes of initializing this aggregate
+ will live as long as it does. This is necessary for global
+ aggregates which do not have their initializers processed until
+ the end of the file. */
+ initialized = TYPE_NEEDS_CONSTRUCTING (type);
+ }
+ }
+
+ if (initialized)
+ {
+ if (! toplevel_bindings_p ()
+ && DECL_EXTERNAL (decl))
+ cp_warning ("declaration of `%#D' has `extern' and is initialized",
+ decl);
+ DECL_EXTERNAL (decl) = 0;
+ if ( toplevel_bindings_p ())
+ TREE_STATIC (decl) = 1;
+
+ /* Tell `pushdecl' this is an initialized decl
+ even though we don't yet have the initializer expression.
+ Also tell `cp_finish_decl' it may store the real initializer. */
+ DECL_INITIAL (decl) = error_mark_node;
+ }
+
+ if (context && TYPE_SIZE (context) != NULL_TREE)
+ {
+ if (TREE_CODE (decl) == VAR_DECL)
+ {
+ tree field = lookup_field (context, DECL_NAME (decl), 0, 0);
+ if (field == NULL_TREE || TREE_CODE (field) != VAR_DECL)
+ cp_error ("`%#D' is not a static member of `%#T'", decl, context);
+ else if (duplicate_decls (decl, field))
+ decl = field;
+ }
+ else
+ {
+ tree field = check_classfn (context, NULL_TREE, decl);
+ if (field && duplicate_decls (decl, field))
+ decl = field;
+ }
+
+ /* cp_finish_decl sets DECL_EXTERNAL if DECL_IN_AGGR_P is set. */
+ if (DECL_LANG_SPECIFIC (decl))
+ DECL_IN_AGGR_P (decl) = 0;
+ if (DECL_USE_TEMPLATE (decl) || CLASSTYPE_USE_TEMPLATE (context))
+ SET_DECL_TEMPLATE_SPECIALIZATION (decl);
+
+ /* Stupid stupid stupid stupid (jason 7/21/95) */
+ if (pedantic && DECL_EXTERNAL (decl)
+ && ! DECL_TEMPLATE_SPECIALIZATION (decl))
+ cp_pedwarn ("declaration of `%#D' outside of class is not definition",
+ decl);
+
+ pushclass (context, 2);
+ }
+
+ /* Add this decl to the current binding level, but not if it
+ comes from another scope, e.g. a static member variable.
+ TEM may equal DECL or it may be a previous decl of the same name. */
+
+ if ((TREE_CODE (decl) != PARM_DECL && DECL_CONTEXT (decl) != NULL_TREE)
+ || (TREE_CODE (decl) == TEMPLATE_DECL && !global_bindings_p ())
+ || TREE_CODE (type) == LANG_TYPE)
+ tem = decl;
+ else
+ tem = pushdecl (decl);
+
+ /* Tell the back-end to use or not use .common as appropriate. If we say
+ -fconserve-space, we want this to save space, at the expense of wrong
+ semantics. If we say -fno-conserve-space, we want this to produce
+ errors about redefs; to do this we force variables into the data
+ segment. Common storage is okay for non-public uninitialized data;
+ the linker can't match it with storage from other files, and we may
+ save some disk space. */
+ DECL_COMMON (tem) = flag_conserve_space || ! TREE_PUBLIC (tem);
+
+#if 0
+ /* We don't do this yet for GNU C++. */
+ /* For a local variable, define the RTL now. */
+ if (! toplevel_bindings_p ()
+ /* But not if this is a duplicate decl
+ and we preserved the rtl from the previous one
+ (which may or may not happen). */
+ && DECL_RTL (tem) == NULL_RTX)
+ {
+ if (TYPE_SIZE (TREE_TYPE (tem)) != NULL_TREE)
+ expand_decl (tem);
+ else if (TREE_CODE (TREE_TYPE (tem)) == ARRAY_TYPE
+ && DECL_INITIAL (tem) != NULL_TREE)
+ expand_decl (tem);
+ }
+#endif
+
+ if (TREE_CODE (decl) == TEMPLATE_DECL)
+ {
+ tree result = DECL_TEMPLATE_RESULT (decl);
+ if (DECL_CONTEXT (result) != NULL_TREE)
+ {
+ tree type;
+ type = DECL_CONTEXT (result);
+
+ if (TREE_CODE (type) != UNINSTANTIATED_P_TYPE)
+ {
+ cp_error ("declaration of `%D' in non-template type `%T'",
+ decl, type);
+ return NULL_TREE;
+ }
+
+ if (TREE_CODE (result) == FUNCTION_DECL)
+ return tem;
+ else if (TREE_CODE (result) == VAR_DECL)
+ {
+#if 0
+ tree tmpl = UPT_TEMPLATE (type);
+
+ fprintf (stderr, "%s:%d: adding ", __FILE__, __LINE__);
+ print_node_brief (stderr, "", DECL_NAME (tem), 0);
+ fprintf (stderr, " to class %s\n",
+ IDENTIFIER_POINTER (DECL_NAME (tmpl)));
+ DECL_TEMPLATE_MEMBERS (tmpl)
+ = perm_tree_cons (DECL_NAME (tem), tem,
+ DECL_TEMPLATE_MEMBERS (tmpl));
+ return tem;
+#else
+ sorry ("static data member templates");
+ return NULL_TREE;
+#endif
+ }
+ else
+ my_friendly_abort (13);
+ }
+ else if (TREE_CODE (result) == FUNCTION_DECL)
+ /*tem = push_overloaded_decl (tem, 0)*/;
+ else if (TREE_CODE (result) == VAR_DECL)
+ {
+ cp_error ("data template `%#D' must be member of a class template",
+ result);
+ return NULL_TREE;
+ }
+ else if (TREE_CODE (result) == TYPE_DECL)
+ {
+ cp_error ("invalid template `%#D'", result);
+ return NULL_TREE;
+ }
+ else
+ my_friendly_abort (14);
+ }
+
+ if (init_written
+ && ! (TREE_CODE (tem) == PARM_DECL
+ || (TREE_READONLY (tem)
+ && (TREE_CODE (tem) == VAR_DECL
+ || TREE_CODE (tem) == FIELD_DECL))))
+ {
+ /* When parsing and digesting the initializer,
+ use temporary storage. Do this even if we will ignore the value. */
+ if (toplevel_bindings_p () && debug_temp_inits)
+ {
+ if (TYPE_NEEDS_CONSTRUCTING (type)
+ || TREE_CODE (type) == REFERENCE_TYPE)
+ /* In this case, the initializer must lay down in permanent
+ storage, since it will be saved until `finish_file' is run. */
+ ;
+ else
+ temporary_allocation ();
+ }
+ }
+
+ if (flag_cadillac)
+ cadillac_start_decl (tem);
+
+ return tem;
+}
+
+#if 0 /* unused */
+static void
+make_temporary_for_reference (decl, ctor_call, init, cleanupp)
+ tree decl, ctor_call, init;
+ tree *cleanupp;
+{
+ tree type = TREE_TYPE (decl);
+ tree target_type = TREE_TYPE (type);
+ tree tmp, tmp_addr;
+
+ if (ctor_call)
+ {
+ tmp_addr = TREE_VALUE (TREE_OPERAND (ctor_call, 1));
+ if (TREE_CODE (tmp_addr) == NOP_EXPR)
+ tmp_addr = TREE_OPERAND (tmp_addr, 0);
+ my_friendly_assert (TREE_CODE (tmp_addr) == ADDR_EXPR, 146);
+ tmp = TREE_OPERAND (tmp_addr, 0);
+ }
+ else
+ {
+ tmp = get_temp_name (target_type, toplevel_bindings_p ());
+ tmp_addr = build_unary_op (ADDR_EXPR, tmp, 0);
+ }
+
+ TREE_TYPE (tmp_addr) = build_pointer_type (target_type);
+ DECL_INITIAL (decl) = convert (build_pointer_type (target_type), tmp_addr);
+ TREE_TYPE (DECL_INITIAL (decl)) = type;
+ if (TYPE_NEEDS_CONSTRUCTING (target_type))
+ {
+ if (toplevel_bindings_p ())
+ {
+ /* lay this variable out now. Otherwise `output_addressed_constants'
+ gets confused by its initializer. */
+ make_decl_rtl (tmp, NULL_PTR, 1);
+ static_aggregates = perm_tree_cons (init, tmp, static_aggregates);
+ }
+ else
+ {
+ if (ctor_call != NULL_TREE)
+ init = ctor_call;
+ else
+ init = build_method_call (tmp, constructor_name_full (target_type),
+ build_tree_list (NULL_TREE, init),
+ NULL_TREE, LOOKUP_NORMAL);
+ DECL_INITIAL (decl) = build (COMPOUND_EXPR, type, init,
+ DECL_INITIAL (decl));
+ *cleanupp = maybe_build_cleanup (tmp);
+ }
+ }
+ else
+ {
+ DECL_INITIAL (tmp) = init;
+ TREE_STATIC (tmp) = toplevel_bindings_p ();
+ cp_finish_decl (tmp, init, NULL_TREE, 0, LOOKUP_ONLYCONVERTING);
+ }
+ if (TREE_STATIC (tmp))
+ preserve_initializer ();
+}
+#endif
+
+/* Handle initialization of references.
+ These three arguments from from `cp_finish_decl', and have the
+ same meaning here that they do there. */
+/* quotes on semantics can be found in ARM 8.4.3. */
+static void
+grok_reference_init (decl, type, init, cleanupp)
+ tree decl, type, init;
+ tree *cleanupp;
+{
+ tree tmp;
+
+ if (init == NULL_TREE)
+ {
+ if ((DECL_LANG_SPECIFIC (decl) == 0
+ || DECL_IN_AGGR_P (decl) == 0)
+ && ! DECL_THIS_EXTERN (decl))
+ {
+ cp_error ("`%D' declared as reference but not initialized", decl);
+ if (TREE_CODE (decl) == VAR_DECL)
+ SET_DECL_REFERENCE_SLOT (decl, error_mark_node);
+ }
+ return;
+ }
+
+ if (init == error_mark_node)
+ return;
+
+ if (TREE_CODE (type) == REFERENCE_TYPE
+ && TREE_CODE (init) == CONSTRUCTOR)
+ {
+ cp_error ("ANSI C++ forbids use of initializer list to initialize reference `%D'", decl);
+ return;
+ }
+
+ if (TREE_CODE (init) == TREE_LIST)
+ init = build_compound_expr (init);
+
+ if (TREE_CODE (TREE_TYPE (init)) == REFERENCE_TYPE)
+ init = convert_from_reference (init);
+
+ if (TREE_CODE (TREE_TYPE (type)) != ARRAY_TYPE
+ && TREE_CODE (TREE_TYPE (init)) == ARRAY_TYPE)
+ {
+ /* Note: default conversion is only called in very special cases. */
+ init = default_conversion (init);
+ }
+
+ tmp = convert_to_reference
+ (type, init, CONV_IMPLICIT, LOOKUP_SPECULATIVELY|LOOKUP_NORMAL, decl);
+
+ if (tmp == error_mark_node)
+ goto fail;
+ else if (tmp != NULL_TREE)
+ {
+ tree subtype = TREE_TYPE (type);
+ init = tmp;
+
+ /* Associate the cleanup with the reference so that we
+ don't get burned by "aggressive" cleanup policy. */
+ if (TYPE_NEEDS_DESTRUCTOR (subtype))
+ {
+ if (TREE_CODE (init) == WITH_CLEANUP_EXPR)
+ {
+ *cleanupp = TREE_OPERAND (init, 2);
+ TREE_OPERAND (init, 2) = error_mark_node;
+ }
+ else
+ {
+ if (TREE_CODE (tmp) == ADDR_EXPR)
+ tmp = TREE_OPERAND (tmp, 0);
+ if (TREE_CODE (tmp) == TARGET_EXPR)
+ {
+ *cleanupp = build_delete
+ (build_pointer_type (subtype),
+ build_unary_op (ADDR_EXPR, TREE_OPERAND (tmp, 0), 0),
+ integer_two_node, LOOKUP_NORMAL|LOOKUP_DESTRUCTOR, 0);
+ TREE_OPERAND (tmp, 2) = error_mark_node;
+ }
+ }
+ }
+
+ DECL_INITIAL (decl) = save_expr (init);
+ }
+ else
+ {
+ cp_error ("cannot initialize `%T' from `%T'", type, TREE_TYPE (init));
+ goto fail;
+ }
+
+ /* ?? Can this be optimized in some cases to
+ hand back the DECL_INITIAL slot?? */
+ if (TYPE_SIZE (TREE_TYPE (type)))
+ {
+ init = convert_from_reference (decl);
+ if (TREE_PERMANENT (decl))
+ init = copy_to_permanent (init);
+ SET_DECL_REFERENCE_SLOT (decl, init);
+ }
+
+ if (TREE_STATIC (decl) && ! TREE_CONSTANT (DECL_INITIAL (decl)))
+ {
+ expand_static_init (decl, DECL_INITIAL (decl));
+ DECL_INITIAL (decl) = NULL_TREE;
+ }
+ return;
+
+ fail:
+ if (TREE_CODE (decl) == VAR_DECL)
+ SET_DECL_REFERENCE_SLOT (decl, error_mark_node);
+ return;
+}
+
+/* Fill in DECL_INITIAL with some magical value to prevent expand_decl from
+ mucking with forces it does not comprehend (i.e. initialization with a
+ constructor). If we are at global scope and won't go into COMMON, fill
+ it in with a dummy CONSTRUCTOR to force the variable into .data;
+ otherwise we can use error_mark_node. */
+
+static tree
+obscure_complex_init (decl, init)
+ tree decl, init;
+{
+ if (! flag_no_inline && TREE_STATIC (decl))
+ {
+ if (extract_init (decl, init))
+ return NULL_TREE;
+ }
+
+ if (toplevel_bindings_p () && ! DECL_COMMON (decl))
+ DECL_INITIAL (decl) = build (CONSTRUCTOR, TREE_TYPE (decl), NULL_TREE,
+ NULL_TREE);
+ else
+ DECL_INITIAL (decl) = error_mark_node;
+
+ return init;
+}
+
+/* Finish processing of a declaration;
+ install its line number and initial value.
+ If the length of an array type is not known before,
+ it must be determined now, from the initial value, or it is an error.
+
+ Call `pop_obstacks' iff NEED_POP is nonzero.
+
+ For C++, `cp_finish_decl' must be fairly evasive: it must keep initializers
+ for aggregates that have constructors alive on the permanent obstack,
+ so that the global initializing functions can be written at the end.
+
+ INIT0 holds the value of an initializer that should be allowed to escape
+ the normal rules.
+
+ FLAGS is LOOKUP_ONLYCONVERTING is the = init syntax was used, else 0
+ if the (init) syntax was used.
+
+ For functions that take default parameters, DECL points to its
+ "maximal" instantiation. `cp_finish_decl' must then also declared its
+ subsequently lower and lower forms of instantiation, checking for
+ ambiguity as it goes. This can be sped up later. */
+
+void
+cp_finish_decl (decl, init, asmspec_tree, need_pop, flags)
+ tree decl, init;
+ tree asmspec_tree;
+ int need_pop;
+ int flags;
+{
+ register tree type;
+ tree cleanup = NULL_TREE, ttype;
+ int was_incomplete;
+ int temporary = allocation_temporary_p ();
+ char *asmspec = NULL;
+ int was_readonly = 0;
+
+ /* If this is 0, then we did not change obstacks. */
+ if (! decl)
+ {
+ if (init)
+ error ("assignment (not initialization) in declaration");
+ return;
+ }
+
+ /* If a name was specified, get the string. */
+ if (asmspec_tree)
+ asmspec = TREE_STRING_POINTER (asmspec_tree);
+
+ /* If the type of the thing we are declaring either has
+ a constructor, or has a virtual function table pointer,
+ AND its initialization was accepted by `start_decl',
+ then we stayed on the permanent obstack through the
+ declaration, otherwise, changed obstacks as GCC would. */
+
+ type = TREE_TYPE (decl);
+
+ if (type == error_mark_node)
+ {
+ if (toplevel_bindings_p () && temporary)
+ end_temporary_allocation ();
+
+ return;
+ }
+
+ was_incomplete = (DECL_SIZE (decl) == NULL_TREE);
+
+ /* Take care of TYPE_DECLs up front. */
+ if (TREE_CODE (decl) == TYPE_DECL)
+ {
+ if (init && DECL_INITIAL (decl))
+ {
+ /* typedef foo = bar; store the type of bar as the type of foo. */
+ TREE_TYPE (decl) = type = TREE_TYPE (init);
+ DECL_INITIAL (decl) = init = NULL_TREE;
+ }
+ if (type != error_mark_node
+ && IS_AGGR_TYPE (type) && DECL_NAME (decl))
+ {
+ if (TREE_TYPE (DECL_NAME (decl)) && TREE_TYPE (decl) != type)
+ cp_warning ("shadowing previous type declaration of `%#D'", decl);
+ set_identifier_type_value (DECL_NAME (decl), type);
+ CLASSTYPE_GOT_SEMICOLON (type) = 1;
+ }
+ GNU_xref_decl (current_function_decl, decl);
+ rest_of_decl_compilation (decl, NULL_PTR,
+ DECL_CONTEXT (decl) == NULL_TREE, 0);
+ goto finish_end;
+ }
+ if (TREE_CODE (decl) != FUNCTION_DECL)
+ {
+ ttype = target_type (type);
+#if 0 /* WTF? -KR
+ Leave this out until we can figure out why it was
+ needed/desirable in the first place. Then put a comment
+ here explaining why. Or just delete the code if no ill
+ effects arise. */
+ if (TYPE_NAME (ttype)
+ && TREE_CODE (TYPE_NAME (ttype)) == TYPE_DECL
+ && ANON_AGGRNAME_P (TYPE_IDENTIFIER (ttype)))
+ {
+ tree old_id = TYPE_IDENTIFIER (ttype);
+ char *newname = (char *)alloca (IDENTIFIER_LENGTH (old_id) + 2);
+ /* Need to preserve template data for UPT nodes. */
+ tree old_template = IDENTIFIER_TEMPLATE (old_id);
+ newname[0] = '_';
+ bcopy (IDENTIFIER_POINTER (old_id), newname + 1,
+ IDENTIFIER_LENGTH (old_id) + 1);
+ old_id = get_identifier (newname);
+ lookup_tag_reverse (ttype, old_id);
+ TYPE_IDENTIFIER (ttype) = old_id;
+ IDENTIFIER_TEMPLATE (old_id) = old_template;
+ }
+#endif
+ }
+
+ if (! DECL_EXTERNAL (decl) && TREE_READONLY (decl)
+ && TYPE_NEEDS_CONSTRUCTING (type))
+ {
+
+ /* Currently, GNU C++ puts constants in text space, making them
+ impossible to initialize. In the future, one would hope for
+ an operating system which understood the difference between
+ initialization and the running of a program. */
+ was_readonly = 1;
+ TREE_READONLY (decl) = 0;
+ }
+
+ if (TREE_CODE (decl) == FIELD_DECL)
+ {
+ if (init && init != error_mark_node)
+ my_friendly_assert (TREE_PERMANENT (init), 147);
+
+ if (asmspec)
+ {
+ /* This must override the asm specifier which was placed
+ by grokclassfn. Lay this out fresh. */
+ DECL_RTL (TREE_TYPE (decl)) = NULL_RTX;
+ DECL_ASSEMBLER_NAME (decl) = get_identifier (asmspec);
+ make_decl_rtl (decl, asmspec, 0);
+ }
+ }
+ /* If `start_decl' didn't like having an initialization, ignore it now. */
+ else if (init != NULL_TREE && DECL_INITIAL (decl) == NULL_TREE)
+ init = NULL_TREE;
+ else if (DECL_EXTERNAL (decl))
+ ;
+ else if (TREE_CODE (type) == REFERENCE_TYPE
+ || (TYPE_LANG_SPECIFIC (type) && IS_SIGNATURE_REFERENCE (type)))
+ {
+ if (TREE_STATIC (decl))
+ make_decl_rtl (decl, NULL_PTR,
+ toplevel_bindings_p ()
+ || pseudo_global_level_p ());
+ grok_reference_init (decl, type, init, &cleanup);
+ init = NULL_TREE;
+ }
+
+ GNU_xref_decl (current_function_decl, decl);
+
+ if (TREE_CODE (decl) == FIELD_DECL)
+ ;
+ else if (TREE_CODE (decl) == CONST_DECL)
+ {
+ my_friendly_assert (TREE_CODE (decl) != REFERENCE_TYPE, 148);
+
+ DECL_INITIAL (decl) = init;
+
+ /* This will keep us from needing to worry about our obstacks. */
+ my_friendly_assert (init != NULL_TREE, 149);
+ init = NULL_TREE;
+ }
+ else if (init)
+ {
+ if (TYPE_HAS_CONSTRUCTOR (type) || TYPE_NEEDS_CONSTRUCTING (type))
+ {
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ init = digest_init (type, init, (tree *) 0);
+ else if (TREE_CODE (init) == CONSTRUCTOR)
+ {
+ if (TYPE_NON_AGGREGATE_CLASS (type))
+ {
+ cp_error ("`%D' must be initialized by constructor, not by `{...}'",
+ decl);
+ init = error_mark_node;
+ }
+ else
+ goto dont_use_constructor;
+ }
+ }
+ else
+ {
+ dont_use_constructor:
+ if (TREE_CODE (init) != TREE_VEC)
+ init = store_init_value (decl, init);
+ }
+
+ if (init)
+ /* We must hide the initializer so that expand_decl
+ won't try to do something it does not understand. */
+ init = obscure_complex_init (decl, init);
+ }
+ else if (DECL_EXTERNAL (decl))
+ ;
+ else if (TREE_CODE_CLASS (TREE_CODE (type)) == 't'
+ && (IS_AGGR_TYPE (type) || TYPE_NEEDS_CONSTRUCTING (type)))
+ {
+ tree ctype = type;
+ while (TREE_CODE (ctype) == ARRAY_TYPE)
+ ctype = TREE_TYPE (ctype);
+ if (! TYPE_NEEDS_CONSTRUCTING (ctype))
+ {
+ if (CLASSTYPE_READONLY_FIELDS_NEED_INIT (ctype))
+ cp_error ("structure `%D' with uninitialized const members", decl);
+ if (CLASSTYPE_REF_FIELDS_NEED_INIT (ctype))
+ cp_error ("structure `%D' with uninitialized reference members",
+ decl);
+ }
+
+ if (TREE_CODE (decl) == VAR_DECL
+ && !DECL_INITIAL (decl)
+ && !TYPE_NEEDS_CONSTRUCTING (type)
+ && (TYPE_READONLY (type) || TREE_READONLY (decl)))
+ cp_error ("uninitialized const `%D'", decl);
+
+ if (TYPE_SIZE (type) != NULL_TREE
+ && TYPE_NEEDS_CONSTRUCTING (type))
+ init = obscure_complex_init (decl, NULL_TREE);
+ }
+ else if (TREE_CODE (decl) == VAR_DECL
+ && TREE_CODE (type) != REFERENCE_TYPE
+ && (TYPE_READONLY (type) || TREE_READONLY (decl)))
+ {
+ /* ``Unless explicitly declared extern, a const object does not have
+ external linkage and must be initialized. ($8.4; $12.1)'' ARM 7.1.6
+ However, if it's `const int foo = 1; const int foo;', don't complain
+ about the second decl, since it does have an initializer before.
+ We deliberately don't complain about arrays, because they're
+ supposed to be initialized by a constructor. */
+ if (! DECL_INITIAL (decl)
+ && TREE_CODE (type) != ARRAY_TYPE
+ && (!pedantic || !current_class_type))
+ cp_error ("uninitialized const `%#D'", decl);
+ }
+
+ /* For top-level declaration, the initial value was read in
+ the temporary obstack. MAXINDEX, rtl, etc. to be made below
+ must go in the permanent obstack; but don't discard the
+ temporary data yet. */
+
+ if (toplevel_bindings_p () && temporary)
+ end_temporary_allocation ();
+
+ /* Deduce size of array from initialization, if not already known. */
+
+ if (TREE_CODE (type) == ARRAY_TYPE
+ && TYPE_DOMAIN (type) == NULL_TREE
+ && TREE_CODE (decl) != TYPE_DECL)
+ {
+ int do_default
+ = (TREE_STATIC (decl)
+ /* Even if pedantic, an external linkage array
+ may have incomplete type at first. */
+ ? pedantic && ! DECL_EXTERNAL (decl)
+ : !DECL_EXTERNAL (decl));
+ tree initializer = init ? init : DECL_INITIAL (decl);
+ int failure = complete_array_type (type, initializer, do_default);
+
+ if (failure == 1)
+ cp_error ("initializer fails to determine size of `%D'", decl);
+
+ if (failure == 2)
+ {
+ if (do_default)
+ cp_error ("array size missing in `%D'", decl);
+ /* If a `static' var's size isn't known, make it extern as
+ well as static, so it does not get allocated. If it's not
+ `static', then don't mark it extern; finish_incomplete_decl
+ will give it a default size and it will get allocated. */
+ else if (!pedantic && TREE_STATIC (decl) && !TREE_PUBLIC (decl))
+ DECL_EXTERNAL (decl) = 1;
+ }
+
+ if (pedantic && TYPE_DOMAIN (type) != NULL_TREE
+ && tree_int_cst_lt (TYPE_MAX_VALUE (TYPE_DOMAIN (type)),
+ integer_zero_node))
+ cp_error ("zero-size array `%D'", decl);
+
+ layout_decl (decl, 0);
+ }
+
+ if (TREE_CODE (decl) == VAR_DECL)
+ {
+ if (DECL_SIZE (decl) == NULL_TREE
+ && TYPE_SIZE (TREE_TYPE (decl)) != NULL_TREE)
+ layout_decl (decl, 0);
+
+ if (TREE_STATIC (decl) && DECL_SIZE (decl) == NULL_TREE)
+ {
+ /* A static variable with an incomplete type:
+ that is an error if it is initialized.
+ Otherwise, let it through, but if it is not `extern'
+ then it may cause an error message later. */
+ if (DECL_INITIAL (decl) != NULL_TREE)
+ cp_error ("storage size of `%D' isn't known", decl);
+ init = NULL_TREE;
+ }
+ else if (!DECL_EXTERNAL (decl) && DECL_SIZE (decl) == NULL_TREE)
+ {
+ /* An automatic variable with an incomplete type: that is an error.
+ Don't talk about array types here, since we took care of that
+ message in grokdeclarator. */
+ cp_error ("storage size of `%D' isn't known", decl);
+ TREE_TYPE (decl) = error_mark_node;
+ }
+ else if (!DECL_EXTERNAL (decl) && IS_AGGR_TYPE (ttype))
+ /* Let debugger know it should output info for this type. */
+ note_debug_info_needed (ttype);
+
+ if (TREE_STATIC (decl) && DECL_CONTEXT (decl)
+ && TREE_CODE_CLASS (TREE_CODE (DECL_CONTEXT (decl))) == 't')
+ note_debug_info_needed (DECL_CONTEXT (decl));
+
+ if ((DECL_EXTERNAL (decl) || TREE_STATIC (decl))
+ && DECL_SIZE (decl) != NULL_TREE
+ && ! TREE_CONSTANT (DECL_SIZE (decl)))
+ {
+ if (TREE_CODE (DECL_SIZE (decl)) == INTEGER_CST)
+ constant_expression_warning (DECL_SIZE (decl));
+ else
+ cp_error ("storage size of `%D' isn't constant", decl);
+ }
+
+ if (!DECL_EXTERNAL (decl) && TYPE_NEEDS_DESTRUCTOR (type))
+ {
+ int yes = suspend_momentary ();
+
+ /* If INIT comes from a functional cast, use the cleanup
+ we built for that. Otherwise, make our own cleanup. */
+ if (init && TREE_CODE (init) == WITH_CLEANUP_EXPR
+ && comptypes (TREE_TYPE (decl), TREE_TYPE (init), 1))
+ {
+ cleanup = TREE_OPERAND (init, 2);
+ init = TREE_OPERAND (init, 0);
+ current_binding_level->have_cleanups = 1;
+ }
+ else
+ cleanup = maybe_build_cleanup (decl);
+ resume_momentary (yes);
+ }
+ }
+ /* PARM_DECLs get cleanups, too. */
+ else if (TREE_CODE (decl) == PARM_DECL && TYPE_NEEDS_DESTRUCTOR (type))
+ {
+ if (temporary)
+ end_temporary_allocation ();
+ cleanup = maybe_build_cleanup (decl);
+ if (temporary)
+ resume_temporary_allocation ();
+ }
+
+ /* Output the assembler code and/or RTL code for variables and functions,
+ unless the type is an undefined structure or union.
+ If not, it will get done when the type is completed. */
+
+ if (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == FUNCTION_DECL
+ || TREE_CODE (decl) == RESULT_DECL)
+ {
+ /* ??? FIXME: What about nested classes? */
+ int toplev = toplevel_bindings_p () || pseudo_global_level_p ();
+ int was_temp
+ = ((flag_traditional
+ || (TREE_STATIC (decl) && TYPE_NEEDS_DESTRUCTOR (type)))
+ && allocation_temporary_p ());
+
+ if (was_temp)
+ end_temporary_allocation ();
+
+ if (TREE_CODE (decl) == VAR_DECL
+ && ! toplevel_bindings_p ()
+ && ! TREE_STATIC (decl)
+ && type_needs_gc_entry (type))
+ DECL_GC_OFFSET (decl) = size_int (++current_function_obstack_index);
+
+ if (TREE_CODE (decl) == VAR_DECL && DECL_VIRTUAL_P (decl))
+ make_decl_rtl (decl, NULL_PTR, toplev);
+ else if (TREE_CODE (decl) == VAR_DECL
+ && TREE_READONLY (decl)
+ && DECL_INITIAL (decl) != NULL_TREE
+ && DECL_INITIAL (decl) != error_mark_node
+ && ! EMPTY_CONSTRUCTOR_P (DECL_INITIAL (decl)))
+ {
+ DECL_INITIAL (decl) = save_expr (DECL_INITIAL (decl));
+
+ if (asmspec)
+ DECL_ASSEMBLER_NAME (decl) = get_identifier (asmspec);
+
+ if (! toplev
+ && TREE_STATIC (decl)
+ && ! TREE_SIDE_EFFECTS (decl)
+ && ! TREE_PUBLIC (decl)
+ && ! DECL_EXTERNAL (decl)
+ && ! TYPE_NEEDS_DESTRUCTOR (type)
+ && DECL_MODE (decl) != BLKmode)
+ {
+ /* If this variable is really a constant, then fill its DECL_RTL
+ slot with something which won't take up storage.
+ If something later should take its address, we can always give
+ it legitimate RTL at that time. */
+ DECL_RTL (decl) = gen_reg_rtx (DECL_MODE (decl));
+ store_expr (DECL_INITIAL (decl), DECL_RTL (decl), 0);
+ TREE_ASM_WRITTEN (decl) = 1;
+ }
+ else if (toplev && ! TREE_PUBLIC (decl))
+ {
+ /* If this is a static const, change its apparent linkage
+ if it belongs to a #pragma interface. */
+ if (!interface_unknown)
+ {
+ TREE_PUBLIC (decl) = 1;
+ DECL_EXTERNAL (decl) = interface_only;
+ }
+ make_decl_rtl (decl, asmspec, toplev);
+ }
+ else
+ rest_of_decl_compilation (decl, asmspec, toplev, 0);
+ }
+ else if (TREE_CODE (decl) == VAR_DECL
+ && DECL_LANG_SPECIFIC (decl)
+ && DECL_IN_AGGR_P (decl))
+ {
+ if (TREE_STATIC (decl))
+ {
+ if (init == NULL_TREE
+#ifdef DEFAULT_STATIC_DEFS
+ /* If this code is dead, then users must
+ explicitly declare static member variables
+ outside the class def'n as well. */
+ && TYPE_NEEDS_CONSTRUCTING (type)
+#endif
+ )
+ {
+ DECL_EXTERNAL (decl) = 1;
+ make_decl_rtl (decl, asmspec, 1);
+ }
+ else
+ rest_of_decl_compilation (decl, asmspec, toplev, 0);
+ }
+ else
+ /* Just a constant field. Should not need any rtl. */
+ goto finish_end0;
+ }
+ else
+ rest_of_decl_compilation (decl, asmspec, toplev, 0);
+
+ if (was_temp)
+ resume_temporary_allocation ();
+
+ if (type != error_mark_node
+ && TYPE_LANG_SPECIFIC (type)
+ && CLASSTYPE_ABSTRACT_VIRTUALS (type))
+ abstract_virtuals_error (decl, type);
+ else if ((TREE_CODE (type) == FUNCTION_TYPE
+ || TREE_CODE (type) == METHOD_TYPE)
+ && TYPE_LANG_SPECIFIC (TREE_TYPE (type))
+ && CLASSTYPE_ABSTRACT_VIRTUALS (TREE_TYPE (type)))
+ abstract_virtuals_error (decl, TREE_TYPE (type));
+
+ if (TYPE_LANG_SPECIFIC (type) && IS_SIGNATURE (type))
+ signature_error (decl, type);
+ else if ((TREE_CODE (type) == FUNCTION_TYPE
+ || TREE_CODE (type) == METHOD_TYPE)
+ && TYPE_LANG_SPECIFIC (TREE_TYPE (type))
+ && IS_SIGNATURE (TREE_TYPE (type)))
+ signature_error (decl, TREE_TYPE (type));
+
+ if (TREE_CODE (decl) == FUNCTION_DECL)
+ ;
+ else if (DECL_EXTERNAL (decl))
+ ;
+ else if (TREE_STATIC (decl) && type != error_mark_node)
+ {
+ /* Cleanups for static variables are handled by `finish_file'. */
+ if (TYPE_NEEDS_CONSTRUCTING (type) || init != NULL_TREE
+ || TYPE_NEEDS_DESTRUCTOR (type))
+ expand_static_init (decl, init);
+
+ /* Make entry in appropriate vector. */
+ if (flag_gc && type_needs_gc_entry (type))
+ build_static_gc_entry (decl, type);
+ }
+ else if (! toplev)
+ {
+ tree old_cleanups = cleanups_this_call;
+ /* This is a declared decl which must live until the
+ end of the binding contour. It may need a cleanup. */
+
+ /* Recompute the RTL of a local array now
+ if it used to be an incomplete type. */
+ if (was_incomplete && ! TREE_STATIC (decl))
+ {
+ /* If we used it already as memory, it must stay in memory. */
+ TREE_ADDRESSABLE (decl) = TREE_USED (decl);
+ /* If it's still incomplete now, no init will save it. */
+ if (DECL_SIZE (decl) == NULL_TREE)
+ DECL_INITIAL (decl) = NULL_TREE;
+ expand_decl (decl);
+ }
+ else if (! TREE_ASM_WRITTEN (decl)
+ && (TYPE_SIZE (type) != NULL_TREE
+ || TREE_CODE (type) == ARRAY_TYPE))
+ {
+ /* Do this here, because we did not expand this decl's
+ rtl in start_decl. */
+ if (DECL_RTL (decl) == NULL_RTX)
+ expand_decl (decl);
+ else if (cleanup)
+ {
+ /* XXX: Why don't we use decl here? */
+ /* Ans: Because it was already expanded? */
+ if (! cp_expand_decl_cleanup (NULL_TREE, cleanup))
+ cp_error ("parser lost in parsing declaration of `%D'",
+ decl);
+ /* Cleanup used up here. */
+ cleanup = NULL_TREE;
+ }
+ }
+
+ if (DECL_SIZE (decl) && type != error_mark_node)
+ {
+ /* Compute and store the initial value. */
+ expand_decl_init (decl);
+
+ if (init || TYPE_NEEDS_CONSTRUCTING (type))
+ {
+ emit_line_note (DECL_SOURCE_FILE (decl),
+ DECL_SOURCE_LINE (decl));
+ expand_aggr_init (decl, init, 0, flags);
+ }
+
+ /* Set this to 0 so we can tell whether an aggregate which
+ was initialized was ever used. Don't do this if it has a
+ destructor, so we don't complain about the 'resource
+ allocation is initialization' idiom. */
+ if (TYPE_NEEDS_CONSTRUCTING (type) && cleanup == NULL_TREE)
+ TREE_USED (decl) = 0;
+
+ /* Store the cleanup, if there was one. */
+ if (cleanup)
+ {
+ if (! cp_expand_decl_cleanup (decl, cleanup))
+ cp_error ("parser lost in parsing declaration of `%D'",
+ decl);
+ }
+ }
+ /* Cleanup any temporaries needed for the initial value. */
+ expand_cleanups_to (old_cleanups);
+ }
+ finish_end0:
+
+ /* Undo call to `pushclass' that was done in `start_decl'
+ due to initialization of qualified member variable.
+ I.e., Foo::x = 10; */
+ {
+ tree context = DECL_REAL_CONTEXT (decl);
+ if (context
+ && TREE_CODE_CLASS (TREE_CODE (context)) == 't'
+ && (TREE_CODE (decl) == VAR_DECL
+ /* We also have a pushclass done that we need to undo here
+ if we're at top level and declare a method. */
+ || (TREE_CODE (decl) == FUNCTION_DECL
+ /* If size hasn't been set, we're still defining it,
+ and therefore inside the class body; don't pop
+ the binding level.. */
+ && TYPE_SIZE (context) != NULL_TREE
+ /* The binding level gets popped elsewhere for a
+ friend declaration inside another class. */
+ /*
+ && TYPE_IDENTIFIER (context) == current_class_name
+ */
+ && context == current_class_type
+ )))
+ popclass (1);
+ }
+ }
+
+ finish_end:
+
+ /* If requested, warn about definitions of large data objects. */
+
+ if (warn_larger_than
+ && (TREE_CODE (decl) == VAR_DECL || TREE_CODE (decl) == PARM_DECL)
+ && !DECL_EXTERNAL (decl))
+ {
+ register tree decl_size = DECL_SIZE (decl);
+
+ if (decl_size && TREE_CODE (decl_size) == INTEGER_CST)
+ {
+ unsigned units = TREE_INT_CST_LOW (decl_size) / BITS_PER_UNIT;
+
+ if (units > larger_than_size)
+ warning_with_decl (decl, "size of `%s' is %u bytes", units);
+ }
+ }
+
+ if (need_pop)
+ {
+ /* Resume permanent allocation, if not within a function. */
+ /* The corresponding push_obstacks_nochange is in start_decl,
+ start_method, groktypename, and in grokfield. */
+ pop_obstacks ();
+ }
+
+ if (was_readonly)
+ TREE_READONLY (decl) = 1;
+
+ if (flag_cadillac)
+ cadillac_finish_decl (decl);
+}
+
+/* This is here for a midend callback from c-common.c */
+void
+finish_decl (decl, init, asmspec_tree)
+ tree decl, init;
+ tree asmspec_tree;
+{
+ cp_finish_decl (decl, init, asmspec_tree, 1, 0);
+}
+
+void
+expand_static_init (decl, init)
+ tree decl;
+ tree init;
+{
+ tree oldstatic = value_member (decl, static_aggregates);
+ tree old_cleanups;
+
+ if (oldstatic)
+ {
+ if (TREE_PURPOSE (oldstatic) && init != NULL_TREE)
+ cp_error ("multiple initializations given for `%D'", decl);
+ }
+ else if (! toplevel_bindings_p () && ! pseudo_global_level_p ())
+ {
+ /* Emit code to perform this initialization but once. */
+ tree temp;
+
+ /* Remember this information until end of file. */
+ push_obstacks (&permanent_obstack, &permanent_obstack);
+
+ /* Emit code to perform this initialization but once. */
+ temp = get_temp_name (integer_type_node, 1);
+ rest_of_decl_compilation (temp, NULL_PTR, 0, 0);
+ expand_start_cond (build_binary_op (EQ_EXPR, temp,
+ integer_zero_node, 1), 0);
+ old_cleanups = cleanups_this_call;
+ expand_assignment (temp, integer_one_node, 0, 0);
+ if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (decl))
+ || (init && TREE_CODE (init) == TREE_LIST))
+ {
+ expand_aggr_init (decl, init, 0, 0);
+ do_pending_stack_adjust ();
+ }
+ else if (init)
+ expand_assignment (decl, init, 0, 0);
+
+ /* Cleanup any temporaries needed for the initial value. */
+ expand_cleanups_to (old_cleanups);
+ expand_end_cond ();
+ if (TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (decl)))
+ {
+ static_aggregates = perm_tree_cons (temp, decl, static_aggregates);
+ TREE_STATIC (static_aggregates) = 1;
+ }
+
+ /* Resume old (possibly temporary) allocation. */
+ pop_obstacks ();
+ }
+ else
+ {
+ /* This code takes into account memory allocation
+ policy of `start_decl'. Namely, if TYPE_NEEDS_CONSTRUCTING
+ does not hold for this object, then we must make permanent
+ the storage currently in the temporary obstack. */
+ if (! TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (decl)))
+ preserve_initializer ();
+ static_aggregates = perm_tree_cons (init, decl, static_aggregates);
+ }
+}
+
+/* Make TYPE a complete type based on INITIAL_VALUE.
+ Return 0 if successful, 1 if INITIAL_VALUE can't be deciphered,
+ 2 if there was no information (in which case assume 1 if DO_DEFAULT). */
+
+int
+complete_array_type (type, initial_value, do_default)
+ tree type, initial_value;
+ int do_default;
+{
+ register tree maxindex = NULL_TREE;
+ int value = 0;
+
+ if (initial_value)
+ {
+ /* Note MAXINDEX is really the maximum index,
+ one less than the size. */
+ if (TREE_CODE (initial_value) == STRING_CST)
+ {
+ int eltsize
+ = int_size_in_bytes (TREE_TYPE (TREE_TYPE (initial_value)));
+ maxindex = build_int_2 ((TREE_STRING_LENGTH (initial_value)
+ / eltsize) - 1, 0);
+ }
+ else if (TREE_CODE (initial_value) == CONSTRUCTOR)
+ {
+ tree elts = CONSTRUCTOR_ELTS (initial_value);
+ maxindex = size_binop (MINUS_EXPR, integer_zero_node, size_one_node);
+ for (; elts; elts = TREE_CHAIN (elts))
+ {
+ if (TREE_PURPOSE (elts))
+ maxindex = TREE_PURPOSE (elts);
+ else
+ maxindex = size_binop (PLUS_EXPR, maxindex, size_one_node);
+ }
+ maxindex = copy_node (maxindex);
+ }
+ else
+ {
+ /* Make an error message unless that happened already. */
+ if (initial_value != error_mark_node)
+ value = 1;
+
+ /* Prevent further error messages. */
+ maxindex = build_int_2 (0, 0);
+ }
+ }
+
+ if (!maxindex)
+ {
+ if (do_default)
+ maxindex = build_int_2 (0, 0);
+ value = 2;
+ }
+
+ if (maxindex)
+ {
+ tree itype;
+
+ TYPE_DOMAIN (type) = build_index_type (maxindex);
+ if (! TREE_TYPE (maxindex))
+ TREE_TYPE (maxindex) = TYPE_DOMAIN (type);
+ if (initial_value)
+ itype = TREE_TYPE (initial_value);
+ else
+ itype = NULL;
+ if (itype && !TYPE_DOMAIN (itype))
+ TYPE_DOMAIN (itype) = TYPE_DOMAIN (type);
+ /* The type of the main variant should never be used for arrays
+ of different sizes. It should only ever be completed with the
+ size of the array. */
+ if (! TYPE_DOMAIN (TYPE_MAIN_VARIANT (type)))
+ TYPE_DOMAIN (TYPE_MAIN_VARIANT (type)) = TYPE_DOMAIN (type);
+ }
+
+ /* Lay out the type now that we can get the real answer. */
+
+ layout_type (type);
+
+ return value;
+}
+
+/* Return zero if something is declared to be a member of type
+ CTYPE when in the context of CUR_TYPE. STRING is the error
+ message to print in that case. Otherwise, quietly return 1. */
+static int
+member_function_or_else (ctype, cur_type, string)
+ tree ctype, cur_type;
+ char *string;
+{
+ if (ctype && ctype != cur_type)
+ {
+ error (string, TYPE_NAME_STRING (ctype));
+ return 0;
+ }
+ return 1;
+}
+
+/* Subroutine of `grokdeclarator'. */
+
+/* Generate errors possibly applicable for a given set of specifiers.
+ This is for ARM $7.1.2. */
+static void
+bad_specifiers (object, type, virtualp, quals, inlinep, friendp, raises)
+ tree object;
+ char *type;
+ int virtualp, quals, friendp, raises, inlinep;
+{
+ if (virtualp)
+ cp_error ("`%D' declared as a `virtual' %s", object, type);
+ if (inlinep)
+ cp_error ("`%D' declared as an `inline' %s", object, type);
+ if (quals)
+ cp_error ("`const' and `volatile' function specifiers on `%D' invalid in %s declaration",
+ object, type);
+ if (friendp)
+ cp_error_at ("invalid friend declaration", object);
+ if (raises)
+ cp_error_at ("invalid exception specifications", object);
+}
+
+/* CTYPE is class type, or null if non-class.
+ TYPE is type this FUNCTION_DECL should have, either FUNCTION_TYPE
+ or METHOD_TYPE.
+ DECLARATOR is the function's name.
+ VIRTUALP is truthvalue of whether the function is virtual or not.
+ FLAGS are to be passed through to `grokclassfn'.
+ QUALS are qualifiers indicating whether the function is `const'
+ or `volatile'.
+ RAISES is a list of exceptions that this function can raise.
+ CHECK is 1 if we must find this method in CTYPE, 0 if we should
+ not look, and -1 if we should not call `grokclassfn' at all. */
+static tree
+grokfndecl (ctype, type, declarator, virtualp, flags, quals,
+ raises, attrlist, check, publicp, inlinep)
+ tree ctype, type;
+ tree declarator;
+ int virtualp;
+ enum overload_flags flags;
+ tree quals, raises, attrlist;
+ int check, publicp, inlinep;
+{
+ tree cname, decl;
+ int staticp = ctype && TREE_CODE (type) == FUNCTION_TYPE;
+
+ if (ctype)
+ cname = TREE_CODE (TYPE_NAME (ctype)) == TYPE_DECL
+ ? TYPE_IDENTIFIER (ctype) : TYPE_NAME (ctype);
+ else
+ cname = NULL_TREE;
+
+ if (raises)
+ {
+ type = build_exception_variant (type, raises);
+ raises = TYPE_RAISES_EXCEPTIONS (type);
+ }
+ decl = build_lang_decl (FUNCTION_DECL, declarator, type);
+ /* propagate volatile out from type to decl */
+ if (TYPE_VOLATILE (type))
+ TREE_THIS_VOLATILE (decl) = 1;
+
+ /* Should probably propagate const out from type to decl I bet (mrs). */
+ if (staticp)
+ {
+ DECL_STATIC_FUNCTION_P (decl) = 1;
+ DECL_CONTEXT (decl) = ctype;
+ DECL_CLASS_CONTEXT (decl) = ctype;
+ }
+
+ /* All function decls start out public; we'll fix their linkage later (at
+ definition or EOF) if appropriate. */
+ TREE_PUBLIC (decl) = 1;
+
+ if (ctype == NULL_TREE && ! strcmp (IDENTIFIER_POINTER (declarator), "main"))
+ {
+ if (inlinep)
+ error ("cannot declare `main' to be inline");
+ else if (! publicp)
+ error ("cannot declare `main' to be static");
+ inlinep = 0;
+ publicp = 1;
+ }
+
+ if (! publicp)
+ DECL_C_STATIC (decl) = 1;
+
+ if (inlinep)
+ DECL_THIS_INLINE (decl) = DECL_INLINE (decl) = 1;
+
+ DECL_EXTERNAL (decl) = 1;
+ if (quals != NULL_TREE && TREE_CODE (type) == FUNCTION_TYPE)
+ {
+ cp_error ("%smember function `%D' cannot have `%T' method qualifier",
+ (ctype ? "static " : "non-"), decl, TREE_VALUE (quals));
+ quals = NULL_TREE;
+ }
+
+ if (IDENTIFIER_OPNAME_P (DECL_NAME (decl)))
+ grok_op_properties (decl, virtualp, check < 0);
+
+ /* Caller will do the rest of this. */
+ if (check < 0)
+ return decl;
+
+ if (flags == NO_SPECIAL && ctype && constructor_name (cname) == declarator)
+ {
+ tree tmp;
+ /* Just handle constructors here. We could do this
+ inside the following if stmt, but I think
+ that the code is more legible by breaking this
+ case out. See comments below for what each of
+ the following calls is supposed to do. */
+ DECL_CONSTRUCTOR_P (decl) = 1;
+
+ grokclassfn (ctype, declarator, decl, flags, quals);
+ if (check)
+ check_classfn (ctype, declarator, decl);
+ if (! grok_ctor_properties (ctype, decl))
+ return NULL_TREE;
+
+ if (check == 0 && ! current_function_decl)
+ {
+ /* FIXME: this should only need to look at
+ IDENTIFIER_GLOBAL_VALUE. */
+ tmp = lookup_name (DECL_ASSEMBLER_NAME (decl), 0);
+ if (tmp == NULL_TREE)
+ IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (decl)) = decl;
+ else if (TREE_CODE (tmp) != TREE_CODE (decl))
+ cp_error ("inconsistent declarations for `%D'", decl);
+ else
+ {
+ duplicate_decls (decl, tmp);
+ decl = tmp;
+ /* avoid creating circularities. */
+ DECL_CHAIN (decl) = NULL_TREE;
+ }
+ make_decl_rtl (decl, NULL_PTR, 1);
+ }
+ }
+ else
+ {
+ tree tmp;
+
+ /* Function gets the ugly name, field gets the nice one.
+ This call may change the type of the function (because
+ of default parameters)! */
+ if (ctype != NULL_TREE)
+ grokclassfn (ctype, cname, decl, flags, quals);
+
+ if (ctype != NULL_TREE && check)
+ check_classfn (ctype, cname, decl);
+
+ if (ctype == NULL_TREE || check)
+ return decl;
+
+ /* Now install the declaration of this function so that others may
+ find it (esp. its DECL_FRIENDLIST). Don't do this for local class
+ methods, though. */
+ if (! current_function_decl)
+ {
+ /* FIXME: this should only need to look at
+ IDENTIFIER_GLOBAL_VALUE. */
+ tmp = lookup_name (DECL_ASSEMBLER_NAME (decl), 0);
+ if (tmp == NULL_TREE)
+ IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (decl)) = decl;
+ else if (TREE_CODE (tmp) != TREE_CODE (decl))
+ cp_error ("inconsistent declarations for `%D'", decl);
+ else
+ {
+ duplicate_decls (decl, tmp);
+ decl = tmp;
+ /* avoid creating circularities. */
+ DECL_CHAIN (decl) = NULL_TREE;
+ }
+
+ if (attrlist)
+ cplus_decl_attributes (decl, TREE_PURPOSE (attrlist),
+ TREE_VALUE (attrlist));
+ make_decl_rtl (decl, NULL_PTR, 1);
+ }
+
+ /* If this declaration supersedes the declaration of
+ a method declared virtual in the base class, then
+ mark this field as being virtual as well. */
+ {
+ tree binfos = BINFO_BASETYPES (TYPE_BINFO (ctype));
+ int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+
+ for (i = 0; i < n_baselinks; i++)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ if (TYPE_VIRTUAL_P (BINFO_TYPE (base_binfo))
+ || flag_all_virtual == 1)
+ {
+ tmp = get_matching_virtual (base_binfo, decl,
+ flags == DTOR_FLAG);
+ if (tmp)
+ {
+ /* If this function overrides some virtual in some base
+ class, then the function itself is also necessarily
+ virtual, even if the user didn't explicitly say so. */
+ DECL_VIRTUAL_P (decl) = 1;
+
+ /* The TMP we really want is the one from the deepest
+ baseclass on this path, taking care not to
+ duplicate if we have already found it (via another
+ path to its virtual baseclass. */
+ if (staticp)
+ {
+ cp_error ("method `%D' may not be declared static",
+ decl);
+ cp_error_at ("(since `%D' declared virtual in base class.)",
+ tmp);
+ break;
+ }
+ virtualp = 1;
+
+ {
+ /* The argument types may have changed... */
+ tree argtypes = TYPE_ARG_TYPES (TREE_TYPE (decl));
+ tree base_variant = TREE_TYPE (TREE_VALUE (argtypes));
+
+ argtypes = commonparms (TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (tmp))),
+ TREE_CHAIN (argtypes));
+ /* But the return type has not. */
+ type = build_cplus_method_type (base_variant, TREE_TYPE (type), argtypes);
+ if (raises)
+ {
+ type = build_exception_variant (type, raises);
+ raises = TYPE_RAISES_EXCEPTIONS (type);
+ }
+ TREE_TYPE (decl) = type;
+ DECL_VINDEX (decl)
+ = tree_cons (NULL_TREE, tmp, DECL_VINDEX (decl));
+ }
+ break;
+ }
+ }
+ }
+ }
+ if (virtualp)
+ {
+ if (DECL_VINDEX (decl) == NULL_TREE)
+ DECL_VINDEX (decl) = error_mark_node;
+ IDENTIFIER_VIRTUAL_P (DECL_NAME (decl)) = 1;
+ if (ctype && CLASSTYPE_VTABLE_NEEDS_WRITING (ctype)
+ /* If this function is derived from a template, don't
+ make it public. This shouldn't be here, but there's
+ no good way to override the interface pragmas for one
+ function or class only. Bletch. */
+ && IDENTIFIER_TEMPLATE (TYPE_IDENTIFIER (ctype)) == NULL_TREE
+ && (write_virtuals == 2
+ || (write_virtuals == 3
+ && CLASSTYPE_INTERFACE_KNOWN (ctype))))
+ TREE_PUBLIC (decl) = 1;
+ }
+ }
+ return decl;
+}
+
+static tree
+grokvardecl (type, declarator, specbits, initialized, constp)
+ tree type;
+ tree declarator;
+ RID_BIT_TYPE specbits;
+ int initialized;
+ int constp;
+{
+ tree decl;
+
+ if (TREE_CODE (type) == OFFSET_TYPE)
+ {
+ /* If you declare a static member so that it
+ can be initialized, the code will reach here. */
+ tree basetype = TYPE_OFFSET_BASETYPE (type);
+ type = TREE_TYPE (type);
+ decl = build_lang_field_decl (VAR_DECL, declarator, type);
+ DECL_CONTEXT (decl) = basetype;
+ DECL_CLASS_CONTEXT (decl) = basetype;
+ DECL_ASSEMBLER_NAME (decl) = build_static_name (basetype, declarator);
+ }
+ else
+ decl = build_decl (VAR_DECL, declarator, type);
+
+ DECL_ASSEMBLER_NAME (decl) = current_namespace_id (DECL_ASSEMBLER_NAME (decl));
+
+ if (RIDBIT_SETP (RID_EXTERN, specbits))
+ {
+ DECL_THIS_EXTERN (decl) = 1;
+ DECL_EXTERNAL (decl) = !initialized;
+ }
+
+ /* In class context, static means one per class,
+ public access, and static storage. */
+ if (DECL_FIELD_CONTEXT (decl) != NULL_TREE
+ && IS_AGGR_TYPE (DECL_FIELD_CONTEXT (decl)))
+ {
+ TREE_PUBLIC (decl) = 1;
+ TREE_STATIC (decl) = 1;
+ DECL_EXTERNAL (decl) = 0;
+ }
+ /* At top level, either `static' or no s.c. makes a definition
+ (perhaps tentative), and absence of `static' makes it public. */
+ else if (toplevel_bindings_p ())
+ {
+ TREE_PUBLIC (decl) = (RIDBIT_NOTSETP (RID_STATIC, specbits)
+ && (DECL_THIS_EXTERN (decl) || ! constp));
+ TREE_STATIC (decl) = ! DECL_EXTERNAL (decl);
+ }
+ /* Not at top level, only `static' makes a static definition. */
+ else
+ {
+ TREE_STATIC (decl) = !! RIDBIT_SETP (RID_STATIC, specbits);
+ TREE_PUBLIC (decl) = DECL_EXTERNAL (decl);
+ }
+ return decl;
+}
+
+/* Create a canonical pointer to member function type. */
+
+tree
+build_ptrmemfunc_type (type)
+ tree type;
+{
+ tree fields[4];
+ tree t;
+ tree u;
+
+ /* If a canonical type already exists for this type, use it. We use
+ this method instead of type_hash_canon, because it only does a
+ simple equality check on the list of field members. */
+
+ if ((t = TYPE_GET_PTRMEMFUNC_TYPE (type)))
+ return t;
+
+ push_obstacks (TYPE_OBSTACK (type), TYPE_OBSTACK (type));
+
+ u = make_lang_type (UNION_TYPE);
+ IS_AGGR_TYPE (u) = 0;
+ fields[0] = build_lang_field_decl (FIELD_DECL, pfn_identifier, type);
+ fields[1] = build_lang_field_decl (FIELD_DECL, delta2_identifier,
+ delta_type_node);
+ finish_builtin_type (u, "__ptrmemfunc_type", fields, 1, ptr_type_node);
+ TYPE_NAME (u) = NULL_TREE;
+
+ t = make_lang_type (RECORD_TYPE);
+
+ /* Let the front-end know this is a pointer to member function. */
+ TYPE_PTRMEMFUNC_FLAG (t) = 1;
+ /* and not really an aggregate. */
+ IS_AGGR_TYPE (t) = 0;
+
+ fields[0] = build_lang_field_decl (FIELD_DECL, delta_identifier,
+ delta_type_node);
+ fields[1] = build_lang_field_decl (FIELD_DECL, index_identifier,
+ delta_type_node);
+ fields[2] = build_lang_field_decl (FIELD_DECL, pfn_or_delta2_identifier, u);
+ finish_builtin_type (t, "__ptrmemfunc_type", fields, 2, ptr_type_node);
+
+ pop_obstacks ();
+
+ /* Zap out the name so that the back-end will give us the debugging
+ information for this anonymous RECORD_TYPE. */
+ TYPE_NAME (t) = NULL_TREE;
+
+ TYPE_SET_PTRMEMFUNC_TYPE (type, t);
+
+ /* Seems to be wanted. */
+ CLASSTYPE_GOT_SEMICOLON (t) = 1;
+ return t;
+}
+
+/* Given declspecs and a declarator,
+ determine the name and type of the object declared
+ and construct a ..._DECL node for it.
+ (In one case we can return a ..._TYPE node instead.
+ For invalid input we sometimes return 0.)
+
+ DECLSPECS is a chain of tree_list nodes whose value fields
+ are the storage classes and type specifiers.
+
+ DECL_CONTEXT says which syntactic context this declaration is in:
+ NORMAL for most contexts. Make a VAR_DECL or FUNCTION_DECL or TYPE_DECL.
+ FUNCDEF for a function definition. Like NORMAL but a few different
+ error messages in each case. Return value may be zero meaning
+ this definition is too screwy to try to parse.
+ MEMFUNCDEF for a function definition. Like FUNCDEF but prepares to
+ handle member functions (which have FIELD context).
+ Return value may be zero meaning this definition is too screwy to
+ try to parse.
+ PARM for a parameter declaration (either within a function prototype
+ or before a function body). Make a PARM_DECL, or return void_type_node.
+ CATCHPARM for a parameter declaration before a catch clause.
+ TYPENAME if for a typename (in a cast or sizeof).
+ Don't make a DECL node; just return the ..._TYPE node.
+ FIELD for a struct or union field; make a FIELD_DECL.
+ BITFIELD for a field with specified width.
+ INITIALIZED is 1 if the decl has an initializer.
+
+ In the TYPENAME case, DECLARATOR is really an absolute declarator.
+ It may also be so in the PARM case, for a prototype where the
+ argument type is specified but not the name.
+
+ This function is where the complicated C meanings of `static'
+ and `extern' are interpreted.
+
+ For C++, if there is any monkey business to do, the function which
+ calls this one must do it, i.e., prepending instance variables,
+ renaming overloaded function names, etc.
+
+ Note that for this C++, it is an error to define a method within a class
+ which does not belong to that class.
+
+ Except in the case where SCOPE_REFs are implicitly known (such as
+ methods within a class being redundantly qualified),
+ declarations which involve SCOPE_REFs are returned as SCOPE_REFs
+ (class_name::decl_name). The caller must also deal with this.
+
+ If a constructor or destructor is seen, and the context is FIELD,
+ then the type gains the attribute TREE_HAS_x. If such a declaration
+ is erroneous, NULL_TREE is returned.
+
+ QUALS is used only for FUNCDEF and MEMFUNCDEF cases. For a member
+ function, these are the qualifiers to give to the `this' pointer.
+
+ May return void_type_node if the declarator turned out to be a friend.
+ See grokfield for details. */
+
+enum return_types { return_normal, return_ctor, return_dtor, return_conversion };
+
+tree
+grokdeclarator (declarator, declspecs, decl_context, initialized, raises, attrlist)
+ tree declspecs;
+ tree declarator;
+ enum decl_context decl_context;
+ int initialized;
+ tree raises, attrlist;
+{
+ RID_BIT_TYPE specbits;
+ int nclasses = 0;
+ tree spec;
+ tree type = NULL_TREE;
+ int longlong = 0;
+ int constp;
+ int volatilep;
+ int virtualp, explicitp, friendp, inlinep, staticp;
+ int explicit_int = 0;
+ int explicit_char = 0;
+ int opaque_typedef = 0;
+ tree typedef_decl = NULL_TREE;
+ char *name;
+ tree typedef_type = NULL_TREE;
+ int funcdef_flag = 0;
+ enum tree_code innermost_code = ERROR_MARK;
+ int bitfield = 0;
+ int size_varies = 0;
+ tree decl_machine_attr = NULL_TREE;
+ /* Set this to error_mark_node for FIELD_DECLs we could not handle properly.
+ All FIELD_DECLs we build here have `init' put into their DECL_INITIAL. */
+ tree init = NULL_TREE;
+
+ /* Keep track of what sort of function is being processed
+ so that we can warn about default return values, or explicit
+ return values which do not match prescribed defaults. */
+ enum return_types return_type = return_normal;
+
+ tree dname = NULL_TREE;
+ tree ctype = current_class_type;
+ tree ctor_return_type = NULL_TREE;
+ enum overload_flags flags = NO_SPECIAL;
+ tree quals = NULL_TREE;
+
+ RIDBIT_RESET_ALL (specbits);
+ if (decl_context == FUNCDEF)
+ funcdef_flag = 1, decl_context = NORMAL;
+ else if (decl_context == MEMFUNCDEF)
+ funcdef_flag = -1, decl_context = FIELD;
+ else if (decl_context == BITFIELD)
+ bitfield = 1, decl_context = FIELD;
+
+ if (flag_traditional && allocation_temporary_p ())
+ end_temporary_allocation ();
+
+ /* Look inside a declarator for the name being declared
+ and get it as a string, for an error message. */
+ {
+ tree last = NULL_TREE;
+ register tree decl = declarator;
+ name = NULL;
+
+ while (decl)
+ switch (TREE_CODE (decl))
+ {
+ case COND_EXPR:
+ ctype = NULL_TREE;
+ decl = TREE_OPERAND (decl, 0);
+ break;
+
+ case BIT_NOT_EXPR: /* for C++ destructors! */
+ {
+ tree name = TREE_OPERAND (decl, 0);
+ tree rename = NULL_TREE;
+
+ my_friendly_assert (flags == NO_SPECIAL, 152);
+ flags = DTOR_FLAG;
+ return_type = return_dtor;
+ my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE, 153);
+ if (ctype == NULL_TREE)
+ {
+ if (current_class_type == NULL_TREE)
+ {
+ error ("destructors must be member functions");
+ flags = NO_SPECIAL;
+ }
+ else
+ {
+ tree t = constructor_name (current_class_name);
+ if (t != name)
+ rename = t;
+ }
+ }
+ else
+ {
+ tree t = constructor_name (ctype);
+ if (t != name)
+ rename = t;
+ }
+
+ if (rename)
+ {
+ error ("destructor `%s' must match class name `%s'",
+ IDENTIFIER_POINTER (name),
+ IDENTIFIER_POINTER (rename));
+ TREE_OPERAND (decl, 0) = rename;
+ }
+ decl = name;
+ }
+ break;
+
+ case ADDR_EXPR: /* C++ reference declaration */
+ /* fall through */
+ case ARRAY_REF:
+ case INDIRECT_REF:
+ ctype = NULL_TREE;
+ innermost_code = TREE_CODE (decl);
+ last = decl;
+ decl = TREE_OPERAND (decl, 0);
+ break;
+
+ case CALL_EXPR:
+ if (parmlist_is_exprlist (TREE_OPERAND (decl, 1)))
+ {
+ /* This is actually a variable declaration using constructor
+ syntax. We need to call start_decl and cp_finish_decl so we
+ can get the variable initialized... */
+
+ if (last)
+ /* We need to insinuate ourselves into the declarator in place
+ of the CALL_EXPR. */
+ TREE_OPERAND (last, 0) = TREE_OPERAND (decl, 0);
+ else
+ declarator = TREE_OPERAND (decl, 0);
+
+ init = TREE_OPERAND (decl, 1);
+
+ decl = start_decl (declarator, declspecs, 1, NULL_TREE);
+ finish_decl (decl, init, NULL_TREE);
+ return 0;
+ }
+ innermost_code = TREE_CODE (decl);
+ if (decl_context == FIELD && ctype == NULL_TREE)
+ ctype = current_class_type;
+ if (ctype
+ && TREE_OPERAND (decl, 0) == constructor_name_full (ctype))
+ TREE_OPERAND (decl, 0) = constructor_name (ctype);
+ decl = TREE_OPERAND (decl, 0);
+ if (ctype != NULL_TREE
+ && decl != NULL_TREE && flags != DTOR_FLAG
+ && decl == constructor_name (ctype))
+ {
+ return_type = return_ctor;
+ ctor_return_type = ctype;
+ }
+ ctype = NULL_TREE;
+ break;
+
+ case IDENTIFIER_NODE:
+ dname = decl;
+ decl = NULL_TREE;
+
+ if (! IDENTIFIER_OPNAME_P (dname)
+ /* Linux headers use '__op'. Arrgh. */
+ || IDENTIFIER_TYPENAME_P (dname) && ! TREE_TYPE (dname))
+ name = IDENTIFIER_POINTER (dname);
+ else
+ {
+ if (IDENTIFIER_TYPENAME_P (dname))
+ {
+ my_friendly_assert (flags == NO_SPECIAL, 154);
+ flags = TYPENAME_FLAG;
+ ctor_return_type = TREE_TYPE (dname);
+ return_type = return_conversion;
+ }
+ name = operator_name_string (dname);
+ }
+ break;
+
+ case RECORD_TYPE:
+ case UNION_TYPE:
+ case ENUMERAL_TYPE:
+ /* Parse error puts this typespec where
+ a declarator should go. */
+ error ("declarator name missing");
+ dname = TYPE_NAME (decl);
+ if (dname && TREE_CODE (dname) == TYPE_DECL)
+ dname = DECL_NAME (dname);
+ name = dname ? IDENTIFIER_POINTER (dname) : "<nameless>";
+ declspecs = temp_tree_cons (NULL_TREE, decl, declspecs);
+ decl = NULL_TREE;
+ break;
+
+ /* C++ extension */
+ case SCOPE_REF:
+ {
+ /* Perform error checking, and convert class names to types.
+ We may call grokdeclarator multiple times for the same
+ tree structure, so only do the conversion once. In this
+ case, we have exactly what we want for `ctype'. */
+ tree cname = TREE_OPERAND (decl, 0);
+ if (cname == NULL_TREE)
+ ctype = NULL_TREE;
+ /* Can't use IS_AGGR_TYPE because CNAME might not be a type. */
+ else if (IS_AGGR_TYPE_CODE (TREE_CODE (cname))
+ || TREE_CODE (cname) == UNINSTANTIATED_P_TYPE)
+ ctype = cname;
+ else if (! is_aggr_typedef (cname, 1))
+ {
+ TREE_OPERAND (decl, 0) = NULL_TREE;
+ }
+ /* Must test TREE_OPERAND (decl, 1), in case user gives
+ us `typedef (class::memfunc)(int); memfunc *memfuncptr;' */
+ else if (TREE_OPERAND (decl, 1)
+ && TREE_CODE (TREE_OPERAND (decl, 1)) == INDIRECT_REF)
+ {
+ TREE_OPERAND (decl, 0) = IDENTIFIER_TYPE_VALUE (cname);
+ }
+ else if (ctype == NULL_TREE)
+ {
+ ctype = IDENTIFIER_TYPE_VALUE (cname);
+ TREE_OPERAND (decl, 0) = ctype;
+ }
+ else if (TREE_COMPLEXITY (decl) == current_class_depth)
+ TREE_OPERAND (decl, 0) = ctype;
+ else
+ {
+ if (! UNIQUELY_DERIVED_FROM_P (IDENTIFIER_TYPE_VALUE (cname),
+ ctype))
+ {
+ cp_error ("type `%T' is not derived from type `%T'",
+ IDENTIFIER_TYPE_VALUE (cname), ctype);
+ TREE_OPERAND (decl, 0) = NULL_TREE;
+ }
+ else
+ {
+ ctype = IDENTIFIER_TYPE_VALUE (cname);
+ TREE_OPERAND (decl, 0) = ctype;
+ }
+ }
+
+ if (ctype
+ && TREE_OPERAND (decl, 1) == constructor_name_full (ctype))
+ TREE_OPERAND (decl, 1) = constructor_name (ctype);
+ decl = TREE_OPERAND (decl, 1);
+ if (ctype)
+ {
+ if (TREE_CODE (decl) == IDENTIFIER_NODE
+ && constructor_name (ctype) == decl)
+ {
+ return_type = return_ctor;
+ ctor_return_type = ctype;
+ }
+ else if (TREE_CODE (decl) == BIT_NOT_EXPR
+ && TREE_CODE (TREE_OPERAND (decl, 0)) == IDENTIFIER_NODE
+ && (constructor_name (ctype) == TREE_OPERAND (decl, 0)
+ || constructor_name_full (ctype) == TREE_OPERAND (decl, 0)))
+ {
+ return_type = return_dtor;
+ ctor_return_type = ctype;
+ flags = DTOR_FLAG;
+ decl = TREE_OPERAND (decl, 0) = constructor_name (ctype);
+ }
+ }
+ }
+ break;
+
+ case ERROR_MARK:
+ decl = NULL_TREE;
+ break;
+
+ default:
+ return 0; /* We used to do a 155 abort here. */
+ }
+ if (name == NULL)
+ name = "type name";
+ }
+
+ /* A function definition's declarator must have the form of
+ a function declarator. */
+
+ if (funcdef_flag && innermost_code != CALL_EXPR)
+ return 0;
+
+ if (((dname && IDENTIFIER_OPNAME_P (dname)) || flags == TYPENAME_FLAG)
+ && innermost_code != CALL_EXPR
+ && ! (ctype && declspecs == NULL_TREE))
+ {
+ cp_error ("declaration of `%D' as non-function", dname);
+ return void_type_node;
+ }
+
+ /* Anything declared one level down from the top level
+ must be one of the parameters of a function
+ (because the body is at least two levels down). */
+
+ /* This heuristic cannot be applied to C++ nodes! Fixed, however,
+ by not allowing C++ class definitions to specify their parameters
+ with xdecls (must be spec.d in the parmlist).
+
+ Since we now wait to push a class scope until we are sure that
+ we are in a legitimate method context, we must set oldcname
+ explicitly (since current_class_name is not yet alive).
+
+ We also want to avoid calling this a PARM if it is in a namespace. */
+
+ if (decl_context == NORMAL && ! namespace_bindings_p ())
+ {
+ struct binding_level *b = current_binding_level;
+ current_binding_level = b->level_chain;
+ if (current_binding_level != 0 && toplevel_bindings_p ())
+ decl_context = PARM;
+ current_binding_level = b;
+ }
+
+ /* Look through the decl specs and record which ones appear.
+ Some typespecs are defined as built-in typenames.
+ Others, the ones that are modifiers of other types,
+ are represented by bits in SPECBITS: set the bits for
+ the modifiers that appear. Storage class keywords are also in SPECBITS.
+
+ If there is a typedef name or a type, store the type in TYPE.
+ This includes builtin typedefs such as `int'.
+
+ Set EXPLICIT_INT if the type is `int' or `char' and did not
+ come from a user typedef.
+
+ Set LONGLONG if `long' is mentioned twice.
+
+ For C++, constructors and destructors have their own fast treatment. */
+
+ for (spec = declspecs; spec; spec = TREE_CHAIN (spec))
+ {
+ register int i;
+ register tree id;
+
+ /* Certain parse errors slip through. For example,
+ `int class;' is not caught by the parser. Try
+ weakly to recover here. */
+ if (TREE_CODE (spec) != TREE_LIST)
+ return 0;
+
+ id = TREE_VALUE (spec);
+
+ if (TREE_CODE (id) == IDENTIFIER_NODE)
+ {
+ if (id == ridpointers[(int) RID_INT]
+ || id == ridpointers[(int) RID_CHAR]
+ || id == ridpointers[(int) RID_BOOL]
+ || id == ridpointers[(int) RID_WCHAR])
+ {
+ if (type)
+ {
+ if (id == ridpointers[(int) RID_BOOL])
+ error ("`bool' is now a keyword");
+ else
+ cp_error ("extraneous `%T' ignored", id);
+ }
+ else
+ {
+ if (id == ridpointers[(int) RID_INT])
+ explicit_int = 1;
+ else if (id == ridpointers[(int) RID_CHAR])
+ explicit_char = 1;
+ type = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (id));
+ }
+ goto found;
+ }
+ /* C++ aggregate types. */
+ if (IDENTIFIER_HAS_TYPE_VALUE (id))
+ {
+ if (type)
+ cp_error ("multiple declarations `%T' and `%T'", type, id);
+ else
+ type = IDENTIFIER_TYPE_VALUE (id);
+ goto found;
+ }
+
+ for (i = (int) RID_FIRST_MODIFIER; i <= (int) RID_LAST_MODIFIER; i++)
+ {
+ if (ridpointers[i] == id)
+ {
+ if (i == (int) RID_LONG && RIDBIT_SETP (i, specbits))
+ {
+ if (pedantic && ! in_system_header)
+ pedwarn ("ANSI C++ does not support `long long'");
+ else if (longlong)
+ error ("`long long long' is too long for GCC");
+ else
+ longlong = 1;
+ }
+ else if (RIDBIT_SETP (i, specbits))
+ pedwarn ("duplicate `%s'", IDENTIFIER_POINTER (id));
+ RIDBIT_SET (i, specbits);
+ goto found;
+ }
+ }
+ }
+ if (type)
+ error ("two or more data types in declaration of `%s'", name);
+ else if (TREE_CODE (id) == IDENTIFIER_NODE)
+ {
+ register tree t = lookup_name (id, 1);
+ if (!t || TREE_CODE (t) != TYPE_DECL)
+ error ("`%s' fails to be a typedef or built in type",
+ IDENTIFIER_POINTER (id));
+ else
+ {
+ type = TREE_TYPE (t);
+ decl_machine_attr = DECL_MACHINE_ATTRIBUTES (id);
+ typedef_decl = t;
+ }
+ }
+ else if (TREE_CODE (id) != ERROR_MARK)
+ /* Can't change CLASS nodes into RECORD nodes here! */
+ type = id;
+
+ found: ;
+ }
+
+ typedef_type = type;
+
+ /* No type at all: default to `int', and set EXPLICIT_INT
+ because it was not a user-defined typedef.
+ Except when we have a `typedef' inside a signature, in
+ which case the type defaults to `unknown type' and is
+ instantiated when assigning to a signature pointer or ref. */
+
+ if (type == NULL_TREE
+ && (RIDBIT_SETP (RID_SIGNED, specbits)
+ || RIDBIT_SETP (RID_UNSIGNED, specbits)
+ || RIDBIT_SETP (RID_LONG, specbits)
+ || RIDBIT_SETP (RID_SHORT, specbits)))
+ {
+ /* These imply 'int'. */
+ type = integer_type_node;
+ explicit_int = 1;
+ }
+
+ if (type == NULL_TREE)
+ {
+ explicit_int = -1;
+ if (return_type == return_dtor)
+ type = void_type_node;
+ else if (return_type == return_ctor)
+ type = build_pointer_type (ctor_return_type);
+ else if (return_type == return_conversion)
+ type = ctor_return_type;
+ else if (current_class_type
+ && IS_SIGNATURE (current_class_type)
+ && (RIDBIT_SETP (RID_TYPEDEF, specbits)
+ || SIGNATURE_GROKKING_TYPEDEF (current_class_type))
+ && (decl_context == FIELD || decl_context == NORMAL))
+ {
+ explicit_int = 0;
+ opaque_typedef = 1;
+ type = copy_node (opaque_type_node);
+ }
+ /* access declaration */
+ else if (decl_context == FIELD && declarator
+ && TREE_CODE (declarator) == SCOPE_REF)
+ type = void_type_node;
+ else
+ {
+ if (funcdef_flag)
+ {
+ if (warn_return_type
+ && return_type == return_normal)
+ /* Save warning until we know what is really going on. */
+ warn_about_return_type = 1;
+ }
+ else if (RIDBIT_SETP (RID_TYPEDEF, specbits))
+ pedwarn ("ANSI C++ forbids typedef which does not specify a type");
+ else if (declspecs == NULL_TREE &&
+ (innermost_code != CALL_EXPR || pedantic))
+ cp_pedwarn ("ANSI C++ forbids declaration `%D' with no type or storage class",
+ dname);
+ type = integer_type_node;
+ }
+ }
+ else if (return_type == return_dtor)
+ {
+ error ("return type specification for destructor invalid");
+ type = void_type_node;
+ }
+ else if (return_type == return_ctor)
+ {
+ error ("return type specification for constructor invalid");
+ type = build_pointer_type (ctor_return_type);
+ }
+ else if (return_type == return_conversion)
+ {
+ if (comptypes (type, ctor_return_type, 1) == 0)
+ cp_error ("operator `%T' declared to return `%T'",
+ ctor_return_type, type);
+ else
+ cp_pedwarn ("return type specified for `operator %T'",
+ ctor_return_type);
+
+ type = ctor_return_type;
+ }
+ /* Catch typedefs that only specify a type, like 'typedef int;'. */
+ else if (RIDBIT_SETP (RID_TYPEDEF, specbits) && declarator == NULL_TREE)
+ {
+ /* Template "this is a type" syntax; just ignore for now. */
+ if (processing_template_defn)
+ return void_type_node;
+ }
+
+ ctype = NULL_TREE;
+
+ /* Now process the modifiers that were specified
+ and check for invalid combinations. */
+
+ /* Long double is a special combination. */
+
+ if (RIDBIT_SETP (RID_LONG, specbits)
+ && TYPE_MAIN_VARIANT (type) == double_type_node)
+ {
+ RIDBIT_RESET (RID_LONG, specbits);
+ type = build_type_variant (long_double_type_node, TYPE_READONLY (type),
+ TYPE_VOLATILE (type));
+ }
+
+ /* Check all other uses of type modifiers. */
+
+ if (RIDBIT_SETP (RID_UNSIGNED, specbits)
+ || RIDBIT_SETP (RID_SIGNED, specbits)
+ || RIDBIT_SETP (RID_LONG, specbits)
+ || RIDBIT_SETP (RID_SHORT, specbits))
+ {
+ int ok = 0;
+
+ if (TREE_CODE (type) == REAL_TYPE)
+ error ("short, signed or unsigned invalid for `%s'", name);
+ else if (TREE_CODE (type) != INTEGER_TYPE)
+ error ("long, short, signed or unsigned invalid for `%s'", name);
+ else if (RIDBIT_SETP (RID_LONG, specbits)
+ && RIDBIT_SETP (RID_SHORT, specbits))
+ error ("long and short specified together for `%s'", name);
+ else if ((RIDBIT_SETP (RID_LONG, specbits)
+ || RIDBIT_SETP (RID_SHORT, specbits))
+ && explicit_char)
+ error ("long or short specified with char for `%s'", name);
+ else if ((RIDBIT_SETP (RID_LONG, specbits)
+ || RIDBIT_SETP (RID_SHORT, specbits))
+ && TREE_CODE (type) == REAL_TYPE)
+ error ("long or short specified with floating type for `%s'", name);
+ else if (RIDBIT_SETP (RID_SIGNED, specbits)
+ && RIDBIT_SETP (RID_UNSIGNED, specbits))
+ error ("signed and unsigned given together for `%s'", name);
+ else
+ {
+ ok = 1;
+ if (!explicit_int && !explicit_char && pedantic)
+ {
+ pedwarn ("long, short, signed or unsigned used invalidly for `%s'",
+ name);
+ if (flag_pedantic_errors)
+ ok = 0;
+ }
+ }
+
+ /* Discard the type modifiers if they are invalid. */
+ if (! ok)
+ {
+ RIDBIT_RESET (RID_UNSIGNED, specbits);
+ RIDBIT_RESET (RID_SIGNED, specbits);
+ RIDBIT_RESET (RID_LONG, specbits);
+ RIDBIT_RESET (RID_SHORT, specbits);
+ longlong = 0;
+ }
+ }
+
+ /* Decide whether an integer type is signed or not.
+ Optionally treat bitfields as signed by default. */
+ if (RIDBIT_SETP (RID_UNSIGNED, specbits)
+ /* Traditionally, all bitfields are unsigned. */
+ || (bitfield && flag_traditional)
+ || (bitfield && ! flag_signed_bitfields
+ && (explicit_int || explicit_char
+ /* A typedef for plain `int' without `signed'
+ can be controlled just like plain `int'. */
+ || ! (typedef_decl != NULL_TREE
+ && C_TYPEDEF_EXPLICITLY_SIGNED (typedef_decl)))
+ && TREE_CODE (type) != ENUMERAL_TYPE
+ && RIDBIT_NOTSETP (RID_SIGNED, specbits)))
+ {
+ if (longlong)
+ type = long_long_unsigned_type_node;
+ else if (RIDBIT_SETP (RID_LONG, specbits))
+ type = long_unsigned_type_node;
+ else if (RIDBIT_SETP (RID_SHORT, specbits))
+ type = short_unsigned_type_node;
+ else if (type == char_type_node)
+ type = unsigned_char_type_node;
+ else if (typedef_decl)
+ type = unsigned_type (type);
+ else
+ type = unsigned_type_node;
+ }
+ else if (RIDBIT_SETP (RID_SIGNED, specbits)
+ && type == char_type_node)
+ type = signed_char_type_node;
+ else if (longlong)
+ type = long_long_integer_type_node;
+ else if (RIDBIT_SETP (RID_LONG, specbits))
+ type = long_integer_type_node;
+ else if (RIDBIT_SETP (RID_SHORT, specbits))
+ type = short_integer_type_node;
+
+ /* Set CONSTP if this declaration is `const', whether by
+ explicit specification or via a typedef.
+ Likewise for VOLATILEP. */
+
+ constp = !! RIDBIT_SETP (RID_CONST, specbits) + TYPE_READONLY (type);
+ volatilep = !! RIDBIT_SETP (RID_VOLATILE, specbits) + TYPE_VOLATILE (type);
+ staticp = 0;
+ inlinep = !! RIDBIT_SETP (RID_INLINE, specbits);
+#if 0
+ /* This sort of redundancy is blessed in a footnote to the Sep 94 WP. */
+ if (constp > 1)
+ warning ("duplicate `const'");
+ if (volatilep > 1)
+ warning ("duplicate `volatile'");
+#endif
+ virtualp = RIDBIT_SETP (RID_VIRTUAL, specbits);
+ RIDBIT_RESET (RID_VIRTUAL, specbits);
+ explicitp = RIDBIT_SETP (RID_EXPLICIT, specbits) != 0;
+ RIDBIT_RESET (RID_EXPLICIT, specbits);
+
+ if (RIDBIT_SETP (RID_STATIC, specbits))
+ staticp = 1 + (decl_context == FIELD);
+
+ if (virtualp && staticp == 2)
+ {
+ cp_error ("member `%D' cannot be declared both virtual and static",
+ dname);
+ staticp = 0;
+ }
+ friendp = RIDBIT_SETP (RID_FRIEND, specbits);
+ RIDBIT_RESET (RID_FRIEND, specbits);
+
+ if (RIDBIT_SETP (RID_MUTABLE, specbits))
+ {
+ if (decl_context == PARM)
+ {
+ error ("non-member `%s' cannot be declared `mutable'", name);
+ RIDBIT_RESET (RID_MUTABLE, specbits);
+ }
+ else if (friendp || decl_context == TYPENAME)
+ {
+ error ("non-object member `%s' cannot be declared `mutable'", name);
+ RIDBIT_RESET (RID_MUTABLE, specbits);
+ }
+#if 0
+ if (RIDBIT_SETP (RID_TYPEDEF, specbits))
+ {
+ error ("non-object member `%s' cannot be declared `mutable'", name);
+ RIDBIT_RESET (RID_MUTABLE, specbits);
+ }
+ /* Because local typedefs are parsed twice, we don't want this
+ message here. */
+ else if (decl_context != FIELD)
+ {
+ error ("non-member `%s' cannot be declared `mutable'", name);
+ RIDBIT_RESET (RID_MUTABLE, specbits);
+ }
+#endif
+ }
+
+ /* Warn if two storage classes are given. Default to `auto'. */
+
+ if (RIDBIT_ANY_SET (specbits))
+ {
+ if (RIDBIT_SETP (RID_STATIC, specbits)) nclasses++;
+ if (RIDBIT_SETP (RID_EXTERN, specbits)) nclasses++;
+ if (decl_context == PARM && nclasses > 0)
+ error ("storage class specifiers invalid in parameter declarations");
+ if (RIDBIT_SETP (RID_TYPEDEF, specbits))
+ {
+ if (decl_context == PARM)
+ error ("typedef declaration invalid in parameter declaration");
+ nclasses++;
+ }
+ if (RIDBIT_SETP (RID_AUTO, specbits)) nclasses++;
+ if (RIDBIT_SETP (RID_REGISTER, specbits)) nclasses++;
+ }
+
+ /* Give error if `virtual' is used outside of class declaration. */
+ if (virtualp
+ && (current_class_name == NULL_TREE || decl_context != FIELD))
+ {
+ error ("virtual outside class declaration");
+ virtualp = 0;
+ }
+ if (current_class_name == NULL_TREE && RIDBIT_SETP (RID_MUTABLE, specbits))
+ {
+ error ("only members can be declared mutable");
+ RIDBIT_RESET (RID_MUTABLE, specbits);
+ }
+
+ /* Static anonymous unions are dealt with here. */
+ if (staticp && decl_context == TYPENAME
+ && TREE_CODE (declspecs) == TREE_LIST
+ && TREE_CODE (TREE_VALUE (declspecs)) == UNION_TYPE
+ && ANON_AGGRNAME_P (TYPE_IDENTIFIER (TREE_VALUE (declspecs))))
+ decl_context = FIELD;
+
+ /* Give error if `const,' `volatile,' `inline,' `friend,' or `virtual'
+ is used in a signature member function declaration. */
+ if (decl_context == FIELD
+ && IS_SIGNATURE (current_class_type)
+ && RIDBIT_NOTSETP(RID_TYPEDEF, specbits)
+ && !SIGNATURE_GROKKING_TYPEDEF (current_class_type))
+ {
+ if (constp)
+ {
+ error ("`const' specified for signature member function `%s'", name);
+ constp = 0;
+ }
+ if (volatilep)
+ {
+ error ("`volatile' specified for signature member function `%s'",
+ name);
+ volatilep = 0;
+ }
+ if (inlinep)
+ {
+ error ("`inline' specified for signature member function `%s'", name);
+ /* Later, we'll make signature member functions inline. */
+ inlinep = 0;
+ }
+ if (friendp)
+ {
+ error ("`friend' declaration in signature definition");
+ friendp = 0;
+ }
+ if (virtualp)
+ {
+ error ("`virtual' specified for signature member function `%s'",
+ name);
+ /* Later, we'll make signature member functions virtual. */
+ virtualp = 0;
+ }
+ }
+
+ /* Warn about storage classes that are invalid for certain
+ kinds of declarations (parameters, typenames, etc.). */
+
+ if (nclasses > 1)
+ error ("multiple storage classes in declaration of `%s'", name);
+ else if (decl_context != NORMAL && nclasses > 0)
+ {
+ if ((decl_context == PARM || decl_context == CATCHPARM)
+ && (RIDBIT_SETP (RID_REGISTER, specbits)
+ || RIDBIT_SETP (RID_AUTO, specbits)))
+ ;
+ else if (decl_context == FIELD
+ && RIDBIT_SETP (RID_TYPEDEF, specbits))
+ {
+ /* Processing a typedef declaration nested within a class type
+ definition. */
+ register tree scanner;
+ register tree previous_declspec;
+ tree loc_typedecl;
+
+ if (initialized)
+ error ("typedef declaration includes an initializer");
+
+ /* To process a class-local typedef declaration, we descend down
+ the chain of declspecs looking for the `typedef' spec. When
+ we find it, we replace it with `static', and then recursively
+ call `grokdeclarator' with the original declarator and with
+ the newly adjusted declspecs. This call should return a
+ FIELD_DECL node with the TREE_TYPE (and other parts) set
+ appropriately. We can then just change the TREE_CODE on that
+ from FIELD_DECL to TYPE_DECL and we're done. */
+
+ for (previous_declspec = NULL_TREE, scanner = declspecs;
+ scanner;
+ previous_declspec = scanner, scanner = TREE_CHAIN (scanner))
+ {
+ if (TREE_VALUE (scanner) == ridpointers[(int) RID_TYPEDEF])
+ break;
+ }
+
+ if (previous_declspec)
+ TREE_CHAIN (previous_declspec) = TREE_CHAIN (scanner);
+ else
+ declspecs = TREE_CHAIN (scanner);
+
+ declspecs = tree_cons (NULL_TREE, ridpointers[(int) RID_STATIC],
+ declspecs);
+
+ /* In the recursive call to grokdeclarator we need to know
+ whether we are working on a signature-local typedef. */
+ if (IS_SIGNATURE (current_class_type))
+ SIGNATURE_GROKKING_TYPEDEF (current_class_type) = 1;
+
+ loc_typedecl =
+ grokdeclarator (declarator, declspecs, FIELD, 0, NULL_TREE, NULL_TREE);
+
+ if (previous_declspec)
+ TREE_CHAIN (previous_declspec) = scanner;
+
+ if (loc_typedecl != error_mark_node)
+ {
+ register int i = sizeof (struct lang_decl_flags) / sizeof (int);
+ register int *pi;
+
+ TREE_SET_CODE (loc_typedecl, TYPE_DECL);
+ /* This is the same field as DECL_ARGUMENTS, which is set for
+ function typedefs by the above grokdeclarator. */
+ DECL_NESTED_TYPENAME (loc_typedecl) = 0;
+
+ pi = (int *) permalloc (sizeof (struct lang_decl_flags));
+ while (i > 0)
+ pi[--i] = 0;
+ DECL_LANG_SPECIFIC (loc_typedecl) = (struct lang_decl *) pi;
+ }
+
+ if (IS_SIGNATURE (current_class_type))
+ {
+ SIGNATURE_GROKKING_TYPEDEF (current_class_type) = 0;
+ if (loc_typedecl != error_mark_node && opaque_typedef)
+ SIGNATURE_HAS_OPAQUE_TYPEDECLS (current_class_type) = 1;
+ }
+
+ return loc_typedecl;
+ }
+ else if (decl_context == FIELD
+ && (! IS_SIGNATURE (current_class_type)
+ || SIGNATURE_GROKKING_TYPEDEF (current_class_type))
+ /* C++ allows static class elements */
+ && RIDBIT_SETP (RID_STATIC, specbits))
+ /* C++ also allows inlines and signed and unsigned elements,
+ but in those cases we don't come in here. */
+ ;
+ else
+ {
+ if (decl_context == FIELD)
+ {
+ tree tmp = NULL_TREE;
+ register int op = 0;
+
+ if (declarator)
+ {
+ tmp = TREE_OPERAND (declarator, 0);
+ op = IDENTIFIER_OPNAME_P (tmp);
+ }
+ error ("storage class specified for %s `%s'",
+ IS_SIGNATURE (current_class_type)
+ ? (op
+ ? "signature member operator"
+ : "signature member function")
+ : (op ? "member operator" : "field"),
+ op ? operator_name_string (tmp) : name);
+ }
+ else
+ error (((decl_context == PARM || decl_context == CATCHPARM)
+ ? "storage class specified for parameter `%s'"
+ : "storage class specified for typename"), name);
+ RIDBIT_RESET (RID_REGISTER, specbits);
+ RIDBIT_RESET (RID_AUTO, specbits);
+ RIDBIT_RESET (RID_EXTERN, specbits);
+
+ if (decl_context == FIELD && IS_SIGNATURE (current_class_type))
+ {
+ RIDBIT_RESET (RID_STATIC, specbits);
+ staticp = 0;
+ }
+ }
+ }
+ else if (RIDBIT_SETP (RID_EXTERN, specbits) && initialized && !funcdef_flag)
+ {
+ if (toplevel_bindings_p ())
+ {
+ /* It's common practice (and completely valid) to have a const
+ be initialized and declared extern. */
+ if (! constp)
+ warning ("`%s' initialized and declared `extern'", name);
+ }
+ else
+ error ("`%s' has both `extern' and initializer", name);
+ }
+ else if (RIDBIT_SETP (RID_EXTERN, specbits) && funcdef_flag
+ && ! toplevel_bindings_p ())
+ error ("nested function `%s' declared `extern'", name);
+ else if (toplevel_bindings_p ())
+ {
+ if (RIDBIT_SETP (RID_AUTO, specbits))
+ error ("top-level declaration of `%s' specifies `auto'", name);
+#if 0
+ if (RIDBIT_SETP (RID_REGISTER, specbits))
+ error ("top-level declaration of `%s' specifies `register'", name);
+#endif
+#if 0
+ /* I'm not sure under what circumstances we should turn
+ on the extern bit, and under what circumstances we should
+ warn if other bits are turned on. */
+ if (decl_context == NORMAL
+ && RIDBIT_NOSETP (RID_EXTERN, specbits)
+ && ! root_lang_context_p ())
+ {
+ RIDBIT_SET (RID_EXTERN, specbits);
+ }
+#endif
+ }
+
+ /* Now figure out the structure of the declarator proper.
+ Descend through it, creating more complex types, until we reach
+ the declared identifier (or NULL_TREE, in an absolute declarator). */
+
+ while (declarator && TREE_CODE (declarator) != IDENTIFIER_NODE)
+ {
+ /* Each level of DECLARATOR is either an ARRAY_REF (for ...[..]),
+ an INDIRECT_REF (for *...),
+ a CALL_EXPR (for ...(...)),
+ an identifier (for the name being declared)
+ or a null pointer (for the place in an absolute declarator
+ where the name was omitted).
+ For the last two cases, we have just exited the loop.
+
+ For C++ it could also be
+ a SCOPE_REF (for class :: ...). In this case, we have converted
+ sensible names to types, and those are the values we use to
+ qualify the member name.
+ an ADDR_EXPR (for &...),
+ a BIT_NOT_EXPR (for destructors)
+
+ At this point, TYPE is the type of elements of an array,
+ or for a function to return, or for a pointer to point to.
+ After this sequence of ifs, TYPE is the type of the
+ array or function or pointer, and DECLARATOR has had its
+ outermost layer removed. */
+
+ if (TREE_CODE (type) == ERROR_MARK)
+ {
+ if (TREE_CODE (declarator) == SCOPE_REF)
+ declarator = TREE_OPERAND (declarator, 1);
+ else
+ declarator = TREE_OPERAND (declarator, 0);
+ continue;
+ }
+ if (quals != NULL_TREE
+ && (declarator == NULL_TREE
+ || TREE_CODE (declarator) != SCOPE_REF))
+ {
+ if (ctype == NULL_TREE && TREE_CODE (type) == METHOD_TYPE)
+ ctype = TYPE_METHOD_BASETYPE (type);
+ if (ctype != NULL_TREE)
+ {
+#if 0 /* not yet, should get fixed properly later */
+ tree dummy = make_type_decl (NULL_TREE, type);
+#else
+ tree dummy = build_decl (TYPE_DECL, NULL_TREE, type);
+#endif
+ ctype = grok_method_quals (ctype, dummy, quals);
+ type = TREE_TYPE (dummy);
+ quals = NULL_TREE;
+ }
+ }
+ switch (TREE_CODE (declarator))
+ {
+ case ARRAY_REF:
+ {
+ register tree itype = NULL_TREE;
+ register tree size = TREE_OPERAND (declarator, 1);
+ /* The index is a signed object `sizetype' bits wide. */
+ tree index_type = signed_type (sizetype);
+
+ declarator = TREE_OPERAND (declarator, 0);
+
+ /* Check for some types that there cannot be arrays of. */
+
+ if (TYPE_MAIN_VARIANT (type) == void_type_node)
+ {
+ cp_error ("declaration of `%D' as array of voids", dname);
+ type = error_mark_node;
+ }
+
+ if (TREE_CODE (type) == FUNCTION_TYPE)
+ {
+ cp_error ("declaration of `%D' as array of functions", dname);
+ type = error_mark_node;
+ }
+
+ /* ARM $8.4.3: Since you can't have a pointer to a reference,
+ you can't have arrays of references. If we allowed them,
+ then we'd be saying x[i] is valid for an array x, but
+ then you'd have to ask: what does `*(x + i)' mean? */
+ if (TREE_CODE (type) == REFERENCE_TYPE)
+ {
+ if (decl_context == TYPENAME)
+ cp_error ("cannot make arrays of references");
+ else
+ cp_error ("declaration of `%D' as array of references",
+ dname);
+ type = error_mark_node;
+ }
+
+ if (TREE_CODE (type) == OFFSET_TYPE)
+ {
+ cp_error ("declaration of `%D' as array of data members",
+ dname);
+ type = error_mark_node;
+ }
+
+ if (TREE_CODE (type) == METHOD_TYPE)
+ {
+ cp_error ("declaration of `%D' as array of function members",
+ dname);
+ type = error_mark_node;
+ }
+
+ if (size == error_mark_node)
+ type = error_mark_node;
+
+ if (type == error_mark_node)
+ continue;
+
+ if (size)
+ {
+ /* Must suspend_momentary here because the index
+ type may need to live until the end of the function.
+ For example, it is used in the declaration of a
+ variable which requires destructing at the end of
+ the function; then build_vec_delete will need this
+ value. */
+ int yes = suspend_momentary ();
+ /* might be a cast */
+ if (TREE_CODE (size) == NOP_EXPR
+ && TREE_TYPE (size) == TREE_TYPE (TREE_OPERAND (size, 0)))
+ size = TREE_OPERAND (size, 0);
+
+ /* If this is a template parameter, it'll be constant, but
+ we don't know what the value is yet. */
+ if (TREE_CODE (size) == TEMPLATE_CONST_PARM)
+ goto dont_grok_size;
+
+ if (TREE_CODE (TREE_TYPE (size)) != INTEGER_TYPE
+ && TREE_CODE (TREE_TYPE (size)) != ENUMERAL_TYPE)
+ {
+ cp_error ("size of array `%D' has non-integer type",
+ dname);
+ size = integer_one_node;
+ }
+ if (TREE_READONLY_DECL_P (size))
+ size = decl_constant_value (size);
+ if (pedantic && integer_zerop (size))
+ cp_pedwarn ("ANSI C++ forbids zero-size array `%D'", dname);
+ if (TREE_CONSTANT (size))
+ {
+ int old_flag_pedantic_errors = flag_pedantic_errors;
+ int old_pedantic = pedantic;
+ pedantic = flag_pedantic_errors = 1;
+ /* Always give overflow errors on array subscripts. */
+ constant_expression_warning (size);
+ pedantic = old_pedantic;
+ flag_pedantic_errors = old_flag_pedantic_errors;
+ if (INT_CST_LT (size, integer_zero_node))
+ {
+ cp_error ("size of array `%D' is negative", dname);
+ size = integer_one_node;
+ }
+ }
+ else
+ {
+ if (pedantic)
+ {
+ if (dname)
+ cp_pedwarn ("ANSI C++ forbids variable-size array `%D'",
+ dname);
+ else
+ cp_pedwarn ("ANSI C++ forbids variable-size array");
+ }
+ /* Make sure the array size remains visibly nonconstant
+ even if it is (eg) a const variable with known value. */
+ size_varies = 1;
+ }
+
+ dont_grok_size:
+ itype =
+ fold (build_binary_op (MINUS_EXPR,
+ convert (index_type, size),
+ convert (index_type,
+ integer_one_node), 1));
+ if (! TREE_CONSTANT (itype))
+ itype = variable_size (itype);
+ itype = build_index_type (itype);
+ resume_momentary (yes);
+ }
+
+ /* Build the array type itself, then merge any constancy or
+ volatility into the target type. We must do it in this order
+ to ensure that the TYPE_MAIN_VARIANT field of the array type
+ is set correctly. */
+
+ type = build_cplus_array_type (type, itype);
+ if (constp || volatilep)
+ type = cp_build_type_variant (type, constp, volatilep);
+
+ ctype = NULL_TREE;
+ }
+ break;
+
+ case CALL_EXPR:
+ {
+ tree arg_types;
+ int funcdecl_p;
+ tree inner_parms = TREE_OPERAND (declarator, 1);
+ tree inner_decl = TREE_OPERAND (declarator, 0);
+
+ /* Declaring a function type.
+ Make sure we have a valid type for the function to return. */
+#if 0
+ /* Is this an error? Should they be merged into TYPE here? */
+ if (pedantic && (constp || volatilep))
+ pedwarn ("function declared to return const or volatile result");
+#else
+ /* Merge any constancy or volatility into the function return
+ type. */
+
+ if (constp || volatilep)
+ {
+ type = cp_build_type_variant (type, constp, volatilep);
+ if (IS_AGGR_TYPE (type))
+ build_pointer_type (type);
+ constp = 0;
+ volatilep = 0;
+ }
+#endif
+
+ /* Warn about some types functions can't return. */
+
+ if (TREE_CODE (type) == FUNCTION_TYPE)
+ {
+ error ("`%s' declared as function returning a function", name);
+ type = integer_type_node;
+ }
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ {
+ error ("`%s' declared as function returning an array", name);
+ type = integer_type_node;
+ }
+
+ if (inner_decl && TREE_CODE (inner_decl) == SCOPE_REF)
+ inner_decl = TREE_OPERAND (inner_decl, 1);
+
+ /* Pick up type qualifiers which should be applied to `this'. */
+ quals = TREE_OPERAND (declarator, 2);
+
+ /* Say it's a definition only for the CALL_EXPR
+ closest to the identifier. */
+ funcdecl_p =
+ inner_decl && (TREE_CODE (inner_decl) == IDENTIFIER_NODE
+ || TREE_CODE (inner_decl) == BIT_NOT_EXPR);
+
+ if (ctype == NULL_TREE
+ && decl_context == FIELD
+ && funcdecl_p
+ && (friendp == 0 || dname == current_class_name))
+ ctype = current_class_type;
+
+ if (ctype && return_type == return_conversion)
+ TYPE_HAS_CONVERSION (ctype) = 1;
+ if (ctype && constructor_name (ctype) == dname)
+ {
+ /* We are within a class's scope. If our declarator name
+ is the same as the class name, and we are defining
+ a function, then it is a constructor/destructor, and
+ therefore returns a void type. */
+
+ if (flags == DTOR_FLAG)
+ {
+ /* ANSI C++ June 5 1992 WP 12.4.1. A destructor may
+ not be declared const or volatile. A destructor
+ may not be static. */
+ if (staticp == 2)
+ error ("destructor cannot be static member function");
+ if (quals)
+ {
+ error ("destructors cannot be declared `const' or `volatile'");
+ return void_type_node;
+ }
+ if (decl_context == FIELD)
+ {
+ if (! member_function_or_else (ctype, current_class_type,
+ "destructor for alien class `%s' cannot be a member"))
+ return void_type_node;
+ }
+ }
+ else /* it's a constructor. */
+ {
+ if (explicitp == 1)
+ explicitp = 2;
+ /* ANSI C++ June 5 1992 WP 12.1.2. A constructor may
+ not be declared const or volatile. A constructor may
+ not be virtual. A constructor may not be static. */
+ if (staticp == 2)
+ error ("constructor cannot be static member function");
+ if (virtualp)
+ {
+ pedwarn ("constructors cannot be declared virtual");
+ virtualp = 0;
+ }
+ if (quals)
+ {
+ error ("constructors cannot be declared `const' or `volatile'");
+ return void_type_node;
+ }
+ {
+ RID_BIT_TYPE tmp_bits;
+ bcopy ((void*)&specbits, (void*)&tmp_bits, sizeof(RID_BIT_TYPE));
+ RIDBIT_RESET (RID_INLINE, tmp_bits);
+ RIDBIT_RESET (RID_STATIC, tmp_bits);
+ if (RIDBIT_ANY_SET (tmp_bits))
+ error ("return value type specifier for constructor ignored");
+ }
+ type = build_pointer_type (ctype);
+ if (decl_context == FIELD &&
+ IS_SIGNATURE (current_class_type))
+ {
+ error ("constructor not allowed in signature");
+ return void_type_node;
+ }
+ else if (decl_context == FIELD)
+ {
+ if (! member_function_or_else (ctype, current_class_type,
+ "constructor for alien class `%s' cannot be member"))
+ return void_type_node;
+ TYPE_HAS_CONSTRUCTOR (ctype) = 1;
+ if (return_type != return_ctor)
+ return NULL_TREE;
+ }
+ }
+ if (decl_context == FIELD)
+ staticp = 0;
+ }
+ else if (friendp)
+ {
+ if (initialized)
+ error ("can't initialize friend function `%s'", name);
+ if (virtualp)
+ {
+ /* Cannot be both friend and virtual. */
+ error ("virtual functions cannot be friends");
+ RIDBIT_RESET (RID_FRIEND, specbits);
+ friendp = 0;
+ }
+ if (decl_context == NORMAL)
+ error ("friend declaration not in class definition");
+ if (current_function_decl && funcdef_flag)
+ cp_error ("can't define friend function `%s' in a local class definition",
+ name);
+ }
+
+ /* Traditionally, declaring return type float means double. */
+
+ if (flag_traditional
+ && TYPE_MAIN_VARIANT (type) == float_type_node)
+ {
+ type = build_type_variant (double_type_node,
+ TYPE_READONLY (type),
+ TYPE_VOLATILE (type));
+ }
+
+ /* Construct the function type and go to the next
+ inner layer of declarator. */
+
+ declarator = TREE_OPERAND (declarator, 0);
+
+ /* FIXME: This is where default args should be fully
+ processed. */
+
+ arg_types = grokparms (inner_parms, funcdecl_p ? funcdef_flag : 0);
+
+ if (declarator)
+ {
+ /* Get past destructors, etc.
+ We know we have one because FLAGS will be non-zero.
+
+ Complain about improper parameter lists here. */
+ if (TREE_CODE (declarator) == BIT_NOT_EXPR)
+ {
+ declarator = TREE_OPERAND (declarator, 0);
+
+ if (strict_prototype == 0 && arg_types == NULL_TREE)
+ arg_types = void_list_node;
+ else if (arg_types == NULL_TREE
+ || arg_types != void_list_node)
+ {
+ error ("destructors cannot be specified with parameters");
+ arg_types = void_list_node;
+ }
+ }
+ }
+
+ /* ANSI seems to say that `const int foo ();'
+ does not make the function foo const. */
+ type = build_function_type (type,
+ flag_traditional ? 0 : arg_types);
+ }
+ break;
+
+ case ADDR_EXPR:
+ case INDIRECT_REF:
+ /* Filter out pointers-to-references and references-to-references.
+ We can get these if a TYPE_DECL is used. */
+
+ if (TREE_CODE (type) == REFERENCE_TYPE)
+ {
+ error ("cannot declare %s to references",
+ TREE_CODE (declarator) == ADDR_EXPR
+ ? "references" : "pointers");
+ declarator = TREE_OPERAND (declarator, 0);
+ continue;
+ }
+
+ if (TREE_CODE (type) == OFFSET_TYPE
+ && (TREE_CODE (TREE_TYPE (type)) == VOID_TYPE
+ || TREE_CODE (TREE_TYPE (type)) == REFERENCE_TYPE))
+ {
+ cp_error ("cannot declare pointer to `%#T' member",
+ TREE_TYPE (type));
+ type = TREE_TYPE (type);
+ }
+
+ /* Merge any constancy or volatility into the target type
+ for the pointer. */
+
+ if (constp || volatilep)
+ {
+ /* A const or volatile signature pointer/reference is
+ pointing to a const or volatile object, i.e., the
+ `optr' is const or volatile, respectively, not the
+ signature pointer/reference itself. */
+ if (! IS_SIGNATURE (type))
+ {
+ type = cp_build_type_variant (type, constp, volatilep);
+ if (IS_AGGR_TYPE (type))
+ build_pointer_type (type);
+ constp = 0;
+ volatilep = 0;
+ }
+ }
+
+ if (IS_SIGNATURE (type))
+ {
+ if (TREE_CODE (declarator) == ADDR_EXPR)
+ {
+ if (CLASSTYPE_METHOD_VEC (type) == NULL_TREE
+ && TYPE_SIZE (type))
+ cp_warning ("empty signature `%T' used in signature reference declaration",
+ type);
+#if 0
+ type = build_signature_reference_type (type,
+ constp, volatilep);
+#else
+ sorry ("signature reference");
+ return NULL_TREE;
+#endif
+ }
+ else
+ {
+ if (CLASSTYPE_METHOD_VEC (type) == NULL_TREE
+ && TYPE_SIZE (type))
+ cp_warning ("empty signature `%T' used in signature pointer declaration",
+ type);
+ type = build_signature_pointer_type (type,
+ constp, volatilep);
+ }
+ constp = 0;
+ volatilep = 0;
+ }
+ else if (TREE_CODE (declarator) == ADDR_EXPR)
+ {
+ if (TREE_CODE (type) == FUNCTION_TYPE)
+ {
+ error ("cannot declare references to functions; use pointer to function instead");
+ type = build_pointer_type (type);
+ }
+ else
+ {
+ if (TYPE_MAIN_VARIANT (type) == void_type_node)
+ error ("invalid type: `void &'");
+ else
+ type = build_reference_type (type);
+ }
+ }
+ else if (TREE_CODE (type) == METHOD_TYPE)
+ {
+ type = build_ptrmemfunc_type (build_pointer_type (type));
+ }
+ else
+ type = build_pointer_type (type);
+
+ /* Process a list of type modifier keywords (such as
+ const or volatile) that were given inside the `*' or `&'. */
+
+ if (TREE_TYPE (declarator))
+ {
+ register tree typemodlist;
+ int erred = 0;
+ for (typemodlist = TREE_TYPE (declarator); typemodlist;
+ typemodlist = TREE_CHAIN (typemodlist))
+ {
+ if (TREE_VALUE (typemodlist) == ridpointers[(int) RID_CONST])
+ constp++;
+ else if (TREE_VALUE (typemodlist) == ridpointers[(int) RID_VOLATILE])
+ volatilep++;
+ else if (!erred)
+ {
+ erred = 1;
+ error ("invalid type modifier within %s declarator",
+ TREE_CODE (declarator) == ADDR_EXPR
+ ? "reference" : "pointer");
+ }
+ }
+ if (constp > 1)
+ pedwarn ("duplicate `const'");
+ if (volatilep > 1)
+ pedwarn ("duplicate `volatile'");
+ if (TREE_CODE (declarator) == ADDR_EXPR
+ && (constp || volatilep))
+ {
+ if (constp)
+ pedwarn ("discarding `const' applied to a reference");
+ if (volatilep)
+ pedwarn ("discarding `volatile' applied to a reference");
+ constp = volatilep = 0;
+ }
+ }
+ declarator = TREE_OPERAND (declarator, 0);
+ ctype = NULL_TREE;
+ break;
+
+ case SCOPE_REF:
+ {
+ /* We have converted type names to NULL_TREE if the
+ name was bogus, or to a _TYPE node, if not.
+
+ The variable CTYPE holds the type we will ultimately
+ resolve to. The code here just needs to build
+ up appropriate member types. */
+ tree sname = TREE_OPERAND (declarator, 1);
+ /* Destructors can have their visibilities changed as well. */
+ if (TREE_CODE (sname) == BIT_NOT_EXPR)
+ sname = TREE_OPERAND (sname, 0);
+
+ if (TREE_COMPLEXITY (declarator) == 0)
+ /* This needs to be here, in case we are called
+ multiple times. */ ;
+ else if (friendp && (TREE_COMPLEXITY (declarator) < 2))
+ /* don't fall out into global scope. Hides real bug? --eichin */ ;
+ else if (TREE_COMPLEXITY (declarator) == current_class_depth)
+ {
+ /* This pop_nested_class corresponds to the
+ push_nested_class used to push into class scope for
+ parsing the argument list of a function decl, in
+ qualified_id. */
+ pop_nested_class (1);
+ TREE_COMPLEXITY (declarator) = current_class_depth;
+ }
+ else
+ my_friendly_abort (16);
+
+ if (TREE_OPERAND (declarator, 0) == NULL_TREE)
+ {
+ /* We had a reference to a global decl, or
+ perhaps we were given a non-aggregate typedef,
+ in which case we cleared this out, and should just
+ keep going as though it wasn't there. */
+ declarator = sname;
+ continue;
+ }
+ ctype = TREE_OPERAND (declarator, 0);
+
+ if (sname == NULL_TREE)
+ goto done_scoping;
+
+ if (TREE_CODE (sname) == IDENTIFIER_NODE)
+ {
+ /* This is the `standard' use of the scoping operator:
+ basetype :: member . */
+
+ if (ctype == current_class_type)
+ {
+ /* class A {
+ void A::f ();
+ };
+
+ Is this ill-formed? */
+
+ if (pedantic)
+ cp_pedwarn ("extra qualification `%T::' on member `%s' ignored",
+ ctype, name);
+ }
+ else if (TREE_CODE (type) == FUNCTION_TYPE)
+ {
+ if (current_class_type == NULL_TREE
+ || friendp)
+ type = build_cplus_method_type (build_type_variant (ctype, constp, volatilep),
+ TREE_TYPE (type), TYPE_ARG_TYPES (type));
+ else
+ {
+ cp_error ("cannot declare member function `%T::%s' within `%T'",
+ ctype, name, current_class_type);
+ return void_type_node;
+ }
+ }
+ else if (TYPE_SIZE (ctype) != NULL_TREE
+ || (RIDBIT_SETP (RID_TYPEDEF, specbits)))
+ {
+ tree t;
+ /* have to move this code elsewhere in this function.
+ this code is used for i.e., typedef int A::M; M *pm;
+
+ It is? How? jason 10/2/94 */
+
+ if (explicit_int == -1 && decl_context == FIELD
+ && funcdef_flag == 0)
+ {
+ /* The code in here should only be used to build
+ stuff that will be grokked as access decls. */
+ t = lookup_field (ctype, sname, 0, 0);
+ if (t)
+ {
+ t = build_lang_field_decl (FIELD_DECL, build_nt (SCOPE_REF, ctype, t), type);
+ DECL_INITIAL (t) = init;
+ return t;
+ }
+ /* No such field, try member functions. */
+ t = lookup_fnfields (TYPE_BINFO (ctype), sname, 0);
+ if (t)
+ {
+ if (flags == DTOR_FLAG)
+ t = TREE_VALUE (t);
+ else if (CLASSTYPE_METHOD_VEC (ctype)
+ && TREE_VALUE (t) == TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (ctype), 0))
+ {
+ /* Don't include destructor with constructors. */
+ t = DECL_CHAIN (TREE_VALUE (t));
+ if (t == NULL_TREE)
+ cp_error ("`%T' does not have any constructors",
+ ctype);
+ t = build_tree_list (NULL_TREE, t);
+ }
+ t = build_lang_field_decl (FIELD_DECL, build_nt (SCOPE_REF, ctype, t), type);
+ DECL_INITIAL (t) = init;
+ return t;
+ }
+
+ cp_error
+ ("field `%D' is not a member of structure `%T'",
+ sname, ctype);
+ }
+
+ if (current_class_type)
+ {
+ cp_error ("cannot declare member `%T::%s' within `%T'",
+ ctype, name, current_class_type);
+ return void_type_node;
+ }
+ type = build_offset_type (ctype, type);
+ }
+ else if (uses_template_parms (ctype))
+ {
+ enum tree_code c;
+ if (TREE_CODE (type) == FUNCTION_TYPE)
+ {
+ type = build_cplus_method_type (build_type_variant (ctype, constp, volatilep),
+ TREE_TYPE (type),
+ TYPE_ARG_TYPES (type));
+ c = FUNCTION_DECL;
+ }
+ }
+ else
+ {
+ cp_error ("structure `%T' not yet defined", ctype);
+ return error_mark_node;
+ }
+
+ declarator = sname;
+ }
+ else if (TREE_CODE (sname) == SCOPE_REF)
+ my_friendly_abort (17);
+ else
+ {
+ done_scoping:
+ declarator = TREE_OPERAND (declarator, 1);
+ if (declarator && TREE_CODE (declarator) == CALL_EXPR)
+ /* In this case, we will deal with it later. */
+ ;
+ else
+ {
+ if (TREE_CODE (type) == FUNCTION_TYPE)
+ type = build_cplus_method_type (build_type_variant (ctype, constp, volatilep), TREE_TYPE (type), TYPE_ARG_TYPES (type));
+ else
+ type = build_offset_type (ctype, type);
+ }
+ }
+ }
+ break;
+
+ case BIT_NOT_EXPR:
+ declarator = TREE_OPERAND (declarator, 0);
+ break;
+
+ case RECORD_TYPE:
+ case UNION_TYPE:
+ case ENUMERAL_TYPE:
+ declarator = NULL_TREE;
+ break;
+
+ case ERROR_MARK:
+ declarator = NULL_TREE;
+ break;
+
+ default:
+ my_friendly_abort (158);
+ }
+ }
+
+ if (explicitp == 1)
+ {
+ error ("only constructors can be declared `explicit'");
+ explicitp = 0;
+ }
+
+ /* Now TYPE has the actual type. */
+
+ /* If this is declaring a typedef name, return a TYPE_DECL. */
+
+ if (RIDBIT_SETP (RID_MUTABLE, specbits))
+ {
+ if (constp)
+ {
+ error ("const `%s' cannot be declared `mutable'", name);
+ RIDBIT_RESET (RID_MUTABLE, specbits);
+ }
+ else if (staticp)
+ {
+ error ("static `%s' cannot be declared `mutable'", name);
+ RIDBIT_RESET (RID_MUTABLE, specbits);
+ }
+ }
+
+ if (RIDBIT_SETP (RID_TYPEDEF, specbits))
+ {
+ tree decl;
+
+ /* Note that the grammar rejects storage classes
+ in typenames, fields or parameters. */
+ if (constp || volatilep)
+ type = cp_build_type_variant (type, constp, volatilep);
+
+ /* If the user declares "struct {...} foo" then `foo' will have
+ an anonymous name. Fill that name in now. Nothing can
+ refer to it, so nothing needs know about the name change.
+ The TYPE_NAME field was filled in by build_struct_xref. */
+ if (type != error_mark_node
+ && TYPE_NAME (type)
+ && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
+ && ANON_AGGRNAME_P (TYPE_IDENTIFIER (type)))
+ {
+ /* replace the anonymous name with the real name everywhere. */
+ lookup_tag_reverse (type, declarator);
+ TYPE_IDENTIFIER (type) = declarator;
+
+ if (TYPE_LANG_SPECIFIC (type))
+ TYPE_WAS_ANONYMOUS (type) = 1;
+
+ {
+ tree d = TYPE_NAME (type), c = DECL_CONTEXT (d);
+
+ if (!c)
+ set_nested_typename (d, 0, declarator, type);
+ else if (TREE_CODE (c) == FUNCTION_DECL)
+ set_nested_typename (d, DECL_ASSEMBLER_NAME (c),
+ declarator, type);
+ else
+ set_nested_typename (d, TYPE_NESTED_NAME (c), declarator, type);
+
+ DECL_ASSEMBLER_NAME (d) = DECL_NAME (d);
+ DECL_ASSEMBLER_NAME (d)
+ = get_identifier (build_overload_name (type, 1, 1));
+ }
+ }
+
+#if 0 /* not yet, should get fixed properly later */
+ decl = make_type_decl (declarator, type);
+#else
+ decl = build_decl (TYPE_DECL, declarator, type);
+#endif
+ if (TREE_CODE (type) == OFFSET_TYPE || TREE_CODE (type) == METHOD_TYPE)
+ {
+ cp_error_at ("typedef name may not be class-qualified", decl);
+ return NULL_TREE;
+ }
+ else if (quals)
+ {
+ if (ctype == NULL_TREE)
+ {
+ if (TREE_CODE (type) != METHOD_TYPE)
+ cp_error_at ("invalid type qualifier for non-method type", decl);
+ else
+ ctype = TYPE_METHOD_BASETYPE (type);
+ }
+ if (ctype != NULL_TREE)
+ grok_method_quals (ctype, decl, quals);
+ }
+
+ if (RIDBIT_SETP (RID_SIGNED, specbits)
+ || (typedef_decl && C_TYPEDEF_EXPLICITLY_SIGNED (typedef_decl)))
+ C_TYPEDEF_EXPLICITLY_SIGNED (decl) = 1;
+
+ if (RIDBIT_SETP (RID_MUTABLE, specbits))
+ {
+ error ("non-object member `%s' cannot be declared mutable", name);
+ }
+
+ return decl;
+ }
+
+ /* Detect the case of an array type of unspecified size
+ which came, as such, direct from a typedef name.
+ We must copy the type, so that each identifier gets
+ a distinct type, so that each identifier's size can be
+ controlled separately by its own initializer. */
+
+ if (type == typedef_type && TREE_CODE (type) == ARRAY_TYPE
+ && TYPE_DOMAIN (type) == NULL_TREE)
+ {
+ type = build_cplus_array_type (TREE_TYPE (type), TYPE_DOMAIN (type));
+ }
+
+ /* If this is a type name (such as, in a cast or sizeof),
+ compute the type and return it now. */
+
+ if (decl_context == TYPENAME)
+ {
+ /* Note that the grammar rejects storage classes
+ in typenames, fields or parameters. */
+ if (constp || volatilep)
+ if (IS_SIGNATURE (type))
+ error ("`const' or `volatile' specified with signature type");
+ else
+ type = cp_build_type_variant (type, constp, volatilep);
+
+ /* Special case: "friend class foo" looks like a TYPENAME context. */
+ if (friendp)
+ {
+ if (volatilep)
+ {
+ cp_error ("`volatile' specified for friend class declaration");
+ volatilep = 0;
+ }
+ if (inlinep)
+ {
+ cp_error ("`inline' specified for friend class declaration");
+ inlinep = 0;
+ }
+
+ /* Only try to do this stuff if we didn't already give up. */
+ if (type != integer_type_node)
+ {
+ /* A friendly class? */
+ if (current_class_type)
+ make_friend_class (current_class_type, TYPE_MAIN_VARIANT (type));
+ else
+ error ("trying to make class `%s' a friend of global scope",
+ TYPE_NAME_STRING (type));
+ type = void_type_node;
+ }
+ }
+ else if (quals)
+ {
+#if 0 /* not yet, should get fixed properly later */
+ tree dummy = make_type_decl (declarator, type);
+#else
+ tree dummy = build_decl (TYPE_DECL, declarator, type);
+#endif
+ if (ctype == NULL_TREE)
+ {
+ my_friendly_assert (TREE_CODE (type) == METHOD_TYPE, 159);
+ ctype = TYPE_METHOD_BASETYPE (type);
+ }
+ grok_method_quals (ctype, dummy, quals);
+ type = TREE_TYPE (dummy);
+ }
+
+ return type;
+ }
+ else if (declarator == NULL_TREE && decl_context != PARM
+ && decl_context != CATCHPARM
+ && TREE_CODE (type) != UNION_TYPE
+ && ! bitfield)
+ {
+ cp_error ("abstract declarator `%T' used as declaration", type);
+ declarator = make_anon_name ();
+ }
+
+ /* `void' at top level (not within pointer)
+ is allowed only in typedefs or type names.
+ We don't complain about parms either, but that is because
+ a better error message can be made later. */
+
+ if (TYPE_MAIN_VARIANT (type) == void_type_node && decl_context != PARM)
+ {
+ if (! declarator)
+ error ("unnamed variable or field declared void");
+ else if (TREE_CODE (declarator) == IDENTIFIER_NODE)
+ {
+ if (IDENTIFIER_OPNAME_P (declarator))
+#if 0 /* How could this happen? */
+ error ("operator `%s' declared void",
+ operator_name_string (declarator));
+#else
+ my_friendly_abort (356);
+#endif
+ else
+ error ("variable or field `%s' declared void", name);
+ }
+ else
+ error ("variable or field declared void");
+ type = integer_type_node;
+ }
+
+ /* Now create the decl, which may be a VAR_DECL, a PARM_DECL
+ or a FUNCTION_DECL, depending on DECL_CONTEXT and TYPE. */
+
+ {
+ register tree decl;
+
+ if (decl_context == PARM)
+ {
+ if (ctype)
+ error ("cannot use `::' in parameter declaration");
+
+ /* A parameter declared as an array of T is really a pointer to T.
+ One declared as a function is really a pointer to a function.
+ One declared as a member is really a pointer to member. */
+
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ {
+ /* Transfer const-ness of array into that of type pointed to. */
+ type = build_pointer_type
+ (cp_build_type_variant (TREE_TYPE (type), constp, volatilep));
+ volatilep = constp = 0;
+ }
+ else if (TREE_CODE (type) == FUNCTION_TYPE)
+ type = build_pointer_type (type);
+ else if (TREE_CODE (type) == OFFSET_TYPE)
+ type = build_pointer_type (type);
+ else if (type == void_type_node && declarator)
+ {
+ error ("declaration of `%s' as void", name);
+ return NULL_TREE;
+ }
+
+ decl = build_decl (PARM_DECL, declarator, type);
+
+ bad_specifiers (decl, "parameter", virtualp, quals != NULL_TREE,
+ inlinep, friendp, raises != NULL_TREE);
+ if (current_class_type
+ && IS_SIGNATURE (current_class_type))
+ {
+ if (inlinep)
+ error ("parameter of signature member function declared `inline'");
+ if (RIDBIT_SETP (RID_AUTO, specbits))
+ error ("parameter of signature member function declared `auto'");
+ if (RIDBIT_SETP (RID_REGISTER, specbits))
+ error ("parameter of signature member function declared `register'");
+ }
+
+ /* Compute the type actually passed in the parmlist,
+ for the case where there is no prototype.
+ (For example, shorts and chars are passed as ints.)
+ When there is a prototype, this is overridden later. */
+
+ DECL_ARG_TYPE (decl) = type_promotes_to (type);
+ }
+ else if (decl_context == FIELD)
+ {
+ if (type == error_mark_node)
+ {
+ /* Happens when declaring arrays of sizes which
+ are error_mark_node, for example. */
+ decl = NULL_TREE;
+ }
+ else if (TREE_CODE (type) == FUNCTION_TYPE)
+ {
+ int publicp = 0;
+
+ if (friendp == 0)
+ {
+ if (ctype == NULL_TREE)
+ ctype = current_class_type;
+
+ if (ctype == NULL_TREE)
+ {
+ cp_error ("can't make `%D' into a method -- not in a class",
+ declarator);
+ return void_type_node;
+ }
+
+ /* ``A union may [ ... ] not [ have ] virtual functions.''
+ ARM 9.5 */
+ if (virtualp && TREE_CODE (ctype) == UNION_TYPE)
+ {
+ cp_error ("function `%D' declared virtual inside a union",
+ declarator);
+ return void_type_node;
+ }
+
+ if (declarator == ansi_opname[(int) NEW_EXPR]
+ || declarator == ansi_opname[(int) VEC_NEW_EXPR]
+ || declarator == ansi_opname[(int) DELETE_EXPR]
+ || declarator == ansi_opname[(int) VEC_DELETE_EXPR])
+ {
+ if (virtualp)
+ {
+ cp_error ("`%D' cannot be declared virtual, since it is always static",
+ declarator);
+ virtualp = 0;
+ }
+ }
+ else if (staticp < 2)
+ type = build_cplus_method_type (build_type_variant (ctype, constp, volatilep),
+ TREE_TYPE (type), TYPE_ARG_TYPES (type));
+ }
+
+ /* Tell grokfndecl if it needs to set TREE_PUBLIC on the node. */
+ publicp = (! friendp
+ || RIDBIT_SETP (RID_EXTERN, specbits)
+ || ! (funcdef_flag < 0 || inlinep));
+ decl = grokfndecl (ctype, type, declarator,
+ virtualp, flags, quals, raises, attrlist,
+ friendp ? -1 : 0, publicp, inlinep);
+ if (decl == NULL_TREE)
+ return NULL_TREE;
+ decl = build_decl_attribute_variant (decl, decl_machine_attr);
+
+ if (explicitp == 2)
+ DECL_NONCONVERTING_P (decl) = 1;
+ }
+ else if (TREE_CODE (type) == METHOD_TYPE)
+ {
+ /* We only get here for friend declarations of
+ members of other classes. */
+ /* All method decls are public, so tell grokfndecl to set
+ TREE_PUBLIC, also. */
+ decl = grokfndecl (ctype, type, declarator,
+ virtualp, flags, quals, raises, attrlist,
+ friendp ? -1 : 0, 1, 0);
+ if (decl == NULL_TREE)
+ return NULL_TREE;
+ }
+ else if (TYPE_SIZE (type) == NULL_TREE && !staticp
+ && (TREE_CODE (type) != ARRAY_TYPE || initialized == 0))
+ {
+ if (declarator)
+ cp_error ("field `%D' has incomplete type", declarator);
+ else
+ cp_error ("name `%T' has incomplete type", type);
+
+ /* If we're instantiating a template, tell them which
+ instantiation made the field's type be incomplete. */
+ if (current_class_type
+ && TYPE_NAME (current_class_type)
+ && IDENTIFIER_TEMPLATE (DECL_NAME (TYPE_NAME (current_class_type)))
+ && declspecs && TREE_VALUE (declspecs)
+ && TREE_TYPE (TREE_VALUE (declspecs)) == type)
+ cp_error (" in instantiation of template `%T'",
+ current_class_type);
+
+ type = error_mark_node;
+ decl = NULL_TREE;
+ }
+ else
+ {
+ if (friendp)
+ {
+ error ("`%s' is neither function nor method; cannot be declared friend",
+ IDENTIFIER_POINTER (declarator));
+ friendp = 0;
+ }
+ decl = NULL_TREE;
+ }
+
+ if (friendp)
+ {
+ /* Friends are treated specially. */
+ if (ctype == current_class_type)
+ warning ("member functions are implicitly friends of their class");
+ else
+ {
+ tree t = NULL_TREE;
+ if (decl && DECL_NAME (decl))
+ t = do_friend (ctype, declarator, decl,
+ last_function_parms, flags, quals);
+ if (t && funcdef_flag)
+ return t;
+
+ return void_type_node;
+ }
+ }
+
+ /* Structure field. It may not be a function, except for C++ */
+
+ if (decl == NULL_TREE)
+ {
+ if (initialized)
+ {
+ /* Motion 10 at San Diego: If a static const integral data
+ member is initialized with an integral constant
+ expression, the initializer may appear either in the
+ declaration (within the class), or in the definition,
+ but not both. If it appears in the class, the member is
+ a member constant. The file-scope definition is always
+ required. */
+ if (staticp)
+ {
+ if (pedantic)
+ {
+ if (! constp)
+ cp_pedwarn ("ANSI C++ forbids in-class initialization of non-const static member `%D'",
+ declarator);
+
+ else if (! INTEGRAL_TYPE_P (type))
+ cp_pedwarn ("ANSI C++ forbids member constant `%D' of non-integral type `%T'", declarator, type);
+ }
+ }
+
+ /* Note that initialization of const members is prohibited
+ by the draft ANSI standard, though it appears to be in
+ common practice. 12.6.2: The argument list is used to
+ initialize the named nonstatic member.... This (or an
+ initializer list) is the only way to initialize
+ nonstatic const and reference members. */
+ else if (pedantic || ! constp)
+ cp_pedwarn ("ANSI C++ forbids initialization of %s `%D'",
+ constp ? "const member" : "member", declarator);
+ }
+
+ if (staticp || (constp && initialized))
+ {
+ /* ANSI C++ Apr '95 wp 9.2 */
+ if (staticp && declarator == current_class_name)
+ cp_pedwarn ("ANSI C++ forbids static member `%D' with same name as enclosing class",
+ declarator);
+
+ /* C++ allows static class members.
+ All other work for this is done by grokfield.
+ This VAR_DECL is built by build_lang_field_decl.
+ All other VAR_DECLs are built by build_decl. */
+ decl = build_lang_field_decl (VAR_DECL, declarator, type);
+ TREE_STATIC (decl) = 1;
+ /* In class context, 'static' means public access. */
+ TREE_PUBLIC (decl) = DECL_EXTERNAL (decl) = !!staticp;
+ }
+ else
+ {
+ decl = build_lang_field_decl (FIELD_DECL, declarator, type);
+ if (RIDBIT_SETP (RID_MUTABLE, specbits))
+ {
+ DECL_MUTABLE_P (decl) = 1;
+ RIDBIT_RESET (RID_MUTABLE, specbits);
+ }
+ }
+
+ bad_specifiers (decl, "field", virtualp, quals != NULL_TREE,
+ inlinep, friendp, raises != NULL_TREE);
+ }
+ }
+ else if (TREE_CODE (type) == FUNCTION_TYPE || TREE_CODE (type) == METHOD_TYPE)
+ {
+ tree original_name = declarator;
+ int publicp = 0;
+
+ if (! declarator)
+ return NULL_TREE;
+
+ if (RIDBIT_SETP (RID_AUTO, specbits))
+ error ("storage class `auto' invalid for function `%s'", name);
+ else if (RIDBIT_SETP (RID_REGISTER, specbits))
+ error ("storage class `register' invalid for function `%s'", name);
+
+ /* Function declaration not at top level.
+ Storage classes other than `extern' are not allowed
+ and `extern' makes no difference. */
+ if (! toplevel_bindings_p ()
+ && ! processing_template_decl
+ && (RIDBIT_SETP (RID_STATIC, specbits)
+ || RIDBIT_SETP (RID_INLINE, specbits))
+ && pedantic)
+ {
+ if (RIDBIT_SETP (RID_STATIC, specbits))
+ pedwarn ("storage class `static' invalid for function `%s' declared out of global scope", name);
+ else
+ pedwarn ("storage class `inline' invalid for function `%s' declared out of global scope", name);
+ }
+
+ if (ctype == NULL_TREE)
+ {
+ if (virtualp)
+ {
+ error ("virtual non-class function `%s'", name);
+ virtualp = 0;
+ }
+
+ if (current_lang_name == lang_name_cplusplus
+ && ! (IDENTIFIER_LENGTH (original_name) == 4
+ && IDENTIFIER_POINTER (original_name)[0] == 'm'
+ && strcmp (IDENTIFIER_POINTER (original_name), "main") == 0)
+ && ! (IDENTIFIER_LENGTH (original_name) > 10
+ && IDENTIFIER_POINTER (original_name)[0] == '_'
+ && IDENTIFIER_POINTER (original_name)[1] == '_'
+ && strncmp (IDENTIFIER_POINTER (original_name)+2, "builtin_", 8) == 0))
+ /* Plain overloading: will not be grok'd by grokclassfn. */
+ declarator = build_decl_overload (dname, TYPE_ARG_TYPES (type), 0);
+ }
+ else if (TREE_CODE (type) == FUNCTION_TYPE && staticp < 2)
+ type = build_cplus_method_type (build_type_variant (ctype, constp, volatilep),
+ TREE_TYPE (type), TYPE_ARG_TYPES (type));
+
+ /* Record presence of `static'. In C++, `inline' implies `static'. */
+ publicp = (ctype != NULL_TREE
+ || RIDBIT_SETP (RID_EXTERN, specbits)
+ || (!RIDBIT_SETP (RID_STATIC, specbits)
+ && !RIDBIT_SETP (RID_INLINE, specbits)));
+
+ decl = grokfndecl (ctype, type, original_name,
+ virtualp, flags, quals, raises, attrlist,
+ processing_template_decl ? 0 : friendp ? 2 : 1,
+ publicp, inlinep);
+ if (decl == NULL_TREE)
+ return NULL_TREE;
+
+ if (ctype == NULL_TREE && DECL_LANGUAGE (decl) != lang_c)
+ DECL_ASSEMBLER_NAME (decl) = current_namespace_id (declarator);
+
+ if (staticp == 1)
+ {
+ int illegal_static = 0;
+
+ /* Don't allow a static member function in a class, and forbid
+ declaring main to be static. */
+ if (TREE_CODE (type) == METHOD_TYPE)
+ {
+ cp_pedwarn ("cannot declare member function `%D' to have static linkage", decl);
+ illegal_static = 1;
+ }
+ else if (current_function_decl)
+ {
+ /* FIXME need arm citation */
+ error ("cannot declare static function inside another function");
+ illegal_static = 1;
+ }
+
+ if (illegal_static)
+ {
+ staticp = 0;
+ RIDBIT_RESET (RID_STATIC, specbits);
+ }
+ }
+ }
+ else
+ {
+ /* It's a variable. */
+
+ if (decl_context == CATCHPARM)
+ {
+ if (ctype)
+ {
+ ctype = NULL_TREE;
+ error ("cannot use `::' in parameter declaration");
+ }
+
+ /* A parameter declared as an array of T is really a pointer to T.
+ One declared as a function is really a pointer to a function.
+ One declared as a member is really a pointer to member. */
+
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ {
+ /* Transfer const-ness of array into that of type pointed to. */
+ type = build_pointer_type
+ (cp_build_type_variant (TREE_TYPE (type), constp, volatilep));
+ volatilep = constp = 0;
+ }
+ else if (TREE_CODE (type) == FUNCTION_TYPE)
+ type = build_pointer_type (type);
+ else if (TREE_CODE (type) == OFFSET_TYPE)
+ type = build_pointer_type (type);
+ }
+
+ /* An uninitialized decl with `extern' is a reference. */
+ decl = grokvardecl (type, declarator, specbits, initialized, constp);
+ bad_specifiers (decl, "variable", virtualp, quals != NULL_TREE,
+ inlinep, friendp, raises != NULL_TREE);
+
+ if (ctype)
+ {
+ DECL_CONTEXT (decl) = ctype;
+ if (staticp == 1)
+ {
+ cp_pedwarn ("static member `%D' re-declared as static", decl);
+ staticp = 0;
+ RIDBIT_RESET (RID_STATIC, specbits);
+ }
+ if (RIDBIT_SETP (RID_REGISTER, specbits) && TREE_STATIC (decl))
+ {
+ cp_error ("static member `%D' declared `register'", decl);
+ RIDBIT_RESET (RID_REGISTER, specbits);
+ }
+ if (RIDBIT_SETP (RID_EXTERN, specbits) && pedantic)
+ {
+ cp_pedwarn ("cannot explicitly declare member `%#D' to have extern linkage",
+ decl);
+ RIDBIT_RESET (RID_EXTERN, specbits);
+ }
+ }
+ }
+
+ if (RIDBIT_SETP (RID_MUTABLE, specbits))
+ {
+ error ("`%s' cannot be declared mutable", name);
+ }
+
+ /* Record `register' declaration for warnings on &
+ and in case doing stupid register allocation. */
+
+ if (RIDBIT_SETP (RID_REGISTER, specbits))
+ DECL_REGISTER (decl) = 1;
+
+ if (RIDBIT_SETP (RID_EXTERN, specbits))
+ DECL_THIS_EXTERN (decl) = 1;
+
+ if (RIDBIT_SETP (RID_STATIC, specbits))
+ DECL_THIS_STATIC (decl) = 1;
+
+ /* Record constancy and volatility. */
+
+ if (constp)
+ TREE_READONLY (decl) = TREE_CODE (type) != REFERENCE_TYPE;
+ if (volatilep)
+ {
+ TREE_SIDE_EFFECTS (decl) = 1;
+ TREE_THIS_VOLATILE (decl) = 1;
+ }
+
+ return decl;
+ }
+}
+
+/* Tell if a parmlist/exprlist looks like an exprlist or a parmlist.
+ An empty exprlist is a parmlist. An exprlist which
+ contains only identifiers at the global level
+ is a parmlist. Otherwise, it is an exprlist. */
+int
+parmlist_is_exprlist (exprs)
+ tree exprs;
+{
+ if (exprs == NULL_TREE || TREE_PARMLIST (exprs))
+ return 0;
+
+ if (toplevel_bindings_p ())
+ {
+ /* At the global level, if these are all identifiers,
+ then it is a parmlist. */
+ while (exprs)
+ {
+ if (TREE_CODE (TREE_VALUE (exprs)) != IDENTIFIER_NODE)
+ return 1;
+ exprs = TREE_CHAIN (exprs);
+ }
+ return 0;
+ }
+ return 1;
+}
+
+/* Subroutine of `grokparms'. In a fcn definition, arg types must
+ be complete.
+
+ C++: also subroutine of `start_function'. */
+static void
+require_complete_types_for_parms (parms)
+ tree parms;
+{
+ while (parms)
+ {
+ tree type = TREE_TYPE (parms);
+ if (TYPE_SIZE (type) == NULL_TREE)
+ {
+ if (DECL_NAME (parms))
+ error ("parameter `%s' has incomplete type",
+ IDENTIFIER_POINTER (DECL_NAME (parms)));
+ else
+ error ("parameter has incomplete type");
+ TREE_TYPE (parms) = error_mark_node;
+ }
+#if 0
+ /* If the arg types are incomplete in a declaration,
+ they must include undefined tags.
+ These tags can never be defined in the scope of the declaration,
+ so the types can never be completed,
+ and no call can be compiled successfully. */
+ /* This is not the right behavior for C++, but not having
+ it is also probably wrong. */
+ else
+ {
+ /* Now warn if is a pointer to an incomplete type. */
+ while (TREE_CODE (type) == POINTER_TYPE
+ || TREE_CODE (type) == REFERENCE_TYPE)
+ type = TREE_TYPE (type);
+ type = TYPE_MAIN_VARIANT (type);
+ if (TYPE_SIZE (type) == NULL_TREE)
+ {
+ if (DECL_NAME (parm) != NULL_TREE)
+ warning ("parameter `%s' points to incomplete type",
+ IDENTIFIER_POINTER (DECL_NAME (parm)));
+ else
+ warning ("parameter points to incomplete type");
+ }
+ }
+#endif
+ parms = TREE_CHAIN (parms);
+ }
+}
+
+/* Decode the list of parameter types for a function type.
+ Given the list of things declared inside the parens,
+ return a list of types.
+
+ The list we receive can have three kinds of elements:
+ an IDENTIFIER_NODE for names given without types,
+ a TREE_LIST node for arguments given as typespecs or names with typespecs,
+ or void_type_node, to mark the end of an argument list
+ when additional arguments are not permitted (... was not used).
+
+ FUNCDEF_FLAG is nonzero for a function definition, 0 for
+ a mere declaration. A nonempty identifier-list gets an error message
+ when FUNCDEF_FLAG is zero.
+ If FUNCDEF_FLAG is 1, then parameter types must be complete.
+ If FUNCDEF_FLAG is -1, then parameter types may be incomplete.
+
+ If all elements of the input list contain types,
+ we return a list of the types.
+ If all elements contain no type (except perhaps a void_type_node
+ at the end), we return a null list.
+ If some have types and some do not, it is an error, and we
+ return a null list.
+
+ Also set last_function_parms to either
+ a list of names (IDENTIFIER_NODEs) or a chain of PARM_DECLs.
+ A list of names is converted to a chain of PARM_DECLs
+ by store_parm_decls so that ultimately it is always a chain of decls.
+
+ Note that in C++, parameters can take default values. These default
+ values are in the TREE_PURPOSE field of the TREE_LIST. It is
+ an error to specify default values which are followed by parameters
+ that have no default values, or an ELLIPSES. For simplicities sake,
+ only parameters which are specified with their types can take on
+ default values. */
+
+static tree
+grokparms (first_parm, funcdef_flag)
+ tree first_parm;
+ int funcdef_flag;
+{
+ tree result = NULL_TREE;
+ tree decls = NULL_TREE;
+
+ if (first_parm != NULL_TREE
+ && TREE_CODE (TREE_VALUE (first_parm)) == IDENTIFIER_NODE)
+ {
+ if (! funcdef_flag)
+ pedwarn ("parameter names (without types) in function declaration");
+ last_function_parms = first_parm;
+ return NULL_TREE;
+ }
+ else if (first_parm != NULL_TREE
+ && TREE_CODE (TREE_VALUE (first_parm)) != TREE_LIST
+ && TREE_VALUE (first_parm) != void_type_node)
+ my_friendly_abort (145);
+ else
+ {
+ /* Types were specified. This is a list of declarators
+ each represented as a TREE_LIST node. */
+ register tree parm, chain;
+ int any_init = 0, any_error = 0, saw_void = 0;
+
+ if (first_parm != NULL_TREE)
+ {
+ tree last_result = NULL_TREE;
+ tree last_decl = NULL_TREE;
+
+ for (parm = first_parm; parm != NULL_TREE; parm = chain)
+ {
+ tree type, list_node = parm;
+ register tree decl = TREE_VALUE (parm);
+ tree init = TREE_PURPOSE (parm);
+
+ chain = TREE_CHAIN (parm);
+ /* @@ weak defense against parse errors. */
+ if (decl != void_type_node && TREE_CODE (decl) != TREE_LIST)
+ {
+ /* Give various messages as the need arises. */
+ if (TREE_CODE (decl) == STRING_CST)
+ error ("invalid string constant `%s'",
+ TREE_STRING_POINTER (decl));
+ else if (TREE_CODE (decl) == INTEGER_CST)
+ error ("invalid integer constant in parameter list, did you forget to give parameter name?");
+ continue;
+ }
+
+ if (decl != void_type_node)
+ {
+ /* @@ May need to fetch out a `raises' here. */
+ decl = grokdeclarator (TREE_VALUE (decl),
+ TREE_PURPOSE (decl),
+ PARM, init != NULL_TREE,
+ NULL_TREE, NULL_TREE);
+ if (! decl)
+ continue;
+ type = TREE_TYPE (decl);
+ if (TYPE_MAIN_VARIANT (type) == void_type_node)
+ decl = void_type_node;
+ else if (TREE_CODE (type) == METHOD_TYPE)
+ {
+ if (DECL_NAME (decl))
+ /* Cannot use `error_with_decl' here because
+ we don't have DECL_CONTEXT set up yet. */
+ error ("parameter `%s' invalidly declared method type",
+ IDENTIFIER_POINTER (DECL_NAME (decl)));
+ else
+ error ("parameter invalidly declared method type");
+ type = build_pointer_type (type);
+ TREE_TYPE (decl) = type;
+ }
+ else if (TREE_CODE (type) == OFFSET_TYPE)
+ {
+ if (DECL_NAME (decl))
+ error ("parameter `%s' invalidly declared offset type",
+ IDENTIFIER_POINTER (DECL_NAME (decl)));
+ else
+ error ("parameter invalidly declared offset type");
+ type = build_pointer_type (type);
+ TREE_TYPE (decl) = type;
+ }
+ else if (TREE_CODE (type) == RECORD_TYPE
+ && TYPE_LANG_SPECIFIC (type)
+ && CLASSTYPE_ABSTRACT_VIRTUALS (type))
+ {
+ abstract_virtuals_error (decl, type);
+ any_error = 1; /* seems like a good idea */
+ }
+ else if (TREE_CODE (type) == RECORD_TYPE
+ && TYPE_LANG_SPECIFIC (type)
+ && IS_SIGNATURE (type))
+ {
+ signature_error (decl, type);
+ any_error = 1; /* seems like a good idea */
+ }
+ }
+
+ if (decl == void_type_node)
+ {
+ if (result == NULL_TREE)
+ {
+ result = void_list_node;
+ last_result = result;
+ }
+ else
+ {
+ TREE_CHAIN (last_result) = void_list_node;
+ last_result = void_list_node;
+ }
+ saw_void = 1;
+ if (chain
+ && (chain != void_list_node || TREE_CHAIN (chain)))
+ error ("`void' in parameter list must be entire list");
+ break;
+ }
+
+ /* Since there is a prototype, args are passed in their own types. */
+ DECL_ARG_TYPE (decl) = TREE_TYPE (decl);
+#ifdef PROMOTE_PROTOTYPES
+ if ((TREE_CODE (type) == INTEGER_TYPE
+ || TREE_CODE (type) == ENUMERAL_TYPE)
+ && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
+ DECL_ARG_TYPE (decl) = integer_type_node;
+#endif
+ if (!any_error)
+ {
+ if (init)
+ {
+ any_init++;
+ if (TREE_CODE (init) == SAVE_EXPR)
+ PARM_DECL_EXPR (init) = 1;
+ else if (TREE_CODE (init) == VAR_DECL
+ || TREE_CODE (init) == PARM_DECL)
+ {
+ if (IDENTIFIER_LOCAL_VALUE (DECL_NAME (init)))
+ {
+ /* ``Local variables may not be used in default
+ argument expressions.'' dpANSI C++ 8.2.6 */
+ /* If extern int i; within a function is not
+ considered a local variable, then this code is
+ wrong. */
+ cp_error ("local variable `%D' may not be used as a default argument", init);
+ any_error = 1;
+ }
+ else if (TREE_READONLY_DECL_P (init))
+ init = decl_constant_value (init);
+ }
+ else
+ init = require_instantiated_type (type, init, integer_zero_node);
+ }
+#if 0 /* This is too early to check; trailing parms might be merged in by
+ duplicate_decls. */
+ else if (any_init)
+ {
+ error ("all trailing parameters must have default arguments");
+ any_error = 1;
+ }
+#endif
+ }
+ else
+ init = NULL_TREE;
+
+ if (decls == NULL_TREE)
+ {
+ decls = decl;
+ last_decl = decls;
+ }
+ else
+ {
+ TREE_CHAIN (last_decl) = decl;
+ last_decl = decl;
+ }
+ if (TREE_PERMANENT (list_node))
+ {
+ TREE_PURPOSE (list_node) = init;
+ TREE_VALUE (list_node) = type;
+ TREE_CHAIN (list_node) = NULL_TREE;
+ }
+ else
+ list_node = saveable_tree_cons (init, type, NULL_TREE);
+ if (result == NULL_TREE)
+ {
+ result = list_node;
+ last_result = result;
+ }
+ else
+ {
+ TREE_CHAIN (last_result) = list_node;
+ last_result = list_node;
+ }
+ }
+ if (last_result)
+ TREE_CHAIN (last_result) = NULL_TREE;
+ /* If there are no parameters, and the function does not end
+ with `...', then last_decl will be NULL_TREE. */
+ if (last_decl != NULL_TREE)
+ TREE_CHAIN (last_decl) = NULL_TREE;
+ }
+ }
+
+ last_function_parms = decls;
+
+ /* In a fcn definition, arg types must be complete. */
+ if (funcdef_flag > 0)
+ require_complete_types_for_parms (last_function_parms);
+
+ return result;
+}
+
+/* These memoizing functions keep track of special properties which
+ a class may have. `grok_ctor_properties' notices whether a class
+ has a constructor of the form X(X&), and also complains
+ if the class has a constructor of the form X(X).
+ `grok_op_properties' takes notice of the various forms of
+ operator= which are defined, as well as what sorts of type conversion
+ may apply. Both functions take a FUNCTION_DECL as an argument. */
+int
+grok_ctor_properties (ctype, decl)
+ tree ctype, decl;
+{
+ tree parmtypes = FUNCTION_ARG_CHAIN (decl);
+ tree parmtype = parmtypes ? TREE_VALUE (parmtypes) : void_type_node;
+
+ /* When a type has virtual baseclasses, a magical first int argument is
+ added to any ctor so we can tell if the class has been initialized
+ yet. This could screw things up in this function, so we deliberately
+ ignore the leading int if we're in that situation. */
+ if (parmtypes
+ && TREE_VALUE (parmtypes) == integer_type_node
+ && TYPE_USES_VIRTUAL_BASECLASSES (ctype))
+ {
+ parmtypes = TREE_CHAIN (parmtypes);
+ parmtype = TREE_VALUE (parmtypes);
+ }
+
+ if (TREE_CODE (parmtype) == REFERENCE_TYPE
+ && TYPE_MAIN_VARIANT (TREE_TYPE (parmtype)) == ctype)
+ {
+ if (TREE_CHAIN (parmtypes) == NULL_TREE
+ || TREE_CHAIN (parmtypes) == void_list_node
+ || TREE_PURPOSE (TREE_CHAIN (parmtypes)))
+ {
+ TYPE_HAS_INIT_REF (ctype) = 1;
+ if (TYPE_READONLY (TREE_TYPE (parmtype)))
+ TYPE_HAS_CONST_INIT_REF (ctype) = 1;
+ }
+ else
+ TYPE_GETS_INIT_AGGR (ctype) = 1;
+ }
+ else if (TYPE_MAIN_VARIANT (parmtype) == ctype)
+ {
+ if (TREE_CHAIN (parmtypes) != NULL_TREE
+ && TREE_CHAIN (parmtypes) == void_list_node)
+ {
+ cp_error ("invalid constructor; you probably meant `%T (%T&)'",
+ ctype, ctype);
+ SET_IDENTIFIER_ERROR_LOCUS (DECL_NAME (decl), ctype);
+
+ return 0;
+ }
+ else
+ TYPE_GETS_INIT_AGGR (ctype) = 1;
+ }
+ else if (TREE_CODE (parmtype) == VOID_TYPE
+ || TREE_PURPOSE (parmtypes) != NULL_TREE)
+ TYPE_HAS_DEFAULT_CONSTRUCTOR (ctype) = 1;
+
+ return 1;
+}
+
+/* An operator with this name can be either unary or binary. */
+static int
+ambi_op_p (name)
+ tree name;
+{
+ return (name == ansi_opname [(int) INDIRECT_REF]
+ || name == ansi_opname [(int) ADDR_EXPR]
+ || name == ansi_opname [(int) NEGATE_EXPR]
+ || name == ansi_opname[(int) POSTINCREMENT_EXPR]
+ || name == ansi_opname[(int) POSTDECREMENT_EXPR]
+ || name == ansi_opname [(int) CONVERT_EXPR]);
+}
+
+/* An operator with this name can only be unary. */
+static int
+unary_op_p (name)
+ tree name;
+{
+ return (name == ansi_opname [(int) TRUTH_NOT_EXPR]
+ || name == ansi_opname [(int) BIT_NOT_EXPR]
+ || name == ansi_opname [(int) COMPONENT_REF]
+ || OPERATOR_TYPENAME_P (name));
+}
+
+/* Do a little sanity-checking on how they declared their operator. */
+static void
+grok_op_properties (decl, virtualp, friendp)
+ tree decl;
+ int virtualp, friendp;
+{
+ tree argtypes = TYPE_ARG_TYPES (TREE_TYPE (decl));
+ int methodp = (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE);
+ tree name = DECL_NAME (decl);
+
+ if (current_class_type == NULL_TREE)
+ friendp = 1;
+
+ if (! friendp)
+ {
+ if (name == ansi_opname[(int) MODIFY_EXPR])
+ TYPE_HAS_ASSIGNMENT (current_class_type) = 1;
+ else if (name == ansi_opname[(int) CALL_EXPR])
+ TYPE_OVERLOADS_CALL_EXPR (current_class_type) = 1;
+ else if (name == ansi_opname[(int) ARRAY_REF])
+ TYPE_OVERLOADS_ARRAY_REF (current_class_type) = 1;
+ else if (name == ansi_opname[(int) COMPONENT_REF]
+ || name == ansi_opname[(int) MEMBER_REF])
+ TYPE_OVERLOADS_ARROW (current_class_type) = 1;
+ else if (name == ansi_opname[(int) NEW_EXPR])
+ TYPE_GETS_NEW (current_class_type) |= 1;
+ else if (name == ansi_opname[(int) DELETE_EXPR])
+ TYPE_GETS_DELETE (current_class_type) |= 1;
+ else if (name == ansi_opname[(int) VEC_NEW_EXPR])
+ TYPE_GETS_NEW (current_class_type) |= 2;
+ else if (name == ansi_opname[(int) VEC_DELETE_EXPR])
+ TYPE_GETS_DELETE (current_class_type) |= 2;
+ }
+
+ if (name == ansi_opname[(int) NEW_EXPR]
+ || name == ansi_opname[(int) VEC_NEW_EXPR])
+ {
+ /* When the compiler encounters the definition of A::operator new, it
+ doesn't look at the class declaration to find out if it's static. */
+ if (methodp)
+ revert_static_member_fn (&decl, NULL, NULL);
+
+ /* Take care of function decl if we had syntax errors. */
+ if (argtypes == NULL_TREE)
+ TREE_TYPE (decl) =
+ build_function_type (ptr_type_node,
+ hash_tree_chain (integer_type_node,
+ void_list_node));
+ else
+ TREE_TYPE (decl) = coerce_new_type (TREE_TYPE (decl));
+ }
+ else if (name == ansi_opname[(int) DELETE_EXPR]
+ || name == ansi_opname[(int) VEC_DELETE_EXPR])
+ {
+ if (methodp)
+ revert_static_member_fn (&decl, NULL, NULL);
+
+ if (argtypes == NULL_TREE)
+ TREE_TYPE (decl) =
+ build_function_type (void_type_node,
+ hash_tree_chain (ptr_type_node,
+ void_list_node));
+ else
+ {
+ TREE_TYPE (decl) = coerce_delete_type (TREE_TYPE (decl));
+
+ if (! friendp && name == ansi_opname[(int) VEC_DELETE_EXPR]
+ && (TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (decl)))
+ != void_list_node))
+ TYPE_VEC_DELETE_TAKES_SIZE (current_class_type) = 1;
+ }
+ }
+ else
+ {
+ /* An operator function must either be a non-static member function
+ or have at least one parameter of a class, a reference to a class,
+ an enumeration, or a reference to an enumeration. 13.4.0.6 */
+ if (! methodp || DECL_STATIC_FUNCTION_P (decl))
+ {
+ if (OPERATOR_TYPENAME_P (name)
+ || name == ansi_opname[(int) CALL_EXPR]
+ || name == ansi_opname[(int) MODIFY_EXPR]
+ || name == ansi_opname[(int) COMPONENT_REF]
+ || name == ansi_opname[(int) ARRAY_REF])
+ cp_error ("`%D' must be a nonstatic member function", decl);
+ else
+ {
+ tree p = argtypes;
+
+ if (DECL_STATIC_FUNCTION_P (decl))
+ cp_error ("`%D' must be either a non-static member function or a non-member function", decl);
+
+ if (p)
+ for (; TREE_VALUE (p) != void_type_node ; p = TREE_CHAIN (p))
+ {
+ tree arg = TREE_VALUE (p);
+ if (TREE_CODE (arg) == REFERENCE_TYPE)
+ arg = TREE_TYPE (arg);
+
+ /* This lets bad template code slip through. */
+ if (IS_AGGR_TYPE (arg)
+ || TREE_CODE (arg) == ENUMERAL_TYPE
+ || TREE_CODE (arg) == TEMPLATE_TYPE_PARM)
+ goto foundaggr;
+ }
+ cp_error
+ ("`%D' must have an argument of class or enumerated type",
+ decl);
+ foundaggr:
+ ;
+ }
+ }
+
+ if (name == ansi_opname[(int) CALL_EXPR]
+ || name == ansi_opname[(int) METHOD_CALL_EXPR])
+ return; /* no restrictions on args */
+
+ if (IDENTIFIER_TYPENAME_P (name))
+ {
+ tree t = TREE_TYPE (name);
+ if (TREE_CODE (t) == VOID_TYPE)
+ pedwarn ("void is not a valid type conversion operator");
+ else if (! friendp)
+ {
+ int ref = (TREE_CODE (t) == REFERENCE_TYPE);
+ char *what = 0;
+ if (ref)
+ t = TYPE_MAIN_VARIANT (TREE_TYPE (t));
+
+ if (t == current_class_type)
+ what = "the same type";
+ else if (IS_AGGR_TYPE (t)
+ && DERIVED_FROM_P (t, current_class_type))
+ what = "a base class";
+
+ if (what)
+ warning ("conversion to %s%s will never use a type conversion operator",
+ ref ? "a reference to " : "", what);
+ }
+ }
+
+ if (name == ansi_opname[(int) MODIFY_EXPR])
+ {
+ tree parmtype;
+
+ if (list_length (argtypes) != 3 && methodp)
+ {
+ cp_error ("`%D' must take exactly one argument", decl);
+ return;
+ }
+ parmtype = TREE_VALUE (TREE_CHAIN (argtypes));
+
+ if (copy_assignment_arg_p (parmtype, virtualp)
+ && ! friendp)
+ {
+ TYPE_HAS_ASSIGN_REF (current_class_type) = 1;
+ if (TREE_CODE (parmtype) != REFERENCE_TYPE
+ || TYPE_READONLY (TREE_TYPE (parmtype)))
+ TYPE_HAS_CONST_ASSIGN_REF (current_class_type) = 1;
+#if 0 /* Too soon; done in grok_function_init */
+ if (DECL_ABSTRACT_VIRTUAL_P (decl))
+ TYPE_HAS_ABSTRACT_ASSIGN_REF (current_class_type) = 1;
+#endif
+ }
+ }
+ else if (name == ansi_opname[(int) COND_EXPR])
+ {
+ /* 13.4.0.3 */
+ pedwarn ("ANSI C++ prohibits overloading operator ?:");
+ if (list_length (argtypes) != 4)
+ cp_error ("`%D' must take exactly three arguments", decl);
+ }
+ else if (ambi_op_p (name))
+ {
+ if (list_length (argtypes) == 2)
+ /* prefix */;
+ else if (list_length (argtypes) == 3)
+ {
+ if ((name == ansi_opname[(int) POSTINCREMENT_EXPR]
+ || name == ansi_opname[(int) POSTDECREMENT_EXPR])
+ && TREE_VALUE (TREE_CHAIN (argtypes)) != integer_type_node)
+ {
+ if (methodp)
+ cp_error ("postfix `%D' must take `int' as its argument",
+ decl);
+ else
+ cp_error
+ ("postfix `%D' must take `int' as its second argument",
+ decl);
+ }
+ }
+ else
+ {
+ if (methodp)
+ cp_error ("`%D' must take either zero or one argument", decl);
+ else
+ cp_error ("`%D' must take either one or two arguments", decl);
+ }
+ }
+ else if (unary_op_p (name))
+ {
+ if (list_length (argtypes) != 2)
+ {
+ if (methodp)
+ cp_error ("`%D' must take `void'", decl);
+ else
+ cp_error ("`%D' must take exactly one argument", decl);
+ }
+ }
+ else /* if (binary_op_p (name)) */
+ {
+ if (list_length (argtypes) != 3)
+ {
+ if (methodp)
+ cp_error ("`%D' must take exactly one argument", decl);
+ else
+ cp_error ("`%D' must take exactly two arguments", decl);
+ }
+ }
+
+ /* 13.4.0.8 */
+ if (argtypes)
+ for (; argtypes != void_list_node ; argtypes = TREE_CHAIN (argtypes))
+ if (TREE_PURPOSE (argtypes))
+ {
+ TREE_PURPOSE (argtypes) = NULL_TREE;
+ if (name == ansi_opname[(int) POSTINCREMENT_EXPR]
+ || name == ansi_opname[(int) POSTDECREMENT_EXPR])
+ {
+ if (pedantic)
+ cp_pedwarn ("`%D' cannot have default arguments", decl);
+ }
+ else
+ cp_error ("`%D' cannot have default arguments", decl);
+ }
+ }
+}
+
+/* Get the struct, enum or union (CODE says which) with tag NAME.
+ Define the tag as a forward-reference if it is not defined.
+
+ C++: If a class derivation is given, process it here, and report
+ an error if multiple derivation declarations are not identical.
+
+ If this is a definition, come in through xref_tag and only look in
+ the current frame for the name (since C++ allows new names in any
+ scope.) */
+
+tree
+xref_tag (code_type_node, name, binfo, globalize)
+ tree code_type_node;
+ tree name, binfo;
+ int globalize;
+{
+ enum tag_types tag_code;
+ enum tree_code code;
+ int temp = 0;
+ int i;
+ register tree ref, t;
+ struct binding_level *b = inner_binding_level;
+
+ tag_code = (enum tag_types) TREE_INT_CST_LOW (code_type_node);
+ switch (tag_code)
+ {
+ case record_type:
+ case class_type:
+ case signature_type:
+ code = RECORD_TYPE;
+ break;
+ case union_type:
+ code = UNION_TYPE;
+ break;
+ case enum_type:
+ code = ENUMERAL_TYPE;
+ break;
+ default:
+ my_friendly_abort (18);
+ }
+
+ /* If a cross reference is requested, look up the type
+ already defined for this tag and return it. */
+ t = IDENTIFIER_TYPE_VALUE (name);
+ if (t && TREE_CODE (t) != code)
+ t = NULL_TREE;
+
+ if (! globalize)
+ {
+ /* If we know we are defining this tag, only look it up in this scope
+ * and don't try to find it as a type. */
+ if (t && TYPE_CONTEXT(t) && TREE_MANGLED (name))
+ ref = t;
+ else
+ ref = lookup_tag (code, name, b, 1);
+ }
+ else
+ {
+ if (t)
+ ref = t;
+ else
+ ref = lookup_tag (code, name, b, 0);
+
+ if (! ref)
+ {
+ /* Try finding it as a type declaration. If that wins, use it. */
+ ref = lookup_name (name, 1);
+ if (ref && TREE_CODE (ref) == TYPE_DECL
+ && TREE_CODE (TREE_TYPE (ref)) == code)
+ ref = TREE_TYPE (ref);
+ else
+ ref = NULL_TREE;
+ }
+ }
+
+ push_obstacks_nochange ();
+
+ if (! ref)
+ {
+ /* If no such tag is yet defined, create a forward-reference node
+ and record it as the "definition".
+ When a real declaration of this type is found,
+ the forward-reference will be altered into a real type. */
+
+ /* In C++, since these migrate into the global scope, we must
+ build them on the permanent obstack. */
+
+ temp = allocation_temporary_p ();
+ if (temp)
+ end_temporary_allocation ();
+
+ if (code == ENUMERAL_TYPE)
+ {
+ ref = make_node (ENUMERAL_TYPE);
+
+ /* Give the type a default layout like unsigned int
+ to avoid crashing if it does not get defined. */
+ TYPE_MODE (ref) = TYPE_MODE (unsigned_type_node);
+ TYPE_ALIGN (ref) = TYPE_ALIGN (unsigned_type_node);
+ TREE_UNSIGNED (ref) = 1;
+ TYPE_PRECISION (ref) = TYPE_PRECISION (unsigned_type_node);
+ TYPE_MIN_VALUE (ref) = TYPE_MIN_VALUE (unsigned_type_node);
+ TYPE_MAX_VALUE (ref) = TYPE_MAX_VALUE (unsigned_type_node);
+
+ /* Enable us to recognize when a type is created in class context.
+ To do nested classes correctly, this should probably be cleared
+ out when we leave this classes scope. Currently this in only
+ done in `start_enum'. */
+
+ pushtag (name, ref, globalize);
+ if (flag_cadillac)
+ cadillac_start_enum (ref);
+ }
+ else
+ {
+ struct binding_level *old_b = class_binding_level;
+
+ ref = make_lang_type (code);
+
+ if (tag_code == signature_type)
+ {
+ SET_SIGNATURE (ref);
+ /* Since a signature type will be turned into the type
+ of signature tables, it's not only an interface. */
+ CLASSTYPE_INTERFACE_ONLY (ref) = 0;
+ SET_CLASSTYPE_INTERFACE_KNOWN (ref);
+ /* A signature doesn't have a vtable. */
+ CLASSTYPE_VTABLE_NEEDS_WRITING (ref) = 0;
+ }
+
+#ifdef NONNESTED_CLASSES
+ /* Class types don't nest the way enums do. */
+ class_binding_level = (struct binding_level *)0;
+#endif
+ pushtag (name, ref, globalize);
+ class_binding_level = old_b;
+
+ if (flag_cadillac)
+ cadillac_start_struct (ref);
+ }
+ }
+ else
+ {
+ /* If it no longer looks like a nested type, make sure it's
+ in global scope. */
+ if (b == global_binding_level && !class_binding_level
+ && IDENTIFIER_GLOBAL_VALUE (name) == NULL_TREE)
+ IDENTIFIER_GLOBAL_VALUE (name) = TYPE_NAME (ref);
+
+#if 0
+ if (binfo)
+ {
+ tree tt1 = binfo;
+ tree tt2 = TYPE_BINFO_BASETYPES (ref);
+
+ if (TYPE_BINFO_BASETYPES (ref))
+ for (i = 0; tt1; i++, tt1 = TREE_CHAIN (tt1))
+ if (TREE_VALUE (tt1) != TYPE_IDENTIFIER (BINFO_TYPE (TREE_VEC_ELT (tt2, i))))
+ {
+ cp_error ("redeclaration of derivation chain of type `%#T'",
+ ref);
+ break;
+ }
+
+ if (tt1 == NULL_TREE)
+ /* The user told us something we already knew. */
+ goto just_return;
+
+ /* In C++, since these migrate into the global scope, we must
+ build them on the permanent obstack. */
+ end_temporary_allocation ();
+ }
+#endif
+ }
+
+ if (binfo)
+ xref_basetypes (code_type_node, name, ref, binfo);
+
+ just_return:
+
+ /* Until the type is defined, tentatively accept whatever
+ structure tag the user hands us. */
+ if (TYPE_SIZE (ref) == NULL_TREE
+ && ref != current_class_type
+ /* Have to check this, in case we have contradictory tag info. */
+ && IS_AGGR_TYPE_CODE (TREE_CODE (ref)))
+ {
+ if (tag_code == class_type)
+ CLASSTYPE_DECLARED_CLASS (ref) = 1;
+ else if (tag_code == record_type || tag_code == signature_type)
+ CLASSTYPE_DECLARED_CLASS (ref) = 0;
+ }
+
+ pop_obstacks ();
+
+ return ref;
+}
+
+void
+xref_basetypes (code_type_node, name, ref, binfo)
+ tree code_type_node;
+ tree name, ref;
+ tree binfo;
+{
+ /* In the declaration `A : X, Y, ... Z' we mark all the types
+ (A, X, Y, ..., Z) so we can check for duplicates. */
+ tree binfos;
+ int i, len;
+ enum tag_types tag_code = (enum tag_types) TREE_INT_CST_LOW (code_type_node);
+
+ if (tag_code == union_type)
+ {
+ cp_error ("derived union `%T' invalid", ref);
+ return;
+ }
+
+ len = list_length (binfo);
+ push_obstacks (TYPE_OBSTACK (ref), TYPE_OBSTACK (ref));
+
+ SET_CLASSTYPE_MARKED (ref);
+ BINFO_BASETYPES (TYPE_BINFO (ref)) = binfos = make_tree_vec (len);
+
+ for (i = 0; binfo; binfo = TREE_CHAIN (binfo))
+ {
+ /* The base of a derived struct is public by default. */
+ int via_public
+ = (TREE_PURPOSE (binfo) == (tree)access_public
+ || TREE_PURPOSE (binfo) == (tree)access_public_virtual
+ || (tag_code != class_type
+ && (TREE_PURPOSE (binfo) == (tree)access_default
+ || TREE_PURPOSE (binfo) == (tree)access_default_virtual)));
+ int via_protected = TREE_PURPOSE (binfo) == (tree)access_protected;
+ int via_virtual
+ = (TREE_PURPOSE (binfo) == (tree)access_private_virtual
+ || TREE_PURPOSE (binfo) == (tree)access_public_virtual
+ || TREE_PURPOSE (binfo) == (tree)access_default_virtual);
+ tree basetype = TREE_TYPE (TREE_VALUE (binfo));
+ tree base_binfo;
+
+ GNU_xref_hier (IDENTIFIER_POINTER (name),
+ IDENTIFIER_POINTER (TREE_VALUE (binfo)),
+ via_public, via_virtual, 0);
+
+ if (basetype && TREE_CODE (basetype) == TYPE_DECL)
+ basetype = TREE_TYPE (basetype);
+ if (!basetype || TREE_CODE (basetype) != RECORD_TYPE)
+ {
+ cp_error ("base type `%T' fails to be a struct or class type",
+ TREE_VALUE (binfo));
+ continue;
+ }
+#if 1
+ /* This code replaces similar code in layout_basetypes. */
+ else if (TYPE_INCOMPLETE (basetype))
+ {
+ cp_error ("base class `%T' has incomplete type", basetype);
+ continue;
+ }
+#endif
+ else
+ {
+ if (CLASSTYPE_MARKED (basetype))
+ {
+ if (basetype == ref)
+ cp_error ("recursive type `%T' undefined", basetype);
+ else
+ cp_error ("duplicate base type `%T' invalid", basetype);
+ continue;
+ }
+
+ /* Note that the BINFO records which describe individual
+ inheritances are *not* shared in the lattice! They
+ cannot be shared because a given baseclass may be
+ inherited with different `accessibility' by different
+ derived classes. (Each BINFO record describing an
+ individual inheritance contains flags which say what
+ the `accessibility' of that particular inheritance is.) */
+
+ base_binfo = make_binfo (integer_zero_node, basetype,
+ TYPE_BINFO_VTABLE (basetype),
+ TYPE_BINFO_VIRTUALS (basetype), NULL_TREE);
+
+ TREE_VEC_ELT (binfos, i) = base_binfo;
+ TREE_VIA_PUBLIC (base_binfo) = via_public;
+ TREE_VIA_PROTECTED (base_binfo) = via_protected;
+ TREE_VIA_VIRTUAL (base_binfo) = via_virtual;
+ BINFO_INHERITANCE_CHAIN (base_binfo) = TYPE_BINFO (ref);
+
+ SET_CLASSTYPE_MARKED (basetype);
+#if 0
+ /* XYZZY TEST VIRTUAL BASECLASSES */
+ if (CLASSTYPE_N_BASECLASSES (basetype) == NULL_TREE
+ && TYPE_HAS_DEFAULT_CONSTRUCTOR (basetype)
+ && via_virtual == 0)
+ {
+ warning ("making type `%s' a virtual baseclass",
+ TYPE_NAME_STRING (basetype));
+ via_virtual = 1;
+ }
+#endif
+ /* We are free to modify these bits because they are meaningless
+ at top level, and BASETYPE is a top-level type. */
+ if (via_virtual || TYPE_USES_VIRTUAL_BASECLASSES (basetype))
+ {
+ TYPE_USES_VIRTUAL_BASECLASSES (ref) = 1;
+ TYPE_USES_COMPLEX_INHERITANCE (ref) = 1;
+ }
+
+ TYPE_OVERLOADS_METHOD_CALL_EXPR (ref) |= TYPE_OVERLOADS_METHOD_CALL_EXPR (basetype);
+ TYPE_GETS_NEW (ref) |= TYPE_GETS_NEW (basetype);
+ TYPE_GETS_DELETE (ref) |= TYPE_GETS_DELETE (basetype);
+ CLASSTYPE_LOCAL_TYPEDECLS (ref) |= CLASSTYPE_LOCAL_TYPEDECLS (basetype);
+ i += 1;
+ }
+ }
+ if (i)
+ TREE_VEC_LENGTH (binfos) = i;
+ else
+ BINFO_BASETYPES (TYPE_BINFO (ref)) = NULL_TREE;
+
+ if (i > 1)
+ TYPE_USES_MULTIPLE_INHERITANCE (ref) = 1;
+ else if (i == 1)
+ TYPE_USES_MULTIPLE_INHERITANCE (ref)
+ = TYPE_USES_MULTIPLE_INHERITANCE (BINFO_TYPE (TREE_VEC_ELT (binfos, 0)));
+ if (TYPE_USES_MULTIPLE_INHERITANCE (ref))
+ TYPE_USES_COMPLEX_INHERITANCE (ref) = 1;
+
+ /* Unmark all the types. */
+ while (--i >= 0)
+ CLEAR_CLASSTYPE_MARKED (BINFO_TYPE (TREE_VEC_ELT (binfos, i)));
+ CLEAR_CLASSTYPE_MARKED (ref);
+
+ pop_obstacks ();
+}
+
+
+static tree current_local_enum = NULL_TREE;
+
+/* Begin compiling the definition of an enumeration type.
+ NAME is its name (or null if anonymous).
+ Returns the type object, as yet incomplete.
+ Also records info about it so that build_enumerator
+ may be used to declare the individual values as they are read. */
+
+tree
+start_enum (name)
+ tree name;
+{
+ register tree enumtype = NULL_TREE;
+ struct binding_level *b = inner_binding_level;
+
+ /* If this is the real definition for a previous forward reference,
+ fill in the contents in the same object that used to be the
+ forward reference. */
+
+ if (name != NULL_TREE)
+ enumtype = lookup_tag (ENUMERAL_TYPE, name, b, 1);
+
+ if (enumtype != NULL_TREE && TREE_CODE (enumtype) == ENUMERAL_TYPE)
+ cp_error ("multiple definition of enum `%T'", enumtype);
+ else
+ {
+ enumtype = make_node (ENUMERAL_TYPE);
+ pushtag (name, enumtype, 0);
+ }
+
+ if (current_class_type)
+ TREE_ADDRESSABLE (b->tags) = 1;
+ current_local_enum = NULL_TREE;
+
+#if 0 /* This stuff gets cleared in finish_enum anyway. */
+ if (TYPE_VALUES (enumtype) != NULL_TREE)
+ /* Completely replace its old definition.
+ The old enumerators remain defined, however. */
+ TYPE_VALUES (enumtype) = NULL_TREE;
+
+ /* Initially, set up this enum as like `int'
+ so that we can create the enumerators' declarations and values.
+ Later on, the precision of the type may be changed and
+ it may be laid out again. */
+
+ TYPE_PRECISION (enumtype) = TYPE_PRECISION (integer_type_node);
+ TYPE_SIZE (enumtype) = NULL_TREE;
+ fixup_signed_type (enumtype);
+#endif
+
+ /* We copy this value because enumerated type constants
+ are really of the type of the enumerator, not integer_type_node. */
+ enum_next_value = copy_node (integer_zero_node);
+ enum_overflow = 0;
+
+ GNU_xref_decl (current_function_decl, enumtype);
+ return enumtype;
+}
+
+/* After processing and defining all the values of an enumeration type,
+ install their decls in the enumeration type and finish it off.
+ ENUMTYPE is the type object and VALUES a list of name-value pairs.
+ Returns ENUMTYPE. */
+
+tree
+finish_enum (enumtype, values)
+ register tree enumtype, values;
+{
+ register tree minnode, maxnode;
+ /* Calculate the maximum value of any enumerator in this type. */
+
+ if (values)
+ {
+ register tree pair;
+ register tree value = DECL_INITIAL (TREE_VALUE (values));
+
+ /* Speed up the main loop by performing some precalculations */
+ TREE_TYPE (TREE_VALUE (values)) = enumtype;
+ TREE_TYPE (value) = enumtype;
+ TREE_VALUE (values) = value;
+ minnode = maxnode = value;
+
+ for (pair = TREE_CHAIN (values); pair; pair = TREE_CHAIN (pair))
+ {
+ value = DECL_INITIAL (TREE_VALUE (pair));
+ TREE_TYPE (TREE_VALUE (pair)) = enumtype;
+ TREE_TYPE (value) = enumtype;
+ TREE_VALUE (pair) = value;
+ if (tree_int_cst_lt (maxnode, value))
+ maxnode = value;
+ else if (tree_int_cst_lt (value, minnode))
+ minnode = value;
+ }
+ }
+ else
+ maxnode = minnode = integer_zero_node;
+
+ TYPE_VALUES (enumtype) = values;
+
+ {
+ int unsignedp = tree_int_cst_sgn (minnode) >= 0;
+ int lowprec = min_precision (minnode, unsignedp);
+ int highprec = min_precision (maxnode, unsignedp);
+ int precision = MAX (lowprec, highprec);
+
+ TYPE_SIZE (enumtype) = NULL_TREE;
+
+ /* Set TYPE_MIN_VALUE and TYPE_MAX_VALUE according to `precision'. */
+
+ TYPE_PRECISION (enumtype) = precision;
+ if (unsignedp)
+ fixup_unsigned_type (enumtype);
+ else
+ fixup_signed_type (enumtype);
+
+ if (flag_short_enums || precision > TYPE_PRECISION (integer_type_node))
+ /* Use the width of the narrowest normal C type which is wide enough. */
+ TYPE_PRECISION (enumtype) = TYPE_PRECISION (type_for_size
+ (precision, 1));
+ else
+ TYPE_PRECISION (enumtype) = TYPE_PRECISION (integer_type_node);
+
+ TYPE_SIZE (enumtype) = 0;
+ layout_type (enumtype);
+ }
+
+ if (flag_cadillac)
+ cadillac_finish_enum (enumtype);
+
+ {
+ register tree tem;
+
+ /* Fix up all variant types of this enum type. */
+ for (tem = TYPE_MAIN_VARIANT (enumtype); tem;
+ tem = TYPE_NEXT_VARIANT (tem))
+ {
+ TYPE_VALUES (tem) = TYPE_VALUES (enumtype);
+ TYPE_MIN_VALUE (tem) = TYPE_MIN_VALUE (enumtype);
+ TYPE_MAX_VALUE (tem) = TYPE_MAX_VALUE (enumtype);
+ TYPE_SIZE (tem) = TYPE_SIZE (enumtype);
+ TYPE_MODE (tem) = TYPE_MODE (enumtype);
+ TYPE_PRECISION (tem) = TYPE_PRECISION (enumtype);
+ TYPE_ALIGN (tem) = TYPE_ALIGN (enumtype);
+ TREE_UNSIGNED (tem) = TREE_UNSIGNED (enumtype);
+ }
+ }
+
+ /* Finish debugging output for this type. */
+#if 0
+ /* @@ Do we ever generate generate ENUMERAL_TYPE nodes for which debugging
+ information should *not* be generated? I think not. */
+ if (! DECL_IGNORED_P (TYPE_NAME (enumtype)))
+#endif
+ rest_of_type_compilation (enumtype, global_bindings_p ());
+
+ return enumtype;
+}
+
+/* Build and install a CONST_DECL for one value of the
+ current enumeration type (one that was begun with start_enum).
+ Return a tree-list containing the name and its value.
+ Assignment of sequential values by default is handled here. */
+
+tree
+build_enumerator (name, value)
+ tree name, value;
+{
+ tree decl, result;
+ /* Change this to zero if we find VALUE is not shareable. */
+ int shareable = 1;
+
+ /* Remove no-op casts from the value. */
+ if (value)
+ STRIP_TYPE_NOPS (value);
+
+ /* Validate and default VALUE. */
+ if (value != NULL_TREE)
+ {
+ if (TREE_READONLY_DECL_P (value))
+ {
+ value = decl_constant_value (value);
+ shareable = 0;
+ }
+
+ if (TREE_CODE (value) == INTEGER_CST)
+ {
+ value = default_conversion (value);
+ constant_expression_warning (value);
+ }
+ else
+ {
+ cp_error ("enumerator value for `%D' not integer constant", name);
+ value = NULL_TREE;
+ }
+ }
+
+ /* The order of things is reversed here so that we
+ can check for possible sharing of enum values,
+ to keep that from happening. */
+ /* Default based on previous value. */
+ if (value == NULL_TREE)
+ {
+ value = enum_next_value;
+ if (enum_overflow)
+ cp_error ("overflow in enumeration values at `%D'", name);
+ }
+
+ /* Remove no-op casts from the value. */
+ if (value)
+ STRIP_TYPE_NOPS (value);
+
+ /* Make up for hacks in lex.c. */
+ if (value == integer_zero_node)
+ value = build_int_2 (0, 0);
+ else if (value == integer_one_node)
+ value = build_int_2 (1, 0);
+ else if (TREE_CODE (value) == INTEGER_CST
+ && (shareable == 0
+ || TREE_CODE (TREE_TYPE (value)) == ENUMERAL_TYPE))
+ {
+ value = copy_node (value);
+ TREE_TYPE (value) = integer_type_node;
+ }
+
+ /* C++ associates enums with global, function, or class declarations. */
+
+ decl = current_scope ();
+ if (decl && decl == current_class_type)
+ {
+ /* This enum declaration is local to the class, so we must put
+ it in that class's list of decls. */
+ decl = build_lang_field_decl (CONST_DECL, name, integer_type_node);
+ DECL_INITIAL (decl) = value;
+ TREE_READONLY (decl) = 1;
+ pushdecl_class_level (decl);
+ TREE_CHAIN (decl) = current_local_enum;
+ current_local_enum = decl;
+ }
+ else
+ {
+ /* It's a global enum, or it's local to a function. (Note local to
+ a function could mean local to a class method. */
+ decl = build_decl (CONST_DECL, name, integer_type_node);
+ DECL_INITIAL (decl) = value;
+
+ pushdecl (decl);
+ GNU_xref_decl (current_function_decl, decl);
+ }
+
+ /* Set basis for default for next value. */
+ enum_next_value = build_binary_op_nodefault (PLUS_EXPR, value,
+ integer_one_node, PLUS_EXPR);
+ enum_overflow = tree_int_cst_lt (enum_next_value, value);
+
+ if (enum_next_value == integer_one_node)
+ enum_next_value = copy_node (enum_next_value);
+
+ result = saveable_tree_cons (name, decl, NULL_TREE);
+ return result;
+}
+
+tree
+grok_enum_decls (type, decl)
+ tree type, decl;
+{
+ tree d = current_local_enum;
+
+ if (d == NULL_TREE)
+ return decl;
+
+ while (1)
+ {
+ TREE_TYPE (d) = type;
+ if (TREE_CHAIN (d) == NULL_TREE)
+ {
+ TREE_CHAIN (d) = decl;
+ break;
+ }
+ d = TREE_CHAIN (d);
+ }
+
+ decl = current_local_enum;
+ current_local_enum = NULL_TREE;
+
+ return decl;
+}
+
+/* Create the FUNCTION_DECL for a function definition.
+ DECLSPECS and DECLARATOR are the parts of the declaration;
+ they describe the function's name and the type it returns,
+ but twisted together in a fashion that parallels the syntax of C.
+
+ This function creates a binding context for the function body
+ as well as setting up the FUNCTION_DECL in current_function_decl.
+
+ Returns 1 on success. If the DECLARATOR is not suitable for a function
+ (it defines a datum instead), we return 0, which tells
+ yyparse to report a parse error.
+
+ For C++, we must first check whether that datum makes any sense.
+ For example, "class A local_a(1,2);" means that variable local_a
+ is an aggregate of type A, which should have a constructor
+ applied to it with the argument list [1, 2].
+
+ @@ There is currently no way to retrieve the storage
+ @@ allocated to FUNCTION (or all of its parms) if we return
+ @@ something we had previously. */
+
+int
+start_function (declspecs, declarator, raises, attrs, pre_parsed_p)
+ tree declspecs, declarator, raises, attrs;
+ int pre_parsed_p;
+{
+ tree decl1, olddecl;
+ tree ctype = NULL_TREE;
+ tree fntype;
+ tree restype;
+ extern int have_extern_spec;
+ extern int used_extern_spec;
+ int doing_friend = 0;
+
+ /* Sanity check. */
+ my_friendly_assert (TREE_VALUE (void_list_node) == void_type_node, 160);
+ my_friendly_assert (TREE_CHAIN (void_list_node) == NULL_TREE, 161);
+
+ /* Assume, until we see it does. */
+ current_function_returns_value = 0;
+ current_function_returns_null = 0;
+ warn_about_return_type = 0;
+ named_labels = 0;
+ shadowed_labels = 0;
+ current_function_assigns_this = 0;
+ current_function_just_assigned_this = 0;
+ current_function_parms_stored = 0;
+ original_result_rtx = NULL_RTX;
+ current_function_obstack_index = 0;
+ current_function_obstack_usage = 0;
+ base_init_expr = NULL_TREE;
+ protect_list = NULL_TREE;
+ current_base_init_list = NULL_TREE;
+ current_member_init_list = NULL_TREE;
+ ctor_label = dtor_label = NULL_TREE;
+
+ clear_temp_name ();
+
+ /* This should only be done once on the top most decl. */
+ if (have_extern_spec && !used_extern_spec)
+ {
+ declspecs = decl_tree_cons (NULL_TREE, get_identifier ("extern"), declspecs);
+ used_extern_spec = 1;
+ }
+
+ if (pre_parsed_p)
+ {
+ decl1 = declarator;
+
+ if (! DECL_ARGUMENTS (decl1)
+ && !DECL_STATIC_FUNCTION_P (decl1)
+ && DECL_CONTEXT (decl1)
+ && DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl1)))
+ && IDENTIFIER_TEMPLATE (DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl1)))))
+ {
+ cp_error ("redeclaration of `%#D'", decl1);
+ if (IDENTIFIER_CLASS_VALUE (DECL_NAME (decl1)))
+ cp_error_at ("previous declaration here", IDENTIFIER_CLASS_VALUE (DECL_NAME (decl1)));
+ else if (IDENTIFIER_GLOBAL_VALUE (DECL_NAME (decl1)))
+ cp_error_at ("previous declaration here", IDENTIFIER_GLOBAL_VALUE (DECL_NAME (decl1)));
+ }
+
+ /* This can happen if a template class is instantiated as part of the
+ specialization of a member function which is defined in the class
+ template. We should just use the specialization, but for now give an
+ error. */
+ if (DECL_INITIAL (decl1) != NULL_TREE)
+ {
+ cp_error_at ("specialization of `%#D' not supported", decl1);
+ cp_error ("when defined in the class template body", decl1);
+ }
+
+ last_function_parms = DECL_ARGUMENTS (decl1);
+ last_function_parm_tags = NULL_TREE;
+ fntype = TREE_TYPE (decl1);
+ if (TREE_CODE (fntype) == METHOD_TYPE)
+ ctype = TYPE_METHOD_BASETYPE (fntype);
+
+ /* ANSI C++ June 5 1992 WP 11.4.5. A friend function defined in a
+ class is in the (lexical) scope of the class in which it is
+ defined. */
+ if (!ctype && DECL_FRIEND_P (decl1))
+ {
+ ctype = DECL_CLASS_CONTEXT (decl1);
+
+ /* CTYPE could be null here if we're dealing with a template;
+ for example, `inline friend float foo()' inside a template
+ will have no CTYPE set. */
+ if (ctype && TREE_CODE (ctype) != RECORD_TYPE)
+ ctype = NULL_TREE;
+ else
+ doing_friend = 1;
+ }
+
+ raises = TYPE_RAISES_EXCEPTIONS (fntype);
+
+ /* In a fcn definition, arg types must be complete. */
+ require_complete_types_for_parms (last_function_parms);
+
+ /* In case some arg types were completed since the declaration was
+ parsed, fix up the decls. */
+ {
+ tree t = last_function_parms;
+ for (; t; t = TREE_CHAIN (t))
+ layout_decl (t, 0);
+ }
+ }
+ else
+ {
+ decl1 = grokdeclarator (declarator, declspecs, FUNCDEF, 1, raises,
+ NULL_TREE);
+ /* If the declarator is not suitable for a function definition,
+ cause a syntax error. */
+ if (decl1 == NULL_TREE || TREE_CODE (decl1) != FUNCTION_DECL) return 0;
+
+ fntype = TREE_TYPE (decl1);
+
+ restype = TREE_TYPE (fntype);
+ if (IS_AGGR_TYPE (restype) && ! TYPE_PTRMEMFUNC_P (restype)
+ && ! CLASSTYPE_GOT_SEMICOLON (restype))
+ {
+ cp_error ("semicolon missing after declaration of `%#T'", restype);
+ shadow_tag (build_tree_list (NULL_TREE, restype));
+ CLASSTYPE_GOT_SEMICOLON (restype) = 1;
+ if (TREE_CODE (fntype) == FUNCTION_TYPE)
+ fntype = build_function_type (integer_type_node,
+ TYPE_ARG_TYPES (fntype));
+ else
+ fntype = build_cplus_method_type (build_type_variant (TYPE_METHOD_BASETYPE (fntype), TREE_READONLY (decl1), TREE_SIDE_EFFECTS (decl1)),
+ integer_type_node,
+ TYPE_ARG_TYPES (fntype));
+ TREE_TYPE (decl1) = fntype;
+ }
+
+ if (TREE_CODE (fntype) == METHOD_TYPE)
+ ctype = TYPE_METHOD_BASETYPE (fntype);
+ else if (IDENTIFIER_LENGTH (DECL_NAME (decl1)) == 4
+ && ! strcmp (IDENTIFIER_POINTER (DECL_NAME (decl1)), "main")
+ && DECL_CONTEXT (decl1) == NULL_TREE)
+ {
+ /* If this doesn't return integer_type, complain. */
+ if (TREE_TYPE (TREE_TYPE (decl1)) != integer_type_node)
+ {
+ if (pedantic || warn_return_type)
+ pedwarn ("return type for `main' changed to integer type");
+ TREE_TYPE (decl1) = fntype = default_function_type;
+ }
+ warn_about_return_type = 0;
+ }
+ }
+
+ /* Warn if function was previously implicitly declared
+ (but not if we warned then). */
+ if (! warn_implicit
+ && IDENTIFIER_IMPLICIT_DECL (DECL_NAME (decl1)) != NULL_TREE)
+ cp_warning_at ("`%D' implicitly declared before its definition", IDENTIFIER_IMPLICIT_DECL (DECL_NAME (decl1)));
+
+ current_function_decl = decl1;
+
+ if (flag_cadillac)
+ cadillac_start_function (decl1);
+ else
+ announce_function (decl1);
+
+ if (TYPE_SIZE (TREE_TYPE (fntype)) == NULL_TREE)
+ {
+ if (IS_AGGR_TYPE (TREE_TYPE (fntype)))
+ error_with_aggr_type (TREE_TYPE (fntype),
+ "return-type `%s' is an incomplete type");
+ else
+ error ("return-type is an incomplete type");
+
+ /* Make it return void instead, but don't change the
+ type of the DECL_RESULT, in case we have a named return value. */
+ if (ctype)
+ TREE_TYPE (decl1)
+ = build_cplus_method_type (build_type_variant (ctype,
+ TREE_READONLY (decl1),
+ TREE_SIDE_EFFECTS (decl1)),
+ void_type_node,
+ FUNCTION_ARG_CHAIN (decl1));
+ else
+ TREE_TYPE (decl1)
+ = build_function_type (void_type_node,
+ TYPE_ARG_TYPES (TREE_TYPE (decl1)));
+ DECL_RESULT (decl1)
+ = build_decl (RESULT_DECL, 0, TYPE_MAIN_VARIANT (TREE_TYPE (fntype)));
+ TREE_READONLY (DECL_RESULT (decl1)) = TYPE_READONLY (TREE_TYPE (fntype));
+ TREE_THIS_VOLATILE (DECL_RESULT (decl1)) = TYPE_VOLATILE (TREE_TYPE (fntype));
+ }
+
+ if (TYPE_LANG_SPECIFIC (TREE_TYPE (fntype))
+ && CLASSTYPE_ABSTRACT_VIRTUALS (TREE_TYPE (fntype)))
+ abstract_virtuals_error (decl1, TREE_TYPE (fntype));
+
+ if (warn_about_return_type)
+ warning ("return-type defaults to `int'");
+
+ /* Make the init_value nonzero so pushdecl knows this is not tentative.
+ error_mark_node is replaced below (in poplevel) with the BLOCK. */
+ DECL_INITIAL (decl1) = error_mark_node;
+
+ /* Didn't get anything from C. */
+ olddecl = NULL_TREE;
+
+ /* This function exists in static storage.
+ (This does not mean `static' in the C sense!) */
+ TREE_STATIC (decl1) = 1;
+
+ /* Record the decl so that the function name is defined.
+ If we already have a decl for this name, and it is a FUNCTION_DECL,
+ use the old decl. */
+
+ if (pre_parsed_p == 0)
+ {
+ current_function_decl = decl1 = pushdecl (decl1);
+ DECL_MAIN_VARIANT (decl1) = decl1;
+ fntype = TREE_TYPE (decl1);
+ }
+ else
+ current_function_decl = decl1;
+
+ if (DECL_INTERFACE_KNOWN (decl1))
+ {
+ if (DECL_NOT_REALLY_EXTERN (decl1))
+ DECL_EXTERNAL (decl1) = 0;
+ }
+ /* If this function belongs to an interface, it is public.
+ If it belongs to someone else's interface, it is also external.
+ It doesn't matter whether it's inline or not. */
+ else if (interface_unknown == 0)
+ {
+ if (DECL_THIS_INLINE (decl1) || DECL_TEMPLATE_INSTANTIATION (decl1))
+ DECL_EXTERNAL (decl1)
+ = (interface_only
+ || (DECL_THIS_INLINE (decl1) && ! flag_implement_inlines));
+ else
+ DECL_EXTERNAL (decl1) = 0;
+ DECL_NOT_REALLY_EXTERN (decl1) = 0;
+ DECL_INTERFACE_KNOWN (decl1) = 1;
+ }
+ else
+ {
+ /* This is a definition, not a reference.
+ So clear DECL_EXTERNAL. */
+ DECL_EXTERNAL (decl1) = 0;
+
+ if (DECL_THIS_INLINE (decl1) && ! DECL_INTERFACE_KNOWN (decl1))
+ DECL_DEFER_OUTPUT (decl1) = 1;
+ else
+ {
+ DECL_INTERFACE_KNOWN (decl1) = 1;
+ if (DECL_C_STATIC (decl1))
+ TREE_PUBLIC (decl1) = 0;
+ }
+ }
+
+ if (ctype != NULL_TREE && DECL_STATIC_FUNCTION_P (decl1))
+ {
+ if (TREE_CODE (fntype) == METHOD_TYPE)
+ TREE_TYPE (decl1) = fntype
+ = build_function_type (TREE_TYPE (fntype),
+ TREE_CHAIN (TYPE_ARG_TYPES (fntype)));
+ last_function_parms = TREE_CHAIN (last_function_parms);
+ DECL_ARGUMENTS (decl1) = last_function_parms;
+ ctype = NULL_TREE;
+ }
+ restype = TREE_TYPE (fntype);
+
+ if (ctype)
+ {
+ push_nested_class (ctype, 1);
+
+ /* If we're compiling a friend function, neither of the variables
+ current_class_decl nor current_class_type will have values. */
+ if (! doing_friend)
+ {
+ /* We know that this was set up by `grokclassfn'.
+ We do not wait until `store_parm_decls', since evil
+ parse errors may never get us to that point. Here
+ we keep the consistency between `current_class_type'
+ and `current_class_decl'. */
+ tree t = last_function_parms;
+
+ my_friendly_assert (t != NULL_TREE
+ && TREE_CODE (t) == PARM_DECL, 162);
+
+ if (TREE_CODE (TREE_TYPE (t)) == POINTER_TYPE)
+ {
+ int i = suspend_momentary ();
+
+ /* Fool build_indirect_ref. */
+ current_class_decl = NULL_TREE;
+ C_C_D = build_indirect_ref (t, NULL_PTR);
+ current_class_decl = t;
+ resume_momentary (i);
+ }
+ else
+ /* We're having a signature pointer here. */
+ C_C_D = current_class_decl = t;
+
+ }
+ }
+ else
+ {
+ if (DECL_STATIC_FUNCTION_P (decl1))
+ push_nested_class (DECL_CONTEXT (decl1), 2);
+ else
+ push_memoized_context (0, 1);
+ current_class_decl = C_C_D = NULL_TREE;
+ }
+
+ pushlevel (0);
+ current_binding_level->parm_flag = 1;
+
+ /* Save the parm names or decls from this function's declarator
+ where store_parm_decls will find them. */
+ current_function_parms = last_function_parms;
+ current_function_parm_tags = last_function_parm_tags;
+
+ GNU_xref_function (decl1, current_function_parms);
+
+ if (attrs)
+ cplus_decl_attributes (decl1, NULL_TREE, attrs);
+ make_function_rtl (decl1);
+
+ /* Allocate further tree nodes temporarily during compilation
+ of this function only. Tiemann moved up here from bottom of fn. */
+ temporary_allocation ();
+
+ /* Promote the value to int before returning it. */
+ if (C_PROMOTING_INTEGER_TYPE_P (restype))
+ {
+ /* It retains unsignedness if traditional or if it isn't
+ really getting wider. */
+ if (TREE_UNSIGNED (restype)
+ && (flag_traditional
+ || TYPE_PRECISION (restype)
+ == TYPE_PRECISION (integer_type_node)))
+ restype = unsigned_type_node;
+ else
+ restype = integer_type_node;
+ }
+ if (DECL_RESULT (decl1) == NULL_TREE)
+ {
+ DECL_RESULT (decl1)
+ = build_decl (RESULT_DECL, 0, TYPE_MAIN_VARIANT (restype));
+ TREE_READONLY (DECL_RESULT (decl1)) = TYPE_READONLY (restype);
+ TREE_THIS_VOLATILE (DECL_RESULT (decl1)) = TYPE_VOLATILE (restype);
+ }
+
+ if (DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (decl1))
+ && DECL_LANGUAGE (decl1) == lang_cplusplus)
+ {
+ dtor_label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
+ ctor_label = NULL_TREE;
+ }
+ else
+ {
+ dtor_label = NULL_TREE;
+ if (DECL_CONSTRUCTOR_P (decl1))
+ ctor_label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
+ }
+
+ /* If this fcn was already referenced via a block-scope `extern' decl
+ (or an implicit decl), propagate certain information about the usage. */
+ if (TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (decl1)))
+ TREE_ADDRESSABLE (decl1) = 1;
+
+ return 1;
+}
+
+void
+expand_start_early_try_stmts ()
+{
+ rtx insns;
+ start_sequence ();
+ expand_start_try_stmts ();
+ insns = get_insns ();
+ end_sequence ();
+ store_in_parms (insns);
+}
+
+void
+store_in_parms (insns)
+ rtx insns;
+{
+ rtx last_parm_insn;
+
+ last_parm_insn = get_first_nonparm_insn ();
+ if (last_parm_insn == NULL_RTX)
+ emit_insns (insns);
+ else
+ emit_insns_before (insns, previous_insn (last_parm_insn));
+}
+
+/* Store the parameter declarations into the current function declaration.
+ This is called after parsing the parameter declarations, before
+ digesting the body of the function.
+
+ Also install to binding contour return value identifier, if any. */
+
+void
+store_parm_decls ()
+{
+ register tree fndecl = current_function_decl;
+ register tree parm;
+ int parms_have_cleanups = 0;
+
+ /* This is either a chain of PARM_DECLs (when a prototype is used). */
+ tree specparms = current_function_parms;
+
+ /* This is a list of types declared among parms in a prototype. */
+ tree parmtags = current_function_parm_tags;
+
+ /* This is a chain of any other decls that came in among the parm
+ declarations. If a parm is declared with enum {foo, bar} x;
+ then CONST_DECLs for foo and bar are put here. */
+ tree nonparms = NULL_TREE;
+
+ if (toplevel_bindings_p ())
+ fatal ("parse errors have confused me too much");
+
+ /* Initialize RTL machinery. */
+ init_function_start (fndecl, input_filename, lineno);
+
+ /* Declare __FUNCTION__ and __PRETTY_FUNCTION__ for this function. */
+ declare_function_name ();
+
+ /* Create a binding level for the parms. */
+ expand_start_bindings (0);
+
+ if (specparms != NULL_TREE)
+ {
+ /* This case is when the function was defined with an ANSI prototype.
+ The parms already have decls, so we need not do anything here
+ except record them as in effect
+ and complain if any redundant old-style parm decls were written. */
+
+ register tree next;
+
+ /* Must clear this because it might contain TYPE_DECLs declared
+ at class level. */
+ storedecls (NULL_TREE);
+ for (parm = nreverse (specparms); parm; parm = next)
+ {
+ next = TREE_CHAIN (parm);
+ if (TREE_CODE (parm) == PARM_DECL)
+ {
+ tree cleanup = maybe_build_cleanup (parm);
+ if (DECL_NAME (parm) == NULL_TREE)
+ {
+#if 0
+ cp_error_at ("parameter name omitted", parm);
+#else
+ /* for C++, this is not an error. */
+ pushdecl (parm);
+#endif
+ }
+ else if (TYPE_MAIN_VARIANT (TREE_TYPE (parm)) == void_type_node)
+ cp_error ("parameter `%D' declared void", parm);
+ else
+ {
+ /* Now fill in DECL_REFERENCE_SLOT for any of the parm decls.
+ A parameter is assumed not to have any side effects.
+ If this should change for any reason, then this
+ will have to wrap the bashed reference type in a save_expr.
+
+ Also, if the parameter type is declared to be an X
+ and there is an X(X&) constructor, we cannot lay it
+ into the stack (any more), so we make this parameter
+ look like it is really of reference type. Functions
+ which pass parameters to this function will know to
+ create a temporary in their frame, and pass a reference
+ to that. */
+
+ if (TREE_CODE (TREE_TYPE (parm)) == REFERENCE_TYPE
+ && TYPE_SIZE (TREE_TYPE (TREE_TYPE (parm))))
+ SET_DECL_REFERENCE_SLOT (parm, convert_from_reference (parm));
+
+ pushdecl (parm);
+ }
+ if (cleanup)
+ {
+ expand_decl (parm);
+ if (! cp_expand_decl_cleanup (parm, cleanup))
+ cp_error ("parser lost in parsing declaration of `%D'",
+ parm);
+ parms_have_cleanups = 1;
+ }
+ }
+ else
+ {
+ /* If we find an enum constant or a type tag,
+ put it aside for the moment. */
+ TREE_CHAIN (parm) = NULL_TREE;
+ nonparms = chainon (nonparms, parm);
+ }
+ }
+
+ /* Get the decls in their original chain order
+ and record in the function. This is all and only the
+ PARM_DECLs that were pushed into scope by the loop above. */
+ DECL_ARGUMENTS (fndecl) = getdecls ();
+
+ storetags (chainon (parmtags, gettags ()));
+ }
+ else
+ DECL_ARGUMENTS (fndecl) = NULL_TREE;
+
+ /* Now store the final chain of decls for the arguments
+ as the decl-chain of the current lexical scope.
+ Put the enumerators in as well, at the front so that
+ DECL_ARGUMENTS is not modified. */
+
+ storedecls (chainon (nonparms, DECL_ARGUMENTS (fndecl)));
+
+ /* Initialize the RTL code for the function. */
+ DECL_SAVED_INSNS (fndecl) = NULL_RTX;
+ expand_function_start (fndecl, parms_have_cleanups);
+
+ /* Create a binding contour which can be used to catch
+ cleanup-generated temporaries. Also, if the return value needs or
+ has initialization, deal with that now. */
+ if (parms_have_cleanups)
+ {
+ pushlevel (0);
+ expand_start_bindings (0);
+ }
+
+ current_function_parms_stored = 1;
+
+ if (flag_gc)
+ {
+ maybe_gc_cleanup = build_tree_list (NULL_TREE, error_mark_node);
+ if (! cp_expand_decl_cleanup (NULL_TREE, maybe_gc_cleanup))
+ cp_error ("parser lost in parsing declaration of `%D'", fndecl);
+ }
+
+ /* If this function is `main', emit a call to `__main'
+ to run global initializers, etc. */
+ if (DECL_NAME (fndecl)
+ && IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 4
+ && strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "main") == 0
+ && DECL_CONTEXT (fndecl) == NULL_TREE)
+ {
+ expand_main_function ();
+
+ if (flag_gc)
+ expand_expr (build_function_call (lookup_name (get_identifier ("__gc_main"), 0), NULL_TREE),
+ 0, VOIDmode, 0);
+#if 0
+ /* done at a different time */
+ if (flag_rtti)
+ output_builtin_tdesc_entries ();
+#endif
+ }
+
+ /* Take care of exception handling things. */
+ if (flag_handle_exceptions)
+ {
+ rtx insns;
+ start_sequence ();
+
+ /* Mark the start of a stack unwinder if we need one. */
+ start_eh_unwinder ();
+
+ /* Do the starting of the exception specifications, if we have any. */
+ if (TYPE_RAISES_EXCEPTIONS (TREE_TYPE (current_function_decl)))
+ expand_start_eh_spec ();
+
+ insns = get_insns ();
+ end_sequence ();
+
+ if (insns)
+ store_in_parms (insns);
+ }
+}
+
+/* Bind a name and initialization to the return value of
+ the current function. */
+void
+store_return_init (return_id, init)
+ tree return_id, init;
+{
+ tree decl = DECL_RESULT (current_function_decl);
+
+ if (pedantic)
+ /* Give this error as many times as there are occurrences,
+ so that users can use Emacs compilation buffers to find
+ and fix all such places. */
+ pedwarn ("ANSI C++ does not permit named return values");
+
+ if (return_id != NULL_TREE)
+ {
+ if (DECL_NAME (decl) == NULL_TREE)
+ {
+ DECL_NAME (decl) = return_id;
+ DECL_ASSEMBLER_NAME (decl) = return_id;
+ }
+ else
+ error ("return identifier `%s' already in place",
+ IDENTIFIER_POINTER (DECL_NAME (decl)));
+ }
+
+ /* Can't let this happen for constructors. */
+ if (DECL_CONSTRUCTOR_P (current_function_decl))
+ {
+ error ("can't redefine default return value for constructors");
+ return;
+ }
+
+ /* If we have a named return value, put that in our scope as well. */
+ if (DECL_NAME (decl) != NULL_TREE)
+ {
+ /* If this named return value comes in a register,
+ put it in a pseudo-register. */
+ if (DECL_REGISTER (decl))
+ {
+ original_result_rtx = DECL_RTL (decl);
+ DECL_RTL (decl) = gen_reg_rtx (DECL_MODE (decl));
+ }
+
+ /* Let `cp_finish_decl' know that this initializer is ok. */
+ DECL_INITIAL (decl) = init;
+ pushdecl (decl);
+ cp_finish_decl (decl, init, NULL_TREE, 0, LOOKUP_ONLYCONVERTING);
+ }
+}
+
+
+/* Finish up a function declaration and compile that function
+ all the way to assembler language output. The free the storage
+ for the function definition.
+
+ This is called after parsing the body of the function definition.
+ LINENO is the current line number.
+
+ C++: CALL_POPLEVEL is non-zero if an extra call to poplevel
+ (and expand_end_bindings) must be made to take care of the binding
+ contour for the base initializers. This is only relevant for
+ constructors. */
+
+void
+finish_function (lineno, call_poplevel, nested)
+ int lineno;
+ int call_poplevel;
+ int nested;
+{
+ register tree fndecl = current_function_decl;
+ tree fntype, ctype = NULL_TREE;
+ rtx last_parm_insn, insns;
+ /* Label to use if this function is supposed to return a value. */
+ tree no_return_label = NULL_TREE;
+ tree decls = NULL_TREE;
+
+ /* When we get some parse errors, we can end up without a
+ current_function_decl, so cope. */
+ if (fndecl == NULL_TREE)
+ return;
+
+ fntype = TREE_TYPE (fndecl);
+
+/* TREE_READONLY (fndecl) = 1;
+ This caused &foo to be of type ptr-to-const-function
+ which then got a warning when stored in a ptr-to-function variable. */
+
+ /* This happens on strange parse errors. */
+ if (! current_function_parms_stored)
+ {
+ call_poplevel = 0;
+ store_parm_decls ();
+ }
+
+ if (write_symbols != NO_DEBUG /*&& TREE_CODE (fntype) != METHOD_TYPE*/)
+ {
+ tree ttype = target_type (fntype);
+ tree parmdecl;
+
+ if (IS_AGGR_TYPE (ttype))
+ /* Let debugger know it should output info for this type. */
+ note_debug_info_needed (ttype);
+
+ for (parmdecl = DECL_ARGUMENTS (fndecl); parmdecl; parmdecl = TREE_CHAIN (parmdecl))
+ {
+ ttype = target_type (TREE_TYPE (parmdecl));
+ if (IS_AGGR_TYPE (ttype))
+ /* Let debugger know it should output info for this type. */
+ note_debug_info_needed (ttype);
+ }
+ }
+
+ /* Clean house because we will need to reorder insns here. */
+ do_pending_stack_adjust ();
+
+ if (dtor_label)
+ {
+ tree binfo = TYPE_BINFO (current_class_type);
+ tree cond = integer_one_node;
+ tree exprstmt, vfields;
+ tree in_charge_node = lookup_name (in_charge_identifier, 0);
+ tree virtual_size;
+ int ok_to_optimize_dtor = 0;
+
+ if (current_function_assigns_this)
+ cond = build (NE_EXPR, boolean_type_node,
+ current_class_decl, integer_zero_node);
+ else
+ {
+ int n_baseclasses = CLASSTYPE_N_BASECLASSES (current_class_type);
+
+ /* If this destructor is empty, then we don't need to check
+ whether `this' is NULL in some cases. */
+ if ((flag_this_is_variable & 1) == 0)
+ ok_to_optimize_dtor = 1;
+ else if (get_last_insn () == get_first_nonparm_insn ())
+ ok_to_optimize_dtor
+ = (n_baseclasses == 0
+ || (n_baseclasses == 1
+ && TYPE_HAS_DESTRUCTOR (TYPE_BINFO_BASETYPE (current_class_type, 0))));
+ }
+
+ /* These initializations might go inline. Protect
+ the binding level of the parms. */
+ pushlevel (0);
+ expand_start_bindings (0);
+
+ if (current_function_assigns_this)
+ {
+ current_function_assigns_this = 0;
+ current_function_just_assigned_this = 0;
+ }
+
+ /* Generate the code to call destructor on base class.
+ If this destructor belongs to a class with virtual
+ functions, then set the virtual function table
+ pointer to represent the type of our base class. */
+
+ /* This side-effect makes call to `build_delete' generate the
+ code we have to have at the end of this destructor. */
+ TYPE_HAS_DESTRUCTOR (current_class_type) = 0;
+
+ /* These are two cases where we cannot delegate deletion. */
+ if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type)
+ || TYPE_GETS_REG_DELETE (current_class_type))
+ exprstmt = build_delete (current_class_type, C_C_D, integer_zero_node,
+ LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR, 0);
+ else
+ exprstmt = build_delete (current_class_type, C_C_D, in_charge_node,
+ LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR, 0);
+
+ /* If we did not assign to this, then `this' is non-zero at
+ the end of a destructor. As a special optimization, don't
+ emit test if this is an empty destructor. If it does nothing,
+ it does nothing. If it calls a base destructor, the base
+ destructor will perform the test. */
+
+ if (exprstmt != error_mark_node
+ && (TREE_CODE (exprstmt) != NOP_EXPR
+ || TREE_OPERAND (exprstmt, 0) != integer_zero_node
+ || TYPE_USES_VIRTUAL_BASECLASSES (current_class_type)))
+ {
+ expand_label (dtor_label);
+ if (cond != integer_one_node)
+ expand_start_cond (cond, 0);
+ if (exprstmt != void_zero_node)
+ /* Don't call `expand_expr_stmt' if we're not going to do
+ anything, since -Wall will give a diagnostic. */
+ expand_expr_stmt (exprstmt);
+
+ /* Run destructor on all virtual baseclasses. */
+ if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type))
+ {
+ tree vbases = nreverse (copy_list (CLASSTYPE_VBASECLASSES (current_class_type)));
+ expand_start_cond (build (BIT_AND_EXPR, integer_type_node,
+ in_charge_node, integer_two_node), 0);
+ while (vbases)
+ {
+ if (TYPE_NEEDS_DESTRUCTOR (BINFO_TYPE (vbases)))
+ {
+ tree ptr = convert_pointer_to_vbase (BINFO_TYPE (vbases), current_class_decl);
+ expand_expr_stmt (build_delete (build_pointer_type (BINFO_TYPE (vbases)),
+ ptr, integer_zero_node,
+ LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR|LOOKUP_HAS_IN_CHARGE, 0));
+ }
+ vbases = TREE_CHAIN (vbases);
+ }
+ expand_end_cond ();
+ }
+
+ do_pending_stack_adjust ();
+ if (cond != integer_one_node)
+ expand_end_cond ();
+ }
+
+ TYPE_HAS_DESTRUCTOR (current_class_type) = 1;
+
+ virtual_size = c_sizeof (current_class_type);
+
+ /* At the end, call delete if that's what's requested. */
+ if (TYPE_GETS_REG_DELETE (current_class_type))
+ /* This NOP_EXPR means we are in a static call context. */
+ exprstmt =
+ build_method_call
+ (build_indirect_ref
+ (build1 (NOP_EXPR, build_pointer_type (current_class_type),
+ error_mark_node),
+ NULL_PTR),
+ ansi_opname[(int) DELETE_EXPR],
+ tree_cons (NULL_TREE, current_class_decl,
+ build_tree_list (NULL_TREE, virtual_size)),
+ NULL_TREE, LOOKUP_NORMAL);
+ else if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type))
+ exprstmt = build_x_delete (ptr_type_node, current_class_decl, 0,
+ virtual_size);
+ else
+ exprstmt = NULL_TREE;
+
+ if (exprstmt)
+ {
+ cond = build (BIT_AND_EXPR, integer_type_node,
+ in_charge_node, integer_one_node);
+ expand_start_cond (cond, 0);
+ expand_expr_stmt (exprstmt);
+ expand_end_cond ();
+ }
+
+ /* End of destructor. */
+ expand_end_bindings (NULL_TREE, getdecls() != NULL_TREE, 0);
+ poplevel (2, 0, 0); /* XXX change to 1 */
+
+ /* Back to the top of destructor. */
+ /* Dont execute destructor code if `this' is NULL. */
+
+ start_sequence ();
+
+ /* Make all virtual function table pointers in non-virtual base
+ classes point to CURRENT_CLASS_TYPE's virtual function
+ tables. */
+ expand_direct_vtbls_init (binfo, binfo, 1, 0, current_class_decl);
+ if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type))
+ expand_indirect_vtbls_init (binfo, C_C_D, current_class_decl, 0);
+ if (! ok_to_optimize_dtor)
+ {
+ cond = build_binary_op (NE_EXPR,
+ current_class_decl, integer_zero_node, 1);
+ expand_start_cond (cond, 0);
+ }
+
+ insns = get_insns ();
+ end_sequence ();
+
+ last_parm_insn = get_first_nonparm_insn ();
+ if (last_parm_insn == NULL_RTX)
+ last_parm_insn = get_last_insn ();
+ else
+ last_parm_insn = previous_insn (last_parm_insn);
+
+ emit_insns_after (insns, last_parm_insn);
+
+ if (! ok_to_optimize_dtor)
+ expand_end_cond ();
+ }
+ else if (current_function_assigns_this)
+ {
+ /* Does not need to call emit_base_init, because
+ that is done (if needed) just after assignment to this
+ is seen. */
+
+ if (DECL_CONSTRUCTOR_P (current_function_decl))
+ {
+ end_protect_partials ();
+ expand_label (ctor_label);
+ ctor_label = NULL_TREE;
+
+ if (call_poplevel)
+ {
+ decls = getdecls ();
+ expand_end_bindings (decls, decls != NULL_TREE, 0);
+ poplevel (decls != NULL_TREE, 0, 0);
+ }
+ c_expand_return (current_class_decl);
+ }
+ else if (TYPE_MAIN_VARIANT (TREE_TYPE (
+ DECL_RESULT (current_function_decl))) != void_type_node
+ && return_label != NULL_RTX)
+ no_return_label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
+
+ current_function_assigns_this = 0;
+ current_function_just_assigned_this = 0;
+ base_init_expr = NULL_TREE;
+ }
+ else if (DECL_CONSTRUCTOR_P (fndecl))
+ {
+ tree allocated_this;
+ tree cond, thenclause;
+ /* Allow constructor for a type to get a new instance of the object
+ using `build_new'. */
+ tree abstract_virtuals = CLASSTYPE_ABSTRACT_VIRTUALS (current_class_type);
+ CLASSTYPE_ABSTRACT_VIRTUALS (current_class_type) = NULL_TREE;
+
+ DECL_RETURNS_FIRST_ARG (fndecl) = 1;
+
+ if (flag_this_is_variable > 0)
+ {
+ cond = build_binary_op (EQ_EXPR,
+ current_class_decl, integer_zero_node, 1);
+ thenclause = build_modify_expr (current_class_decl, NOP_EXPR,
+ build_new (NULL_TREE, current_class_type, void_type_node, 0));
+ }
+
+ CLASSTYPE_ABSTRACT_VIRTUALS (current_class_type) = abstract_virtuals;
+
+ start_sequence ();
+
+ if (flag_this_is_variable > 0)
+ {
+ expand_start_cond (cond, 0);
+ expand_expr_stmt (thenclause);
+ expand_end_cond ();
+ }
+
+#if 0
+ if (DECL_NAME (fndecl) == NULL_TREE
+ && TREE_CHAIN (DECL_ARGUMENTS (fndecl)) != NULL_TREE)
+ build_default_constructor (fndecl);
+#endif
+
+ /* Emit insns from `emit_base_init' which sets up virtual
+ function table pointer(s). */
+ if (base_init_expr)
+ {
+ expand_expr_stmt (base_init_expr);
+ base_init_expr = NULL_TREE;
+ }
+
+ insns = get_insns ();
+ end_sequence ();
+
+ /* This is where the body of the constructor begins.
+ If there were no insns in this function body, then the
+ last_parm_insn is also the last insn.
+
+ If optimization is enabled, last_parm_insn may move, so
+ we don't hold on to it (across emit_base_init). */
+ last_parm_insn = get_first_nonparm_insn ();
+ if (last_parm_insn == NULL_RTX)
+ last_parm_insn = get_last_insn ();
+ else
+ last_parm_insn = previous_insn (last_parm_insn);
+
+ emit_insns_after (insns, last_parm_insn);
+
+ end_protect_partials ();
+
+ /* This is where the body of the constructor ends. */
+ expand_label (ctor_label);
+ ctor_label = NULL_TREE;
+
+ if (call_poplevel)
+ {
+ decls = getdecls ();
+ expand_end_bindings (decls, decls != NULL_TREE, 0);
+ poplevel (decls != NULL_TREE, 1, 0);
+ }
+
+ c_expand_return (current_class_decl);
+
+ current_function_assigns_this = 0;
+ current_function_just_assigned_this = 0;
+ }
+ else if (IDENTIFIER_LENGTH (DECL_NAME (fndecl)) == 4
+ && ! strcmp (IDENTIFIER_POINTER (DECL_NAME (fndecl)), "main")
+ && DECL_CONTEXT (fndecl) == NULL_TREE)
+ {
+ /* Make it so that `main' always returns 0 by default. */
+#ifdef VMS
+ c_expand_return (integer_one_node);
+#else
+ c_expand_return (integer_zero_node);
+#endif
+ }
+ else if (return_label != NULL_RTX
+ && current_function_return_value == NULL_TREE
+ && ! DECL_NAME (DECL_RESULT (current_function_decl)))
+ no_return_label = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
+
+ if (flag_gc)
+ expand_gc_prologue_and_epilogue ();
+
+ /* If this function is supposed to return a value, ensure that
+ we do not fall into the cleanups by mistake. The end of our
+ function will look like this:
+
+ user code (may have return stmt somewhere)
+ goto no_return_label
+ cleanup_label:
+ cleanups
+ goto return_label
+ no_return_label:
+ NOTE_INSN_FUNCTION_END
+ return_label:
+ things for return
+
+ If the user omits a return stmt in the USER CODE section, we
+ will have a control path which reaches NOTE_INSN_FUNCTION_END.
+ Otherwise, we won't. */
+ if (no_return_label)
+ {
+ DECL_CONTEXT (no_return_label) = fndecl;
+ DECL_INITIAL (no_return_label) = error_mark_node;
+ DECL_SOURCE_FILE (no_return_label) = input_filename;
+ DECL_SOURCE_LINE (no_return_label) = lineno;
+ expand_goto (no_return_label);
+ }
+
+ if (cleanup_label)
+ {
+ /* remove the binding contour which is used
+ to catch cleanup-generated temporaries. */
+ expand_end_bindings (0, 0, 0);
+ poplevel (0, 0, 0);
+ }
+
+ if (cleanup_label)
+ /* Emit label at beginning of cleanup code for parameters. */
+ emit_label (cleanup_label);
+
+ /* Get return value into register if that's where it's supposed to be. */
+ if (original_result_rtx)
+ fixup_result_decl (DECL_RESULT (fndecl), original_result_rtx);
+
+ /* Finish building code that will trigger warnings if users forget
+ to make their functions return values. */
+ if (no_return_label || cleanup_label)
+ emit_jump (return_label);
+ if (no_return_label)
+ {
+ /* We don't need to call `expand_*_return' here because we
+ don't need any cleanups here--this path of code is only
+ for error checking purposes. */
+ expand_label (no_return_label);
+ }
+
+ /* Generate rtl for function exit. */
+ expand_function_end (input_filename, lineno, 1);
+
+ if (flag_handle_exceptions)
+ expand_exception_blocks ();
+
+ /* This must come after expand_function_end because cleanups might
+ have declarations (from inline functions) that need to go into
+ this function's blocks. */
+ if (current_binding_level->parm_flag != 1)
+ my_friendly_abort (122);
+ poplevel (1, 0, 1);
+
+ /* reset scope for C++: if we were in the scope of a class,
+ then when we finish this function, we are not longer so.
+ This cannot be done until we know for sure that no more
+ class members will ever be referenced in this function
+ (i.e., calls to destructors). */
+ if (current_class_name)
+ {
+ ctype = current_class_type;
+ pop_nested_class (1);
+ }
+ else
+ pop_memoized_context (1);
+
+ /* Must mark the RESULT_DECL as being in this function. */
+ DECL_CONTEXT (DECL_RESULT (fndecl)) = DECL_INITIAL (fndecl);
+
+ /* Obey `register' declarations if `setjmp' is called in this fn. */
+ if (flag_traditional && current_function_calls_setjmp)
+ setjmp_protect (DECL_INITIAL (fndecl));
+
+ /* Set the BLOCK_SUPERCONTEXT of the outermost function scope to point
+ to the FUNCTION_DECL node itself. */
+ BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
+
+ /* So we can tell if jump_optimize sets it to 1. */
+ can_reach_end = 0;
+
+ /* Run the optimizers and output the assembler code for this function. */
+ rest_of_compilation (fndecl);
+
+ if (DECL_SAVED_INSNS (fndecl) && ! TREE_ASM_WRITTEN (fndecl))
+ {
+ /* Set DECL_EXTERNAL so that assemble_external will be called as
+ necessary. We'll clear it again in finish_file. */
+ if (! DECL_EXTERNAL (fndecl))
+ DECL_NOT_REALLY_EXTERN (fndecl) = 1;
+ DECL_EXTERNAL (fndecl) = 1;
+ mark_inline_for_output (fndecl);
+ }
+
+ if (ctype && TREE_ASM_WRITTEN (fndecl))
+ note_debug_info_needed (ctype);
+
+ current_function_returns_null |= can_reach_end;
+
+ /* Since we don't normally go through c_expand_return for constructors,
+ this normally gets the wrong value.
+ Also, named return values have their return codes emitted after
+ NOTE_INSN_FUNCTION_END, confusing jump.c. */
+ if (DECL_CONSTRUCTOR_P (fndecl)
+ || DECL_NAME (DECL_RESULT (fndecl)) != NULL_TREE)
+ current_function_returns_null = 0;
+
+ if (TREE_THIS_VOLATILE (fndecl) && current_function_returns_null)
+ cp_warning ("`noreturn' function `%D' does return", fndecl);
+ else if ((warn_return_type || pedantic)
+ && current_function_returns_null
+ && TYPE_MAIN_VARIANT (TREE_TYPE (fntype)) != void_type_node)
+ {
+ /* If this function returns non-void and control can drop through,
+ complain. */
+ cp_pedwarn ("control reaches end of non-void function `%D'", fndecl);
+ }
+ /* With just -W, complain only if function returns both with
+ and without a value. */
+ else if (extra_warnings
+ && current_function_returns_value && current_function_returns_null)
+ warning ("this function may return with or without a value");
+
+ /* Free all the tree nodes making up this function. */
+ /* Switch back to allocating nodes permanently
+ until we start another function. */
+ if (! nested)
+ permanent_allocation (1);
+
+ if (flag_cadillac)
+ cadillac_finish_function (fndecl);
+
+ if (DECL_SAVED_INSNS (fndecl) == NULL_RTX)
+ {
+ /* Stop pointing to the local nodes about to be freed. */
+ /* But DECL_INITIAL must remain nonzero so we know this
+ was an actual function definition. */
+ DECL_INITIAL (fndecl) = error_mark_node;
+ if (! DECL_CONSTRUCTOR_P (fndecl)
+ || !TYPE_USES_VIRTUAL_BASECLASSES (TYPE_METHOD_BASETYPE (fntype)))
+ DECL_ARGUMENTS (fndecl) = NULL_TREE;
+ }
+
+ if (DECL_STATIC_CONSTRUCTOR (fndecl))
+ static_ctors = perm_tree_cons (NULL_TREE, fndecl, static_ctors);
+ if (DECL_STATIC_DESTRUCTOR (fndecl))
+ static_dtors = perm_tree_cons (NULL_TREE, fndecl, static_dtors);
+
+ if (! nested)
+ {
+ /* Let the error reporting routines know that we're outside a
+ function. For a nested function, this value is used in
+ pop_cp_function_context and then reset via pop_function_context. */
+ current_function_decl = NULL_TREE;
+ }
+
+ named_label_uses = NULL_TREE;
+ current_class_decl = NULL_TREE;
+}
+
+/* Create the FUNCTION_DECL for a function definition.
+ LINE1 is the line number that the definition absolutely begins on.
+ LINE2 is the line number that the name of the function appears on.
+ DECLSPECS and DECLARATOR are the parts of the declaration;
+ they describe the return type and the name of the function,
+ but twisted together in a fashion that parallels the syntax of C.
+
+ This function creates a binding context for the function body
+ as well as setting up the FUNCTION_DECL in current_function_decl.
+
+ Returns a FUNCTION_DECL on success.
+
+ If the DECLARATOR is not suitable for a function (it defines a datum
+ instead), we return 0, which tells yyparse to report a parse error.
+
+ May return void_type_node indicating that this method is actually
+ a friend. See grokfield for more details.
+
+ Came here with a `.pushlevel' .
+
+ DO NOT MAKE ANY CHANGES TO THIS CODE WITHOUT MAKING CORRESPONDING
+ CHANGES TO CODE IN `grokfield'. */
+tree
+start_method (declspecs, declarator, raises)
+ tree declarator, declspecs, raises;
+{
+ tree fndecl = grokdeclarator (declarator, declspecs, MEMFUNCDEF, 0, raises,
+ NULL_TREE);
+
+ /* Something too ugly to handle. */
+ if (fndecl == NULL_TREE)
+ return NULL_TREE;
+
+ /* Pass friends other than inline friend functions back. */
+ if (TYPE_MAIN_VARIANT (fndecl) == void_type_node)
+ return fndecl;
+
+ if (TREE_CODE (fndecl) != FUNCTION_DECL)
+ /* Not a function, tell parser to report parse error. */
+ return NULL_TREE;
+
+ if (IS_SIGNATURE (current_class_type))
+ {
+ IS_DEFAULT_IMPLEMENTATION (fndecl) = 1;
+ /* In case we need this info later. */
+ HAS_DEFAULT_IMPLEMENTATION (current_class_type) = 1;
+ }
+
+ if (DECL_IN_AGGR_P (fndecl))
+ {
+ if (IDENTIFIER_ERROR_LOCUS (DECL_ASSEMBLER_NAME (fndecl)) != current_class_type)
+ {
+ if (DECL_CONTEXT (fndecl))
+ cp_error ("`%D' is already defined in class %s", fndecl,
+ TYPE_NAME_STRING (DECL_CONTEXT (fndecl)));
+ }
+ return void_type_node;
+ }
+
+ DECL_THIS_INLINE (fndecl) = 1;
+
+ if (flag_default_inline)
+ DECL_INLINE (fndecl) = 1;
+
+ if (processing_template_defn)
+ {
+ SET_DECL_IMPLICIT_INSTANTIATION (fndecl);
+ repo_template_used (fndecl);
+ }
+
+ /* We read in the parameters on the maybepermanent_obstack,
+ but we won't be getting back to them until after we
+ may have clobbered them. So the call to preserve_data
+ will keep them safe. */
+ preserve_data ();
+
+ if (! DECL_FRIEND_P (fndecl))
+ {
+ if (DECL_CHAIN (fndecl) != NULL_TREE)
+ {
+ /* Need a fresh node here so that we don't get circularity
+ when we link these together. If FNDECL was a friend, then
+ `pushdecl' does the right thing, which is nothing wrt its
+ current value of DECL_CHAIN. */
+ fndecl = copy_node (fndecl);
+ }
+ if (TREE_CHAIN (fndecl))
+ {
+ fndecl = copy_node (fndecl);
+ TREE_CHAIN (fndecl) = NULL_TREE;
+ }
+
+ if (DECL_CONSTRUCTOR_P (fndecl))
+ {
+ if (! grok_ctor_properties (current_class_type, fndecl))
+ return void_type_node;
+ }
+ else if (IDENTIFIER_OPNAME_P (DECL_NAME (fndecl)))
+ grok_op_properties (fndecl, DECL_VIRTUAL_P (fndecl), 0);
+ }
+
+ cp_finish_decl (fndecl, NULL_TREE, NULL_TREE, 0, 0);
+
+ /* Make a place for the parms */
+ pushlevel (0);
+ current_binding_level->parm_flag = 1;
+
+ DECL_IN_AGGR_P (fndecl) = 1;
+ return fndecl;
+}
+
+/* Go through the motions of finishing a function definition.
+ We don't compile this method until after the whole class has
+ been processed.
+
+ FINISH_METHOD must return something that looks as though it
+ came from GROKFIELD (since we are defining a method, after all).
+
+ This is called after parsing the body of the function definition.
+ STMTS is the chain of statements that makes up the function body.
+
+ DECL is the ..._DECL that `start_method' provided. */
+
+tree
+finish_method (decl)
+ tree decl;
+{
+ register tree fndecl = decl;
+ tree old_initial;
+
+ register tree link;
+
+ if (TYPE_MAIN_VARIANT (decl) == void_type_node)
+ return decl;
+
+ old_initial = DECL_INITIAL (fndecl);
+
+ /* Undo the level for the parms (from start_method).
+ This is like poplevel, but it causes nothing to be
+ saved. Saving information here confuses symbol-table
+ output routines. Besides, this information will
+ be correctly output when this method is actually
+ compiled. */
+
+ /* Clear out the meanings of the local variables of this level;
+ also record in each decl which block it belongs to. */
+
+ for (link = current_binding_level->names; link; link = TREE_CHAIN (link))
+ {
+ if (DECL_NAME (link) != NULL_TREE)
+ IDENTIFIER_LOCAL_VALUE (DECL_NAME (link)) = 0;
+ my_friendly_assert (TREE_CODE (link) != FUNCTION_DECL, 163);
+ DECL_CONTEXT (link) = NULL_TREE;
+ }
+
+ /* Restore all name-meanings of the outer levels
+ that were shadowed by this level. */
+
+ for (link = current_binding_level->shadowed; link; link = TREE_CHAIN (link))
+ IDENTIFIER_LOCAL_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
+ for (link = current_binding_level->class_shadowed;
+ link; link = TREE_CHAIN (link))
+ IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
+ for (link = current_binding_level->type_shadowed;
+ link; link = TREE_CHAIN (link))
+ IDENTIFIER_TYPE_VALUE (TREE_PURPOSE (link)) = TREE_VALUE (link);
+
+ GNU_xref_end_scope ((HOST_WIDE_INT) current_binding_level,
+ (HOST_WIDE_INT) current_binding_level->level_chain,
+ current_binding_level->parm_flag,
+ current_binding_level->keep,
+ current_binding_level->tag_transparent);
+
+ poplevel (0, 0, 0);
+
+ DECL_INITIAL (fndecl) = old_initial;
+
+ /* We used to check if the context of FNDECL was different from
+ current_class_type as another way to get inside here. This didn't work
+ for String.cc in libg++. */
+ if (DECL_FRIEND_P (fndecl))
+ {
+ CLASSTYPE_INLINE_FRIENDS (current_class_type)
+ = tree_cons (NULL_TREE, fndecl, CLASSTYPE_INLINE_FRIENDS (current_class_type));
+ decl = void_type_node;
+ }
+
+ return decl;
+}
+
+/* Called when a new struct TYPE is defined.
+ If this structure or union completes the type of any previous
+ variable declaration, lay it out and output its rtl. */
+
+void
+hack_incomplete_structures (type)
+ tree type;
+{
+ tree *list;
+
+ if (current_binding_level->incomplete == NULL_TREE)
+ return;
+
+ if (!type) /* Don't do this for class templates. */
+ return;
+
+ for (list = &current_binding_level->incomplete; *list; )
+ {
+ tree decl = TREE_VALUE (*list);
+ if (decl && TREE_TYPE (decl) == type
+ || (TREE_TYPE (decl)
+ && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
+ && TREE_TYPE (TREE_TYPE (decl)) == type))
+ {
+ int toplevel = toplevel_bindings_p ();
+ if (TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE
+ && TREE_TYPE (TREE_TYPE (decl)) == type)
+ layout_type (TREE_TYPE (decl));
+ layout_decl (decl, 0);
+ rest_of_decl_compilation (decl, NULL_PTR, toplevel, 0);
+ if (! toplevel)
+ {
+ tree cleanup;
+ expand_decl (decl);
+ cleanup = maybe_build_cleanup (decl);
+ expand_decl_init (decl);
+ if (! cp_expand_decl_cleanup (decl, cleanup))
+ cp_error ("parser lost in parsing declaration of `%D'",
+ decl);
+ }
+ *list = TREE_CHAIN (*list);
+ }
+ else
+ list = &TREE_CHAIN (*list);
+ }
+}
+
+/* Nonzero if presently building a cleanup. Needed because
+ SAVE_EXPRs are not the right things to use inside of cleanups.
+ They are only ever evaluated once, where the cleanup
+ might be evaluated several times. In this case, a later evaluation
+ of the cleanup might fill in the SAVE_EXPR_RTL, and it will
+ not be valid for an earlier cleanup. */
+
+int building_cleanup;
+
+/* If DECL is of a type which needs a cleanup, build that cleanup here.
+ We don't build cleanups if just going for syntax checking, since
+ fixup_cleanups does not know how to not handle them.
+
+ Don't build these on the momentary obstack; they must live
+ the life of the binding contour. */
+tree
+maybe_build_cleanup (decl)
+ tree decl;
+{
+ tree type = TREE_TYPE (decl);
+ if (TYPE_NEEDS_DESTRUCTOR (type))
+ {
+ int temp = 0, flags = LOOKUP_NORMAL|LOOKUP_DESTRUCTOR;
+ tree rval;
+ int old_building_cleanup = building_cleanup;
+ building_cleanup = 1;
+
+ if (TREE_CODE (decl) != PARM_DECL)
+ temp = suspend_momentary ();
+
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ rval = decl;
+ else
+ {
+ mark_addressable (decl);
+ rval = build_unary_op (ADDR_EXPR, decl, 0);
+ }
+
+ /* Optimize for space over speed here. */
+ if (! TYPE_USES_VIRTUAL_BASECLASSES (type)
+ || flag_expensive_optimizations)
+ flags |= LOOKUP_NONVIRTUAL;
+
+ rval = build_delete (TREE_TYPE (rval), rval, integer_two_node, flags, 0);
+
+ if (TYPE_USES_VIRTUAL_BASECLASSES (type)
+ && ! TYPE_HAS_DESTRUCTOR (type))
+ rval = build_compound_expr (tree_cons (NULL_TREE, rval,
+ build_tree_list (NULL_TREE, build_vbase_delete (type, decl))));
+
+ if (TREE_CODE (decl) != PARM_DECL)
+ resume_momentary (temp);
+
+ building_cleanup = old_building_cleanup;
+
+ return rval;
+ }
+ return 0;
+}
+
+/* Expand a C++ expression at the statement level.
+ This is needed to ferret out nodes which have UNKNOWN_TYPE.
+ The C++ type checker should get all of these out when
+ expressions are combined with other, type-providing, expressions,
+ leaving only orphan expressions, such as:
+
+ &class::bar; / / takes its address, but does nothing with it.
+
+ */
+void
+cplus_expand_expr_stmt (exp)
+ tree exp;
+{
+ if (TREE_TYPE (exp) == unknown_type_node)
+ {
+ if (TREE_CODE (exp) == ADDR_EXPR || TREE_CODE (exp) == TREE_LIST)
+ error ("address of overloaded function with no contextual type information");
+ else if (TREE_CODE (exp) == COMPONENT_REF)
+ warning ("useless reference to a member function name, did you forget the ()?");
+ }
+ else
+ {
+ int remove_implicit_immediately = 0;
+
+ if (TREE_CODE (exp) == FUNCTION_DECL)
+ {
+ cp_warning ("reference, not call, to function `%D'", exp);
+ warning ("at this point in file");
+ }
+
+#if 0
+ /* We should do this eventually, but right now this causes regex.o from
+ libg++ to miscompile, and tString to core dump. */
+ exp = build1 (CLEANUP_POINT_EXPR, TREE_TYPE (exp), exp);
+#endif
+ expand_expr_stmt (break_out_cleanups (exp));
+ }
+
+ /* Clean up any pending cleanups. This happens when a function call
+ returns a cleanup-needing value that nobody uses. */
+ expand_cleanups_to (NULL_TREE);
+}
+
+/* When a stmt has been parsed, this function is called.
+
+ Currently, this function only does something within a
+ constructor's scope: if a stmt has just assigned to this,
+ and we are in a derived class, we call `emit_base_init'. */
+
+void
+finish_stmt ()
+{
+ extern struct nesting *cond_stack, *loop_stack, *case_stack;
+
+
+ if (current_function_assigns_this
+ || ! current_function_just_assigned_this)
+ return;
+ if (DECL_CONSTRUCTOR_P (current_function_decl))
+ {
+ /* Constructors must wait until we are out of control
+ zones before calling base constructors. */
+ if (cond_stack || loop_stack || case_stack)
+ return;
+ expand_expr_stmt (base_init_expr);
+ check_base_init (current_class_type);
+ }
+ current_function_assigns_this = 1;
+
+ if (flag_cadillac)
+ cadillac_finish_stmt ();
+}
+
+/* Change a static member function definition into a FUNCTION_TYPE, instead
+ of the METHOD_TYPE that we create when it's originally parsed.
+
+ WARNING: DO NOT pass &TREE_TYPE (decl) to FN or &TYPE_ARG_TYPES
+ (TREE_TYPE (decl)) to ARGTYPES, as doing so will corrupt the types of
+ other decls. Either pass the addresses of local variables or NULL. */
+
+void
+revert_static_member_fn (decl, fn, argtypes)
+ tree *decl, *fn, *argtypes;
+{
+ tree tmp;
+ tree function = fn ? *fn : TREE_TYPE (*decl);
+ tree args = argtypes ? *argtypes : TYPE_ARG_TYPES (function);
+
+ if (TYPE_READONLY (TREE_TYPE (TREE_VALUE (args))))
+ cp_error ("static member function `%#D' declared const", *decl);
+ if (TYPE_VOLATILE (TREE_TYPE (TREE_VALUE (args))))
+ cp_error ("static member function `%#D' declared volatile", *decl);
+
+ args = TREE_CHAIN (args);
+ tmp = build_function_type (TREE_TYPE (function), args);
+ tmp = build_type_variant (tmp, TYPE_READONLY (function),
+ TYPE_VOLATILE (function));
+ tmp = build_exception_variant (tmp,
+ TYPE_RAISES_EXCEPTIONS (function));
+ TREE_TYPE (*decl) = tmp;
+ if (DECL_ARGUMENTS (*decl))
+ DECL_ARGUMENTS (*decl) = TREE_CHAIN (DECL_ARGUMENTS (*decl));
+ DECL_STATIC_FUNCTION_P (*decl) = 1;
+ if (fn)
+ *fn = tmp;
+ if (argtypes)
+ *argtypes = args;
+}
+
+int
+id_in_current_class (id)
+ tree id;
+{
+ return !!purpose_member (id, class_binding_level->class_shadowed);
+}
+
+struct cp_function
+{
+ int returns_value;
+ int returns_null;
+ int warn_about_return_type;
+ int assigns_this;
+ int just_assigned_this;
+ int parms_stored;
+ int temp_name_counter;
+ tree named_labels;
+ tree shadowed_labels;
+ tree ctor_label;
+ tree dtor_label;
+ tree protect_list;
+ tree base_init_list;
+ tree member_init_list;
+ tree base_init_expr;
+ tree class_decl;
+ tree C_C_D;
+ rtx result_rtx;
+ struct cp_function *next;
+ struct binding_level *binding_level;
+};
+
+struct cp_function *cp_function_chain;
+
+extern int temp_name_counter;
+
+/* Save and reinitialize the variables
+ used during compilation of a C++ function. */
+
+void
+push_cp_function_context (context)
+ tree context;
+{
+ struct cp_function *p
+ = (struct cp_function *) xmalloc (sizeof (struct cp_function));
+
+ push_function_context_to (context);
+
+ p->next = cp_function_chain;
+ cp_function_chain = p;
+
+ p->named_labels = named_labels;
+ p->shadowed_labels = shadowed_labels;
+ p->returns_value = current_function_returns_value;
+ p->returns_null = current_function_returns_null;
+ p->warn_about_return_type = warn_about_return_type;
+ p->binding_level = current_binding_level;
+ p->ctor_label = ctor_label;
+ p->dtor_label = dtor_label;
+ p->assigns_this = current_function_assigns_this;
+ p->just_assigned_this = current_function_just_assigned_this;
+ p->parms_stored = current_function_parms_stored;
+ p->result_rtx = original_result_rtx;
+ p->base_init_expr = base_init_expr;
+ p->protect_list = protect_list;
+ p->temp_name_counter = temp_name_counter;
+ p->base_init_list = current_base_init_list;
+ p->member_init_list = current_member_init_list;
+ p->class_decl = current_class_decl;
+ p->C_C_D = C_C_D;
+}
+
+/* Restore the variables used during compilation of a C++ function. */
+
+void
+pop_cp_function_context (context)
+ tree context;
+{
+ struct cp_function *p = cp_function_chain;
+ tree link;
+
+ /* Bring back all the labels that were shadowed. */
+ for (link = shadowed_labels; link; link = TREE_CHAIN (link))
+ if (DECL_NAME (TREE_VALUE (link)) != 0)
+ SET_IDENTIFIER_LABEL_VALUE (DECL_NAME (TREE_VALUE (link)),
+ TREE_VALUE (link));
+
+#if 0
+ if (DECL_SAVED_INSNS (current_function_decl) == 0)
+ {
+ /* Stop pointing to the local nodes about to be freed. */
+ /* But DECL_INITIAL must remain nonzero so we know this
+ was an actual function definition. */
+ DECL_INITIAL (current_function_decl) = error_mark_node;
+ DECL_ARGUMENTS (current_function_decl) = 0;
+ }
+#endif
+
+ pop_function_context_from (context);
+
+ cp_function_chain = p->next;
+
+ named_labels = p->named_labels;
+ shadowed_labels = p->shadowed_labels;
+ current_function_returns_value = p->returns_value;
+ current_function_returns_null = p->returns_null;
+ warn_about_return_type = p->warn_about_return_type;
+ current_binding_level = p->binding_level;
+ ctor_label = p->ctor_label;
+ dtor_label = p->dtor_label;
+ protect_list = p->protect_list;
+ current_function_assigns_this = p->assigns_this;
+ current_function_just_assigned_this = p->just_assigned_this;
+ current_function_parms_stored = p->parms_stored;
+ original_result_rtx = p->result_rtx;
+ base_init_expr = p->base_init_expr;
+ temp_name_counter = p->temp_name_counter;
+ current_base_init_list = p->base_init_list;
+ current_member_init_list = p->member_init_list;
+ current_class_decl = p->class_decl;
+ C_C_D = p->C_C_D;
+
+ free (p);
+}
+
+/* FSF LOCAL dje prefix attributes */
+/* Split SPECS_ATTRS, a list of declspecs and prefix attributes, into two
+ lists. SPECS_ATTRS may also be just a typespec (eg: RECORD_TYPE).
+
+ The head of the declspec list is stored in DECLSPECS.
+ The head of the attribute list is stored in PREFIX_ATTRIBUTES.
+
+ Note that attributes in SPECS_ATTRS are stored in the TREE_PURPOSE of
+ the list elements. We drop the containing TREE_LIST nodes and link the
+ resulting attributes together the way decl_attributes expects them. */
+
+void
+split_specs_attrs (specs_attrs, declspecs, prefix_attributes)
+ tree specs_attrs;
+ tree *declspecs, *prefix_attributes;
+{
+ tree t, s, a, next, specs, attrs;
+
+ /* This can happen in c++ (eg: decl: typespec initdecls ';'). */
+ if (specs_attrs != NULL_TREE
+ && TREE_CODE (specs_attrs) != TREE_LIST)
+ {
+ *declspecs = specs_attrs;
+ *prefix_attributes = NULL_TREE;
+ return;
+ }
+
+ /* Remember to keep the lists in the same order, element-wise. */
+
+ specs = s = NULL_TREE;
+ attrs = a = NULL_TREE;
+ for (t = specs_attrs; t; t = next)
+ {
+ next = TREE_CHAIN (t);
+ /* Declspecs have a non-NULL TREE_VALUE. */
+ if (TREE_VALUE (t) != NULL_TREE)
+ {
+ if (specs == NULL_TREE)
+ specs = s = t;
+ else
+ {
+ TREE_CHAIN (s) = t;
+ s = t;
+ }
+ }
+ else
+ {
+ if (attrs == NULL_TREE)
+ attrs = a = TREE_PURPOSE (t);
+ else
+ {
+ TREE_CHAIN (a) = TREE_PURPOSE (t);
+ a = TREE_PURPOSE (t);
+ }
+ }
+ }
+
+ /* Terminate the lists. */
+ if (s != NULL_TREE)
+ TREE_CHAIN (s) = NULL_TREE;
+ if (a != NULL_TREE)
+ TREE_CHAIN (a) = NULL_TREE;
+
+ /* All done. */
+ *declspecs = specs;
+ *prefix_attributes = attrs;
+}
+
+/* Strip attributes from SPECS_ATTRS, a list of declspecs and attributes.
+ This function is used by the parser when a rule will accept attributes
+ in a particular position, but we don't want to support that just yet.
+
+ A warning is issued for every ignored attribute. */
+
+tree
+strip_attrs (specs_attrs)
+ tree specs_attrs;
+{
+ tree specs, attrs;
+
+ split_specs_attrs (specs_attrs, &specs, &attrs);
+
+ while (attrs)
+ {
+ warning ("`%s' attribute ignored",
+ IDENTIFIER_POINTER (TREE_PURPOSE (attrs)));
+ attrs = TREE_CHAIN (attrs);
+ }
+
+ return specs;
+}
+/* END FSF LOCAL */
+
diff --git a/contrib/gcc/cp/decl.h b/contrib/gcc/cp/decl.h
new file mode 100644
index 0000000..0824c13
--- /dev/null
+++ b/contrib/gcc/cp/decl.h
@@ -0,0 +1,59 @@
+/* Variables and structures for declaration processing.
+ Copyright (C) 1993 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+/* In grokdeclarator, distinguish syntactic contexts of declarators. */
+enum decl_context
+{ NORMAL, /* Ordinary declaration */
+ FUNCDEF, /* Function definition */
+ PARM, /* Declaration of parm before function body */
+ CATCHPARM, /* Declaration of catch parm */
+ FIELD, /* Declaration inside struct or union */
+ BITFIELD, /* Likewise but with specified width */
+ TYPENAME, /* Typename (inside cast or sizeof) */
+ MEMFUNCDEF /* Member function definition */
+};
+
+/* We need this in here to get the decl_context definition. */
+extern tree grokdeclarator PROTO((tree, tree, enum decl_context, int, tree, tree));
+
+/* C++: Keep these around to reduce calls to `get_identifier'.
+ Identifiers for `this' in member functions and the auto-delete
+ parameter for destructors. */
+extern tree this_identifier, in_charge_identifier;
+
+/* Parsing a function declarator leaves a list of parameter names
+ or a chain or parameter decls here. */
+extern tree last_function_parms;
+
+/* A list of static class variables. This is needed, because a
+ static class variable can be declared inside the class without
+ an initializer, and then initialized, staticly, outside the class. */
+extern tree pending_statics;
+
+/* A list of objects which have constructors or destructors
+ which reside in the global scope. The decl is stored in
+ the TREE_VALUE slot and the initializer is stored
+ in the TREE_PURPOSE slot. */
+extern tree static_aggregates;
+
+#ifdef DEBUG_CP_BINDING_LEVELS
+/* Purely for debugging purposes. */
+extern int debug_bindings_indentation;
+#endif
diff --git a/contrib/gcc/cp/decl2.c b/contrib/gcc/cp/decl2.c
new file mode 100644
index 0000000..7a3f7d5
--- /dev/null
+++ b/contrib/gcc/cp/decl2.c
@@ -0,0 +1,3511 @@
+/* Process declarations and variables for C compiler.
+ Copyright (C) 1988, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+ Hacked by Michael Tiemann (tiemann@cygnus.com)
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+/* Process declarations and symbol lookup for C front end.
+ Also constructs types; the standard scalar types at initialization,
+ and structure, union, array and enum types when they are declared. */
+
+/* ??? not all decl nodes are given the most useful possible
+ line numbers. For example, the CONST_DECLs for enum values. */
+
+#include "config.h"
+#include <stdio.h>
+#include "tree.h"
+#include "rtl.h"
+#include "flags.h"
+#include "cp-tree.h"
+#include "decl.h"
+#include "lex.h"
+#include "output.h"
+#include "defaults.h"
+
+extern tree get_file_function_name ();
+extern tree cleanups_this_call;
+static void grok_function_init ();
+
+/* A list of virtual function tables we must make sure to write out. */
+tree pending_vtables;
+
+/* A list of static class variables. This is needed, because a
+ static class variable can be declared inside the class without
+ an initializer, and then initialized, staticly, outside the class. */
+tree pending_statics;
+
+/* A list of functions which were declared inline, but which we
+ may need to emit outline anyway. */
+static tree saved_inlines;
+
+/* Used to help generate temporary names which are unique within
+ a function. Reset to 0 by start_function. */
+
+int temp_name_counter;
+
+/* Same, but not reset. Local temp variables and global temp variables
+ can have the same name. */
+static int global_temp_name_counter;
+
+/* Flag used when debugging spew.c */
+
+extern int spew_debug;
+
+/* Functions called along with real static constructors and destructors. */
+
+tree static_ctors, static_dtors;
+
+/* C (and C++) language-specific option variables. */
+
+/* Nonzero means allow type mismatches in conditional expressions;
+ just make their values `void'. */
+
+int flag_cond_mismatch;
+
+/* Nonzero means give `double' the same size as `float'. */
+
+int flag_short_double;
+
+/* Nonzero means don't recognize the keyword `asm'. */
+
+int flag_no_asm;
+
+/* Nonzero means don't recognize any extension keywords. */
+
+int flag_no_gnu_keywords;
+
+/* Nonzero means don't recognize the non-ANSI builtin functions. */
+
+int flag_no_builtin;
+
+/* Nonzero means don't recognize the non-ANSI builtin functions.
+ -ansi sets this. */
+
+int flag_no_nonansi_builtin;
+
+/* Nonzero means do some things the same way PCC does. */
+
+int flag_traditional;
+
+/* Nonzero means to treat bitfields as unsigned unless they say `signed'. */
+
+int flag_signed_bitfields = 1;
+
+/* Nonzero means handle `#ident' directives. 0 means ignore them. */
+
+int flag_no_ident;
+
+/* Nonzero means enable obscure ANSI features and disable GNU extensions
+ that might cause ANSI-compliant code to be miscompiled. */
+
+int flag_ansi;
+
+/* Nonzero means do emit exported implementations of functions even if
+ they can be inlined. */
+
+int flag_implement_inlines = 1;
+
+/* Nonzero means do emit exported implementations of templates, instead of
+ multiple static copies in each file that needs a definition. */
+
+int flag_external_templates;
+
+/* Nonzero means that the decision to emit or not emit the implementation of a
+ template depends on where the template is instantiated, rather than where
+ it is defined. */
+
+int flag_alt_external_templates;
+
+/* Nonzero means that implicit instantiations will be emitted if needed. */
+
+int flag_implicit_templates = 1;
+
+/* Nonzero means warn about implicit declarations. */
+
+int warn_implicit = 1;
+
+/* Nonzero means warn when all ctors or dtors are private, and the class
+ has no friends. */
+
+int warn_ctor_dtor_privacy = 1;
+
+/* True if we want to implement vtbvales using "thunks".
+ The default is off now, but will be on later. */
+
+int flag_vtable_thunks;
+
+/* True if we want to deal with repository information. */
+
+int flag_use_repository;
+
+/* Nonzero means give string constants the type `const char *'
+ to get extra warnings from them. These warnings will be too numerous
+ to be useful, except in thoroughly ANSIfied programs. */
+
+int warn_write_strings;
+
+/* Nonzero means warn about pointer casts that can drop a type qualifier
+ from the pointer target type. */
+
+int warn_cast_qual;
+
+/* Nonzero means warn that dbx info for template class methods isn't fully
+ supported yet. */
+
+int warn_template_debugging;
+
+/* Warn about traditional constructs whose meanings changed in ANSI C. */
+
+int warn_traditional;
+
+/* Nonzero means warn about sizeof(function) or addition/subtraction
+ of function pointers. */
+
+int warn_pointer_arith;
+
+/* Nonzero means warn for non-prototype function decls
+ or non-prototyped defs without previous prototype. */
+
+int warn_strict_prototypes;
+
+/* Nonzero means warn for any function def without prototype decl. */
+
+int warn_missing_prototypes;
+
+/* Nonzero means warn about multiple (redundant) decls for the same single
+ variable or function. */
+
+int warn_redundant_decls;
+
+/* Warn if initializer is not completely bracketed. */
+
+int warn_missing_braces;
+
+/* Warn about *printf or *scanf format/argument anomalies. */
+
+int warn_format;
+
+/* Warn about a subscript that has type char. */
+
+int warn_char_subscripts;
+
+/* Warn if a type conversion is done that might have confusing results. */
+
+int warn_conversion;
+
+/* Warn if adding () is suggested. */
+
+int warn_parentheses;
+
+/* Non-zero means warn in function declared in derived class has the
+ same name as a virtual in the base class, but fails to match the
+ type signature of any virtual function in the base class. */
+int warn_overloaded_virtual;
+
+/* Non-zero means warn when declaring a class that has a non virtual
+ destructor, when it really ought to have a virtual one. */
+int warn_nonvdtor;
+
+/* Non-zero means warn when a function is declared extern and later inline. */
+int warn_extern_inline;
+
+/* Non-zero means warn when the compiler will reorder code. */
+int warn_reorder;
+
+/* Non-zero means warn when synthesis behavior differs from Cfront's. */
+int warn_synth;
+
+/* Nonzero means `$' can be in an identifier.
+ See cccp.c for reasons why this breaks some obscure ANSI C programs. */
+
+#ifndef DOLLARS_IN_IDENTIFIERS
+#define DOLLARS_IN_IDENTIFIERS 1
+#endif
+int dollars_in_ident = DOLLARS_IN_IDENTIFIERS;
+
+/* Nonzero for -fno-strict-prototype switch: do not consider empty
+ argument prototype to mean function takes no arguments. */
+
+int flag_strict_prototype = 2;
+int strict_prototype = 1;
+int strict_prototypes_lang_c, strict_prototypes_lang_cplusplus = 1;
+
+/* Nonzero means that labels can be used as first-class objects */
+
+int flag_labels_ok;
+
+/* Non-zero means to collect statistics which might be expensive
+ and to print them when we are done. */
+int flag_detailed_statistics;
+
+/* C++ specific flags. */
+/* Nonzero for -fall-virtual: make every member function (except
+ constructors) lay down in the virtual function table. Calls
+ can then either go through the virtual function table or not,
+ depending. */
+
+int flag_all_virtual;
+
+/* Zero means that `this' is a *const. This gives nice behavior in the
+ 2.0 world. 1 gives 1.2-compatible behavior. 2 gives Spring behavior.
+ -2 means we're constructing an object and it has fixed type. */
+
+int flag_this_is_variable;
+
+/* Nonzero means memoize our member lookups. */
+
+int flag_memoize_lookups; int flag_save_memoized_contexts;
+
+/* 3 means write out only virtuals function tables `defined'
+ in this implementation file.
+ 2 means write out only specific virtual function tables
+ and give them (C) public access.
+ 1 means write out virtual function tables and give them
+ (C) public access.
+ 0 means write out virtual function tables and give them
+ (C) static access (default).
+ -1 means declare virtual function tables extern. */
+
+int write_virtuals;
+
+/* Nonzero means we should attempt to elide constructors when possible. */
+
+int flag_elide_constructors;
+
+/* Nonzero means recognize and handle exception handling constructs.
+ Use ansi syntax and semantics. WORK IN PROGRESS! */
+
+int flag_handle_exceptions;
+
+/* Nonzero means recognize and handle signature language constructs. */
+
+int flag_handle_signatures;
+
+/* Nonzero means that member functions defined in class scope are
+ inline by default. */
+
+int flag_default_inline = 1;
+
+/* Controls whether enums and ints freely convert.
+ 1 means with complete freedom.
+ 0 means enums can convert to ints, but not vice-versa. */
+int flag_int_enum_equivalence;
+
+/* Controls whether compiler is operating under LUCID's Cadillac
+ system. 1 means yes, 0 means no. */
+int flag_cadillac;
+
+/* Controls whether compiler generates code to build objects
+ that can be collected when they become garbage. */
+int flag_gc;
+
+/* Controls whether compiler generates 'type descriptor' that give
+ run-time type information. */
+int flag_rtti;
+
+/* Nonzero if we wish to output cross-referencing information
+ for the GNU class browser. */
+extern int flag_gnu_xref;
+
+/* Nonzero if compiler can make `reasonable' assumptions about
+ references and objects. For example, the compiler must be
+ conservative about the following and not assume that `a' is nonnull:
+
+ obj &a = g ();
+ a.f (2);
+
+ In general, it is `reasonable' to assume that for many programs,
+ and better code can be generated in that case. */
+
+int flag_assume_nonnull_objects = 1;
+
+/* Nonzero if we want to support huge (> 2^(sizeof(short)*8-1) bytes)
+ objects. */
+
+int flag_huge_objects;
+
+/* Nonzero if we want to conserve space in the .o files. We do this
+ by putting uninitialized data and runtime initialized data into
+ .common instead of .data at the expense of not flagging multiple
+ definitions. */
+
+int flag_conserve_space;
+
+/* Nonzero if we want to obey access control semantics. */
+
+int flag_access_control = 1;
+
+/* Nonzero if we want to understand the operator names, i.e. 'bitand'. */
+
+int flag_operator_names;
+
+/* Nonzero if we want to check the return value of new and avoid calling
+ constructors if it is a null pointer. */
+
+int flag_check_new;
+
+/* Nonzero if we want the new ANSI rules for pushing a new scope for `for'
+ initialization variables.
+ 0: Old rules, set by -fno-for-scope.
+ 2: New ANSI rules, set by -ffor-scope.
+ 1: Try to implement new ANSI rules, but with backup compatibility
+ (and warnings). This is the default, for now. */
+
+int flag_new_for_scope = 1;
+
+/* Table of language-dependent -f options.
+ STRING is the option name. VARIABLE is the address of the variable.
+ ON_VALUE is the value to store in VARIABLE
+ if `-fSTRING' is seen as an option.
+ (If `-fno-STRING' is seen as an option, the opposite value is stored.) */
+
+static struct { char *string; int *variable; int on_value;} lang_f_options[] =
+{
+ {"signed-char", &flag_signed_char, 1},
+ {"unsigned-char", &flag_signed_char, 0},
+ {"signed-bitfields", &flag_signed_bitfields, 1},
+ {"unsigned-bitfields", &flag_signed_bitfields, 0},
+ {"short-enums", &flag_short_enums, 1},
+ {"short-double", &flag_short_double, 1},
+ {"cond-mismatch", &flag_cond_mismatch, 1},
+ {"asm", &flag_no_asm, 0},
+ {"builtin", &flag_no_builtin, 0},
+ {"ident", &flag_no_ident, 0},
+ {"labels-ok", &flag_labels_ok, 1},
+ {"stats", &flag_detailed_statistics, 1},
+ {"this-is-variable", &flag_this_is_variable, 1},
+ {"strict-prototype", &flag_strict_prototype, 1},
+ {"all-virtual", &flag_all_virtual, 1},
+ {"memoize-lookups", &flag_memoize_lookups, 1},
+ {"elide-constructors", &flag_elide_constructors, 1},
+ {"handle-exceptions", &flag_handle_exceptions, 1},
+ {"handle-signatures", &flag_handle_signatures, 1},
+ {"default-inline", &flag_default_inline, 1},
+ {"dollars-in-identifiers", &dollars_in_ident, 1},
+ {"enum-int-equiv", &flag_int_enum_equivalence, 1},
+ {"gc", &flag_gc, 1},
+ {"rtti", &flag_rtti, 1},
+ {"xref", &flag_gnu_xref, 1},
+ {"nonnull-objects", &flag_assume_nonnull_objects, 1},
+ {"implement-inlines", &flag_implement_inlines, 1},
+ {"external-templates", &flag_external_templates, 1},
+ {"implicit-templates", &flag_implicit_templates, 1},
+ {"huge-objects", &flag_huge_objects, 1},
+ {"conserve-space", &flag_conserve_space, 1},
+ {"vtable-thunks", &flag_vtable_thunks, 1},
+ {"short-temps", &flag_short_temps, 1},
+ {"access-control", &flag_access_control, 1},
+ {"nonansi-builtins", &flag_no_nonansi_builtin, 0},
+ {"gnu-keywords", &flag_no_gnu_keywords, 0},
+ {"operator-names", &flag_operator_names, 1},
+ {"check-new", &flag_check_new, 1},
+ {"repo", &flag_use_repository, 1},
+ {"for-scope", &flag_new_for_scope, 2}
+};
+
+/* Decode the string P as a language-specific option.
+ Return 1 if it is recognized (and handle it);
+ return 0 if not recognized. */
+
+int
+lang_decode_option (p)
+ char *p;
+{
+ if (!strcmp (p, "-ftraditional") || !strcmp (p, "-traditional"))
+ flag_traditional = 1, dollars_in_ident = 1, flag_writable_strings = 1,
+ flag_this_is_variable = 1, flag_new_for_scope = 0;
+ /* The +e options are for cfront compatibility. They come in as
+ `-+eN', to kludge around gcc.c's argument handling. */
+ else if (p[0] == '-' && p[1] == '+' && p[2] == 'e')
+ {
+ int old_write_virtuals = write_virtuals;
+ if (p[3] == '1')
+ write_virtuals = 1;
+ else if (p[3] == '0')
+ write_virtuals = -1;
+ else if (p[3] == '2')
+ write_virtuals = 2;
+ else error ("invalid +e option");
+ if (old_write_virtuals != 0
+ && write_virtuals != old_write_virtuals)
+ error ("conflicting +e options given");
+ }
+ else if (p[0] == '-' && p[1] == 'f')
+ {
+ /* Some kind of -f option.
+ P's value is the option sans `-f'.
+ Search for it in the table of options. */
+ int found = 0, j;
+
+ p += 2;
+ /* Try special -f options. */
+
+ if (!strcmp (p, "save-memoized"))
+ {
+ flag_memoize_lookups = 1;
+ flag_save_memoized_contexts = 1;
+ found = 1;
+ }
+ if (!strcmp (p, "no-save-memoized"))
+ {
+ flag_memoize_lookups = 0;
+ flag_save_memoized_contexts = 0;
+ found = 1;
+ }
+ else if (! strncmp (p, "cadillac", 8))
+ {
+ flag_cadillac = atoi (p+9);
+ found = 1;
+ }
+ else if (! strncmp (p, "no-cadillac", 11))
+ {
+ flag_cadillac = 0;
+ found = 1;
+ }
+ else if (! strcmp (p, "gc"))
+ {
+ flag_gc = 1;
+ /* This must come along for the ride. */
+ flag_rtti = 1;
+ found = 1;
+ }
+ else if (! strcmp (p, "no-gc"))
+ {
+ flag_gc = 0;
+ /* This must come along for the ride. */
+ flag_rtti = 0;
+ found = 1;
+ }
+ else if (! strcmp (p, "alt-external-templates"))
+ {
+ flag_external_templates = 1;
+ flag_alt_external_templates = 1;
+ found = 1;
+ }
+ else if (! strcmp (p, "no-alt-external-templates"))
+ {
+ flag_alt_external_templates = 0;
+ found = 1;
+ }
+ else if (!strcmp (p, "ansi-overloading"))
+ {
+ warning ("-fansi-overloading is no longer meaningful");
+ found = 1;
+ }
+ else if (!strcmp (p, "repo"))
+ {
+ flag_use_repository = 1;
+ flag_implicit_templates = 0;
+ found = 1;
+ }
+ else for (j = 0;
+ !found && j < sizeof (lang_f_options) / sizeof (lang_f_options[0]);
+ j++)
+ {
+ if (!strcmp (p, lang_f_options[j].string))
+ {
+ *lang_f_options[j].variable = lang_f_options[j].on_value;
+ /* A goto here would be cleaner,
+ but breaks the vax pcc. */
+ found = 1;
+ }
+ if (p[0] == 'n' && p[1] == 'o' && p[2] == '-'
+ && ! strcmp (p+3, lang_f_options[j].string))
+ {
+ *lang_f_options[j].variable = ! lang_f_options[j].on_value;
+ found = 1;
+ }
+ }
+ return found;
+ }
+ else if (p[0] == '-' && p[1] == 'W')
+ {
+ int setting = 1;
+
+ /* The -W options control the warning behavior of the compiler. */
+ p += 2;
+
+ if (p[0] == 'n' && p[1] == 'o' && p[2] == '-')
+ setting = 0, p += 3;
+
+ if (!strcmp (p, "implicit"))
+ warn_implicit = setting;
+ else if (!strcmp (p, "return-type"))
+ warn_return_type = setting;
+ else if (!strcmp (p, "ctor-dtor-privacy"))
+ warn_ctor_dtor_privacy = setting;
+ else if (!strcmp (p, "write-strings"))
+ warn_write_strings = setting;
+ else if (!strcmp (p, "cast-qual"))
+ warn_cast_qual = setting;
+ else if (!strcmp (p, "traditional"))
+ warn_traditional = setting;
+ else if (!strcmp (p, "char-subscripts"))
+ warn_char_subscripts = setting;
+ else if (!strcmp (p, "pointer-arith"))
+ warn_pointer_arith = setting;
+ else if (!strcmp (p, "strict-prototypes"))
+ warn_strict_prototypes = setting;
+ else if (!strcmp (p, "missing-prototypes"))
+ warn_missing_prototypes = setting;
+ else if (!strcmp (p, "redundant-decls"))
+ warn_redundant_decls = setting;
+ else if (!strcmp (p, "missing-braces"))
+ warn_missing_braces = setting;
+ else if (!strcmp (p, "format"))
+ warn_format = setting;
+ else if (!strcmp (p, "conversion"))
+ warn_conversion = setting;
+ else if (!strcmp (p, "parentheses"))
+ warn_parentheses = setting;
+ else if (!strcmp (p, "non-virtual-dtor"))
+ warn_nonvdtor = setting;
+ else if (!strcmp (p, "extern-inline"))
+ warn_extern_inline = setting;
+ else if (!strcmp (p, "reorder"))
+ warn_reorder = setting;
+ else if (!strcmp (p, "synth"))
+ warn_synth = setting;
+ else if (!strcmp (p, "comment"))
+ ; /* cpp handles this one. */
+ else if (!strcmp (p, "comments"))
+ ; /* cpp handles this one. */
+ else if (!strcmp (p, "trigraphs"))
+ ; /* cpp handles this one. */
+ else if (!strcmp (p, "import"))
+ ; /* cpp handles this one. */
+ else if (!strcmp (p, "all"))
+ {
+ extra_warnings = setting;
+ warn_return_type = setting;
+ warn_unused = setting;
+ warn_implicit = setting;
+ warn_ctor_dtor_privacy = setting;
+ warn_switch = setting;
+ warn_format = setting;
+ warn_parentheses = setting;
+ warn_missing_braces = setting;
+ warn_extern_inline = setting;
+ warn_nonvdtor = setting;
+ /* We save the value of warn_uninitialized, since if they put
+ -Wuninitialized on the command line, we need to generate a
+ warning about not using it without also specifying -O. */
+ if (warn_uninitialized != 1)
+ warn_uninitialized = (setting ? 2 : 0);
+ warn_template_debugging = setting;
+ warn_reorder = setting;
+ }
+
+ else if (!strcmp (p, "overloaded-virtual"))
+ warn_overloaded_virtual = setting;
+ else return 0;
+ }
+ else if (!strcmp (p, "-ansi"))
+ dollars_in_ident = 0, flag_no_nonansi_builtin = 1, flag_ansi = 1,
+ flag_no_gnu_keywords = 1, flag_operator_names = 1;
+#ifdef SPEW_DEBUG
+ /* Undocumented, only ever used when you're invoking cc1plus by hand, since
+ it's probably safe to assume no sane person would ever want to use this
+ under normal circumstances. */
+ else if (!strcmp (p, "-spew-debug"))
+ spew_debug = 1;
+#endif
+ else
+ return 0;
+
+ return 1;
+}
+
+/* Incorporate `const' and `volatile' qualifiers for member functions.
+ FUNCTION is a TYPE_DECL or a FUNCTION_DECL.
+ QUALS is a list of qualifiers. */
+tree
+grok_method_quals (ctype, function, quals)
+ tree ctype, function, quals;
+{
+ tree fntype = TREE_TYPE (function);
+ tree raises = TYPE_RAISES_EXCEPTIONS (fntype);
+
+ do
+ {
+ extern tree ridpointers[];
+
+ if (TREE_VALUE (quals) == ridpointers[(int)RID_CONST])
+ {
+ if (TYPE_READONLY (ctype))
+ error ("duplicate `%s' %s",
+ IDENTIFIER_POINTER (TREE_VALUE (quals)),
+ (TREE_CODE (function) == FUNCTION_DECL
+ ? "for member function" : "in type declaration"));
+ ctype = build_type_variant (ctype, 1, TYPE_VOLATILE (ctype));
+ build_pointer_type (ctype);
+ }
+ else if (TREE_VALUE (quals) == ridpointers[(int)RID_VOLATILE])
+ {
+ if (TYPE_VOLATILE (ctype))
+ error ("duplicate `%s' %s",
+ IDENTIFIER_POINTER (TREE_VALUE (quals)),
+ (TREE_CODE (function) == FUNCTION_DECL
+ ? "for member function" : "in type declaration"));
+ ctype = build_type_variant (ctype, TYPE_READONLY (ctype), 1);
+ build_pointer_type (ctype);
+ }
+ else
+ my_friendly_abort (20);
+ quals = TREE_CHAIN (quals);
+ }
+ while (quals);
+ fntype = build_cplus_method_type (ctype, TREE_TYPE (fntype),
+ (TREE_CODE (fntype) == METHOD_TYPE
+ ? TREE_CHAIN (TYPE_ARG_TYPES (fntype))
+ : TYPE_ARG_TYPES (fntype)));
+ if (raises)
+ fntype = build_exception_variant (fntype, raises);
+
+ TREE_TYPE (function) = fntype;
+ return ctype;
+}
+
+#if 0 /* Not used. */
+/* This routine replaces cryptic DECL_NAMEs with readable DECL_NAMEs.
+ It leaves DECL_ASSEMBLER_NAMEs with the correct value. */
+/* This does not yet work with user defined conversion operators
+ It should. */
+static void
+substitute_nice_name (decl)
+ tree decl;
+{
+ if (DECL_NAME (decl) && TREE_CODE (DECL_NAME (decl)) == IDENTIFIER_NODE)
+ {
+ char *n = decl_as_string (DECL_NAME (decl), 1);
+ if (n[strlen (n) - 1] == ' ')
+ n[strlen (n) - 1] = 0;
+ DECL_NAME (decl) = get_identifier (n);
+ }
+}
+#endif
+
+/* Warn when -fexternal-templates is used and #pragma
+ interface/implementation is not used all the times it should be,
+ inform the user. */
+void
+warn_if_unknown_interface (decl)
+ tree decl;
+{
+ static int already_warned = 0;
+ if (already_warned++)
+ return;
+
+ if (flag_alt_external_templates)
+ {
+ struct tinst_level *til = tinst_for_decl ();
+ int sl = lineno;
+ char *sf = input_filename;
+
+ if (til)
+ {
+ lineno = til->line;
+ input_filename = til->file;
+ }
+ cp_warning ("template `%#D' instantiated in file without #pragma interface",
+ decl);
+ lineno = sl;
+ input_filename = sf;
+ }
+ else
+ cp_warning_at ("template `%#D' defined in file without #pragma interface",
+ decl);
+}
+
+/* A subroutine of the parser, to handle a component list. */
+tree
+grok_x_components (specs, components)
+ tree specs, components;
+{
+ register tree t, x, tcode;
+
+ /* We just got some friends. They have been recorded elsewhere. */
+ if (components == void_type_node)
+ return NULL_TREE;
+
+ if (components == NULL_TREE)
+ {
+ t = groktypename (build_decl_list (specs, NULL_TREE));
+
+ if (t == NULL_TREE)
+ {
+ error ("error in component specification");
+ return NULL_TREE;
+ }
+
+ switch (TREE_CODE (t))
+ {
+ case VAR_DECL:
+ /* Static anonymous unions come out as VAR_DECLs. */
+ if (TREE_CODE (TREE_TYPE (t)) == UNION_TYPE
+ && ANON_AGGRNAME_P (TYPE_IDENTIFIER (TREE_TYPE (t))))
+ return t;
+
+ /* We return SPECS here, because in the parser it was ending
+ up with not doing anything to $$, which is what SPECS
+ represents. */
+ return specs;
+ break;
+
+ case RECORD_TYPE:
+ /* This code may be needed for UNION_TYPEs as
+ well. */
+ tcode = record_type_node;
+ if (CLASSTYPE_DECLARED_CLASS(t))
+ tcode = class_type_node;
+ else if (IS_SIGNATURE(t))
+ tcode = signature_type_node;
+
+ t = xref_tag (tcode, TYPE_IDENTIFIER (t), NULL_TREE, 0);
+ if (TYPE_CONTEXT(t))
+ CLASSTYPE_NO_GLOBALIZE(t) = 1;
+ return NULL_TREE;
+ break;
+
+ case UNION_TYPE:
+ case ENUMERAL_TYPE:
+ if (TREE_CODE(t) == UNION_TYPE)
+ tcode = union_type_node;
+ else
+ tcode = enum_type_node;
+
+ t = xref_tag (tcode, TYPE_IDENTIFIER (t), NULL_TREE, 0);
+ if (TREE_CODE(t) == UNION_TYPE && TYPE_CONTEXT(t))
+ CLASSTYPE_NO_GLOBALIZE(t) = 1;
+ if (TREE_CODE (t) == UNION_TYPE
+ && ANON_AGGRNAME_P (TYPE_IDENTIFIER (t)))
+ {
+ struct pending_inline **p;
+ x = build_lang_field_decl (FIELD_DECL, NULL_TREE, t);
+
+ /* Wipe out memory of synthesized methods */
+ TYPE_HAS_CONSTRUCTOR (t) = 0;
+ TYPE_HAS_DEFAULT_CONSTRUCTOR (t) = 0;
+ TYPE_HAS_INIT_REF (t) = 0;
+ TYPE_HAS_CONST_INIT_REF (t) = 0;
+ TYPE_HAS_ASSIGN_REF (t) = 0;
+ TYPE_HAS_ASSIGNMENT (t) = 0;
+ TYPE_HAS_CONST_ASSIGN_REF (t) = 0;
+
+ p = &pending_inlines;
+ for (; *p; *p = (*p)->next)
+ if (DECL_CONTEXT ((*p)->fndecl) != t)
+ break;
+ }
+ else if (TREE_CODE (t) == ENUMERAL_TYPE)
+ x = grok_enum_decls (t, NULL_TREE);
+ else
+ x = NULL_TREE;
+ return x;
+ break;
+
+ default:
+ if (t != void_type_node)
+ error ("empty component declaration");
+ return NULL_TREE;
+ }
+ }
+ else
+ {
+ t = TREE_TYPE (components);
+ if (TREE_CODE (t) == ENUMERAL_TYPE && TREE_NONLOCAL_FLAG (t))
+ return grok_enum_decls (t, components);
+ else
+ return components;
+ }
+}
+
+/* Classes overload their constituent function names automatically.
+ When a function name is declared in a record structure,
+ its name is changed to it overloaded name. Since names for
+ constructors and destructors can conflict, we place a leading
+ '$' for destructors.
+
+ CNAME is the name of the class we are grokking for.
+
+ FUNCTION is a FUNCTION_DECL. It was created by `grokdeclarator'.
+
+ FLAGS contains bits saying what's special about today's
+ arguments. 1 == DESTRUCTOR. 2 == OPERATOR.
+
+ If FUNCTION is a destructor, then we must add the `auto-delete' field
+ as a second parameter. There is some hair associated with the fact
+ that we must "declare" this variable in the manner consistent with the
+ way the rest of the arguments were declared.
+
+ QUALS are the qualifiers for the this pointer. */
+
+void
+grokclassfn (ctype, cname, function, flags, quals)
+ tree ctype, cname, function;
+ enum overload_flags flags;
+ tree quals;
+{
+ tree fn_name = DECL_NAME (function);
+ tree arg_types;
+ tree parm;
+ tree qualtype;
+ tree fntype = TREE_TYPE (function);
+ tree raises = TYPE_RAISES_EXCEPTIONS (fntype);
+
+ if (fn_name == NULL_TREE)
+ {
+ error ("name missing for member function");
+ fn_name = get_identifier ("<anonymous>");
+ DECL_NAME (function) = fn_name;
+ }
+
+ if (quals)
+ qualtype = grok_method_quals (ctype, function, quals);
+ else
+ qualtype = ctype;
+
+ arg_types = TYPE_ARG_TYPES (TREE_TYPE (function));
+ if (TREE_CODE (TREE_TYPE (function)) == METHOD_TYPE)
+ {
+ /* Must add the class instance variable up front. */
+ /* Right now we just make this a pointer. But later
+ we may wish to make it special. */
+ tree type = TREE_VALUE (arg_types);
+ int constp = 1;
+
+ if ((flag_this_is_variable > 0)
+ && (flags == DTOR_FLAG || DECL_CONSTRUCTOR_P (function)))
+ constp = 0;
+
+ if (DECL_CONSTRUCTOR_P (function))
+ {
+ if (TYPE_USES_VIRTUAL_BASECLASSES (ctype))
+ {
+ DECL_CONSTRUCTOR_FOR_VBASE_P (function) = 1;
+ /* In this case we need "in-charge" flag saying whether
+ this constructor is responsible for initialization
+ of virtual baseclasses or not. */
+ parm = build_decl (PARM_DECL, in_charge_identifier, integer_type_node);
+ /* Mark the artificial `__in_chrg' parameter as "artificial". */
+ SET_DECL_ARTIFICIAL (parm);
+ DECL_ARG_TYPE (parm) = integer_type_node;
+ DECL_REGISTER (parm) = 1;
+ TREE_CHAIN (parm) = last_function_parms;
+ last_function_parms = parm;
+ }
+ }
+
+ parm = build_decl (PARM_DECL, this_identifier, type);
+ /* Mark the artificial `this' parameter as "artificial". */
+ SET_DECL_ARTIFICIAL (parm);
+ DECL_ARG_TYPE (parm) = type;
+ /* We can make this a register, so long as we don't
+ accidentally complain if someone tries to take its address. */
+ DECL_REGISTER (parm) = 1;
+ if (constp)
+ TREE_READONLY (parm) = 1;
+ TREE_CHAIN (parm) = last_function_parms;
+ last_function_parms = parm;
+ }
+
+ if (flags == DTOR_FLAG)
+ {
+ char *buf, *dbuf;
+ tree const_integer_type = build_type_variant (integer_type_node, 1, 0);
+ int len = sizeof (DESTRUCTOR_DECL_PREFIX)-1;
+
+ arg_types = hash_tree_chain (const_integer_type, void_list_node);
+ TREE_SIDE_EFFECTS (arg_types) = 1;
+ /* Build the overload name. It will look like `7Example'. */
+ if (IDENTIFIER_TYPE_VALUE (cname))
+ dbuf = build_overload_name (IDENTIFIER_TYPE_VALUE (cname), 1, 1);
+ else if (IDENTIFIER_LOCAL_VALUE (cname))
+ dbuf = build_overload_name (TREE_TYPE (IDENTIFIER_LOCAL_VALUE (cname)), 1, 1);
+ else
+ /* Using ctype fixes the `X::Y::~Y()' crash. The cname has no type when
+ it's defined out of the class definition, since poplevel_class wipes
+ it out. This used to be internal error 346. */
+ dbuf = build_overload_name (ctype, 1, 1);
+ buf = (char *) alloca (strlen (dbuf) + sizeof (DESTRUCTOR_DECL_PREFIX));
+ bcopy (DESTRUCTOR_DECL_PREFIX, buf, len);
+ buf[len] = '\0';
+ strcat (buf, dbuf);
+ DECL_ASSEMBLER_NAME (function) = get_identifier (buf);
+ parm = build_decl (PARM_DECL, in_charge_identifier, const_integer_type);
+ /* Mark the artificial `__in_chrg' parameter as "artificial". */
+ SET_DECL_ARTIFICIAL (parm);
+ TREE_USED (parm) = 1;
+#if 0
+ /* We don't need to mark the __in_chrg parameter itself as `const'
+ since its type is already `const int'. In fact we MUST NOT mark
+ it as `const' cuz that will screw up the debug info (causing it
+ to say that the type of __in_chrg is `const const int'). */
+ TREE_READONLY (parm) = 1;
+#endif
+ DECL_ARG_TYPE (parm) = const_integer_type;
+ /* This is the same chain as DECL_ARGUMENTS (...). */
+ TREE_CHAIN (last_function_parms) = parm;
+
+ fntype = build_cplus_method_type (qualtype, void_type_node,
+ arg_types);
+ if (raises)
+ {
+ fntype = build_exception_variant (fntype, raises);
+ }
+ TREE_TYPE (function) = fntype;
+ TYPE_HAS_DESTRUCTOR (ctype) = 1;
+ }
+ else
+ {
+ tree these_arg_types;
+
+ if (DECL_CONSTRUCTOR_FOR_VBASE_P (function))
+ {
+ arg_types = hash_tree_chain (integer_type_node,
+ TREE_CHAIN (arg_types));
+ fntype = build_cplus_method_type (qualtype,
+ TREE_TYPE (TREE_TYPE (function)),
+ arg_types);
+ if (raises)
+ {
+ fntype = build_exception_variant (fntype, raises);
+ }
+ TREE_TYPE (function) = fntype;
+ arg_types = TYPE_ARG_TYPES (TREE_TYPE (function));
+ }
+
+ these_arg_types = arg_types;
+
+ if (TREE_CODE (TREE_TYPE (function)) == FUNCTION_TYPE)
+ /* Only true for static member functions. */
+ these_arg_types = hash_tree_chain (build_pointer_type (qualtype),
+ arg_types);
+
+ DECL_ASSEMBLER_NAME (function)
+ = build_decl_overload (fn_name, these_arg_types,
+ 1 + DECL_CONSTRUCTOR_P (function));
+
+#if 0
+ /* This code is going into the compiler, but currently, it makes
+ libg++/src/Integer.cc not compile. The problem is that the nice name
+ winds up going into the symbol table, and conversion operations look
+ for the manged name. */
+ substitute_nice_name (function);
+#endif
+ }
+
+ DECL_ARGUMENTS (function) = last_function_parms;
+ /* First approximations. */
+ DECL_CONTEXT (function) = ctype;
+ DECL_CLASS_CONTEXT (function) = ctype;
+}
+
+/* Work on the expr used by alignof (this is only called by the parser). */
+tree
+grok_alignof (expr)
+ tree expr;
+{
+ tree best, t;
+ int bestalign;
+
+ if (TREE_CODE (expr) == COMPONENT_REF
+ && DECL_BIT_FIELD (TREE_OPERAND (expr, 1)))
+ error ("`__alignof__' applied to a bit-field");
+
+ if (TREE_CODE (expr) == INDIRECT_REF)
+ {
+ best = t = TREE_OPERAND (expr, 0);
+ bestalign = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (t)));
+
+ while (TREE_CODE (t) == NOP_EXPR
+ && TREE_CODE (TREE_TYPE (TREE_OPERAND (t, 0))) == POINTER_TYPE)
+ {
+ int thisalign;
+ t = TREE_OPERAND (t, 0);
+ thisalign = TYPE_ALIGN (TREE_TYPE (TREE_TYPE (t)));
+ if (thisalign > bestalign)
+ best = t, bestalign = thisalign;
+ }
+ return c_alignof (TREE_TYPE (TREE_TYPE (best)));
+ }
+ else
+ {
+ /* ANSI says arrays and fns are converted inside comma.
+ But we can't convert them in build_compound_expr
+ because that would break commas in lvalues.
+ So do the conversion here if operand was a comma. */
+ if (TREE_CODE (expr) == COMPOUND_EXPR
+ && (TREE_CODE (TREE_TYPE (expr)) == ARRAY_TYPE
+ || TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE))
+ expr = default_conversion (expr);
+ return c_alignof (TREE_TYPE (expr));
+ }
+}
+
+/* Create an ARRAY_REF, checking for the user doing things backwards
+ along the way. */
+tree
+grok_array_decl (array_expr, index_exp)
+ tree array_expr, index_exp;
+{
+ tree type = TREE_TYPE (array_expr);
+ tree p1, p2, i1, i2;
+
+ if (type == error_mark_node || index_exp == error_mark_node)
+ return error_mark_node;
+ if (type == NULL_TREE)
+ {
+ /* Something has gone very wrong. Assume we are mistakenly reducing
+ an expression instead of a declaration. */
+ error ("parser may be lost: is there a '{' missing somewhere?");
+ return NULL_TREE;
+ }
+
+ if (TREE_CODE (type) == OFFSET_TYPE
+ || TREE_CODE (type) == REFERENCE_TYPE)
+ type = TREE_TYPE (type);
+
+ /* If they have an `operator[]', use that. */
+ if (TYPE_LANG_SPECIFIC (type)
+ && TYPE_OVERLOADS_ARRAY_REF (type))
+ return build_opfncall (ARRAY_REF, LOOKUP_NORMAL,
+ array_expr, index_exp, NULL_TREE);
+
+ /* Otherwise, create an ARRAY_REF for a pointer or array type. */
+
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ p1 = array_expr;
+ else
+ p1 = build_expr_type_conversion (WANT_POINTER, array_expr, 0);
+
+ if (TREE_CODE (TREE_TYPE (index_exp)) == ARRAY_TYPE)
+ p2 = index_exp;
+ else
+ p2 = build_expr_type_conversion (WANT_POINTER, index_exp, 0);
+
+ i1 = build_expr_type_conversion (WANT_INT | WANT_ENUM, array_expr, 0);
+ i2 = build_expr_type_conversion (WANT_INT | WANT_ENUM, index_exp, 0);
+
+ if ((p1 && i2) && (i1 && p2))
+ error ("ambiguous conversion for array subscript");
+
+ if (p1 && i2)
+ array_expr = p1, index_exp = i2;
+ else if (i1 && p2)
+ array_expr = p2, index_exp = i1;
+ else
+ {
+ cp_error ("invalid types `%T[%T]' for array subscript",
+ type, TREE_TYPE (index_exp));
+ return error_mark_node;
+ }
+
+ if (array_expr == error_mark_node || index_exp == error_mark_node)
+ error ("ambiguous conversion for array subscript");
+
+ return build_array_ref (array_expr, index_exp);
+}
+
+/* Given the cast expression EXP, checking out its validity. Either return
+ an error_mark_node if there was an unavoidable error, return a cast to
+ void for trying to delete a pointer w/ the value 0, or return the
+ call to delete. If DOING_VEC is 1, we handle things differently
+ for doing an array delete. If DOING_VEC is 2, they gave us the
+ array size as an argument to delete.
+ Implements ARM $5.3.4. This is called from the parser. */
+tree
+delete_sanity (exp, size, doing_vec, use_global_delete)
+ tree exp, size;
+ int doing_vec, use_global_delete;
+{
+ tree t = stabilize_reference (convert_from_reference (exp));
+ tree type = TREE_TYPE (t);
+ enum tree_code code = TREE_CODE (type);
+ /* For a regular vector delete (aka, no size argument) we will pass
+ this down as a NULL_TREE into build_vec_delete. */
+ tree maxindex = NULL_TREE;
+ /* This is used for deleting arrays. */
+ tree elt_size;
+
+ switch (doing_vec)
+ {
+ case 2:
+ maxindex = build_binary_op (MINUS_EXPR, size, integer_one_node, 1);
+ if (! flag_traditional)
+ pedwarn ("anachronistic use of array size in vector delete");
+ /* Fall through. */
+ case 1:
+ elt_size = c_sizeof (type);
+ break;
+ default:
+ if (code != POINTER_TYPE)
+ {
+ cp_error ("type `%#T' argument given to `delete', expected pointer",
+ type);
+ return error_mark_node;
+ }
+
+ /* Deleting a pointer with the value zero is valid and has no effect. */
+ if (integer_zerop (t))
+ return build1 (NOP_EXPR, void_type_node, t);
+ }
+
+ if (code == POINTER_TYPE)
+ {
+#if 0
+ /* As of Valley Forge, you can delete a pointer to constant. */
+ /* You can't delete a pointer to constant. */
+ if (TREE_READONLY (TREE_TYPE (type)))
+ {
+ error ("`const *' cannot be deleted");
+ return error_mark_node;
+ }
+#endif
+ /* You also can't delete functions. */
+ if (TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE)
+ {
+ error ("cannot delete a function");
+ return error_mark_node;
+ }
+ }
+
+#if 0
+ /* If the type has no destructor, then we should build a regular
+ delete, instead of a vector delete. Otherwise, we would end
+ up passing a bogus offset into __builtin_delete, which is
+ not expecting it. */
+ if (doing_vec
+ && TREE_CODE (type) == POINTER_TYPE
+ && !TYPE_HAS_DESTRUCTOR (TREE_TYPE (type)))
+ {
+ doing_vec = 0;
+ use_global_delete = 1;
+ }
+#endif
+
+ if (doing_vec)
+ return build_vec_delete (t, maxindex, elt_size, integer_one_node,
+ integer_two_node, use_global_delete);
+ else
+ {
+ if (IS_AGGR_TYPE (TREE_TYPE (type))
+ && TYPE_GETS_REG_DELETE (TREE_TYPE (type)))
+ {
+ /* Only do access checking here; we'll be calling op delete
+ from the destructor. */
+ tree tmp = build_opfncall (DELETE_EXPR, LOOKUP_NORMAL, t,
+ size_zero_node, NULL_TREE);
+ if (tmp == error_mark_node)
+ return error_mark_node;
+ }
+
+ return build_delete (type, t, integer_three_node,
+ LOOKUP_NORMAL|LOOKUP_HAS_IN_CHARGE,
+ use_global_delete);
+ }
+}
+
+/* Sanity check: report error if this function FUNCTION is not
+ really a member of the class (CTYPE) it is supposed to belong to.
+ CNAME is the same here as it is for grokclassfn above. */
+
+tree
+check_classfn (ctype, cname, function)
+ tree ctype, cname, function;
+{
+ tree fn_name = DECL_NAME (function);
+ tree fndecl;
+ tree method_vec = CLASSTYPE_METHOD_VEC (ctype);
+ tree *methods = 0;
+ tree *end = 0;
+
+ if (method_vec != 0)
+ {
+ methods = &TREE_VEC_ELT (method_vec, 0);
+ end = TREE_VEC_END (method_vec);
+
+ /* First suss out ctors and dtors. */
+ if (*methods && fn_name == DECL_NAME (*methods))
+ goto got_it;
+
+ while (++methods != end)
+ {
+ if (fn_name == DECL_NAME (*methods))
+ {
+ got_it:
+ fndecl = *methods;
+ while (fndecl)
+ {
+ if (DECL_ASSEMBLER_NAME (function) == DECL_ASSEMBLER_NAME (fndecl))
+ return fndecl;
+#if 0
+ /* This should work, but causes libg++ to fail
+ make check-tFix. */
+ /* We have to do more extensive argument checking here, as
+ the name may have been changed by asm("new_name"). */
+ if (decls_match (function, fndecl))
+ return fndecl;
+#else
+ if (DECL_NAME (function) == DECL_NAME (fndecl))
+ {
+ tree p1 = TYPE_ARG_TYPES (TREE_TYPE (function));
+ tree p2 = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
+
+ /* Get rid of the this parameter on functions that become
+ static. */
+ if (DECL_STATIC_FUNCTION_P (fndecl)
+ && TREE_CODE (TREE_TYPE (function)) == METHOD_TYPE)
+ p1 = TREE_CHAIN (p1);
+
+ if (comptypes (TREE_TYPE (TREE_TYPE (function)),
+ TREE_TYPE (TREE_TYPE (fndecl)), 1)
+ && compparms (p1, p2, 3))
+ {
+ if (DECL_STATIC_FUNCTION_P (fndecl)
+ && TREE_CODE (TREE_TYPE (function)) == METHOD_TYPE)
+ revert_static_member_fn (&function, NULL, NULL);
+ return fndecl;
+ }
+ }
+#endif
+ fndecl = DECL_CHAIN (fndecl);
+ }
+ break; /* loser */
+ }
+ }
+ }
+
+ if (methods != end)
+ {
+ tree fndecl = *methods;
+ cp_error ("prototype for `%#D' does not match any in class `%T'",
+ function, ctype);
+ cp_error_at ("candidate%s: %+#D", DECL_CHAIN (fndecl) ? "s are" : " is",
+ fndecl);
+ while (fndecl = DECL_CHAIN (fndecl), fndecl)
+ cp_error_at (" %#D", fndecl);
+ }
+ else
+ {
+ methods = 0;
+ cp_error ("no `%#D' member function declared in class `%T'",
+ function, ctype);
+ }
+
+ /* If we did not find the method in the class, add it to
+ avoid spurious errors. */
+ add_method (ctype, methods, function);
+ return NULL_TREE;
+}
+
+/* Process the specs, declarator (NULL if omitted) and width (NULL if omitted)
+ of a structure component, returning a FIELD_DECL node.
+ QUALS is a list of type qualifiers for this decl (such as for declaring
+ const member functions).
+
+ This is done during the parsing of the struct declaration.
+ The FIELD_DECL nodes are chained together and the lot of them
+ are ultimately passed to `build_struct' to make the RECORD_TYPE node.
+
+ C++:
+
+ If class A defines that certain functions in class B are friends, then
+ the way I have set things up, it is B who is interested in permission
+ granted by A. However, it is in A's context that these declarations
+ are parsed. By returning a void_type_node, class A does not attempt
+ to incorporate the declarations of the friends within its structure.
+
+ DO NOT MAKE ANY CHANGES TO THIS CODE WITHOUT MAKING CORRESPONDING
+ CHANGES TO CODE IN `start_method'. */
+
+tree
+grokfield (declarator, declspecs, raises, init, asmspec_tree, attrlist)
+ tree declarator, declspecs, raises, init, asmspec_tree, attrlist;
+{
+ register tree value;
+ char *asmspec = 0;
+ int flags = LOOKUP_ONLYCONVERTING;
+
+ /* Convert () initializers to = initializers. */
+ if (init == NULL_TREE && declarator != NULL_TREE
+ && TREE_CODE (declarator) == CALL_EXPR
+ && TREE_OPERAND (declarator, 0)
+ && (TREE_CODE (TREE_OPERAND (declarator, 0)) == IDENTIFIER_NODE
+ || TREE_CODE (TREE_OPERAND (declarator, 0)) == SCOPE_REF)
+ && parmlist_is_exprlist (TREE_OPERAND (declarator, 1)))
+ {
+ init = TREE_OPERAND (declarator, 1);
+ declarator = TREE_OPERAND (declarator, 0);
+ flags = 0;
+ }
+
+ if (init
+ && TREE_CODE (init) == TREE_LIST
+ && TREE_VALUE (init) == error_mark_node
+ && TREE_CHAIN (init) == NULL_TREE)
+ init = NULL_TREE;
+
+ value = grokdeclarator (declarator, declspecs, FIELD, init != 0,
+ raises, attrlist);
+ if (! value)
+ return value; /* friend or constructor went bad. */
+
+ /* Pass friendly classes back. */
+ if (TREE_CODE (value) == VOID_TYPE)
+ return void_type_node;
+
+ if (DECL_NAME (value) != NULL_TREE
+ && IDENTIFIER_POINTER (DECL_NAME (value))[0] == '_'
+ && ! strcmp (IDENTIFIER_POINTER (DECL_NAME (value)), "_vptr"))
+ cp_error ("member `%D' conflicts with virtual function table field name", value);
+
+ /* Stash away type declarations. */
+ if (TREE_CODE (value) == TYPE_DECL)
+ {
+ DECL_NONLOCAL (value) = 1;
+ DECL_CONTEXT (value) = current_class_type;
+ DECL_CLASS_CONTEXT (value) = current_class_type;
+ CLASSTYPE_LOCAL_TYPEDECLS (current_class_type) = 1;
+
+ /* If we declare a typedef name for something that has no name,
+ the typedef name is used for linkage. See 7.1.3 p4 94/0158. */
+ if (TYPE_NAME (TREE_TYPE (value))
+ && TREE_CODE (TYPE_NAME (TREE_TYPE (value))) == TYPE_DECL
+ && ANON_AGGRNAME_P (TYPE_IDENTIFIER (TREE_TYPE (value))))
+ {
+ TYPE_NAME (TREE_TYPE (value)) = value;
+ TYPE_STUB_DECL (TREE_TYPE (value)) = value;
+ }
+
+ pushdecl_class_level (value);
+ return value;
+ }
+
+ if (IS_SIGNATURE (current_class_type)
+ && TREE_CODE (value) != FUNCTION_DECL)
+ {
+ error ("field declaration not allowed in signature");
+ return void_type_node;
+ }
+
+ if (DECL_IN_AGGR_P (value))
+ {
+ cp_error ("`%D' is already defined in the class %T", value,
+ DECL_CONTEXT (value));
+ return void_type_node;
+ }
+
+ if (flag_cadillac)
+ cadillac_start_decl (value);
+
+ if (asmspec_tree)
+ asmspec = TREE_STRING_POINTER (asmspec_tree);
+
+ if (init)
+ {
+ if (IS_SIGNATURE (current_class_type)
+ && TREE_CODE (value) == FUNCTION_DECL)
+ {
+ error ("function declarations cannot have initializers in signature");
+ init = NULL_TREE;
+ }
+ else if (TREE_CODE (value) == FUNCTION_DECL)
+ {
+ grok_function_init (value, init);
+ init = NULL_TREE;
+ }
+ else if (pedantic && TREE_CODE (value) != VAR_DECL)
+ /* Already complained in grokdeclarator. */
+ init = NULL_TREE;
+ else
+ {
+ /* We allow initializers to become parameters to base
+ initializers. */
+ if (TREE_CODE (init) == TREE_LIST)
+ {
+ if (TREE_CHAIN (init) == NULL_TREE)
+ init = TREE_VALUE (init);
+ else
+ init = digest_init (TREE_TYPE (value), init, (tree *)0);
+ }
+
+ if (TREE_CODE (init) == CONST_DECL)
+ init = DECL_INITIAL (init);
+ else if (TREE_READONLY_DECL_P (init))
+ init = decl_constant_value (init);
+ else if (TREE_CODE (init) == CONSTRUCTOR)
+ init = digest_init (TREE_TYPE (value), init, (tree *)0);
+ my_friendly_assert (TREE_PERMANENT (init), 192);
+ if (init == error_mark_node)
+ /* We must make this look different than `error_mark_node'
+ because `decl_const_value' would mis-interpret it
+ as only meaning that this VAR_DECL is defined. */
+ init = build1 (NOP_EXPR, TREE_TYPE (value), init);
+ else if (! TREE_CONSTANT (init))
+ {
+ /* We can allow references to things that are effectively
+ static, since references are initialized with the address. */
+ if (TREE_CODE (TREE_TYPE (value)) != REFERENCE_TYPE
+ || (TREE_STATIC (init) == 0
+ && (TREE_CODE_CLASS (TREE_CODE (init)) != 'd'
+ || DECL_EXTERNAL (init) == 0)))
+ {
+ error ("field initializer is not constant");
+ init = error_mark_node;
+ }
+ }
+ }
+ }
+
+ /* The corresponding pop_obstacks is in cp_finish_decl. */
+ push_obstacks_nochange ();
+
+ if (TREE_CODE (value) == VAR_DECL)
+ {
+ /* We cannot call pushdecl here, because that would
+ fill in the value of our TREE_CHAIN. Instead, we
+ modify cp_finish_decl to do the right thing, namely, to
+ put this decl out straight away. */
+ if (TREE_PUBLIC (value))
+ {
+ /* current_class_type can be NULL_TREE in case of error. */
+ if (asmspec == 0 && current_class_type)
+ {
+ TREE_PUBLIC (value) = 1;
+ DECL_INITIAL (value) = error_mark_node;
+ DECL_ASSEMBLER_NAME (value)
+ = build_static_name (current_class_type, DECL_NAME (value));
+ }
+ pending_statics = perm_tree_cons (NULL_TREE, value, pending_statics);
+
+ /* Static consts need not be initialized in the class definition. */
+ if (init != NULL_TREE && TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (value)))
+ {
+ static int explanation = 0;
+
+ error ("initializer invalid for static member with constructor");
+ if (explanation++ == 0)
+ error ("(you really want to initialize it separately)");
+ init = 0;
+ }
+ /* Force the compiler to know when an uninitialized static
+ const member is being used. */
+ if (TYPE_READONLY (value) && init == 0)
+ TREE_USED (value) = 1;
+ }
+ DECL_INITIAL (value) = init;
+ DECL_IN_AGGR_P (value) = 1;
+
+ cp_finish_decl (value, init, asmspec_tree, 1, flags);
+ pushdecl_class_level (value);
+ return value;
+ }
+ if (TREE_CODE (value) == FIELD_DECL)
+ {
+ if (asmspec)
+ {
+ /* This must override the asm specifier which was placed
+ by grokclassfn. Lay this out fresh. */
+ DECL_RTL (value) = NULL_RTX;
+ DECL_ASSEMBLER_NAME (value) = get_identifier (asmspec);
+ }
+ if (DECL_INITIAL (value) == error_mark_node)
+ init = error_mark_node;
+ cp_finish_decl (value, init, asmspec_tree, 1, flags);
+ DECL_INITIAL (value) = init;
+ DECL_IN_AGGR_P (value) = 1;
+ return value;
+ }
+ if (TREE_CODE (value) == FUNCTION_DECL)
+ {
+ check_default_args (value);
+ if (DECL_CHAIN (value) != NULL_TREE)
+ {
+ /* Need a fresh node here so that we don't get circularity
+ when we link these together. */
+ value = copy_node (value);
+ /* When does this happen? */
+ my_friendly_assert (init == NULL_TREE, 193);
+ }
+ if (asmspec)
+ {
+ /* This must override the asm specifier which was placed
+ by grokclassfn. Lay this out fresh. */
+ DECL_RTL (value) = NULL_RTX;
+ DECL_ASSEMBLER_NAME (value) = get_identifier (asmspec);
+ }
+ cp_finish_decl (value, init, asmspec_tree, 1, flags);
+
+ /* Pass friends back this way. */
+ if (DECL_FRIEND_P (value))
+ return void_type_node;
+
+#if 0 /* Just because a fn is declared doesn't mean we'll try to define it. */
+ if (current_function_decl && ! IS_SIGNATURE (current_class_type))
+ cp_error ("method `%#D' of local class must be defined in class body",
+ value);
+#endif
+
+ DECL_IN_AGGR_P (value) = 1;
+ return value;
+ }
+ my_friendly_abort (21);
+ /* NOTREACHED */
+ return NULL_TREE;
+}
+
+/* Like `grokfield', but for bitfields.
+ WIDTH is non-NULL for bit fields only, and is an INTEGER_CST node. */
+
+tree
+grokbitfield (declarator, declspecs, width)
+ tree declarator, declspecs, width;
+{
+ register tree value = grokdeclarator (declarator, declspecs, BITFIELD,
+ 0, NULL_TREE, NULL_TREE);
+
+ if (! value) return NULL_TREE; /* friends went bad. */
+
+ /* Pass friendly classes back. */
+ if (TREE_CODE (value) == VOID_TYPE)
+ return void_type_node;
+
+ if (TREE_CODE (value) == TYPE_DECL)
+ {
+ cp_error ("cannot declare `%D' to be a bitfield type", value);
+ return NULL_TREE;
+ }
+
+ if (IS_SIGNATURE (current_class_type))
+ {
+ error ("field declaration not allowed in signature");
+ return void_type_node;
+ }
+
+ if (DECL_IN_AGGR_P (value))
+ {
+ cp_error ("`%D' is already defined in the class %T", value,
+ DECL_CONTEXT (value));
+ return void_type_node;
+ }
+
+ GNU_xref_member (current_class_name, value);
+
+ if (TREE_STATIC (value))
+ {
+ cp_error ("static member `%D' cannot be a bitfield", value);
+ return NULL_TREE;
+ }
+ cp_finish_decl (value, NULL_TREE, NULL_TREE, 0, 0);
+
+ if (width != error_mark_node)
+ {
+ /* detect invalid field size. */
+ if (TREE_CODE (width) == CONST_DECL)
+ width = DECL_INITIAL (width);
+ else if (TREE_READONLY_DECL_P (width))
+ width = decl_constant_value (width);
+ if (TREE_CODE (width) != INTEGER_CST)
+ {
+ cp_error ("structure field `%D' width not an integer constant",
+ value);
+ DECL_INITIAL (value) = NULL_TREE;
+ }
+ else
+ {
+ constant_expression_warning (width);
+ DECL_INITIAL (value) = width;
+ DECL_BIT_FIELD (value) = 1;
+ }
+ }
+
+ DECL_IN_AGGR_P (value) = 1;
+ return value;
+}
+
+#if 0
+/* Like GROKFIELD, except that the declarator has been
+ buried in DECLSPECS. Find the declarator, and
+ return something that looks like it came from
+ GROKFIELD. */
+tree
+groktypefield (declspecs, parmlist)
+ tree declspecs;
+ tree parmlist;
+{
+ tree spec = declspecs;
+ tree prev = NULL_TREE;
+
+ tree type_id = NULL_TREE;
+ tree quals = NULL_TREE;
+ tree lengths = NULL_TREE;
+ tree decl = NULL_TREE;
+
+ while (spec)
+ {
+ register tree id = TREE_VALUE (spec);
+
+ if (TREE_CODE (spec) != TREE_LIST)
+ /* Certain parse errors slip through. For example,
+ `int class ();' is not caught by the parser. Try
+ weakly to recover here. */
+ return NULL_TREE;
+
+ if (TREE_CODE (id) == TYPE_DECL
+ || (TREE_CODE (id) == IDENTIFIER_NODE && TREE_TYPE (id)))
+ {
+ /* We have a constructor/destructor or
+ conversion operator. Use it. */
+ if (prev)
+ TREE_CHAIN (prev) = TREE_CHAIN (spec);
+ else
+ declspecs = TREE_CHAIN (spec);
+
+ type_id = id;
+ goto found;
+ }
+ prev = spec;
+ spec = TREE_CHAIN (spec);
+ }
+
+ /* Nope, we have a conversion operator to a scalar type or something
+ else, that includes things like constructor declarations for
+ templates. */
+ spec = declspecs;
+ while (spec)
+ {
+ tree id = TREE_VALUE (spec);
+
+ if (TREE_CODE (id) == IDENTIFIER_NODE)
+ {
+ if (id == ridpointers[(int)RID_INT]
+ || id == ridpointers[(int)RID_DOUBLE]
+ || id == ridpointers[(int)RID_FLOAT]
+ || id == ridpointers[(int)RID_WCHAR])
+ {
+ if (type_id)
+ error ("extra `%s' ignored",
+ IDENTIFIER_POINTER (id));
+ else
+ type_id = id;
+ }
+ else if (id == ridpointers[(int)RID_LONG]
+ || id == ridpointers[(int)RID_SHORT]
+ || id == ridpointers[(int)RID_CHAR])
+ {
+ lengths = tree_cons (NULL_TREE, id, lengths);
+ }
+ else if (id == ridpointers[(int)RID_VOID])
+ {
+ if (type_id)
+ error ("spurious `void' type ignored");
+ else
+ error ("conversion to `void' type invalid");
+ }
+ else if (id == ridpointers[(int)RID_AUTO]
+ || id == ridpointers[(int)RID_REGISTER]
+ || id == ridpointers[(int)RID_TYPEDEF]
+ || id == ridpointers[(int)RID_CONST]
+ || id == ridpointers[(int)RID_VOLATILE])
+ {
+ error ("type specifier `%s' used invalidly",
+ IDENTIFIER_POINTER (id));
+ }
+ else if (id == ridpointers[(int)RID_FRIEND]
+ || id == ridpointers[(int)RID_VIRTUAL]
+ || id == ridpointers[(int)RID_INLINE]
+ || id == ridpointers[(int)RID_UNSIGNED]
+ || id == ridpointers[(int)RID_SIGNED]
+ || id == ridpointers[(int)RID_STATIC]
+ || id == ridpointers[(int)RID_EXTERN])
+ {
+ quals = tree_cons (NULL_TREE, id, quals);
+ }
+ else
+ {
+ /* Happens when we have a global typedef
+ and a class-local member function with
+ the same name. */
+ type_id = id;
+ goto found;
+ }
+ }
+ else if (TREE_CODE (id) == RECORD_TYPE)
+ {
+ type_id = TYPE_NAME (id);
+ if (TREE_CODE (type_id) == TYPE_DECL)
+ type_id = DECL_NAME (type_id);
+ if (type_id == NULL_TREE)
+ error ("identifier for aggregate type conversion omitted");
+ }
+ else if (TREE_CODE_CLASS (TREE_CODE (id)) == 't')
+ error ("`operator' missing on conversion operator or tag missing from type");
+ else
+ my_friendly_abort (194);
+ spec = TREE_CHAIN (spec);
+ }
+
+ if (type_id)
+ declspecs = chainon (lengths, quals);
+ else if (lengths)
+ {
+ if (TREE_CHAIN (lengths))
+ error ("multiple length specifiers");
+ type_id = ridpointers[(int)RID_INT];
+ declspecs = chainon (lengths, quals);
+ }
+ else if (quals)
+ {
+ error ("no type given, defaulting to `operator int ...'");
+ type_id = ridpointers[(int)RID_INT];
+ declspecs = quals;
+ }
+ else
+ return NULL_TREE;
+
+ found:
+ decl = grokdeclarator (build_parse_node (CALL_EXPR, type_id, parmlist, NULL_TREE),
+ declspecs, FIELD, 0, NULL_TREE, NULL_TREE);
+ if (decl == NULL_TREE)
+ return NULL_TREE;
+
+ if (TREE_CODE (decl) == FUNCTION_DECL && DECL_CHAIN (decl) != NULL_TREE)
+ {
+ /* Need a fresh node here so that we don't get circularity
+ when we link these together. */
+ decl = copy_node (decl);
+ }
+
+ if (decl == void_type_node
+ || (TREE_CODE (decl) == FUNCTION_DECL
+ && TREE_CODE (TREE_TYPE (decl)) != METHOD_TYPE))
+ /* bunch of friends. */
+ return decl;
+
+ if (DECL_IN_AGGR_P (decl))
+ {
+ cp_error ("`%D' already defined in the class ", decl);
+ return void_type_node;
+ }
+
+ cp_finish_decl (decl, NULL_TREE, NULL_TREE, 0, 0);
+
+ /* If this declaration is common to another declaration
+ complain about such redundancy, and return NULL_TREE
+ so that we don't build a circular list. */
+ if (DECL_CHAIN (decl))
+ {
+ cp_error ("function `%D' declared twice in class %T", decl,
+ DECL_CONTEXT (decl));
+ return NULL_TREE;
+ }
+ DECL_IN_AGGR_P (decl) = 1;
+ return decl;
+}
+#endif
+
+tree
+grokoptypename (declspecs, declarator)
+ tree declspecs, declarator;
+{
+ tree t = grokdeclarator (declarator, declspecs, TYPENAME, 0,
+ NULL_TREE, NULL_TREE);
+ return build_typename_overload (t);
+}
+
+/* When a function is declared with an initializer,
+ do the right thing. Currently, there are two possibilities:
+
+ class B
+ {
+ public:
+ // initialization possibility #1.
+ virtual void f () = 0;
+ int g ();
+ };
+
+ class D1 : B
+ {
+ public:
+ int d1;
+ // error, no f ();
+ };
+
+ class D2 : B
+ {
+ public:
+ int d2;
+ void f ();
+ };
+
+ class D3 : B
+ {
+ public:
+ int d3;
+ // initialization possibility #2
+ void f () = B::f;
+ };
+
+*/
+
+int
+copy_assignment_arg_p (parmtype, virtualp)
+ tree parmtype;
+ int virtualp;
+{
+ if (TREE_CODE (parmtype) == REFERENCE_TYPE)
+ parmtype = TREE_TYPE (parmtype);
+
+ if ((TYPE_MAIN_VARIANT (parmtype) == current_class_type)
+ || (virtualp && DERIVED_FROM_P (parmtype, current_class_type)))
+ return 1;
+
+ return 0;
+}
+
+static void
+grok_function_init (decl, init)
+ tree decl;
+ tree init;
+{
+ /* An initializer for a function tells how this function should
+ be inherited. */
+ tree type = TREE_TYPE (decl);
+
+ if (TREE_CODE (type) == FUNCTION_TYPE)
+ cp_error ("initializer specified for non-member function `%D'", decl);
+ else if (DECL_VINDEX (decl) == NULL_TREE)
+ cp_error ("initializer specified for non-virtual method `%D'", decl);
+ else if (integer_zerop (init))
+ {
+#if 0
+ /* Mark this function as being "defined". */
+ DECL_INITIAL (decl) = error_mark_node;
+ /* pure virtual destructors must be defined. */
+ /* pure virtual needs to be defined (as abort) only when put in
+ vtbl. For wellformed call, it should be itself. pr4737 */
+ if (!DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (decl)))
+ {
+ extern tree abort_fndecl;
+ /* Give this node rtl from `abort'. */
+ DECL_RTL (decl) = DECL_RTL (abort_fndecl);
+ }
+#endif
+ DECL_ABSTRACT_VIRTUAL_P (decl) = 1;
+ if (DECL_NAME (decl) == ansi_opname [(int) MODIFY_EXPR])
+ {
+ tree parmtype
+ = TREE_VALUE (TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (decl))));
+
+ if (copy_assignment_arg_p (parmtype, 1))
+ TYPE_HAS_ABSTRACT_ASSIGN_REF (current_class_type) = 1;
+ }
+ }
+ else if (TREE_CODE (init) == OFFSET_REF
+ && TREE_OPERAND (init, 0) == NULL_TREE
+ && TREE_CODE (TREE_TYPE (init)) == METHOD_TYPE)
+ {
+ tree basetype = DECL_CLASS_CONTEXT (init);
+ tree basefn = TREE_OPERAND (init, 1);
+ if (TREE_CODE (basefn) != FUNCTION_DECL)
+ cp_error ("non-method initializer invalid for method `%D'", decl);
+ else if (! BINFO_OFFSET_ZEROP (TYPE_BINFO (DECL_CLASS_CONTEXT (basefn))))
+ sorry ("base member function from other than first base class");
+ else
+ {
+ tree binfo = get_binfo (basetype, TYPE_METHOD_BASETYPE (type), 1);
+ if (binfo == error_mark_node)
+ ;
+ else if (binfo == 0)
+ error_not_base_type (TYPE_METHOD_BASETYPE (TREE_TYPE (init)),
+ TYPE_METHOD_BASETYPE (type));
+ else
+ {
+ /* Mark this function as being defined,
+ and give it new rtl. */
+ DECL_INITIAL (decl) = error_mark_node;
+ DECL_RTL (decl) = DECL_RTL (basefn);
+ }
+ }
+ }
+ else
+ cp_error ("invalid initializer for virtual method `%D'", decl);
+}
+
+/* When we get a declaration of the form
+
+ type cname::fname ...
+
+ the node for `cname::fname' gets built here in a special way.
+ Namely, we push into `cname's scope. When this declaration is
+ processed, we pop back out. */
+tree
+build_push_scope (cname, name)
+ tree cname;
+ tree name;
+{
+ extern int current_class_depth;
+ tree ctype, rval;
+ int is_ttp = 0;
+
+ if (cname == error_mark_node)
+ return error_mark_node;
+
+ ctype = IDENTIFIER_TYPE_VALUE (cname);
+
+ if (TREE_CODE (ctype) == TEMPLATE_TYPE_PARM)
+ is_ttp = 1;
+ else if (ctype == NULL_TREE || ! IS_AGGR_TYPE (ctype))
+ {
+ cp_error ("`%T' not defined as aggregate type", cname);
+ return name;
+ }
+ else if (IS_SIGNATURE (ctype))
+ {
+ error ("cannot push into signature scope, scope resolution operator ignored");
+ return name;
+ }
+
+ rval = build_parse_node (SCOPE_REF, cname, name);
+
+ /* Don't need to push the scope if we're already in it.
+ We also don't need to push the scope for a ptr-to-member/method. */
+
+ if (ctype == current_class_type || TREE_CODE (name) != IDENTIFIER_NODE
+ || is_ttp)
+ return rval;
+
+ /* We do need to push the scope in this case, since CTYPE helps
+ determine subsequent initializers (i.e., Foo::Bar x = foo_enum_1;). */
+
+ push_nested_class (ctype, 3);
+ TREE_COMPLEXITY (rval) = current_class_depth;
+ return rval;
+}
+
+void
+cplus_decl_attributes (decl, attributes, prefix_attributes)
+ tree decl, attributes, prefix_attributes;
+{
+ if (decl == NULL_TREE || decl == void_type_node)
+ return;
+
+ if (TREE_CODE (decl) == TEMPLATE_DECL)
+ decl = DECL_TEMPLATE_RESULT (decl);
+
+ decl_attributes (decl, attributes, prefix_attributes);
+
+ if (TREE_CODE (decl) == TYPE_DECL)
+ SET_IDENTIFIER_TYPE_VALUE (DECL_NAME (decl), TREE_TYPE (decl));
+}
+
+/* CONSTRUCTOR_NAME:
+ Return the name for the constructor (or destructor) for the
+ specified class. Argument can be RECORD_TYPE, TYPE_DECL, or
+ IDENTIFIER_NODE. When given a template, this routine doesn't
+ lose the specialization. */
+tree
+constructor_name_full (thing)
+ tree thing;
+{
+ if (TREE_CODE (thing) == UNINSTANTIATED_P_TYPE)
+ return DECL_NAME (UPT_TEMPLATE (thing));
+ if (IS_AGGR_TYPE_CODE (TREE_CODE (thing)))
+ {
+ if (TYPE_WAS_ANONYMOUS (thing) && TYPE_HAS_CONSTRUCTOR (thing))
+ thing = DECL_NAME (TREE_VEC_ELT (TYPE_METHODS (thing), 0));
+ else
+ thing = TYPE_NAME (thing);
+ }
+ if (TREE_CODE (thing) == TYPE_DECL
+ || (TREE_CODE (thing) == TEMPLATE_DECL
+ && DECL_TEMPLATE_IS_CLASS (thing)))
+ thing = DECL_NAME (thing);
+ my_friendly_assert (TREE_CODE (thing) == IDENTIFIER_NODE, 197);
+ return thing;
+}
+
+/* CONSTRUCTOR_NAME:
+ Return the name for the constructor (or destructor) for the
+ specified class. Argument can be RECORD_TYPE, TYPE_DECL, or
+ IDENTIFIER_NODE. When given a template, return the plain
+ unspecialized name. */
+tree
+constructor_name (thing)
+ tree thing;
+{
+ tree t;
+ thing = constructor_name_full (thing);
+ t = IDENTIFIER_TEMPLATE (thing);
+ if (!t)
+ return thing;
+ t = TREE_PURPOSE (t);
+ return DECL_NAME (t);
+}
+
+/* Cache the value of this class's main virtual function table pointer
+ in a register variable. This will save one indirection if a
+ more than one virtual function call is made this function. */
+void
+setup_vtbl_ptr ()
+{
+ extern tree base_init_expr;
+
+ if (base_init_expr == 0
+ && DECL_CONSTRUCTOR_P (current_function_decl))
+ emit_base_init (current_class_type, 0);
+}
+
+/* Record the existence of an addressable inline function. */
+void
+mark_inline_for_output (decl)
+ tree decl;
+{
+ decl = DECL_MAIN_VARIANT (decl);
+ if (DECL_SAVED_INLINE (decl))
+ return;
+ my_friendly_assert (TREE_PERMANENT (decl), 363);
+ DECL_SAVED_INLINE (decl) = 1;
+#if 0
+ if (DECL_PENDING_INLINE_INFO (decl) != 0
+ && ! DECL_PENDING_INLINE_INFO (decl)->deja_vu)
+ {
+ struct pending_inline *t = pending_inlines;
+ my_friendly_assert (DECL_SAVED_INSNS (decl) == 0, 198);
+ while (t)
+ {
+ if (t == DECL_PENDING_INLINE_INFO (decl))
+ break;
+ t = t->next;
+ }
+ if (t == 0)
+ {
+ t = DECL_PENDING_INLINE_INFO (decl);
+ t->next = pending_inlines;
+ pending_inlines = t;
+ }
+ DECL_PENDING_INLINE_INFO (decl) = 0;
+ }
+#endif
+ saved_inlines = perm_tree_cons (NULL_TREE, decl, saved_inlines);
+}
+
+void
+clear_temp_name ()
+{
+ temp_name_counter = 0;
+}
+
+/* Hand off a unique name which can be used for variable we don't really
+ want to know about anyway, for example, the anonymous variables which
+ are needed to make references work. Declare this thing so we can use it.
+ The variable created will be of type TYPE.
+
+ STATICP is nonzero if this variable should be static. */
+
+tree
+get_temp_name (type, staticp)
+ tree type;
+ int staticp;
+{
+ char buf[sizeof (AUTO_TEMP_FORMAT) + 20];
+ tree decl;
+ int toplev = toplevel_bindings_p ();
+
+ push_obstacks_nochange ();
+ if (toplev || staticp)
+ {
+ end_temporary_allocation ();
+ sprintf (buf, AUTO_TEMP_FORMAT, global_temp_name_counter++);
+ decl = pushdecl_top_level (build_decl (VAR_DECL, get_identifier (buf), type));
+ }
+ else
+ {
+ sprintf (buf, AUTO_TEMP_FORMAT, temp_name_counter++);
+ decl = pushdecl (build_decl (VAR_DECL, get_identifier (buf), type));
+ }
+ TREE_USED (decl) = 1;
+ TREE_STATIC (decl) = staticp;
+
+ /* If this is a local variable, then lay out its rtl now.
+ Otherwise, callers of this function are responsible for dealing
+ with this variable's rtl. */
+ if (! toplev)
+ {
+ expand_decl (decl);
+ expand_decl_init (decl);
+ }
+ pop_obstacks ();
+
+ return decl;
+}
+
+/* Get a variable which we can use for multiple assignments.
+ It is not entered into current_binding_level, because
+ that breaks things when it comes time to do final cleanups
+ (which take place "outside" the binding contour of the function). */
+tree
+get_temp_regvar (type, init)
+ tree type, init;
+{
+ static char buf[sizeof (AUTO_TEMP_FORMAT) + 20] = { '_' };
+ tree decl;
+
+ sprintf (buf+1, AUTO_TEMP_FORMAT, temp_name_counter++);
+ decl = build_decl (VAR_DECL, get_identifier (buf), type);
+ TREE_USED (decl) = 1;
+ DECL_REGISTER (decl) = 1;
+
+ if (init)
+ store_init_value (decl, init);
+
+ /* We can expand these without fear, since they cannot need
+ constructors or destructors. */
+ expand_decl (decl);
+ expand_decl_init (decl);
+
+ if (type_needs_gc_entry (type))
+ DECL_GC_OFFSET (decl) = size_int (++current_function_obstack_index);
+
+ return decl;
+}
+
+/* Make the macro TEMP_NAME_P available to units which do not
+ include c-tree.h. */
+int
+temp_name_p (decl)
+ tree decl;
+{
+ return TEMP_NAME_P (decl);
+}
+
+/* Finish off the processing of a UNION_TYPE structure.
+ If there are static members, then all members are
+ static, and must be laid out together. If the
+ union is an anonymous union, we arrange for that
+ as well. PUBLIC_P is nonzero if this union is
+ not declared static. */
+void
+finish_anon_union (anon_union_decl)
+ tree anon_union_decl;
+{
+ tree type = TREE_TYPE (anon_union_decl);
+ tree field, main_decl = NULL_TREE;
+ tree elems = NULL_TREE;
+ int public_p = TREE_PUBLIC (anon_union_decl);
+ int static_p = TREE_STATIC (anon_union_decl);
+ int external_p = DECL_EXTERNAL (anon_union_decl);
+
+ if ((field = TYPE_FIELDS (type)) == NULL_TREE)
+ return;
+
+ if (public_p)
+ {
+ error ("global anonymous unions must be declared static");
+ return;
+ }
+
+ for (; field; field = TREE_CHAIN (field))
+ {
+ tree decl;
+ if (TREE_CODE (field) != FIELD_DECL)
+ continue;
+
+ if (TREE_PRIVATE (field))
+ cp_pedwarn_at ("private member `%#D' in anonymous union", field);
+ else if (TREE_PROTECTED (field))
+ cp_pedwarn_at ("protected member `%#D' in anonymous union", field);
+
+ decl = build_decl (VAR_DECL, DECL_NAME (field), TREE_TYPE (field));
+ /* tell `pushdecl' that this is not tentative. */
+ DECL_INITIAL (decl) = error_mark_node;
+ TREE_PUBLIC (decl) = public_p;
+ TREE_STATIC (decl) = static_p;
+ DECL_EXTERNAL (decl) = external_p;
+ decl = pushdecl (decl);
+
+ /* Only write out one anon union element--choose the one that
+ can hold them all. */
+ if (main_decl == NULL_TREE
+ && 1 == simple_cst_equal (DECL_SIZE (decl),
+ DECL_SIZE (anon_union_decl)))
+ {
+ main_decl = decl;
+ }
+ else
+ {
+ /* ??? This causes there to be no debug info written out
+ about this decl. */
+ TREE_ASM_WRITTEN (decl) = 1;
+ }
+
+ DECL_INITIAL (decl) = NULL_TREE;
+ /* If there's a cleanup to do, it belongs in the
+ TREE_PURPOSE of the following TREE_LIST. */
+ elems = tree_cons (NULL_TREE, decl, elems);
+ TREE_TYPE (elems) = type;
+ }
+ if (static_p)
+ {
+ if (main_decl)
+ {
+ make_decl_rtl (main_decl, 0, toplevel_bindings_p ());
+ DECL_RTL (anon_union_decl) = DECL_RTL (main_decl);
+ }
+ else
+ {
+ warning ("anonymous union with no members");
+ return;
+ }
+ }
+
+ /* The following call assumes that there are never any cleanups
+ for anonymous unions--a reasonable assumption. */
+ expand_anon_union_decl (anon_union_decl, NULL_TREE, elems);
+
+ if (flag_cadillac)
+ cadillac_finish_anon_union (anon_union_decl);
+}
+
+/* Finish and output a table which is generated by the compiler.
+ NAME is the name to give the table.
+ TYPE is the type of the table entry.
+ INIT is all the elements in the table.
+ PUBLICP is non-zero if this table should be given external access. */
+tree
+finish_table (name, type, init, publicp)
+ tree name, type, init;
+ int publicp;
+{
+ tree itype, atype, decl;
+ static tree empty_table;
+ int is_empty = 0;
+ tree asmspec;
+
+ itype = build_index_type (size_int (list_length (init) - 1));
+ atype = build_cplus_array_type (type, itype);
+ layout_type (atype);
+
+ if (TREE_VALUE (init) == integer_zero_node
+ && TREE_CHAIN (init) == NULL_TREE)
+ {
+#if 0
+ if (empty_table == NULL_TREE)
+#endif
+ {
+ empty_table = get_temp_name (atype, 1);
+ init = build (CONSTRUCTOR, atype, NULL_TREE, init);
+ TREE_CONSTANT (init) = 1;
+ TREE_STATIC (init) = 1;
+ DECL_INITIAL (empty_table) = init;
+ asmspec = build_string (IDENTIFIER_LENGTH (DECL_NAME (empty_table)),
+ IDENTIFIER_POINTER (DECL_NAME (empty_table)));
+ cp_finish_decl (empty_table, NULL_TREE, asmspec, 0, 0);
+ }
+ is_empty = 1;
+ }
+
+ if (name == NULL_TREE)
+ {
+ if (is_empty)
+ return empty_table;
+ decl = get_temp_name (atype, 1);
+ }
+ else
+ {
+ decl = build_decl (VAR_DECL, name, atype);
+ decl = pushdecl (decl);
+ TREE_STATIC (decl) = 1;
+ }
+
+ if (is_empty == 0)
+ {
+ TREE_PUBLIC (decl) = publicp;
+ init = build (CONSTRUCTOR, atype, NULL_TREE, init);
+ TREE_CONSTANT (init) = 1;
+ TREE_STATIC (init) = 1;
+ DECL_INITIAL (decl) = init;
+ asmspec = build_string (IDENTIFIER_LENGTH (DECL_NAME (decl)),
+ IDENTIFIER_POINTER (DECL_NAME (decl)));
+ }
+ else
+ {
+ /* This will cause DECL to point to EMPTY_TABLE in rtl-land. */
+ DECL_EXTERNAL (decl) = 1;
+ TREE_STATIC (decl) = 0;
+ init = 0;
+ asmspec = build_string (IDENTIFIER_LENGTH (DECL_NAME (empty_table)),
+ IDENTIFIER_POINTER (DECL_NAME (empty_table)));
+ }
+
+ cp_finish_decl (decl, NULL_TREE, asmspec, 0, 0);
+ return decl;
+}
+
+/* Finish processing a builtin type TYPE. It's name is NAME,
+ its fields are in the array FIELDS. LEN is the number of elements
+ in FIELDS minus one, or put another way, it is the maximum subscript
+ used in FIELDS.
+
+ It is given the same alignment as ALIGN_TYPE. */
+void
+finish_builtin_type (type, name, fields, len, align_type)
+ tree type;
+ char *name;
+ tree fields[];
+ int len;
+ tree align_type;
+{
+ register int i;
+
+ TYPE_FIELDS (type) = fields[0];
+ for (i = 0; i < len; i++)
+ {
+ layout_type (TREE_TYPE (fields[i]));
+ DECL_FIELD_CONTEXT (fields[i]) = type;
+ TREE_CHAIN (fields[i]) = fields[i+1];
+ }
+ DECL_FIELD_CONTEXT (fields[i]) = type;
+ DECL_CLASS_CONTEXT (fields[i]) = type;
+ TYPE_ALIGN (type) = TYPE_ALIGN (align_type);
+ layout_type (type);
+#if 0 /* not yet, should get fixed properly later */
+ TYPE_NAME (type) = make_type_decl (get_identifier (name), type);
+#else
+ TYPE_NAME (type) = build_decl (TYPE_DECL, get_identifier (name), type);
+#endif
+ layout_decl (TYPE_NAME (type), 0);
+}
+
+/* Auxiliary functions to make type signatures for
+ `operator new' and `operator delete' correspond to
+ what compiler will be expecting. */
+
+extern tree sizetype;
+
+tree
+coerce_new_type (type)
+ tree type;
+{
+ int e1 = 0, e2 = 0;
+
+ if (TREE_CODE (type) == METHOD_TYPE)
+ type = build_function_type (TREE_TYPE (type), TREE_CHAIN (TYPE_ARG_TYPES (type)));
+ if (TREE_TYPE (type) != ptr_type_node)
+ e1 = 1, error ("`operator new' must return type `void *'");
+
+ /* Technically the type must be `size_t', but we may not know
+ what that is. */
+ if (TYPE_ARG_TYPES (type) == NULL_TREE)
+ e1 = 1, error ("`operator new' takes type `size_t' parameter");
+ else if (TREE_CODE (TREE_VALUE (TYPE_ARG_TYPES (type))) != INTEGER_TYPE
+ || TYPE_PRECISION (TREE_VALUE (TYPE_ARG_TYPES (type))) != TYPE_PRECISION (sizetype))
+ e2 = 1, error ("`operator new' takes type `size_t' as first parameter");
+ if (e2)
+ type = build_function_type (ptr_type_node, tree_cons (NULL_TREE, sizetype, TREE_CHAIN (TYPE_ARG_TYPES (type))));
+ else if (e1)
+ type = build_function_type (ptr_type_node, TYPE_ARG_TYPES (type));
+ return type;
+}
+
+tree
+coerce_delete_type (type)
+ tree type;
+{
+ int e1 = 0, e2 = 0, e3 = 0;
+ tree arg_types = TYPE_ARG_TYPES (type);
+
+ if (TREE_CODE (type) == METHOD_TYPE)
+ {
+ type = build_function_type (TREE_TYPE (type), TREE_CHAIN (arg_types));
+ arg_types = TREE_CHAIN (arg_types);
+ }
+ if (TREE_TYPE (type) != void_type_node)
+ e1 = 1, error ("`operator delete' must return type `void'");
+ if (arg_types == NULL_TREE
+ || TREE_VALUE (arg_types) != ptr_type_node)
+ e2 = 1, error ("`operator delete' takes type `void *' as first parameter");
+
+ if (arg_types
+ && TREE_CHAIN (arg_types)
+ && TREE_CHAIN (arg_types) != void_list_node)
+ {
+ /* Again, technically this argument must be `size_t', but again
+ we may not know what that is. */
+ tree t2 = TREE_VALUE (TREE_CHAIN (arg_types));
+ if (TREE_CODE (t2) != INTEGER_TYPE
+ || TYPE_PRECISION (t2) != TYPE_PRECISION (sizetype))
+ e3 = 1, error ("second argument to `operator delete' must be of type `size_t'");
+ else if (TREE_CHAIN (TREE_CHAIN (arg_types)) != void_list_node)
+ {
+ e3 = 1;
+ if (TREE_CHAIN (TREE_CHAIN (arg_types)))
+ error ("too many arguments in declaration of `operator delete'");
+ else
+ error ("`...' invalid in specification of `operator delete'");
+ }
+ }
+ if (e3)
+ arg_types = tree_cons (NULL_TREE, ptr_type_node, build_tree_list (NULL_TREE, sizetype));
+ else if (e3 |= e2)
+ {
+ if (arg_types == NULL_TREE)
+ arg_types = tree_cons (NULL_TREE, ptr_type_node, void_list_node);
+ else
+ arg_types = tree_cons (NULL_TREE, ptr_type_node, TREE_CHAIN (arg_types));
+ }
+ else e3 |= e1;
+
+ if (e3)
+ type = build_function_type (void_type_node, arg_types);
+
+ return type;
+}
+
+static void
+mark_vtable_entries (decl)
+ tree decl;
+{
+ tree entries = CONSTRUCTOR_ELTS (DECL_INITIAL (decl));
+
+ skip_rtti_stuff (&entries);
+
+ for (; entries; entries = TREE_CHAIN (entries))
+ {
+ tree fnaddr = FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (entries));
+ tree fn = TREE_OPERAND (fnaddr, 0);
+ TREE_ADDRESSABLE (fn) = 1;
+ if (DECL_ABSTRACT_VIRTUAL_P (fn))
+ {
+ extern tree abort_fndecl;
+ if (flag_vtable_thunks)
+ fnaddr = TREE_VALUE (entries);
+ TREE_OPERAND (fnaddr, 0) = fn = abort_fndecl;
+ }
+ assemble_external (fn);
+ }
+}
+
+/* Set TREE_PUBLIC and/or DECL_EXTERN on the vtable DECL,
+ based on TYPE and other static flags.
+
+ Note that anything public is tagged TREE_PUBLIC, whether
+ it's public in this file or in another one. */
+
+void
+import_export_vtable (decl, type, final)
+ tree decl, type;
+ int final;
+{
+ if (DECL_INTERFACE_KNOWN (decl))
+ return;
+
+ /* +e0 or +e1 */
+ if (write_virtuals < 2 && write_virtuals != 0)
+ {
+ TREE_PUBLIC (decl) = 1;
+ if (write_virtuals < 0)
+ DECL_EXTERNAL (decl) = 1;
+ DECL_INTERFACE_KNOWN (decl) = 1;
+ }
+ else if (CLASSTYPE_INTERFACE_KNOWN (type))
+ {
+ TREE_PUBLIC (decl) = 1;
+ DECL_EXTERNAL (decl) = ! CLASSTYPE_VTABLE_NEEDS_WRITING (type);
+ DECL_INTERFACE_KNOWN (decl) = 1;
+ }
+ else
+ {
+ /* We can only wait to decide if we have real non-inline virtual
+ functions in our class, or if we come from a template. */
+
+ int found = CLASSTYPE_TEMPLATE_INSTANTIATION (type);
+
+ if (! found && ! final)
+ {
+ tree method;
+ for (method = CLASSTYPE_METHODS (type); method != NULL_TREE;
+ method = DECL_NEXT_METHOD (method))
+ if (DECL_VINDEX (method) != NULL_TREE
+ && ! DECL_THIS_INLINE (method)
+ && ! DECL_ABSTRACT_VIRTUAL_P (method))
+ {
+ found = 1;
+ break;
+ }
+ }
+
+ if (final || ! found)
+ {
+#ifdef ASSEMBLE_EXTERNAL
+ if (TREE_PUBLIC (decl))
+ cp_error ("all virtual functions redeclared inline");
+#endif
+ if (SUPPORTS_WEAK)
+ DECL_WEAK (decl) = 1;
+ else
+ TREE_PUBLIC (decl) = 0;
+ DECL_EXTERNAL (decl) = 0;
+ }
+ else
+ {
+ TREE_PUBLIC (decl) = 1;
+ DECL_EXTERNAL (decl) = 1;
+ }
+ }
+}
+
+static void
+import_export_template (type)
+ tree type;
+{
+ if (CLASSTYPE_IMPLICIT_INSTANTIATION (type)
+ && ! flag_implicit_templates
+ && CLASSTYPE_INTERFACE_UNKNOWN (type))
+ {
+ SET_CLASSTYPE_INTERFACE_KNOWN (type);
+ CLASSTYPE_INTERFACE_ONLY (type) = 1;
+ CLASSTYPE_VTABLE_NEEDS_WRITING (type) = 0;
+ }
+}
+
+static void
+finish_prevtable_vardecl (prev, vars)
+ tree prev, vars;
+{
+ tree ctype = DECL_CONTEXT (vars);
+ import_export_template (ctype);
+
+ if (CLASSTYPE_INTERFACE_UNKNOWN (ctype) && TYPE_VIRTUAL_P (ctype)
+ && ! CLASSTYPE_TEMPLATE_INSTANTIATION (ctype))
+ {
+ tree method;
+ for (method = CLASSTYPE_METHODS (ctype); method != NULL_TREE;
+ method = DECL_NEXT_METHOD (method))
+ {
+ if (DECL_VINDEX (method) != NULL_TREE
+ && !DECL_THIS_INLINE (method)
+ && !DECL_ABSTRACT_VIRTUAL_P (method))
+ {
+ SET_CLASSTYPE_INTERFACE_KNOWN (ctype);
+ CLASSTYPE_VTABLE_NEEDS_WRITING (ctype) = ! DECL_EXTERNAL (method);
+ CLASSTYPE_INTERFACE_ONLY (ctype) = DECL_EXTERNAL (method);
+ break;
+ }
+ }
+ }
+
+ import_export_vtable (vars, ctype, 1);
+
+ /* We cannot use TREE_USED here, as it may be set by the expanding of a
+ ctor that is used to build a global object. The long term plan is to
+ make the TD entries statically initialized and move this to
+ finish_vtable_vardecl time. */
+ if (flag_rtti && write_virtuals >= 0
+ && ! DECL_EXTERNAL (vars) && (TREE_PUBLIC (vars) || 1 || TREE_USED (vars)))
+ {
+ /* Kick out the type descriptor before we dump out global
+ initializers, as they are initialized at run time and
+ we have to find them when we scan for things that need initialized
+ at the top level. */
+ build_t_desc (ctype, 1);
+ }
+}
+
+static void
+finish_vtable_vardecl (prev, vars)
+ tree prev, vars;
+{
+ if (write_virtuals >= 0
+ && ! DECL_EXTERNAL (vars) && (TREE_PUBLIC (vars) || TREE_USED (vars)))
+ {
+#if 0
+ /* The long term plan it to make the TD entries statically initialized,
+ have the entries built and emitted here. When that happens, this
+ can be enabled, and the other call to build_t_desc removed. */
+ /* Kick out the type descriptor before writing out the vtable. */
+ if (flag_rtti)
+ build_t_desc (DECL_CONTEXT (vars), 1);
+#endif
+
+ /* Write it out. */
+ mark_vtable_entries (vars);
+ if (TREE_TYPE (DECL_INITIAL (vars)) == 0)
+ store_init_value (vars, DECL_INITIAL (vars));
+
+#ifdef DWARF_DEBUGGING_INFO
+ if (write_symbols == DWARF_DEBUG)
+ {
+ /* Mark the VAR_DECL node representing the vtable itself as a
+ "gratuitous" one, thereby forcing dwarfout.c to ignore it.
+ It is rather important that such things be ignored because
+ any effort to actually generate DWARF for them will run
+ into trouble when/if we encounter code like:
+
+ #pragma interface
+ struct S { virtual void member (); };
+
+ because the artificial declaration of the vtable itself (as
+ manufactured by the g++ front end) will say that the vtable
+ is a static member of `S' but only *after* the debug output
+ for the definition of `S' has already been output. This causes
+ grief because the DWARF entry for the definition of the vtable
+ will try to refer back to an earlier *declaration* of the
+ vtable as a static member of `S' and there won't be one.
+ We might be able to arrange to have the "vtable static member"
+ attached to the member list for `S' before the debug info for
+ `S' get written (which would solve the problem) but that would
+ require more intrusive changes to the g++ front end. */
+
+ DECL_IGNORED_P (vars) = 1;
+ }
+#endif /* DWARF_DEBUGGING_INFO */
+
+ rest_of_decl_compilation (vars, NULL_PTR, 1, 1);
+ }
+ else if (! TREE_USED (vars))
+ /* We don't know what to do with this one yet. */
+ return;
+
+ /* We know that PREV must be non-zero here. */
+ TREE_CHAIN (prev) = TREE_CHAIN (vars);
+}
+
+static void
+prune_vtable_vardecl (prev, vars)
+ tree prev, vars;
+{
+ /* We know that PREV must be non-zero here. */
+ TREE_CHAIN (prev) = TREE_CHAIN (vars);
+}
+
+void
+walk_vtables (typedecl_fn, vardecl_fn)
+ register void (*typedecl_fn)();
+ register void (*vardecl_fn)();
+{
+ tree prev, vars;
+
+ for (prev = 0, vars = getdecls (); vars; vars = TREE_CHAIN (vars))
+ {
+ register tree type = TREE_TYPE (vars);
+
+ if (TREE_CODE (vars) == VAR_DECL && DECL_VIRTUAL_P (vars))
+ {
+ if (vardecl_fn) (*vardecl_fn) (prev, vars);
+
+ if (prev && TREE_CHAIN (prev) != vars)
+ continue;
+ }
+ else if (TREE_CODE (vars) == TYPE_DECL
+ && type != error_mark_node
+ && TYPE_LANG_SPECIFIC (type)
+ && CLASSTYPE_VSIZE (type))
+ {
+ if (typedecl_fn) (*typedecl_fn) (prev, vars);
+ }
+
+ prev = vars;
+ }
+}
+
+static void
+finish_sigtable_vardecl (prev, vars)
+ tree prev, vars;
+{
+ /* We don't need to mark sigtable entries as addressable here as is done
+ for vtables. Since sigtables, unlike vtables, are always written out,
+ that was already done in build_signature_table_constructor. */
+
+ rest_of_decl_compilation (vars, NULL_PTR, 1, 1);
+
+ /* We know that PREV must be non-zero here. */
+ TREE_CHAIN (prev) = TREE_CHAIN (vars);
+}
+
+void
+walk_sigtables (typedecl_fn, vardecl_fn)
+ register void (*typedecl_fn)();
+ register void (*vardecl_fn)();
+{
+ tree prev, vars;
+
+ for (prev = 0, vars = getdecls (); vars; vars = TREE_CHAIN (vars))
+ {
+ register tree type = TREE_TYPE (vars);
+
+ if (TREE_CODE (vars) == TYPE_DECL
+ && type != error_mark_node
+ && IS_SIGNATURE (type))
+ {
+ if (typedecl_fn) (*typedecl_fn) (prev, vars);
+ }
+ else if (TREE_CODE (vars) == VAR_DECL
+ && TREE_TYPE (vars) != error_mark_node
+ && IS_SIGNATURE (TREE_TYPE (vars)))
+ {
+ if (vardecl_fn) (*vardecl_fn) (prev, vars);
+ }
+ else
+ prev = vars;
+ }
+}
+
+/* Determines the proper settings of TREE_PUBLIC and DECL_EXTERNAL for an
+ inline function at end-of-file. */
+
+void
+import_export_inline (decl)
+ tree decl;
+{
+ if (DECL_INTERFACE_KNOWN (decl))
+ return;
+
+ if (DECL_TEMPLATE_INSTANTIATION (decl))
+ {
+ if (DECL_IMPLICIT_INSTANTIATION (decl) && flag_implicit_templates)
+ {
+ if (SUPPORTS_WEAK)
+ DECL_WEAK (decl) = 1;
+ else
+ TREE_PUBLIC (decl) = 0;
+ }
+ else
+ DECL_NOT_REALLY_EXTERN (decl) = 0;
+ }
+ else if (DECL_FUNCTION_MEMBER_P (decl))
+ {
+ tree ctype = DECL_CLASS_CONTEXT (decl);
+ if (CLASSTYPE_INTERFACE_KNOWN (ctype) && ! DECL_ARTIFICIAL (decl))
+ {
+ DECL_NOT_REALLY_EXTERN (decl)
+ = ! (CLASSTYPE_INTERFACE_ONLY (ctype)
+ || (DECL_THIS_INLINE (decl) && ! flag_implement_inlines));
+ }
+ else if (SUPPORTS_WEAK)
+ DECL_WEAK (decl) = 1;
+ else
+ TREE_PUBLIC (decl) = 0;
+ }
+ else if (DECL_C_STATIC (decl))
+ TREE_PUBLIC (decl) = 0;
+ else if (SUPPORTS_WEAK)
+ DECL_WEAK (decl) = 1;
+ else
+ TREE_PUBLIC (decl) = 0;
+
+ DECL_INTERFACE_KNOWN (decl) = 1;
+}
+
+extern int parse_time, varconst_time;
+
+#define TIMEVAR(VAR, BODY) \
+do { int otime = get_run_time (); BODY; VAR += get_run_time () - otime; } while (0)
+
+/* This routine is called from the last rule in yyparse ().
+ Its job is to create all the code needed to initialize and
+ destroy the global aggregates. We do the destruction
+ first, since that way we only need to reverse the decls once. */
+
+void
+finish_file ()
+{
+ extern int lineno;
+ int start_time, this_time;
+
+ tree fnname;
+ tree vars;
+ int needs_cleaning = 0, needs_messing_up = 0;
+
+ if (flag_detailed_statistics)
+ dump_tree_statistics ();
+
+ /* Bad parse errors. Just forget about it. */
+ if (! global_bindings_p () || current_class_type)
+ return;
+
+ start_time = get_run_time ();
+
+ /* Push into C language context, because that's all
+ we'll need here. */
+ push_lang_context (lang_name_c);
+
+ /* Otherwise, GDB can get confused, because in only knows
+ about source for LINENO-1 lines. */
+ lineno -= 1;
+
+ interface_unknown = 1;
+ interface_only = 0;
+
+#if 1
+ /* The reason for pushing garbage onto the global_binding_level is to
+ ensure that we can slice out _DECLs which pertain to virtual function
+ tables. If the last thing pushed onto the global_binding_level was a
+ virtual function table, then slicing it out would slice away all the
+ decls (i.e., we lose the head of the chain).
+
+ There are several ways of getting the same effect, from changing the
+ way that iterators over the chain treat the elements that pertain to
+ virtual function tables, moving the implementation of this code to
+ decl.c (where we can manipulate global_binding_level directly),
+ popping the garbage after pushing it and slicing away the vtable
+ stuff, or just leaving it alone. */
+
+ /* Make last thing in global scope not be a virtual function table. */
+#if 0 /* not yet, should get fixed properly later */
+ vars = make_type_decl (get_identifier (" @%$#@!"), integer_type_node);
+#else
+ vars = build_decl (TYPE_DECL, get_identifier (" @%$#@!"), integer_type_node);
+#endif
+ DECL_IGNORED_P (vars) = 1;
+ SET_DECL_ARTIFICIAL (vars);
+ pushdecl (vars);
+#endif
+
+ /* Walk to mark the inline functions we need, then output them so
+ that we can pick up any other tdecls that those routines need. */
+ walk_vtables ((void (*)())0, finish_prevtable_vardecl);
+
+ vars = static_aggregates;
+
+ if (static_ctors || vars || might_have_exceptions_p ())
+ needs_messing_up = 1;
+ if (static_dtors)
+ needs_cleaning = 1;
+
+ /* See if we really need the hassle. */
+ while (vars && needs_cleaning == 0)
+ {
+ tree decl = TREE_VALUE (vars);
+ tree type = TREE_TYPE (decl);
+ if (TYPE_NEEDS_DESTRUCTOR (type))
+ {
+ needs_cleaning = 1;
+ needs_messing_up = 1;
+ break;
+ }
+ else
+ needs_messing_up |= TYPE_NEEDS_CONSTRUCTING (type);
+ vars = TREE_CHAIN (vars);
+ }
+
+ if (needs_cleaning == 0)
+ goto mess_up;
+
+ fnname = get_file_function_name ('D');
+ start_function (void_list_node,
+ build_parse_node (CALL_EXPR, fnname, void_list_node,
+ NULL_TREE),
+ NULL_TREE, NULL_TREE, 0);
+ fnname = DECL_ASSEMBLER_NAME (current_function_decl);
+ store_parm_decls ();
+
+ pushlevel (0);
+ clear_last_expr ();
+ push_momentary ();
+ expand_start_bindings (0);
+
+ /* These must be done in backward order to destroy,
+ in which they happen to be! */
+ for (vars = static_aggregates; vars; vars = TREE_CHAIN (vars))
+ {
+ tree decl = TREE_VALUE (vars);
+ tree type = TREE_TYPE (decl);
+ tree temp = TREE_PURPOSE (vars);
+
+ if (TYPE_NEEDS_DESTRUCTOR (type))
+ {
+ if (TREE_STATIC (vars))
+ expand_start_cond (build_binary_op (NE_EXPR, temp, integer_zero_node, 1), 0);
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ temp = decl;
+ else
+ {
+ mark_addressable (decl);
+ temp = build1 (ADDR_EXPR, build_pointer_type (type), decl);
+ }
+ temp = build_delete (TREE_TYPE (temp), temp,
+ integer_two_node, LOOKUP_NORMAL|LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR, 0);
+ expand_expr_stmt (temp);
+
+ if (TREE_STATIC (vars))
+ expand_end_cond ();
+ }
+ }
+
+ for (; static_dtors; static_dtors = TREE_CHAIN (static_dtors))
+ expand_expr_stmt (build_function_call (TREE_VALUE (static_dtors),
+ NULL_TREE));
+
+ expand_end_bindings (getdecls(), 1, 0);
+ poplevel (1, 0, 0);
+ pop_momentary ();
+
+ finish_function (lineno, 0, 0);
+
+ assemble_destructor (IDENTIFIER_POINTER (fnname));
+
+ /* if it needed cleaning, then it will need messing up: drop through */
+
+ mess_up:
+ /* Must do this while we think we are at the top level. */
+ vars = nreverse (static_aggregates);
+ if (needs_messing_up)
+ {
+ fnname = get_file_function_name ('I');
+ start_function (void_list_node,
+ build_parse_node (CALL_EXPR, fnname,
+ void_list_node, NULL_TREE),
+ NULL_TREE, NULL_TREE, 0);
+ fnname = DECL_ASSEMBLER_NAME (current_function_decl);
+ store_parm_decls ();
+
+ pushlevel (0);
+ clear_last_expr ();
+ push_momentary ();
+ expand_start_bindings (0);
+
+ if (might_have_exceptions_p ())
+ register_exception_table ();
+
+ while (vars)
+ {
+ tree decl = TREE_VALUE (vars);
+ tree init = TREE_PURPOSE (vars);
+ tree old_cleanups = cleanups_this_call;
+
+ /* If this was a static attribute within some function's scope,
+ then don't initialize it here. Also, don't bother
+ with initializers that contain errors. */
+ if (TREE_STATIC (vars)
+ || (init && TREE_CODE (init) == TREE_LIST
+ && value_member (error_mark_node, init)))
+ {
+ vars = TREE_CHAIN (vars);
+ continue;
+ }
+
+ if (TREE_CODE (decl) == VAR_DECL)
+ {
+ /* Set these global variables so that GDB at least puts
+ us near the declaration which required the initialization. */
+ input_filename = DECL_SOURCE_FILE (decl);
+ lineno = DECL_SOURCE_LINE (decl);
+ emit_note (input_filename, lineno);
+
+ /* 9.5p5: The initializer of a static member of a class has
+ the same access rights as a member function. */
+ DECL_CLASS_CONTEXT (current_function_decl) = DECL_CONTEXT (decl);
+ DECL_STATIC_FUNCTION_P (current_function_decl) = 1;
+
+ if (IS_AGGR_TYPE (TREE_TYPE (decl))
+ || TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
+ expand_aggr_init (decl, init, 0, 0);
+ else if (TREE_CODE (init) == TREE_VEC)
+ {
+ expand_expr (expand_vec_init (decl, TREE_VEC_ELT (init, 0),
+ TREE_VEC_ELT (init, 1),
+ TREE_VEC_ELT (init, 2), 0),
+ const0_rtx, VOIDmode, 0);
+ free_temp_slots ();
+ }
+ else
+ expand_assignment (decl, init, 0, 0);
+
+ DECL_CLASS_CONTEXT (current_function_decl) = NULL_TREE;
+ }
+ else if (TREE_CODE (decl) == SAVE_EXPR)
+ {
+ if (! PARM_DECL_EXPR (decl))
+ {
+ /* a `new' expression at top level. */
+ expand_expr (decl, const0_rtx, VOIDmode, 0);
+ free_temp_slots ();
+ if (TREE_CODE (init) == TREE_VEC)
+ {
+ expand_expr (expand_vec_init (decl, TREE_VEC_ELT (init, 0),
+ TREE_VEC_ELT (init, 1),
+ TREE_VEC_ELT (init, 2), 0),
+ const0_rtx, VOIDmode, 0);
+ free_temp_slots ();
+ }
+ else
+ expand_aggr_init (build_indirect_ref (decl, NULL_PTR), init, 0, 0);
+ }
+ }
+ else if (decl == error_mark_node)
+ ;
+ else my_friendly_abort (22);
+ vars = TREE_CHAIN (vars);
+ /* Cleanup any temporaries needed for the initial value. */
+ expand_cleanups_to (old_cleanups);
+ }
+
+ for (; static_ctors; static_ctors = TREE_CHAIN (static_ctors))
+ expand_expr_stmt (build_function_call (TREE_VALUE (static_ctors),
+ NULL_TREE));
+
+ expand_end_bindings (getdecls(), 1, 0);
+ poplevel (1, 0, 0);
+ pop_momentary ();
+
+ finish_function (lineno, 0, 0);
+ assemble_constructor (IDENTIFIER_POINTER (fnname));
+ }
+
+ expand_builtin_throw ();
+
+ permanent_allocation (1);
+
+ /* Done with C language context needs. */
+ pop_lang_context ();
+
+ /* Now write out any static class variables (which may have since
+ learned how to be initialized). */
+ while (pending_statics)
+ {
+ tree decl = TREE_VALUE (pending_statics);
+ if (TREE_USED (decl) == 1
+ || TREE_READONLY (decl) == 0
+ || DECL_INITIAL (decl) == 0)
+ rest_of_decl_compilation (decl, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)), 1, 1);
+ pending_statics = TREE_CHAIN (pending_statics);
+ }
+
+ this_time = get_run_time ();
+ parse_time -= this_time - start_time;
+ varconst_time += this_time - start_time;
+
+ start_time = get_run_time ();
+
+ if (flag_handle_signatures)
+ walk_sigtables ((void (*)())0, finish_sigtable_vardecl);
+
+ for (fnname = saved_inlines; fnname; fnname = TREE_CHAIN (fnname))
+ {
+ tree decl = TREE_VALUE (fnname);
+ import_export_inline (decl);
+ if (DECL_ARTIFICIAL (decl) && ! DECL_INITIAL (decl)
+ && TREE_PUBLIC (decl) && ! DECL_WEAK (decl)
+ && DECL_NOT_REALLY_EXTERN (decl))
+ synthesize_method (decl);
+ }
+
+ /* Now write out inline functions which had their addresses taken and
+ which were not declared virtual and which were not declared `extern
+ inline'. */
+ {
+ int reconsider = 1; /* More may be referenced; check again */
+
+ while (reconsider)
+ {
+ tree last = saved_inlines = tree_cons (NULL_TREE, NULL_TREE,
+ saved_inlines);
+ tree last_head = last;
+ tree place = TREE_CHAIN (saved_inlines);
+ reconsider = 0;
+
+ walk_vtables ((void (*)())0, finish_vtable_vardecl);
+
+ for (; place; place = TREE_CHAIN (place))
+ {
+ tree decl = TREE_VALUE (place);
+
+ /* Slice out the empty elements put in just above in the
+ previous reconsidering. */
+ if (decl == NULL_TREE)
+ {
+ TREE_CHAIN (last) = TREE_CHAIN (place);
+ continue;
+ }
+
+ if (DECL_ARTIFICIAL (decl) && ! DECL_INITIAL (decl))
+ {
+ if (TREE_USED (decl))
+ {
+ synthesize_method (decl);
+ if (TREE_ASM_WRITTEN (decl))
+ reconsider = 1;
+ }
+ else
+ {
+ last = place;
+ continue;
+ }
+ }
+
+ if (TREE_ASM_WRITTEN (decl) || DECL_SAVED_INSNS (decl) == 0)
+ {
+ TREE_CHAIN (last) = TREE_CHAIN (place);
+ continue;
+ }
+
+ if ((TREE_PUBLIC (decl) && ! DECL_WEAK (decl))
+ || TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (decl))
+ || flag_keep_inline_functions)
+ {
+ TREE_CHAIN (last) = TREE_CHAIN (place);
+
+ if (DECL_NOT_REALLY_EXTERN (decl))
+ {
+ DECL_EXTERNAL (decl) = 0;
+ reconsider = 1;
+ temporary_allocation ();
+ output_inline_function (decl);
+ permanent_allocation (1);
+ }
+
+ continue;
+ }
+
+ last = place;
+ }
+ }
+ }
+
+ /* Now delete from the chain of variables all virtual function tables.
+ We output them all ourselves, because each will be treated specially. */
+
+ walk_vtables ((void (*)())0, prune_vtable_vardecl);
+
+ for (vars = getdecls (); vars; vars = TREE_CHAIN (vars))
+ {
+ if (TREE_CODE (vars) == THUNK_DECL)
+ emit_thunk (vars);
+ else if (TREE_CODE (vars) == FUNCTION_DECL
+ && ! DECL_INTERFACE_KNOWN (vars)
+ && DECL_C_STATIC (vars))
+ TREE_PUBLIC (vars) = 0;
+ }
+
+ if (might_have_exceptions_p ())
+ emit_exception_table ();
+
+ if (write_virtuals == 2)
+ {
+ /* Now complain about an virtual function tables promised
+ but not delivered. */
+ while (pending_vtables)
+ {
+ if (TREE_PURPOSE (pending_vtables) == NULL_TREE)
+ error ("virtual function table for `%s' not defined",
+ IDENTIFIER_POINTER (TREE_VALUE (pending_vtables)));
+ pending_vtables = TREE_CHAIN (pending_vtables);
+ }
+ }
+
+ finish_repo ();
+
+ this_time = get_run_time ();
+ parse_time -= this_time - start_time;
+ varconst_time += this_time - start_time;
+
+ if (flag_detailed_statistics)
+ dump_time_statistics ();
+}
+
+/* This is something of the form 'A()()()()()+1' that has turned out to be an
+ expr. Since it was parsed like a type, we need to wade through and fix
+ that. Unfortunately, since operator() is left-associative, we can't use
+ tail recursion. In the above example, TYPE is `A', and DECL is
+ `()()()()()'.
+
+ Maybe this shouldn't be recursive, but how often will it actually be
+ used? (jason) */
+tree
+reparse_absdcl_as_expr (type, decl)
+ tree type, decl;
+{
+ /* do build_functional_cast (type, NULL_TREE) at bottom */
+ if (TREE_OPERAND (decl, 0) == NULL_TREE)
+ return build_functional_cast (type, NULL_TREE);
+
+ /* recurse */
+ decl = reparse_decl_as_expr (type, TREE_OPERAND (decl, 0));
+
+ decl = build_x_function_call (decl, NULL_TREE, current_class_decl);
+
+ if (TREE_CODE (decl) == CALL_EXPR && TREE_TYPE (decl) != void_type_node)
+ decl = require_complete_type (decl);
+
+ return decl;
+}
+
+/* This is something of the form `int ((int)(int)(int)1)' that has turned
+ out to be an expr. Since it was parsed like a type, we need to wade
+ through and fix that. Since casts are right-associative, we are
+ reversing the order, so we don't have to recurse.
+
+ In the above example, DECL is the `(int)(int)(int)', and EXPR is the
+ `1'. */
+tree
+reparse_absdcl_as_casts (decl, expr)
+ tree decl, expr;
+{
+ tree type;
+
+ if (TREE_CODE (expr) == CONSTRUCTOR)
+ {
+ type = groktypename (TREE_VALUE (TREE_OPERAND (decl, 1)));
+ decl = TREE_OPERAND (decl, 0);
+
+ if (IS_SIGNATURE (type))
+ {
+ error ("cast specifies signature type");
+ return error_mark_node;
+ }
+
+ expr = digest_init (type, expr, (tree *) 0);
+ if (TREE_CODE (type) == ARRAY_TYPE && TYPE_SIZE (type) == 0)
+ {
+ int failure = complete_array_type (type, expr, 1);
+ if (failure)
+ my_friendly_abort (78);
+ }
+ }
+
+ while (decl)
+ {
+ type = groktypename (TREE_VALUE (TREE_OPERAND (decl, 1)));
+ decl = TREE_OPERAND (decl, 0);
+ expr = build_c_cast (type, expr, 0);
+ }
+
+ return expr;
+}
+
+/* Recursive helper function for reparse_decl_as_expr. It may be a good
+ idea to reimplement this using an explicit stack, rather than recursion. */
+static tree
+reparse_decl_as_expr1 (decl)
+ tree decl;
+{
+ switch (TREE_CODE (decl))
+ {
+ case IDENTIFIER_NODE:
+ return do_identifier (decl);
+ case INDIRECT_REF:
+ return build_x_indirect_ref
+ (reparse_decl_as_expr1 (TREE_OPERAND (decl, 0)), "unary *");
+ case ADDR_EXPR:
+ return build_x_unary_op (ADDR_EXPR,
+ reparse_decl_as_expr1 (TREE_OPERAND (decl, 0)));
+ case BIT_NOT_EXPR:
+ return build_x_unary_op (BIT_NOT_EXPR,
+ reparse_decl_as_expr1 (TREE_OPERAND (decl, 0)));
+ case SCOPE_REF:
+ return build_offset_ref (TREE_OPERAND (decl, 0), TREE_OPERAND (decl, 1));
+ case ARRAY_REF:
+ return grok_array_decl (reparse_decl_as_expr1 (TREE_OPERAND (decl, 0)),
+ TREE_OPERAND (decl, 1));
+ default:
+ my_friendly_abort (5);
+ return NULL_TREE;
+ }
+}
+
+/* This is something of the form `int (*a)++' that has turned out to be an
+ expr. It was only converted into parse nodes, so we need to go through
+ and build up the semantics. Most of the work is done by
+ reparse_decl_as_expr1, above.
+
+ In the above example, TYPE is `int' and DECL is `*a'. */
+tree
+reparse_decl_as_expr (type, decl)
+ tree type, decl;
+{
+ decl = reparse_decl_as_expr1 (decl);
+ if (type)
+ return build_functional_cast (type, build_tree_list (NULL_TREE, decl));
+ else
+ return decl;
+}
+
+/* This is something of the form `int (*a)' that has turned out to be a
+ decl. It was only converted into parse nodes, so we need to do the
+ checking that make_{pointer,reference}_declarator do. */
+
+tree
+finish_decl_parsing (decl)
+ tree decl;
+{
+ extern int current_class_depth;
+
+ switch (TREE_CODE (decl))
+ {
+ case IDENTIFIER_NODE:
+ return decl;
+ case INDIRECT_REF:
+ return make_pointer_declarator
+ (NULL_TREE, finish_decl_parsing (TREE_OPERAND (decl, 0)));
+ case ADDR_EXPR:
+ return make_reference_declarator
+ (NULL_TREE, finish_decl_parsing (TREE_OPERAND (decl, 0)));
+ case BIT_NOT_EXPR:
+ TREE_OPERAND (decl, 0) = finish_decl_parsing (TREE_OPERAND (decl, 0));
+ return decl;
+ case SCOPE_REF:
+ push_nested_class (TREE_TYPE (TREE_OPERAND (decl, 0)), 3);
+ TREE_COMPLEXITY (decl) = current_class_depth;
+ return decl;
+ case ARRAY_REF:
+ TREE_OPERAND (decl, 0) = finish_decl_parsing (TREE_OPERAND (decl, 0));
+ return decl;
+ default:
+ my_friendly_abort (5);
+ return NULL_TREE;
+ }
+}
+
+tree
+check_cp_case_value (value)
+ tree value;
+{
+ if (value == NULL_TREE)
+ return value;
+
+ /* build_c_cast puts on a NOP_EXPR to make a non-lvalue.
+ Strip such NOP_EXPRs. */
+ if (TREE_CODE (value) == NOP_EXPR
+ && TREE_TYPE (value) == TREE_TYPE (TREE_OPERAND (value, 0)))
+ value = TREE_OPERAND (value, 0);
+
+ if (TREE_READONLY_DECL_P (value))
+ {
+ value = decl_constant_value (value);
+ /* build_c_cast puts on a NOP_EXPR to make a non-lvalue.
+ Strip such NOP_EXPRs. */
+ if (TREE_CODE (value) == NOP_EXPR
+ && TREE_TYPE (value) == TREE_TYPE (TREE_OPERAND (value, 0)))
+ value = TREE_OPERAND (value, 0);
+ }
+ value = fold (value);
+
+ if (TREE_CODE (value) != INTEGER_CST
+ && value != error_mark_node)
+ {
+ cp_error ("case label `%E' does not reduce to an integer constant",
+ value);
+ value = error_mark_node;
+ }
+ else
+ /* Promote char or short to int. */
+ value = default_conversion (value);
+
+ constant_expression_warning (value);
+
+ return value;
+}
+
+tree current_namespace;
+
+/* Get the inner part of a namespace id. It doesn't have any prefix, nor
+ postfix. Returns 0 if in global namespace. */
+tree
+get_namespace_id ()
+{
+ tree x = current_namespace;
+ if (x)
+ x = TREE_PURPOSE (x);
+ return x;
+}
+
+/* Build up a DECL_ASSEMBLER_NAME for NAME in the current namespace. */
+tree
+current_namespace_id (name)
+ tree name;
+{
+ tree old_id = get_namespace_id ();
+ char *buf;
+
+ /* Global names retain old encoding. */
+ if (! old_id)
+ return name;
+
+ buf = (char *) alloca (8 + IDENTIFIER_LENGTH (old_id)
+ + IDENTIFIER_LENGTH (name));
+ sprintf (buf, "__ns_%s_%s", IDENTIFIER_POINTER (old_id),
+ IDENTIFIER_POINTER (name));
+ return get_identifier (buf);
+}
+
+void
+do_namespace_alias (alias, namespace)
+ tree alias, namespace;
+{
+}
+
+tree
+do_toplevel_using_decl (decl)
+ tree decl;
+{
+ if (decl == NULL_TREE || decl == error_mark_node)
+ return;
+
+ if (TREE_CODE (decl) == SCOPE_REF)
+ decl = resolve_scope_to_name (NULL_TREE, decl);
+
+ /* Is this the right way to do an id list? */
+ if (TREE_CODE (decl) != TREE_LIST)
+ {
+ pushdecl (decl);
+ }
+ else
+ while (decl)
+ {
+ pushdecl (TREE_VALUE (decl));
+ decl = TREE_CHAIN (decl);
+ }
+}
+
+tree
+do_class_using_decl (decl)
+ tree decl;
+{
+ tree type;
+
+ /* Ignore for now, unimplemented. */
+ return NULL_TREE;
+}
+
+void
+do_using_directive (namespace)
+ tree namespace;
+{
+}
+
+void
+check_default_args (x)
+ tree x;
+{
+ tree arg = TYPE_ARG_TYPES (TREE_TYPE (x));
+ int saw_def = 0, i = 0 - (TREE_CODE (TREE_TYPE (x)) == METHOD_TYPE);
+ for (; arg && arg != void_list_node; arg = TREE_CHAIN (arg), ++i)
+ {
+ if (TREE_PURPOSE (arg))
+ saw_def = 1;
+ else if (saw_def)
+ {
+ cp_error ("default argument missing for parameter %P of `%#D'",
+ i, x);
+ break;
+ }
+ }
+}
diff --git a/contrib/gcc/cp/edsel.c b/contrib/gcc/cp/edsel.c
new file mode 100644
index 0000000..35099d5
--- /dev/null
+++ b/contrib/gcc/cp/edsel.c
@@ -0,0 +1,928 @@
+/* Interface to LUCID Cadillac system for GNU compiler.
+ Copyright (C) 1988, 1992, 1993 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include "config.h"
+
+#include "tree.h"
+#include "flags.h"
+#include <stdio.h>
+#include "cp-tree.h"
+#include "obstack.h"
+
+#ifdef CADILLAC
+#include <compilerreq.h>
+#include <compilerconn.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <errno.h>
+#include <sys/file.h>
+
+#define obstack_chunk_alloc xmalloc
+#define obstack_chunk_free free
+
+void init_cadillac ();
+
+extern char *input_filename;
+extern int lineno;
+
+/* Put random information we might want to get back from
+ Cadillac here. */
+typedef struct
+{
+ /* The connection to the Cadillac kernel. */
+ Connection *conn;
+
+ /* Input and output file descriptors for Cadillac. */
+ short fd_input, fd_output;
+
+ /* #include nesting of current file. */
+ short depth;
+
+ /* State variables for the connection. */
+ char messages;
+ char conversion;
+ char emission;
+ char process_until;
+
+ /* #if level of current file. */
+ int iflevel;
+
+ /* Line number that starts current source file. */
+ int lineno;
+
+ /* Name of current file. */
+ char *filename;
+
+ /* Where to stop processing (if process_until is set). */
+ char *end_filename;
+ int end_position;
+
+} cadillac_struct;
+static cadillac_struct cadillacObj;
+
+/* Nonzero if in the process of exiting. */
+static int exiting;
+
+void cadillac_note_source ();
+static void CWriteLanguageDecl ();
+static void CWriteLanguageType ();
+static void CWriteTopLevel ();
+static void cadillac_note_filepos ();
+static void cadillac_process_request (), cadillac_process_requests ();
+static void cadillac_switch_source ();
+static void exit_cadillac ();
+
+/* Blocking test. */
+static int
+readable_p (fd)
+ int fd;
+{
+ fd_set f;
+
+ FD_ZERO (&f);
+ FD_SET (fd, &f);
+
+ return select (32, &f, NULL, NULL, 0) == 1;
+}
+
+static CObjectType *tree_to_cadillac_map;
+struct obstack cadillac_obstack;
+
+
+#include "stack.h"
+
+struct context_level
+{
+ struct stack_level base;
+
+ tree context;
+};
+
+/* Stack for maintaining contexts (in case functions or types are nested).
+ When defining a struct type, the `context' field is the RECORD_TYPE.
+ When defining a function, the `context' field is the FUNCTION_DECL. */
+
+static struct context_level *context_stack;
+
+static struct context_level *
+push_context_level (stack, obstack)
+ struct stack_level *stack;
+ struct obstack *obstack;
+{
+ struct context_level tem;
+
+ tem.base.prev = stack;
+ return (struct context_level *)push_stack_level (obstack, &tem, sizeof (tem));
+}
+
+/* Discard a level of search allocation. */
+
+static struct context_level *
+pop_context_level (stack)
+ struct context_level *stack;
+{
+ stack = (struct context_level *)pop_stack_level (stack);
+ return stack;
+}
+
+void
+init_cadillac ()
+{
+ extern FILE *finput;
+ extern int errno;
+ CCompilerMessage* req;
+ cadillac_struct *cp = &cadillacObj;
+ int i;
+
+ if (! flag_cadillac)
+ return;
+
+ tree_to_cadillac_map = (CObjectType*) xmalloc (sizeof (CObjectType) * LAST_CPLUS_TREE_CODE);
+ for (i = 0; i < LAST_CPLUS_TREE_CODE; i++)
+ tree_to_cadillac_map[i] = MiscOType;
+ tree_to_cadillac_map[RECORD_TYPE] = StructOType;
+ tree_to_cadillac_map[UNION_TYPE] = UnionOType;
+ tree_to_cadillac_map[ENUMERAL_TYPE] = EnumTypeOType;
+ tree_to_cadillac_map[TYPE_DECL] = TypedefOType;
+ tree_to_cadillac_map[VAR_DECL] = VariableOType;
+ tree_to_cadillac_map[CONST_DECL] = EnumConstantOType;
+ tree_to_cadillac_map[FUNCTION_DECL] = FunctionOType;
+ tree_to_cadillac_map[FIELD_DECL] = FieldOType;
+
+#ifdef sun
+ on_exit (&exit_cadillac, 0);
+#endif
+
+ gcc_obstack_init (&cadillac_obstack);
+
+ /* Yow! This is the way Cadillac was designed to deal with
+ Oregon C++ compiler! */
+ cp->fd_input = flag_cadillac;
+ cp->fd_output = flag_cadillac;
+
+ /* Start in "turned-on" state. */
+ cp->messages = 1;
+ cp->conversion = 1;
+ cp->emission = 1;
+
+ /* Establish a connection with Cadillac here. */
+ cp->conn = NewConnection (cp, cp->fd_input, cp->fd_output);
+
+ CWriteHeader (cp->conn, WaitingMType, 0);
+ CWriteRequestBuffer (cp->conn);
+
+ if (!readable_p (cp->fd_input))
+ ;
+
+ req = CReadCompilerMessage (cp->conn);
+
+ if (!req)
+ switch (errno)
+ {
+ case EWOULDBLOCK:
+ sleep (5);
+ return;
+
+ case 0:
+ fatal ("init_cadillac: EOF on connection to kernel, exiting\n");
+ break;
+
+ default:
+ perror ("Editor to kernel connection");
+ exit (0);
+ }
+}
+
+static void
+cadillac_process_requests (conn)
+ Connection *conn;
+{
+ CCompilerMessage *req;
+ while (req = (CCompilerMessage*) CPeekNextRequest (conn))
+ {
+ req = CReadCompilerMessage (conn);
+ cadillac_process_request (&cadillacObj, req);
+ }
+}
+
+static void
+cadillac_process_request (cp, req)
+ cadillac_struct *cp;
+ CCompilerMessage *req;
+{
+ if (! req)
+ return;
+
+ switch (req->reqType)
+ {
+ case ProcessUntilMType:
+ if (cp->process_until)
+ my_friendly_abort (23);
+ cp->process_until = 1;
+ /* This is not really right. */
+ cp->end_position = ((CCompilerCommand*)req)->processuntil.position;
+#if 0
+ cp->end_filename = req->processuntil.filename;
+#endif
+ break;
+
+ case CommandMType:
+ switch (req->header.data)
+ {
+ case MessagesOnCType:
+ cp->messages = 1;
+ break;
+ case MessagesOffCType:
+ cp->messages = 0;
+ break;
+ case ConversionOnCType:
+ cp->conversion = 1;
+ break;
+ case ConversionOffCType:
+ cp->conversion = 0;
+ break;
+ case EmissionOnCType:
+ cp->emission = 1;
+ break;
+ case EmissionOffCType:
+ cp->emission = 0;
+ break;
+
+ case FinishAnalysisCType:
+ return;
+
+ case PuntAnalysisCType:
+ case ContinueAnalysisCType:
+ case GotoFileposCType:
+ case OpenSucceededCType:
+ case OpenFailedCType:
+ fprintf (stderr, "request type %d not implemented\n", req->reqType);
+ return;
+
+ case DieCType:
+ if (! exiting)
+ my_friendly_abort (24);
+ return;
+
+ }
+ break;
+
+ default:
+ fatal ("unknown request type %d", req->reqType);
+ }
+}
+
+void
+cadillac_start ()
+{
+ Connection *conn = cadillacObj.conn;
+ CCompilerMessage *req;
+
+ /* Let Cadillac know that we start in C++ language scope. */
+ CWriteHeader (conn, ForeignLinkageMType, LinkCPlus);
+ CWriteLength (conn);
+ CWriteRequestBuffer (conn);
+
+ cadillac_process_requests (conn);
+}
+
+static void
+cadillac_printf (msg, name)
+{
+ if (cadillacObj.messages)
+ printf ("[%s,%4d] %s `%s'\n", input_filename, lineno, msg, name);
+}
+
+void
+cadillac_start_decl (decl)
+ tree decl;
+{
+ Connection *conn = cadillacObj.conn;
+ CObjectType object_type = tree_to_cadillac_map [TREE_CODE (decl)];
+
+ if (context_stack)
+ switch (TREE_CODE (context_stack->context))
+ {
+ case FUNCTION_DECL:
+ /* Currently, cadillac only implements top-level forms. */
+ return;
+ case RECORD_TYPE:
+ case UNION_TYPE:
+ cadillac_printf ("start class-level decl", IDENTIFIER_POINTER (DECL_NAME (decl)));
+ break;
+ default:
+ my_friendly_abort (25);
+ }
+ else
+ {
+ cadillac_printf ("start top-level decl", IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
+ CWriteTopLevel (conn, StartMType);
+ }
+
+ CWriteLanguageDecl (conn, decl, tree_to_cadillac_map[TREE_CODE (decl)]);
+ CWriteRequestBuffer (conn);
+ cadillac_process_requests (conn);
+}
+
+void
+cadillac_finish_decl (decl)
+ tree decl;
+{
+ Connection *conn = cadillacObj.conn;
+
+ if (context_stack)
+ switch (TREE_CODE (context_stack->context))
+ {
+ case FUNCTION_DECL:
+ return;
+ case RECORD_TYPE:
+ case UNION_TYPE:
+ cadillac_printf ("end class-level decl", IDENTIFIER_POINTER (DECL_NAME (decl)));
+ CWriteHeader (conn, EndDefMType, 0);
+ CWriteLength (conn);
+ break;
+ default:
+ my_friendly_abort (26);
+ }
+ else
+ {
+ cadillac_printf ("end top-level decl", IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
+ CWriteHeader (conn, EndDefMType, 0);
+ CWriteLength (conn);
+ CWriteTopLevel (conn, StopMType);
+ }
+
+ CWriteRequestBuffer (conn);
+ cadillac_process_requests (conn);
+}
+
+void
+cadillac_start_function (fndecl)
+ tree fndecl;
+{
+ Connection *conn = cadillacObj.conn;
+
+ if (context_stack)
+ /* nested functions not yet handled. */
+ my_friendly_abort (27);
+
+ cadillac_printf ("start top-level function", lang_printable_name (fndecl));
+ context_stack = push_context_level (context_stack, &cadillac_obstack);
+ context_stack->context = fndecl;
+
+ CWriteTopLevel (conn, StartMType);
+ my_friendly_assert (TREE_CODE (fndecl) == FUNCTION_DECL, 202);
+ CWriteLanguageDecl (conn, fndecl,
+ (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE
+ ? MemberFnOType : FunctionOType));
+ CWriteRequestBuffer (conn);
+ cadillac_process_requests (conn);
+}
+
+void
+cadillac_finish_function (fndecl)
+ tree fndecl;
+{
+ Connection *conn = cadillacObj.conn;
+
+ cadillac_printf ("end top-level function", lang_printable_name (fndecl));
+ context_stack = pop_context_level (context_stack);
+
+ if (context_stack)
+ /* nested functions not yet implemented. */
+ my_friendly_abort (28);
+
+ CWriteHeader (conn, EndDefMType, 0);
+ CWriteLength (conn);
+ CWriteTopLevel (conn, StopMType);
+ CWriteRequestBuffer (conn);
+ cadillac_process_requests (conn);
+}
+
+void
+cadillac_finish_anon_union (decl)
+ tree decl;
+{
+ Connection *conn = cadillacObj.conn;
+
+ if (! global_bindings_p ())
+ return;
+ cadillac_printf ("finish top-level anon union", "");
+ CWriteHeader (conn, EndDefMType, 0);
+ CWriteLength (conn);
+ CWriteTopLevel (conn, StopMType);
+ CWriteRequestBuffer (conn);
+ cadillac_process_requests (conn);
+}
+
+void
+cadillac_start_enum (type)
+ tree type;
+{
+ Connection *conn = cadillacObj.conn;
+
+ tree name = TYPE_NAME (type);
+
+ if (TREE_CODE (name) == TYPE_DECL)
+ name = DECL_NAME (name);
+
+ if (context_stack)
+ switch (TREE_CODE (context_stack->context))
+ {
+ case FUNCTION_DECL:
+ return;
+ case RECORD_TYPE:
+ case UNION_TYPE:
+ break;
+ default:
+ my_friendly_abort (29);
+ }
+ else
+ {
+ cadillac_printf ("start top-level enum", IDENTIFIER_POINTER (name));
+ CWriteTopLevel (conn, StartMType);
+ }
+
+ CWriteLanguageType (conn, type, tree_to_cadillac_map[ENUMERAL_TYPE]);
+}
+
+void
+cadillac_finish_enum (type)
+ tree type;
+{
+ Connection *conn = cadillacObj.conn;
+ tree name = TYPE_NAME (type);
+
+ if (TREE_CODE (name) == TYPE_DECL)
+ name = DECL_NAME (name);
+
+ if (context_stack)
+ switch (TREE_CODE (context_stack->context))
+ {
+ case FUNCTION_DECL:
+ return;
+ case RECORD_TYPE:
+ case UNION_TYPE:
+ CWriteHeader (conn, EndDefMType, 0);
+ CWriteLength (conn);
+ break;
+ default:
+ my_friendly_abort (30);
+ }
+ else
+ {
+ CWriteHeader (conn, EndDefMType, 0);
+ CWriteLength (conn);
+ cadillac_printf ("finish top-level enum", IDENTIFIER_POINTER (name));
+ CWriteTopLevel (conn, StopMType);
+ }
+
+ CWriteRequestBuffer (conn);
+ cadillac_process_requests (conn);
+}
+
+void
+cadillac_start_struct (type)
+ tree type;
+{
+ Connection *conn = cadillacObj.conn;
+ tree name = TYPE_NAME (type);
+
+ if (TREE_CODE (name) == TYPE_DECL)
+ name = DECL_NAME (name);
+
+ if (context_stack)
+ switch (TREE_CODE (context_stack->context))
+ {
+ case FUNCTION_DECL:
+ return;
+ case RECORD_TYPE:
+ case UNION_TYPE:
+ return;
+ default:
+ my_friendly_abort (31);
+ }
+ else
+ {
+ cadillac_printf ("start struct", IDENTIFIER_POINTER (name));
+ CWriteTopLevel (conn, StartMType);
+ }
+
+ context_stack = push_context_level (context_stack, &cadillac_obstack);
+ context_stack->context = type;
+
+ CWriteLanguageType (conn, type,
+ TYPE_LANG_SPECIFIC (type) && CLASSTYPE_DECLARED_CLASS (type) ? ClassOType : tree_to_cadillac_map[TREE_CODE (type)]);
+}
+
+void
+cadillac_finish_struct (type)
+ tree type;
+{
+ Connection *conn = cadillacObj.conn;
+ tree name = TYPE_NAME (type);
+
+ if (TREE_CODE (name) == TYPE_DECL)
+ name = DECL_NAME (name);
+
+ context_stack = pop_context_level (context_stack);
+ if (context_stack)
+ return;
+
+ cadillac_printf ("finish struct", IDENTIFIER_POINTER (name));
+ CWriteHeader (conn, EndDefMType, 0);
+ CWriteLength (conn);
+ CWriteTopLevel (conn, StopMType);
+ CWriteRequestBuffer (conn);
+ cadillac_process_requests (conn);
+}
+
+void
+cadillac_finish_exception (type)
+ tree type;
+{
+ Connection *conn = cadillacObj.conn;
+
+ fatal ("cadillac_finish_exception");
+ CWriteHeader (conn, EndDefMType, 0);
+ CWriteLength (conn);
+ CWriteTopLevel (conn, StopMType);
+ CWriteRequestBuffer (conn);
+ cadillac_process_requests (conn);
+}
+
+void
+cadillac_push_class (type)
+ tree type;
+{
+}
+
+void
+cadillac_pop_class ()
+{
+}
+
+void
+cadillac_push_lang (name)
+ tree name;
+{
+ Connection *conn = cadillacObj.conn;
+ CLinkLanguageType m;
+
+ if (name == lang_name_cplusplus)
+ m = LinkCPlus;
+ else if (name == lang_name_c)
+ m = LinkC;
+ else
+ my_friendly_abort (32);
+ CWriteHeader (conn, ForeignLinkageMType, m);
+ CWriteRequestBuffer (conn);
+ cadillac_process_requests (conn);
+}
+
+void
+cadillac_pop_lang ()
+{
+ Connection *conn = cadillacObj.conn;
+
+ CWriteHeader (conn, ForeignLinkageMType, LinkPop);
+ CWriteRequestBuffer (conn);
+ cadillac_process_requests (conn);
+}
+
+void
+cadillac_finish_stmt ()
+{
+}
+
+void
+cadillac_note_source ()
+{
+ cadillacObj.lineno = lineno;
+ cadillacObj.filename = input_filename;
+}
+
+static void
+CWriteTopLevel (conn, m)
+ Connection *conn;
+ CMessageSubType m;
+{
+ static context_id = 0;
+ CWriteHeader (conn, TopLevelFormMType, m);
+ cadillac_note_filepos ();
+
+ /* Eventually, this will point somewhere into the digest file. */
+ context_id += 1;
+ CWriteSomething (conn, &context_id, sizeof (BITS32));
+
+ CWriteSomething (conn, &cadillacObj.iflevel, sizeof (BITS32));
+ CWriteLength (conn);
+}
+
+static void
+cadillac_note_filepos ()
+{
+ extern FILE *finput;
+ int pos = ftell (finput);
+ CWriteSomething (cadillacObj.conn, &pos, sizeof (BITS32));
+}
+
+void
+cadillac_switch_source (startflag)
+ int startflag;
+{
+ Connection *conn = cadillacObj.conn;
+ /* Send out the name of the source file being compiled. */
+
+ CWriteHeader (conn, SourceFileMType, startflag ? StartMType : StopMType);
+ CWriteSomething (conn, &cadillacObj.depth, sizeof (BITS16));
+ CWriteVstring0 (conn, input_filename);
+ CWriteLength (conn);
+ CWriteRequestBuffer (conn);
+ cadillac_process_requests (conn);
+}
+
+void
+cadillac_push_source ()
+{
+ cadillacObj.depth += 1;
+ cadillac_switch_source (1);
+}
+
+void
+cadillac_pop_source ()
+{
+ cadillacObj.depth -= 1;
+ cadillac_switch_source (0);
+}
+
+struct cadillac_mdep
+{
+ short object_type;
+ char linkage;
+ char access;
+ short length;
+};
+
+static void
+CWriteLanguageElem (conn, p, name)
+ Connection *conn;
+ struct cadillac_mdep *p;
+ char *name;
+{
+ CWriteSomething (conn, &p->object_type, sizeof (BITS16));
+ CWriteSomething (conn, &p->linkage, sizeof (BITS8));
+ CWriteSomething (conn, &p->access, sizeof (BITS8));
+ CWriteSomething (conn, &p->length, sizeof (BITS16));
+ CWriteVstring0 (conn, name);
+
+#if 0
+ /* Don't write date_type. */
+ CWriteVstring0 (conn, "");
+#endif
+ CWriteLength (conn);
+}
+
+static void
+CWriteLanguageDecl (conn, decl, object_type)
+ Connection *conn;
+ tree decl;
+ CObjectType object_type;
+{
+ struct cadillac_mdep foo;
+ tree name;
+
+ CWriteHeader (conn, LanguageElementMType, StartDefineMType);
+ foo.object_type = object_type;
+ if (decl_type_context (decl))
+ {
+ foo.linkage = ParentLinkage;
+ if (TREE_PRIVATE (decl))
+ foo.access = PrivateAccess;
+ else if (TREE_PROTECTED (decl))
+ foo.access = ProtectedAccess;
+ else
+ foo.access = PublicAccess;
+ }
+ else
+ {
+ if (TREE_PUBLIC (decl))
+ foo.linkage = GlobalLinkage;
+ else
+ foo.linkage = FileLinkage;
+ foo.access = PublicAccess;
+ }
+ name = DECL_NAME (decl);
+ foo.length = IDENTIFIER_LENGTH (name);
+
+ CWriteLanguageElem (conn, &foo, IDENTIFIER_POINTER (name));
+ CWriteRequestBuffer (conn);
+ cadillac_process_requests (conn);
+}
+
+static void
+CWriteLanguageType (conn, type, object_type)
+ Connection *conn;
+ tree type;
+ CObjectType object_type;
+{
+ struct cadillac_mdep foo;
+ tree name = TYPE_NAME (type);
+
+ CWriteHeader (conn, LanguageElementMType, StartDefineMType);
+ foo.object_type = object_type;
+ if (current_class_type)
+ {
+ foo.linkage = ParentLinkage;
+ if (TREE_PRIVATE (type))
+ foo.access = PrivateAccess;
+ else if (TREE_PROTECTED (type))
+ foo.access = ProtectedAccess;
+ else
+ foo.access = PublicAccess;
+ }
+ else
+ {
+ foo.linkage = NoLinkage;
+ foo.access = PublicAccess;
+ }
+ if (TREE_CODE (name) == TYPE_DECL)
+ name = DECL_NAME (name);
+
+ foo.length = IDENTIFIER_LENGTH (name);
+
+ CWriteLanguageElem (conn, &foo, IDENTIFIER_POINTER (name));
+ CWriteRequestBuffer (conn);
+ cadillac_process_requests (conn);
+}
+
+static void
+CWriteUseObject (conn, type, object_type, use)
+ Connection *conn;
+ tree type;
+ CObjectType object_type;
+ CMessageSubType use;
+{
+ struct cadillac_mdep foo;
+ tree name = NULL_TREE;
+
+ CWriteHeader (conn, LanguageElementMType, use);
+ foo.object_type = object_type;
+ if (current_class_type)
+ {
+ foo.linkage = ParentLinkage;
+ if (TREE_PRIVATE (type))
+ foo.access = PrivateAccess;
+ else if (TREE_PROTECTED (type))
+ foo.access = ProtectedAccess;
+ else
+ foo.access = PublicAccess;
+ }
+ else
+ {
+ foo.linkage = NoLinkage;
+ foo.access = PublicAccess;
+ }
+ switch (TREE_CODE (type))
+ {
+ case VAR_DECL:
+ case FIELD_DECL:
+ case TYPE_DECL:
+ case CONST_DECL:
+ case FUNCTION_DECL:
+ name = DECL_NAME (type);
+ break;
+
+ default:
+ my_friendly_abort (33);
+ }
+
+ foo.length = IDENTIFIER_LENGTH (name);
+
+ CWriteLanguageElem (conn, &foo, IDENTIFIER_POINTER (name));
+ CWriteRequestBuffer (conn);
+ cadillac_process_requests (conn);
+}
+
+/* Here's how we exit under cadillac. */
+
+static void
+exit_cadillac ()
+{
+ extern int errorcount;
+
+ Connection *conn = cadillacObj.conn;
+
+ if (flag_cadillac)
+ {
+ CCompilerMessage *req;
+
+ CWriteHeader (conn, FinishedMType,
+ errorcount ? 0 : CsObjectWritten | CsComplete);
+ /* Bye, bye! */
+ CWriteRequestBuffer (conn);
+
+ /* Block on read. */
+ while (! readable_p (cadillacObj.fd_input))
+ {
+ if (exiting)
+ my_friendly_abort (34);
+ exiting = 1;
+ }
+ exiting = 1;
+
+ req = CReadCompilerMessage (conn);
+ cadillac_process_request (&cadillacObj, req);
+ }
+}
+
+#else
+/* Stubs. */
+void init_cadillac () {}
+void cadillac_start () {}
+void cadillac_start_decl (decl)
+ tree decl;
+{}
+void
+cadillac_finish_decl (decl)
+ tree decl;
+{}
+void
+cadillac_start_function (fndecl)
+ tree fndecl;
+{}
+void
+cadillac_finish_function (fndecl)
+ tree fndecl;
+{}
+void
+cadillac_finish_anon_union (decl)
+ tree decl;
+{}
+void
+cadillac_start_enum (type)
+ tree type;
+{}
+void
+cadillac_finish_enum (type)
+ tree type;
+{}
+void
+cadillac_start_struct (type)
+ tree type;
+{}
+void
+cadillac_finish_struct (type)
+ tree type;
+{}
+void
+cadillac_finish_exception (type)
+ tree type;
+{}
+void
+cadillac_push_class (type)
+ tree type;
+{}
+void
+cadillac_pop_class ()
+{}
+void
+cadillac_push_lang (name)
+ tree name;
+{}
+void
+cadillac_pop_lang ()
+{}
+void
+cadillac_note_source ()
+{}
+void
+cadillac_finish_stmt ()
+{}
+void
+cadillac_switch_source ()
+{}
+void
+cadillac_push_source ()
+{}
+void
+cadillac_pop_source ()
+{}
+#endif
diff --git a/contrib/gcc/cp/errfn.c b/contrib/gcc/cp/errfn.c
new file mode 100644
index 0000000..f36b0e1
--- /dev/null
+++ b/contrib/gcc/cp/errfn.c
@@ -0,0 +1,230 @@
+/* Provide a call-back mechanism for handling error output.
+ Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
+ Contributed by Jason Merrill (jason@cygnus.com)
+
+ This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include "config.h"
+#include "tree.h"
+#include <ctype.h>
+
+/* cp_printer is the type of a function which converts an argument into
+ a string for digestion by printf. The cp_printer function should deal
+ with all memory management; the functions in this file will not free
+ the char*s returned. See error.c for an example use of this code. */
+
+typedef char* cp_printer PROTO((HOST_WIDE_INT, int));
+extern cp_printer * cp_printers[256];
+
+/* Whether or not we should try to be quiet for errors and warnings; this is
+ used to avoid being too talkative about problems with tentative choices
+ when we're computing the conversion costs for a method call. */
+int cp_silent = 0;
+
+typedef void errorfn (); /* deliberately vague */
+
+extern char* cp_file_of PROTO((tree));
+extern int cp_line_of PROTO((tree));
+
+#define STRDUP(f) (ap = (char *) alloca (strlen (f) +1), strcpy (ap, (f)), ap)
+
+#define NARGS 4
+#define arglist a1, a2, a3, a4
+#define arglist_dcl HOST_WIDE_INT a1, a2, a3, a4;
+#define ARGSINIT args[0] = a1; args[1] = a2; args[2] = a3; args[3] = a4;
+#define ARGSLIST args[0], args[1], args[2], args[3]
+
+static void
+cp_thing (errfn, atarg1, format, arglist)
+ errorfn *errfn;
+ int atarg1;
+ char *format;
+ arglist_dcl
+{
+ char *fmt;
+ char *f;
+ char *ap;
+ int arg;
+ HOST_WIDE_INT atarg = atarg1 ? a1 : 0;
+ HOST_WIDE_INT args[NARGS];
+ ARGSINIT
+
+ fmt = STRDUP(format);
+
+ for (f = fmt, arg = 0; *f; ++f)
+ {
+ cp_printer * function;
+ int alternate;
+ int maybe_here;
+
+ /* ignore text */
+ if (*f != '%') continue;
+
+ ++f;
+
+ alternate = 0;
+ maybe_here = 0;
+
+ /* ignore most flags */
+ while (*f == ' ' || *f == '-' || *f == '+' || *f == '#')
+ {
+ if (*f == '+')
+ maybe_here = 1;
+ else if (*f == '#')
+ alternate = 1;
+ ++f;
+ }
+
+ /* ignore field width */
+ if (*f == '*')
+ {
+ ++f;
+ ++arg;
+ }
+ else
+ while (isdigit (*f))
+ ++f;
+
+ /* ignore precision */
+ if (*f == '.')
+ {
+ ++f;
+ if (*f == '*')
+ {
+ ++f;
+ ++arg;
+ }
+ else
+ while (isdigit (*f))
+ ++f;
+ }
+
+ /* ignore "long" */
+ if (*f == 'l')
+ ++f;
+
+ function = cp_printers[(int)*f];
+
+ if (function)
+ {
+ char *p;
+
+ if (arg >= NARGS) abort ();
+
+ if (maybe_here && atarg1)
+ atarg = args[arg];
+
+ /* Must use a temporary to avoid calling *function twice */
+ p = (*function) (args[arg], alternate);
+ args[arg] = (HOST_WIDE_INT) STRDUP(p);
+ *f = 's';
+ }
+
+ ++arg; /* Assume valid format string */
+
+ }
+
+ if (atarg)
+ {
+ char *file = cp_file_of ((tree) atarg);
+ int line = cp_line_of ((tree) atarg);
+ (*errfn) (file, line, fmt, ARGSLIST);
+ }
+ else
+ (*errfn) (fmt, ARGSLIST);
+
+}
+
+void
+cp_error (format, arglist)
+ char *format;
+ arglist_dcl
+{
+ extern errorfn error;
+ if (! cp_silent)
+ cp_thing (error, 0, format, arglist);
+}
+
+void
+cp_warning (format, arglist)
+ char *format;
+ arglist_dcl
+{
+ extern errorfn warning;
+ if (! cp_silent)
+ cp_thing (warning, 0, format, arglist);
+}
+
+void
+cp_pedwarn (format, arglist)
+ char *format;
+ arglist_dcl
+{
+ extern errorfn pedwarn;
+ if (! cp_silent)
+ cp_thing (pedwarn, 0, format, arglist);
+}
+
+void
+cp_compiler_error (format, arglist)
+ char *format;
+ arglist_dcl
+{
+ extern errorfn compiler_error;
+ if (! cp_silent)
+ cp_thing (compiler_error, 0, format, arglist);
+}
+
+void
+cp_sprintf (format, arglist)
+ char *format;
+ arglist_dcl
+{
+ extern errorfn sprintf;
+ cp_thing (sprintf, 0, format, arglist);
+}
+
+void
+cp_error_at (format, arglist)
+ char *format;
+ arglist_dcl
+{
+ extern errorfn error_with_file_and_line;
+ if (! cp_silent)
+ cp_thing (error_with_file_and_line, 1, format, arglist);
+}
+
+void
+cp_warning_at (format, arglist)
+ char *format;
+ arglist_dcl
+{
+ extern errorfn warning_with_file_and_line;
+ if (! cp_silent)
+ cp_thing (warning_with_file_and_line, 1, format, arglist);
+}
+
+void
+cp_pedwarn_at (format, arglist)
+ char *format;
+ arglist_dcl
+{
+ extern errorfn pedwarn_with_file_and_line;
+ if (! cp_silent)
+ cp_thing (pedwarn_with_file_and_line, 1, format, arglist);
+}
diff --git a/contrib/gcc/cp/error.c b/contrib/gcc/cp/error.c
new file mode 100644
index 0000000..4eb196e
--- /dev/null
+++ b/contrib/gcc/cp/error.c
@@ -0,0 +1,1482 @@
+/* Call-backs for C++ error reporting.
+ This code is non-reentrant.
+ Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
+
+ This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include "config.h"
+#include "tree.h"
+#include "cp-tree.h"
+#include "obstack.h"
+#include <ctype.h>
+
+typedef char* cp_printer ();
+
+#define A args_as_string
+#define C code_as_string
+#define D decl_as_string
+#define E expr_as_string
+#define L language_as_string
+#define O op_as_string
+#define P parm_as_string
+#define T type_as_string
+#define V cv_as_string
+
+#define _ (cp_printer *) 0
+cp_printer * cp_printers[256] =
+{
+/*0 1 2 3 4 5 6 7 8 9 A B C D E F */
+ _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0x00 */
+ _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0x10 */
+ _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0x20 */
+ _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0x30 */
+ _, A, _, C, D, E, _, _, _, _, _, _, L, _, _, O, /* 0x40 */
+ P, _, _, _, T, _, V, _, _, _, _, _, _, _, _, _, /* 0x50 */
+ _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0x60 */
+ _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, _, /* 0x70 */
+};
+#undef C
+#undef D
+#undef E
+#undef L
+#undef O
+#undef P
+#undef T
+#undef V
+#undef _
+
+#define obstack_chunk_alloc xmalloc
+#define obstack_chunk_free free
+
+/* Obstack where we build text strings for overloading, etc. */
+static struct obstack scratch_obstack;
+static char *scratch_firstobj;
+
+# define OB_INIT() (scratch_firstobj ? (obstack_free (&scratch_obstack, scratch_firstobj), 0) : 0)
+# define OB_PUTC(C) (obstack_1grow (&scratch_obstack, (C)))
+# define OB_PUTC2(C1,C2) \
+ (obstack_1grow (&scratch_obstack, (C1)), obstack_1grow (&scratch_obstack, (C2)))
+# define OB_PUTS(S) (obstack_grow (&scratch_obstack, (S), sizeof (S) - 1))
+# define OB_PUTID(ID) \
+ (obstack_grow (&scratch_obstack, IDENTIFIER_POINTER (ID), \
+ IDENTIFIER_LENGTH (ID)))
+# define OB_PUTCP(S) (obstack_grow (&scratch_obstack, (S), strlen (S)))
+# define OB_FINISH() (obstack_1grow (&scratch_obstack, '\0'))
+# define OB_PUTI(CST) do { sprintf (digit_buffer, "%d", (CST)); \
+ OB_PUTCP (digit_buffer); } while (0)
+# define OB_UNPUT(N) obstack_blank (&scratch_obstack, - (N));
+
+# define NEXT_CODE(t) (TREE_CODE (TREE_TYPE (t)))
+
+static void dump_type (), dump_decl (), dump_function_decl ();
+static void dump_expr (), dump_unary_op (), dump_binary_op ();
+static void dump_aggr_type (), dump_type_prefix (), dump_type_suffix ();
+static void dump_function_name ();
+
+void
+init_error ()
+{
+ gcc_obstack_init (&scratch_obstack);
+ scratch_firstobj = (char *)obstack_alloc (&scratch_obstack, 0);
+}
+
+enum pad { none, before, after };
+
+static void
+dump_readonly_or_volatile (t, p)
+ tree t;
+ enum pad p;
+{
+ if (TYPE_READONLY (t) || TYPE_VOLATILE (t))
+ {
+ if (p == before) OB_PUTC (' ');
+ if (TYPE_READONLY (t))
+ OB_PUTS ("const");
+ if (TYPE_READONLY (t) && TYPE_VOLATILE (t))
+ OB_PUTC (' ');
+ if (TYPE_VOLATILE (t))
+ OB_PUTS ("volatile");
+ if (p == after) OB_PUTC (' ');
+ }
+}
+
+/* This must be large enough to hold any printed integer or floating-point
+ value. */
+static char digit_buffer[128];
+
+/* Dump into the obstack a human-readable equivalent of TYPE. */
+static void
+dump_type (t, v)
+ tree t;
+ int v; /* verbose? */
+{
+ if (t == NULL_TREE)
+ return;
+
+ if (TYPE_PTRMEMFUNC_P (t))
+ goto offset_type;
+
+ switch (TREE_CODE (t))
+ {
+ case ERROR_MARK:
+ OB_PUTS ("{error}");
+ break;
+
+ case UNKNOWN_TYPE:
+ OB_PUTS ("{unknown type}");
+ break;
+
+ case TREE_LIST:
+ /* i.e. function taking no arguments */
+ if (t != void_list_node)
+ {
+ dump_type (TREE_VALUE (t), v);
+ /* Can this happen other than for default arguments? */
+ if (TREE_PURPOSE (t) && v)
+ {
+ OB_PUTS (" = ");
+ dump_expr (TREE_PURPOSE (t));
+ }
+ if (TREE_CHAIN (t))
+ {
+ if (TREE_CHAIN (t) != void_list_node)
+ {
+ OB_PUTC2 (',', ' ');
+ dump_type (TREE_CHAIN (t), v);
+ }
+ }
+ else OB_PUTS (" ...");
+ }
+ break;
+
+ case IDENTIFIER_NODE:
+ OB_PUTID (t);
+ break;
+
+ case TREE_VEC:
+ dump_type (BINFO_TYPE (t), v);
+ break;
+
+ case RECORD_TYPE:
+ case UNION_TYPE:
+ case ENUMERAL_TYPE:
+ if (TYPE_LANG_SPECIFIC (t)
+ && (IS_SIGNATURE_POINTER (t) || IS_SIGNATURE_REFERENCE (t)))
+ {
+ if (TYPE_READONLY (t) | TYPE_VOLATILE (t))
+ dump_readonly_or_volatile (t);
+ dump_type (SIGNATURE_TYPE (t), v);
+ if (IS_SIGNATURE_POINTER (t))
+ OB_PUTC ('*');
+ else
+ OB_PUTC ('&');
+ }
+ else
+ dump_aggr_type (t, v);
+ break;
+
+ case TYPE_DECL:
+ dump_decl (t, v);
+ break;
+
+ case INTEGER_TYPE:
+ if (!TREE_UNSIGNED (TYPE_MAIN_VARIANT (t)) && TREE_UNSIGNED (t))
+ OB_PUTS ("unsigned ");
+ else if (TREE_UNSIGNED (TYPE_MAIN_VARIANT (t)) && !TREE_UNSIGNED (t))
+ OB_PUTS ("signed ");
+
+ /* fall through. */
+ case REAL_TYPE:
+ case VOID_TYPE:
+ case BOOLEAN_TYPE:
+ dump_readonly_or_volatile (t, after);
+ OB_PUTID (TYPE_IDENTIFIER (t));
+ break;
+
+ case TEMPLATE_TYPE_PARM:
+ OB_PUTID (TYPE_IDENTIFIER (t));
+ break;
+
+ case UNINSTANTIATED_P_TYPE:
+ OB_PUTID (DECL_NAME (UPT_TEMPLATE (t)));
+ OB_PUTS ("<...>");
+ break;
+
+ /* This is not always necessary for pointers and such, but doing this
+ reduces code size. */
+ case ARRAY_TYPE:
+ case POINTER_TYPE:
+ case REFERENCE_TYPE:
+ case OFFSET_TYPE:
+ offset_type:
+ case FUNCTION_TYPE:
+ case METHOD_TYPE:
+ dump_type_prefix (t, v);
+ dump_type_suffix (t, v);
+ break;
+
+ default:
+ sorry ("`%s' not supported by dump_type",
+ tree_code_name[(int) TREE_CODE (t)]);
+ }
+}
+
+static char *
+aggr_variety (t)
+ tree t;
+{
+ if (TREE_CODE (t) == ENUMERAL_TYPE)
+ return "enum";
+ else if (TREE_CODE (t) == UNION_TYPE)
+ return "union";
+ else if (TYPE_LANG_SPECIFIC (t) && CLASSTYPE_DECLARED_CLASS (t))
+ return "class";
+ else if (TYPE_LANG_SPECIFIC (t) && IS_SIGNATURE (t))
+ return "signature";
+ else
+ return "struct";
+}
+
+/* Print out a class declaration, in the form `class foo'. */
+static void
+dump_aggr_type (t, v)
+ tree t;
+ int v; /* verbose? */
+{
+ tree name;
+ char *variety = aggr_variety (t);
+
+ dump_readonly_or_volatile (t, after);
+
+ if (v > 0)
+ {
+ OB_PUTCP (variety);
+ OB_PUTC (' ');
+ }
+
+ name = TYPE_NAME (t);
+
+ if (name && DECL_CONTEXT (name))
+ {
+ /* FUNCTION_DECL or RECORD_TYPE */
+ dump_decl (DECL_CONTEXT (name), 0);
+ OB_PUTC2 (':', ':');
+ }
+
+ /* kludge around weird behavior on g++.brendan/line1.C */
+ if (name && TREE_CODE (name) != IDENTIFIER_NODE)
+ name = DECL_NAME (name);
+
+ if (name == 0 || ANON_AGGRNAME_P (name))
+ {
+ OB_PUTS ("{anonymous");
+ if (!v)
+ {
+ OB_PUTC (' ');
+ OB_PUTCP (variety);
+ }
+ OB_PUTC ('}');
+ }
+ else
+ OB_PUTID (name);
+}
+
+/* Dump into the obstack the initial part of the output for a given type.
+ This is necessary when dealing with things like functions returning
+ functions. Examples:
+
+ return type of `int (* fee ())()': pointer -> function -> int. Both
+ pointer (and reference and offset) and function (and member) types must
+ deal with prefix and suffix.
+
+ Arrays must also do this for DECL nodes, like int a[], and for things like
+ int *[]&. */
+
+static void
+dump_type_prefix (t, v)
+ tree t;
+ int v; /* verbosity */
+{
+ if (TYPE_PTRMEMFUNC_P (t))
+ {
+ t = TYPE_PTRMEMFUNC_FN_TYPE (t);
+ goto offset_type;
+ }
+
+ switch (TREE_CODE (t))
+ {
+ case POINTER_TYPE:
+ {
+ tree sub = TREE_TYPE (t);
+
+ dump_type_prefix (sub, v);
+ /* A tree for a member pointer looks like pointer to offset,
+ so let the OFFSET_TYPE case handle it. */
+ if (TREE_CODE (sub) != OFFSET_TYPE)
+ {
+ switch (TREE_CODE (sub))
+ {
+ /* We don't want int ( *)() */
+ case FUNCTION_TYPE:
+ case METHOD_TYPE:
+ break;
+
+ case ARRAY_TYPE:
+ OB_PUTC2 (' ', '(');
+ break;
+
+ case POINTER_TYPE:
+ /* We don't want "char * *" */
+ if (! (TYPE_READONLY (sub) || TYPE_VOLATILE (sub)))
+ break;
+ /* But we do want "char *const *" */
+
+ default:
+ OB_PUTC (' ');
+ }
+ OB_PUTC ('*');
+ dump_readonly_or_volatile (t, none);
+ }
+ }
+ break;
+
+ case REFERENCE_TYPE:
+ {
+ tree sub = TREE_TYPE (t);
+ dump_type_prefix (sub, v);
+
+ switch (TREE_CODE (sub))
+ {
+ case ARRAY_TYPE:
+ OB_PUTC2 (' ', '(');
+ break;
+
+ case POINTER_TYPE:
+ /* We don't want "char * &" */
+ if (! (TYPE_READONLY (sub) || TYPE_VOLATILE (sub)))
+ break;
+ /* But we do want "char *const &" */
+
+ default:
+ OB_PUTC (' ');
+ }
+ }
+ OB_PUTC ('&');
+ dump_readonly_or_volatile (t, none);
+ break;
+
+ case OFFSET_TYPE:
+ offset_type:
+ dump_type_prefix (TREE_TYPE (t), v);
+ if (TREE_CODE (t) == OFFSET_TYPE) /* pmfs deal with this in d_t_p */
+ {
+ OB_PUTC (' ');
+ dump_type (TYPE_OFFSET_BASETYPE (t), 0);
+ OB_PUTC2 (':', ':');
+ }
+ OB_PUTC ('*');
+ dump_readonly_or_volatile (t, none);
+ break;
+
+ /* Can only be reached through function pointer -- this would not be
+ correct if FUNCTION_DECLs used it. */
+ case FUNCTION_TYPE:
+ dump_type_prefix (TREE_TYPE (t), v);
+ OB_PUTC2 (' ', '(');
+ break;
+
+ case METHOD_TYPE:
+ dump_type_prefix (TREE_TYPE (t), v);
+ OB_PUTC2 (' ', '(');
+ dump_aggr_type (TYPE_METHOD_BASETYPE (t), 0);
+ OB_PUTC2 (':', ':');
+ break;
+
+ case ARRAY_TYPE:
+ dump_type_prefix (TREE_TYPE (t), v);
+ break;
+
+ case ENUMERAL_TYPE:
+ case ERROR_MARK:
+ case IDENTIFIER_NODE:
+ case INTEGER_TYPE:
+ case BOOLEAN_TYPE:
+ case REAL_TYPE:
+ case RECORD_TYPE:
+ case TEMPLATE_TYPE_PARM:
+ case TREE_LIST:
+ case TYPE_DECL:
+ case TREE_VEC:
+ case UNINSTANTIATED_P_TYPE:
+ case UNION_TYPE:
+ case UNKNOWN_TYPE:
+ case VOID_TYPE:
+ dump_type (t, v);
+ break;
+
+ default:
+ sorry ("`%s' not supported by dump_type_prefix",
+ tree_code_name[(int) TREE_CODE (t)]);
+ }
+}
+
+static void
+dump_type_suffix (t, v)
+ tree t;
+ int v; /* verbose? */
+{
+ if (TYPE_PTRMEMFUNC_P (t))
+ t = TYPE_PTRMEMFUNC_FN_TYPE (t);
+
+ switch (TREE_CODE (t))
+ {
+ case POINTER_TYPE:
+ case REFERENCE_TYPE:
+ case OFFSET_TYPE:
+ if (TREE_CODE (TREE_TYPE (t)) == ARRAY_TYPE)
+ OB_PUTC (')');
+ dump_type_suffix (TREE_TYPE (t), v);
+ break;
+
+ /* Can only be reached through function pointer */
+ case FUNCTION_TYPE:
+ case METHOD_TYPE:
+ {
+ tree arg;
+ OB_PUTC2 (')', '(');
+ arg = TYPE_ARG_TYPES (t);
+ if (TREE_CODE (t) == METHOD_TYPE)
+ arg = TREE_CHAIN (arg);
+
+ if (arg)
+ dump_type (arg, v);
+ else
+ OB_PUTS ("...");
+ OB_PUTC (')');
+ if (TREE_CODE (t) == METHOD_TYPE)
+ dump_readonly_or_volatile
+ (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t))), before);
+ dump_type_suffix (TREE_TYPE (t), v);
+ break;
+ }
+
+ case ARRAY_TYPE:
+ OB_PUTC ('[');
+ if (TYPE_DOMAIN (t))
+ OB_PUTI (TREE_INT_CST_LOW (TYPE_MAX_VALUE (TYPE_DOMAIN (t))) + 1);
+ OB_PUTC (']');
+ dump_type_suffix (TREE_TYPE (t), v);
+ break;
+
+ case ENUMERAL_TYPE:
+ case ERROR_MARK:
+ case IDENTIFIER_NODE:
+ case INTEGER_TYPE:
+ case BOOLEAN_TYPE:
+ case REAL_TYPE:
+ case RECORD_TYPE:
+ case TEMPLATE_TYPE_PARM:
+ case TREE_LIST:
+ case TYPE_DECL:
+ case TREE_VEC:
+ case UNINSTANTIATED_P_TYPE:
+ case UNION_TYPE:
+ case UNKNOWN_TYPE:
+ case VOID_TYPE:
+ break;
+
+ default:
+ sorry ("`%s' not supported by dump_type_suffix",
+ tree_code_name[(int) TREE_CODE (t)]);
+ }
+}
+
+/* Return a function declaration which corresponds to the IDENTIFIER_NODE
+ argument. */
+tree
+ident_fndecl (t)
+ tree t;
+{
+ tree n = lookup_name (t, 0);
+
+ if (n == NULL_TREE)
+ return NULL_TREE;
+
+ if (TREE_CODE (n) == FUNCTION_DECL)
+ return n;
+ else if (TREE_CODE (n) == TREE_LIST
+ && TREE_CODE (TREE_VALUE (n)) == FUNCTION_DECL)
+ return TREE_VALUE (n);
+
+ my_friendly_abort (66);
+ return NULL_TREE;
+}
+
+#ifndef NO_DOLLAR_IN_LABEL
+# define GLOBAL_THING "_GLOBAL_$"
+#else
+# ifndef NO_DOT_IN_LABEL
+# define GLOBAL_THING "_GLOBAL_."
+# else
+# define GLOBAL_THING "_GLOBAL__"
+# endif
+#endif
+
+#define GLOBAL_IORD_P(NODE) \
+ !strncmp(IDENTIFIER_POINTER(NODE),GLOBAL_THING,sizeof(GLOBAL_THING)-1)
+
+void
+dump_global_iord (t)
+ tree t;
+{
+ char *name = IDENTIFIER_POINTER (t);
+
+ OB_PUTS ("(static ");
+ if (name [sizeof (GLOBAL_THING) - 1] == 'I')
+ OB_PUTS ("initializers");
+ else if (name [sizeof (GLOBAL_THING) - 1] == 'D')
+ OB_PUTS ("destructors");
+ else
+ my_friendly_abort (352);
+
+ OB_PUTS (" for ");
+ OB_PUTCP (input_filename);
+ OB_PUTC (')');
+}
+
+static void
+dump_decl (t, v)
+ tree t;
+ int v; /* verbosity */
+{
+ if (t == NULL_TREE)
+ return;
+
+ switch (TREE_CODE (t))
+ {
+ case ERROR_MARK:
+ OB_PUTS (" /* decl error */ ");
+ break;
+
+ case TYPE_DECL:
+ {
+ /* Don't say 'typedef class A' */
+ tree type = TREE_TYPE (t);
+ if (((IS_AGGR_TYPE (type) && ! TYPE_PTRMEMFUNC_P (type))
+ || TREE_CODE (type) == ENUMERAL_TYPE)
+ && type == TYPE_MAIN_VARIANT (type))
+ {
+ dump_type (type, v);
+ break;
+ }
+ }
+ if (v > 0)
+ OB_PUTS ("typedef ");
+ goto general;
+ break;
+
+ case VAR_DECL:
+ if (DECL_NAME (t) && VTABLE_NAME_P (DECL_NAME (t)))
+ {
+ OB_PUTS ("vtable for ");
+ dump_type (DECL_CONTEXT (t), v);
+ break;
+ }
+ /* else fall through */
+ case FIELD_DECL:
+ case PARM_DECL:
+ general:
+ if (v > 0)
+ {
+ dump_type_prefix (TREE_TYPE (t), v);
+ OB_PUTC (' ');
+ dump_readonly_or_volatile (t, after);
+ }
+ /* DECL_CLASS_CONTEXT isn't being set in some cases. Hmm... */
+ if (DECL_CONTEXT (t)
+ && TREE_CODE_CLASS (TREE_CODE (DECL_CONTEXT (t))) == 't')
+ {
+ dump_type (DECL_CONTEXT (t), 0);
+ OB_PUTC2 (':', ':');
+ }
+ if (DECL_NAME (t))
+ dump_decl (DECL_NAME (t), v);
+ else
+ OB_PUTS ("{anon}");
+ if (v > 0)
+ dump_type_suffix (TREE_TYPE (t), v);
+ break;
+
+ case NAMESPACE_DECL:
+ OB_PUTID (DECL_NAME (t));
+ break;
+
+ case ARRAY_REF:
+ dump_decl (TREE_OPERAND (t, 0), v);
+ OB_PUTC ('[');
+ dump_decl (TREE_OPERAND (t, 1), v);
+ OB_PUTC (']');
+ break;
+
+ /* So that we can do dump_decl in dump_aggr_type and have it work for
+ both class and function scope. */
+ case RECORD_TYPE:
+ case UNION_TYPE:
+ case ENUMERAL_TYPE:
+ dump_type (t, v);
+ break;
+
+ case TYPE_EXPR:
+ my_friendly_abort (69);
+ break;
+
+ /* These special cases are duplicated here so that other functions
+ can feed identifiers to cp_error and get them demangled properly. */
+ case IDENTIFIER_NODE:
+ { tree f;
+ if (DESTRUCTOR_NAME_P (t)
+ && (f = ident_fndecl (t))
+ && DECL_LANGUAGE (f) == lang_cplusplus)
+ {
+ OB_PUTC ('~');
+ dump_decl (DECL_NAME (f), 0);
+ }
+ else if (IDENTIFIER_TYPENAME_P (t))
+ {
+ OB_PUTS ("operator ");
+ /* Not exactly IDENTIFIER_TYPE_VALUE. */
+ dump_type (TREE_TYPE (t), 0);
+ break;
+ }
+ else if (IDENTIFIER_OPNAME_P (t))
+ {
+ char *name_string = operator_name_string (t);
+ OB_PUTS ("operator ");
+ OB_PUTCP (name_string);
+ }
+ else
+ OB_PUTID (t);
+ }
+ break;
+
+ case FUNCTION_DECL:
+ if (GLOBAL_IORD_P (DECL_ASSEMBLER_NAME (t)))
+ dump_global_iord (DECL_ASSEMBLER_NAME (t));
+ else
+ dump_function_decl (t, v);
+ break;
+
+ case TEMPLATE_DECL:
+ {
+ tree args = DECL_TEMPLATE_PARMS (t);
+ int i, len = args ? TREE_VEC_LENGTH (args) : 0;
+ OB_PUTS ("template <");
+ for (i = 0; i < len; i++)
+ {
+ tree arg = TREE_VEC_ELT (args, i);
+ tree defval = TREE_PURPOSE (arg);
+ arg = TREE_VALUE (arg);
+ if (TREE_CODE (arg) == TYPE_DECL)
+ {
+ OB_PUTS ("class ");
+ OB_PUTID (DECL_NAME (arg));
+ }
+ else
+ dump_decl (arg, 1);
+
+ if (defval)
+ {
+ OB_PUTS (" = ");
+ dump_decl (defval, 1);
+ }
+
+ OB_PUTC2 (',', ' ');
+ }
+ if (len != 0)
+ OB_UNPUT (2);
+ OB_PUTC2 ('>', ' ');
+
+ if (DECL_TEMPLATE_IS_CLASS (t))
+ {
+ OB_PUTS ("class ");
+ OB_PUTID (DECL_NAME (t));
+ }
+ else switch (NEXT_CODE (t))
+ {
+ case METHOD_TYPE:
+ case FUNCTION_TYPE:
+ dump_function_decl (t, v);
+ break;
+
+ default:
+ my_friendly_abort (353);
+ }
+ }
+ break;
+
+ case LABEL_DECL:
+ OB_PUTID (DECL_NAME (t));
+ break;
+
+ case CONST_DECL:
+ if (NEXT_CODE (t) == ENUMERAL_TYPE)
+ goto general;
+ else
+ dump_expr (DECL_INITIAL (t), 0);
+ break;
+
+ default:
+ sorry ("`%s' not supported by dump_decl",
+ tree_code_name[(int) TREE_CODE (t)]);
+ }
+}
+
+/* Pretty printing for announce_function. T is the declaration of the
+ function we are interested in seeing. V is non-zero if we should print
+ the type that this function returns. */
+
+static void
+dump_function_decl (t, v)
+ tree t;
+ int v;
+{
+ tree name = DECL_ASSEMBLER_NAME (t);
+ tree fntype = TREE_TYPE (t);
+ tree parmtypes = TYPE_ARG_TYPES (fntype);
+ tree cname = NULL_TREE;
+
+ /* Friends have DECL_CLASS_CONTEXT set, but not DECL_CONTEXT. */
+ if (DECL_CONTEXT (t))
+ cname = DECL_CLASS_CONTEXT (t);
+ /* this is for partially instantiated template methods */
+ else if (TREE_CODE (fntype) == METHOD_TYPE)
+ cname = TREE_TYPE (TREE_VALUE (parmtypes));
+
+ v = (v > 0);
+
+ if (v)
+ {
+ if (DECL_STATIC_FUNCTION_P (t))
+ OB_PUTS ("static ");
+
+ if (! IDENTIFIER_TYPENAME_P (name)
+ && ! DECL_CONSTRUCTOR_P (t)
+ && ! DESTRUCTOR_NAME_P (name))
+ {
+ dump_type_prefix (TREE_TYPE (fntype), 1);
+ OB_PUTC (' ');
+ }
+ }
+
+ if (cname)
+ {
+ dump_type (cname, 0);
+ OB_PUTC2 (':', ':');
+ if (TREE_CODE (fntype) == METHOD_TYPE && parmtypes)
+ parmtypes = TREE_CHAIN (parmtypes);
+ if (DECL_CONSTRUCTOR_FOR_VBASE_P (t))
+ /* Skip past "in_charge" identifier. */
+ parmtypes = TREE_CHAIN (parmtypes);
+ }
+
+ if (DESTRUCTOR_NAME_P (name) && DECL_LANGUAGE (t) == lang_cplusplus)
+ parmtypes = TREE_CHAIN (parmtypes);
+
+ dump_function_name (t);
+
+ OB_PUTC ('(');
+
+ if (parmtypes)
+ dump_type (parmtypes, v);
+ else
+ OB_PUTS ("...");
+
+ OB_PUTC (')');
+
+ if (v && ! IDENTIFIER_TYPENAME_P (name))
+ dump_type_suffix (TREE_TYPE (fntype), 1);
+
+ if (TREE_CODE (fntype) == METHOD_TYPE)
+ {
+ if (IS_SIGNATURE (cname))
+ /* We look at the type pointed to by the `optr' field of `this.' */
+ dump_readonly_or_volatile
+ (TREE_TYPE (TREE_TYPE (TYPE_FIELDS (TREE_VALUE (TYPE_ARG_TYPES (fntype))))), before);
+ else
+ dump_readonly_or_volatile
+ (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (fntype))), before);
+ }
+}
+
+/* Handle the function name for a FUNCTION_DECL node, grokking operators
+ and destructors properly. */
+static void
+dump_function_name (t)
+ tree t;
+{
+ tree name = DECL_NAME (t);
+
+ /* There ought to be a better way to find out whether or not something is
+ a destructor. */
+ if (DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (t))
+ && DECL_LANGUAGE (t) == lang_cplusplus)
+ {
+ OB_PUTC ('~');
+ dump_decl (name, 0);
+ }
+ else if (IDENTIFIER_TYPENAME_P (name))
+ {
+ /* This cannot use the hack that the operator's return
+ type is stashed off of its name because it may be
+ used for error reporting. In the case of conflicting
+ declarations, both will have the same name, yet
+ the types will be different, hence the TREE_TYPE field
+ of the first name will be clobbered by the second. */
+ OB_PUTS ("operator ");
+ dump_type (TREE_TYPE (TREE_TYPE (t)), 0);
+ }
+ else if (IDENTIFIER_OPNAME_P (name))
+ {
+ char *name_string = operator_name_string (name);
+ OB_PUTS ("operator ");
+ OB_PUTCP (name_string);
+ }
+ else
+ dump_decl (name, 0);
+}
+
+static void
+dump_char (c)
+ char c;
+{
+ switch (c)
+ {
+ case TARGET_NEWLINE:
+ OB_PUTS ("\\n");
+ break;
+ case TARGET_TAB:
+ OB_PUTS ("\\t");
+ break;
+ case TARGET_VT:
+ OB_PUTS ("\\v");
+ break;
+ case TARGET_BS:
+ OB_PUTS ("\\b");
+ break;
+ case TARGET_CR:
+ OB_PUTS ("\\r");
+ break;
+ case TARGET_FF:
+ OB_PUTS ("\\f");
+ break;
+ case TARGET_BELL:
+ OB_PUTS ("\\a");
+ break;
+ case '\\':
+ OB_PUTS ("\\\\");
+ break;
+ case '\'':
+ OB_PUTS ("\\'");
+ break;
+ case '\"':
+ OB_PUTS ("\\\"");
+ break;
+ default:
+ if (isprint (c))
+ OB_PUTC (c);
+ else
+ {
+ sprintf (digit_buffer, "\\%03o", (int) c);
+ OB_PUTCP (digit_buffer);
+ }
+ }
+}
+
+/* Print out a list of initializers (subr of dump_expr) */
+static void
+dump_expr_list (l)
+ tree l;
+{
+ while (l)
+ {
+ dump_expr (TREE_VALUE (l), 0);
+ if (TREE_CHAIN (l))
+ OB_PUTC2 (',', ' ');
+ l = TREE_CHAIN (l);
+ }
+}
+
+/* Print out an expression */
+static void
+dump_expr (t, nop)
+ tree t;
+ int nop; /* suppress parens */
+{
+ switch (TREE_CODE (t))
+ {
+ case VAR_DECL:
+ case PARM_DECL:
+ case FIELD_DECL:
+ case CONST_DECL:
+ case FUNCTION_DECL:
+ dump_decl (t, -1);
+ break;
+
+ case INTEGER_CST:
+ {
+ tree type = TREE_TYPE (t);
+ my_friendly_assert (type != 0, 81);
+
+ /* If it's an enum, output its tag, rather than its value. */
+ if (TREE_CODE (type) == ENUMERAL_TYPE)
+ {
+ char *p = enum_name_string (t, type);
+ OB_PUTCP (p);
+ }
+ else if (type == boolean_type_node)
+ {
+ if (t == boolean_false_node)
+ OB_PUTS ("false");
+ else if (t == boolean_true_node)
+ OB_PUTS ("true");
+ else
+ my_friendly_abort (366);
+ }
+ else if (type == char_type_node)
+ {
+ OB_PUTC ('\'');
+ dump_char (TREE_INT_CST_LOW (t));
+ OB_PUTC ('\'');
+ }
+ else if (TREE_INT_CST_HIGH (t)
+ != (TREE_INT_CST_LOW (t) >> (HOST_BITS_PER_WIDE_INT - 1)))
+ {
+ tree val = t;
+ if (TREE_INT_CST_HIGH (val) < 0)
+ {
+ OB_PUTC ('-');
+ val = build_int_2 (~TREE_INT_CST_LOW (val),
+ -TREE_INT_CST_HIGH (val));
+ }
+ /* Would "%x%0*x" or "%x%*0x" get zero-padding on all
+ systems? */
+ {
+ static char format[10]; /* "%x%09999x\0" */
+ if (!format[0])
+ sprintf (format, "%%x%%0%dx", HOST_BITS_PER_INT / 4);
+ sprintf (digit_buffer, format, TREE_INT_CST_HIGH (val),
+ TREE_INT_CST_LOW (val));
+ OB_PUTCP (digit_buffer);
+ }
+ }
+ else
+ OB_PUTI (TREE_INT_CST_LOW (t));
+ }
+ break;
+
+ case REAL_CST:
+#ifndef REAL_IS_NOT_DOUBLE
+ sprintf (digit_buffer, "%g", TREE_REAL_CST (t));
+#else
+ {
+ unsigned char *p = (unsigned char *) &TREE_REAL_CST (t);
+ int i;
+ strcpy (digit_buffer, "0x");
+ for (i = 0; i < sizeof TREE_REAL_CST (t); i++)
+ sprintf (digit_buffer + 2 + 2*i, "%02x", *p++);
+ }
+#endif
+ OB_PUTCP (digit_buffer);
+ break;
+
+ case STRING_CST:
+ {
+ char *p = TREE_STRING_POINTER (t);
+ int len = TREE_STRING_LENGTH (t) - 1;
+ int i;
+
+ OB_PUTC ('\"');
+ for (i = 0; i < len; i++)
+ dump_char (p[i]);
+ OB_PUTC ('\"');
+ }
+ break;
+
+ case COMPOUND_EXPR:
+ dump_binary_op (",", t);
+ break;
+
+ case COND_EXPR:
+ OB_PUTC ('(');
+ dump_expr (TREE_OPERAND (t, 0), 0);
+ OB_PUTS (" ? ");
+ dump_expr (TREE_OPERAND (t, 1), 0);
+ OB_PUTS (" : ");
+ dump_expr (TREE_OPERAND (t, 2), 0);
+ OB_PUTC (')');
+ break;
+
+ case SAVE_EXPR:
+ if (TREE_HAS_CONSTRUCTOR (t))
+ {
+ OB_PUTS ("new ");
+ dump_type (TREE_TYPE (TREE_TYPE (t)), 0);
+ PARM_DECL_EXPR (t) = 1;
+ }
+ else
+ {
+ dump_expr (TREE_OPERAND (t, 0), 0);
+ }
+ break;
+
+ case NEW_EXPR:
+ OB_PUTID (TYPE_IDENTIFIER (TREE_TYPE (t)));
+ OB_PUTC ('(');
+ dump_expr_list (TREE_CHAIN (TREE_OPERAND (t, 1)));
+ OB_PUTC (')');
+ break;
+
+ case CALL_EXPR:
+ {
+ tree fn = TREE_OPERAND (t, 0);
+ tree args = TREE_OPERAND (t, 1);
+
+ if (TREE_CODE (fn) == ADDR_EXPR)
+ fn = TREE_OPERAND (fn, 0);
+
+ if (NEXT_CODE (fn) == METHOD_TYPE)
+ {
+ tree ob = TREE_VALUE (args);
+ if (TREE_CODE (ob) == ADDR_EXPR)
+ {
+ dump_expr (TREE_OPERAND (ob, 0), 0);
+ OB_PUTC ('.');
+ }
+ else if (TREE_CODE (ob) != PARM_DECL
+ || strcmp (IDENTIFIER_POINTER (DECL_NAME (ob)), "this"))
+ {
+ dump_expr (ob, 0);
+ OB_PUTC2 ('-', '>');
+ }
+ args = TREE_CHAIN (args);
+ }
+ dump_expr (fn, 0);
+ OB_PUTC('(');
+ dump_expr_list (args);
+ OB_PUTC (')');
+ }
+ break;
+
+ case WITH_CLEANUP_EXPR:
+ /* Note that this only works for G++ cleanups. If somebody
+ builds a general cleanup, there's no way to represent it. */
+ dump_expr (TREE_OPERAND (t, 0), 0);
+ break;
+
+ case TARGET_EXPR:
+ /* Note that this only works for G++ target exprs. If somebody
+ builds a general TARGET_EXPR, there's no way to represent that
+ it initializes anything other that the parameter slot for the
+ default argument. Note we may have cleared out the first
+ operand in expand_expr, so don't go killing ourselves. */
+ if (TREE_OPERAND (t, 1))
+ dump_expr (TREE_OPERAND (t, 1), 0);
+ break;
+
+ case MODIFY_EXPR:
+ case PLUS_EXPR:
+ case MINUS_EXPR:
+ case MULT_EXPR:
+ case TRUNC_DIV_EXPR:
+ case TRUNC_MOD_EXPR:
+ case MIN_EXPR:
+ case MAX_EXPR:
+ case LSHIFT_EXPR:
+ case RSHIFT_EXPR:
+ case BIT_IOR_EXPR:
+ case BIT_XOR_EXPR:
+ case BIT_AND_EXPR:
+ case BIT_ANDTC_EXPR:
+ case TRUTH_ANDIF_EXPR:
+ case TRUTH_ORIF_EXPR:
+ case LT_EXPR:
+ case LE_EXPR:
+ case GT_EXPR:
+ case GE_EXPR:
+ case EQ_EXPR:
+ case NE_EXPR:
+ dump_binary_op (opname_tab[(int) TREE_CODE (t)], t);
+ break;
+
+ case CEIL_DIV_EXPR:
+ case FLOOR_DIV_EXPR:
+ case ROUND_DIV_EXPR:
+ dump_binary_op ("/", t);
+ break;
+
+ case CEIL_MOD_EXPR:
+ case FLOOR_MOD_EXPR:
+ case ROUND_MOD_EXPR:
+ dump_binary_op ("%", t);
+ break;
+
+ case COMPONENT_REF:
+ {
+ tree ob = TREE_OPERAND (t, 0);
+ if (TREE_CODE (ob) == INDIRECT_REF)
+ {
+ ob = TREE_OPERAND (ob, 0);
+ if (TREE_CODE (ob) != PARM_DECL
+ || strcmp (IDENTIFIER_POINTER (DECL_NAME (ob)), "this"))
+ {
+ dump_expr (ob, 0);
+ OB_PUTC2 ('-', '>');
+ }
+ }
+ else
+ {
+ dump_expr (ob, 0);
+ OB_PUTC ('.');
+ }
+ dump_expr (TREE_OPERAND (t, 1), 1);
+ }
+ break;
+
+ case ARRAY_REF:
+ dump_expr (TREE_OPERAND (t, 0), 0);
+ OB_PUTC ('[');
+ dump_expr (TREE_OPERAND (t, 1), 0);
+ OB_PUTC (']');
+ break;
+
+ case CONVERT_EXPR:
+ dump_unary_op ("+", t, nop);
+ break;
+
+ case ADDR_EXPR:
+ if (TREE_CODE (TREE_OPERAND (t, 0)) == FUNCTION_DECL
+ || TREE_CODE (TREE_OPERAND (t, 0)) == STRING_CST)
+ dump_expr (TREE_OPERAND (t, 0), 0);
+ else
+ dump_unary_op ("&", t, nop);
+ break;
+
+ case INDIRECT_REF:
+ if (TREE_HAS_CONSTRUCTOR (t))
+ {
+ t = TREE_OPERAND (t, 0);
+ my_friendly_assert (TREE_CODE (t) == CALL_EXPR, 237);
+ dump_expr (TREE_OPERAND (t, 0), 0);
+ OB_PUTC ('(');
+ dump_expr_list (TREE_CHAIN (TREE_OPERAND (t, 1)));
+ OB_PUTC (')');
+ }
+ else
+ {
+ if (NEXT_CODE (TREE_OPERAND (t, 0)) == REFERENCE_TYPE)
+ dump_expr (TREE_OPERAND (t, 0), nop);
+ else
+ dump_unary_op ("*", t, nop);
+ }
+ break;
+
+ case NEGATE_EXPR:
+ case BIT_NOT_EXPR:
+ case TRUTH_NOT_EXPR:
+ case PREDECREMENT_EXPR:
+ case PREINCREMENT_EXPR:
+ dump_unary_op (opname_tab [(int)TREE_CODE (t)], t, nop);
+ break;
+
+ case POSTDECREMENT_EXPR:
+ case POSTINCREMENT_EXPR:
+ OB_PUTC ('(');
+ dump_expr (TREE_OPERAND (t, 0), 0);
+ OB_PUTCP (opname_tab[(int)TREE_CODE (t)]);
+ OB_PUTC (')');
+ break;
+
+ case NON_LVALUE_EXPR:
+ /* FIXME: This is a KLUDGE workaround for a parsing problem. There
+ should be another level of INDIRECT_REF so that I don't have to do
+ this. */
+ if (NEXT_CODE (t) == POINTER_TYPE)
+ {
+ tree next = TREE_TYPE (TREE_TYPE (t));
+
+ while (TREE_CODE (next) == POINTER_TYPE)
+ next = TREE_TYPE (next);
+
+ if (TREE_CODE (next) == FUNCTION_TYPE)
+ {
+ if (!nop) OB_PUTC ('(');
+ OB_PUTC ('*');
+ dump_expr (TREE_OPERAND (t, 0), 1);
+ if (!nop) OB_PUTC (')');
+ break;
+ }
+ /* else FALLTHRU */
+ }
+ dump_expr (TREE_OPERAND (t, 0), 0);
+ break;
+
+ case NOP_EXPR:
+ dump_expr (TREE_OPERAND (t, 0), nop);
+ break;
+
+ case CONSTRUCTOR:
+ OB_PUTC ('{');
+ dump_expr_list (CONSTRUCTOR_ELTS (t), 0);
+ OB_PUTC ('}');
+ break;
+
+ case OFFSET_REF:
+ {
+ tree ob = TREE_OPERAND (t, 0);
+ if (TREE_CODE (ob) == NOP_EXPR
+ && TREE_OPERAND (ob, 0) == error_mark_node
+ && TREE_CODE (TREE_OPERAND (t, 1)) == FUNCTION_DECL)
+ /* A::f */
+ dump_expr (TREE_OPERAND (t, 1), 0);
+ else
+ {
+ sorry ("operand of OFFSET_REF not understood");
+ goto error;
+ }
+ break;
+ }
+
+ case TREE_LIST:
+ if (TREE_VALUE (t) && TREE_CODE (TREE_VALUE (t)) == FUNCTION_DECL)
+ {
+ OB_PUTID (DECL_NAME (TREE_VALUE (t)));
+ break;
+ }
+ /* else fall through */
+
+ /* This list is incomplete, but should suffice for now.
+ It is very important that `sorry' does not call
+ `report_error_function'. That could cause an infinite loop. */
+ default:
+ sorry ("`%s' not supported by dump_expr",
+ tree_code_name[(int) TREE_CODE (t)]);
+
+ /* fall through to ERROR_MARK... */
+ case ERROR_MARK:
+ error:
+ OB_PUTCP ("{error}");
+ break;
+ }
+}
+
+static void
+dump_binary_op (opstring, t)
+ char *opstring;
+ tree t;
+{
+ OB_PUTC ('(');
+ dump_expr (TREE_OPERAND (t, 0), 1);
+ OB_PUTC (' ');
+ OB_PUTCP (opstring);
+ OB_PUTC (' ');
+ dump_expr (TREE_OPERAND (t, 1), 1);
+ OB_PUTC (')');
+}
+
+static void
+dump_unary_op (opstring, t, nop)
+ char *opstring;
+ tree t;
+ int nop;
+{
+ if (!nop) OB_PUTC ('(');
+ OB_PUTCP (opstring);
+ dump_expr (TREE_OPERAND (t, 0), 1);
+ if (!nop) OB_PUTC (')');
+}
+
+char *
+fndecl_as_string (cname, fndecl, print_ret_type_p)
+ tree cname, fndecl;
+ int print_ret_type_p;
+{
+ return decl_as_string (fndecl, print_ret_type_p);
+}
+
+/* Same, but handtype a _TYPE.
+ Called from convert_to_reference, mangle_class_name_for_template,
+ build_unary_op, and GNU_xref_decl. */
+char *
+type_as_string (typ, v)
+ tree typ;
+ int v;
+{
+ OB_INIT ();
+
+ dump_type (typ, v);
+
+ OB_FINISH ();
+
+ return (char *)obstack_base (&scratch_obstack);
+}
+
+char *
+expr_as_string (decl, v)
+ tree decl;
+ int v;
+{
+ OB_INIT ();
+
+ dump_expr (decl, 1);
+
+ OB_FINISH ();
+
+ return (char *)obstack_base (&scratch_obstack);
+}
+
+/* A cross between type_as_string and fndecl_as_string.
+ Only called from substitute_nice_name. */
+char *
+decl_as_string (decl, v)
+ tree decl;
+ int v;
+{
+ OB_INIT ();
+
+ dump_decl (decl, v);
+
+ OB_FINISH ();
+
+ return (char *)obstack_base (&scratch_obstack);
+}
+
+char *
+cp_file_of (t)
+ tree t;
+{
+ if (TREE_CODE (t) == PARM_DECL)
+ return DECL_SOURCE_FILE (DECL_CONTEXT (t));
+ else if (TREE_CODE_CLASS (TREE_CODE (t)) == 't')
+ return DECL_SOURCE_FILE (TYPE_NAME (t));
+ else
+ return DECL_SOURCE_FILE (t);
+}
+
+int
+cp_line_of (t)
+ tree t;
+{
+ int line = 0;
+ if (TREE_CODE (t) == PARM_DECL)
+ line = DECL_SOURCE_LINE (DECL_CONTEXT (t));
+ if (TREE_CODE (t) == TYPE_DECL && DECL_ARTIFICIAL (t))
+ t = TREE_TYPE (t);
+
+ if (TREE_CODE_CLASS (TREE_CODE (t)) == 't')
+ {
+ if (IS_AGGR_TYPE (t))
+ line = CLASSTYPE_SOURCE_LINE (t);
+ else
+ line = DECL_SOURCE_LINE (TYPE_NAME (t));
+ }
+ else
+ line = DECL_SOURCE_LINE (t);
+
+ if (line == 0)
+ return lineno;
+
+ return line;
+}
+
+char *
+code_as_string (c, v)
+ enum tree_code c;
+ int v;
+{
+ return tree_code_name [c];
+}
+
+char *
+language_as_string (c, v)
+ enum languages c;
+ int v;
+{
+ switch (c)
+ {
+ case lang_c:
+ return "C";
+
+ case lang_cplusplus:
+ return "C++";
+
+ default:
+ my_friendly_abort (355);
+ return 0;
+ }
+}
+
+/* Return the proper printed version of a parameter to a C++ function. */
+char *
+parm_as_string (p, v)
+ int p, v;
+{
+ if (p < 0)
+ return "`this'";
+
+ sprintf (digit_buffer, "%d", p+1);
+ return digit_buffer;
+}
+
+char *
+op_as_string (p, v)
+ enum tree_code p;
+ int v;
+{
+ static char buf[] = "operator ";
+
+ if (p == 0)
+ return "{unknown}";
+
+ strcpy (buf + 9, opname_tab [p]);
+ return buf;
+}
+
+char *
+args_as_string (p, v)
+ tree p;
+ int v;
+{
+ if (p == NULL_TREE)
+ return "...";
+
+ return type_as_string (p, v);
+}
+
+char *
+cv_as_string (p, v)
+ tree p;
+ int v;
+{
+ OB_INIT ();
+
+ dump_readonly_or_volatile (p, before);
+
+ OB_FINISH ();
+
+ return (char *)obstack_base (&scratch_obstack);
+}
diff --git a/contrib/gcc/cp/except.c b/contrib/gcc/cp/except.c
new file mode 100644
index 0000000..51577f8
--- /dev/null
+++ b/contrib/gcc/cp/except.c
@@ -0,0 +1,1690 @@
+/* Handle exceptional things in C++.
+ Copyright (C) 1989, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+ Contributed by Michael Tiemann <tiemann@cygnus.com>
+ Rewritten by Mike Stump <mrs@cygnus.com>, based upon an
+ initial re-implementation courtesy Tad Hunt.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+/* High-level class interface. */
+
+#include "config.h"
+#include "tree.h"
+#include "rtl.h"
+#include "cp-tree.h"
+#include "flags.h"
+#include "obstack.h"
+#include "expr.h"
+
+tree protect_list;
+
+extern void (*interim_eh_hook) PROTO((tree));
+rtx expand_builtin_return_addr PROTO((enum built_in_function, int, rtx));
+
+/* holds the fndecl for __builtin_return_address () */
+tree builtin_return_address_fndecl;
+tree throw_fndecl;
+
+static int
+doing_eh (do_warn)
+ int do_warn;
+{
+ if (! flag_handle_exceptions)
+ {
+ static int warned = 0;
+ if (! warned && do_warn)
+ {
+ error ("exception handling disabled, use -fhandle-exceptions to enable.");
+ warned = 1;
+ }
+ return 0;
+ }
+ return 1;
+}
+
+
+/*
+NO GNEWS IS GOOD GNEWS WITH GARRY GNUS: This version is much closer
+to supporting exception handling as per ANSI C++ working draft.
+It is a complete rewrite of all the EH stuff that was here before
+ Shortcomings:
+ 1. Throw specifications of functions still don't work.
+ Cool Things:
+ 1. Destructors are called properly :-)
+ 2. No overhead for the non-exception thrown case.
+ 3. Fixing shortcoming 1 is simple.
+ -Tad Hunt (tad@mail.csh.rit.edu)
+
+*/
+
+/* A couple of backend routines from m88k.c */
+
+/* used to cache a call to __builtin_return_address () */
+static tree BuiltinReturnAddress;
+
+
+#include <stdio.h>
+
+/* XXX - Tad: for EH */
+/* output an exception table entry */
+
+static void
+output_exception_table_entry (file, start_label, end_label, eh_label)
+ FILE *file;
+ rtx start_label, end_label, eh_label;
+{
+ char label[100];
+
+ assemble_integer (start_label, GET_MODE_SIZE (Pmode), 1);
+ assemble_integer (end_label, GET_MODE_SIZE (Pmode), 1);
+ assemble_integer (eh_label, GET_MODE_SIZE (Pmode), 1);
+ putc ('\n', file); /* blank line */
+}
+
+static void
+easy_expand_asm (str)
+ char *str;
+{
+ expand_asm (build_string (strlen (str)+1, str));
+}
+
+
+#if 0
+/* This is the startup, and finish stuff per exception table. */
+
+/* XXX - Tad: exception handling section */
+#ifndef EXCEPT_SECTION_ASM_OP
+#define EXCEPT_SECTION_ASM_OP "section\t.gcc_except_table,\"a\",@progbits"
+#endif
+
+#ifdef EXCEPT_SECTION_ASM_OP
+typedef struct {
+ void *start_protect;
+ void *end_protect;
+ void *exception_handler;
+ } exception_table;
+#endif /* EXCEPT_SECTION_ASM_OP */
+
+#ifdef EXCEPT_SECTION_ASM_OP
+
+ /* on machines which support it, the exception table lives in another section,
+ but it needs a label so we can reference it... This sets up that
+ label! */
+asm (EXCEPT_SECTION_ASM_OP);
+exception_table __EXCEPTION_TABLE__[1] = { (void*)0, (void*)0, (void*)0 };
+asm (TEXT_SECTION_ASM_OP);
+
+#endif /* EXCEPT_SECTION_ASM_OP */
+
+#ifdef EXCEPT_SECTION_ASM_OP
+
+ /* we need to know where the end of the exception table is... so this
+ is how we do it! */
+
+asm (EXCEPT_SECTION_ASM_OP);
+exception_table __EXCEPTION_END__[1] = { (void*)-1, (void*)-1, (void*)-1 };
+asm (TEXT_SECTION_ASM_OP);
+
+#endif /* EXCEPT_SECTION_ASM_OP */
+
+#endif
+
+void
+exception_section ()
+{
+#ifdef ASM_OUTPUT_SECTION_NAME
+ named_section (NULL_TREE, ".gcc_except_table");
+#else
+ if (flag_pic)
+ data_section ();
+ else
+#if defined(TARGET_POWERPC) /* are we on a __rs6000? */
+ data_section ();
+#else
+ readonly_data_section ();
+#endif
+#endif
+}
+
+
+
+
+/* from: my-cp-except.c */
+
+/* VI: ":set ts=4" */
+#if 0
+#include <stdio.h> */
+#include "config.h"
+#include "tree.h"
+#include "rtl.h"
+#include "cp-tree.h"
+#endif
+#include "decl.h"
+#if 0
+#include "flags.h"
+#endif
+#include "insn-flags.h"
+#include "obstack.h"
+#if 0
+#include "expr.h"
+#endif
+
+/* ======================================================================
+ Briefly the algorithm works like this:
+
+ When a constructor or start of a try block is encountered,
+ push_eh_entry (&eh_stack) is called. Push_eh_entry () creates a
+ new entry in the unwind protection stack and returns a label to
+ output to start the protection for that block.
+
+ When a destructor or end try block is encountered, pop_eh_entry
+ (&eh_stack) is called. Pop_eh_entry () returns the ehEntry it
+ created when push_eh_entry () was called. The ehEntry structure
+ contains three things at this point. The start protect label,
+ the end protect label, and the exception handler label. The end
+ protect label should be output before the call to the destructor
+ (if any). If it was a destructor, then its parse tree is stored
+ in the finalization variable in the ehEntry structure. Otherwise
+ the finalization variable is set to NULL to reflect the fact that
+ is the the end of a try block. Next, this modified ehEntry node
+ is enqueued in the finalizations queue by calling
+ enqueue_eh_entry (&queue,entry).
+
+ +---------------------------------------------------------------+
+ |XXX: Will need modification to deal with partially |
+ | constructed arrays of objects |
+ | |
+ | Basically, this consists of keeping track of how many |
+ | of the objects have been constructed already (this |
+ | should be in a register though, so that shouldn't be a |
+ | problem. |
+ +---------------------------------------------------------------+
+
+ When a catch block is encountered, there is a lot of work to be
+ done.
+
+ Since we don't want to generate the catch block inline with the
+ regular flow of the function, we need to have some way of doing
+ so. Luckily, we can use sequences to defer the catch sections.
+ When the start of a catch block is encountered, we start the
+ sequence. After the catch block is generated, we end the
+ sequence.
+
+ Next we must insure that when the catch block is executed, all
+ finalizations for the matching try block have been completed. If
+ any of those finalizations throw an exception, we must call
+ terminate according to the ARM (section r.15.6.1). What this
+ means is that we need to dequeue and emit finalizations for each
+ entry in the ehQueue until we get to an entry with a NULL
+ finalization field. For any of the finalization entries, if it
+ is not a call to terminate (), we must protect it by giving it
+ another start label, end label, and exception handler label,
+ setting its finalization tree to be a call to terminate (), and
+ enqueue'ing this new ehEntry to be output at an outer level.
+ Finally, after all that is done, we can get around to outputting
+ the catch block which basically wraps all the "catch (...) {...}"
+ statements in a big if/then/else construct that matches the
+ correct block to call.
+
+ ===================================================================== */
+
+extern rtx emit_insn PROTO((rtx));
+extern rtx gen_nop PROTO(());
+
+/* local globals for function calls
+ ====================================================================== */
+
+/* used to cache "terminate ()", "unexpected ()", "set_terminate ()", and
+ "set_unexpected ()" after default_conversion. (lib-except.c) */
+static tree Terminate, Unexpected, SetTerminate, SetUnexpected, CatchMatch, Throw;
+
+/* used to cache __find_first_exception_table_match ()
+ for throw (lib-except.c) */
+static tree FirstExceptionMatch;
+
+/* used to cache a call to __unwind_function () (lib-except.c) */
+static tree Unwind;
+
+/* holds a ready to emit call to "terminate ()". */
+static tree TerminateFunctionCall;
+
+/* ====================================================================== */
+
+
+
+/* data structures for my various quick and dirty stacks and queues
+ Eventually, most of this should go away, because I think it can be
+ integrated with stuff already built into the compiler. */
+
+/* =================================================================== */
+
+struct labelNode {
+ rtx label;
+ struct labelNode *chain;
+};
+
+
+/* this is the most important structure here. Basically this is how I store
+ an exception table entry internally. */
+struct ehEntry {
+ rtx start_label;
+ rtx end_label;
+ rtx exception_handler_label;
+
+ tree finalization;
+ tree context;
+};
+
+struct ehNode {
+ struct ehEntry *entry;
+ struct ehNode *chain;
+};
+
+struct ehStack {
+ struct ehNode *top;
+};
+
+struct ehQueue {
+ struct ehNode *head;
+ struct ehNode *tail;
+};
+/* ========================================================================= */
+
+
+
+/* local globals - these local globals are for storing data necessary for
+ generating the exception table and code in the correct order.
+
+ ========================================================================= */
+
+/* Holds the pc for doing "throw" */
+tree saved_pc;
+/* Holds the type of the thing being thrown. */
+tree saved_throw_type;
+/* Holds the value being thrown. */
+tree saved_throw_value;
+
+int throw_used;
+
+static rtx catch_clauses;
+static first_catch_label;
+
+static struct ehStack ehstack;
+static struct ehQueue ehqueue;
+static struct ehQueue eh_table_output_queue;
+static struct labelNode *false_label_stack = NULL;
+static struct labelNode *caught_return_label_stack = NULL;
+/* ========================================================================= */
+
+/* function prototypes */
+static struct ehEntry *pop_eh_entry PROTO((struct ehStack *stack));
+static void enqueue_eh_entry PROTO((struct ehQueue *queue, struct ehEntry *entry));
+static rtx push_eh_entry PROTO((struct ehStack *stack));
+static struct ehEntry *dequeue_eh_entry PROTO((struct ehQueue *queue));
+static void new_eh_queue PROTO((struct ehQueue *queue));
+static void new_eh_stack PROTO((struct ehStack *stack));
+static void push_label_entry PROTO((struct labelNode **labelstack, rtx label));
+static rtx pop_label_entry PROTO((struct labelNode **labelstack));
+static rtx top_label_entry PROTO((struct labelNode **labelstack));
+static struct ehEntry *copy_eh_entry PROTO((struct ehEntry *entry));
+
+
+
+/* All my cheesy stack/queue/misc data structure handling routines
+
+ ========================================================================= */
+
+static void
+push_label_entry (labelstack, label)
+ struct labelNode **labelstack;
+ rtx label;
+{
+ struct labelNode *newnode=(struct labelNode*)xmalloc (sizeof (struct labelNode));
+
+ newnode->label = label;
+ newnode->chain = *labelstack;
+ *labelstack = newnode;
+}
+
+static rtx
+pop_label_entry (labelstack)
+ struct labelNode **labelstack;
+{
+ rtx label;
+ struct labelNode *tempnode;
+
+ if (! *labelstack) return NULL_RTX;
+
+ tempnode = *labelstack;
+ label = tempnode->label;
+ *labelstack = (*labelstack)->chain;
+ free (tempnode);
+
+ return label;
+}
+
+static rtx
+top_label_entry (labelstack)
+ struct labelNode **labelstack;
+{
+ if (! *labelstack) return NULL_RTX;
+
+ return (*labelstack)->label;
+}
+
+/* Push to permanent obstack for rtl generation.
+ One level only! */
+static struct obstack *saved_rtl_obstack;
+void
+push_rtl_perm ()
+{
+ extern struct obstack permanent_obstack;
+ extern struct obstack *rtl_obstack;
+
+ saved_rtl_obstack = rtl_obstack;
+ rtl_obstack = &permanent_obstack;
+}
+
+/* Pop back to normal rtl handling. */
+static void
+pop_rtl_from_perm ()
+{
+ extern struct obstack permanent_obstack;
+ extern struct obstack *rtl_obstack;
+
+ rtl_obstack = saved_rtl_obstack;
+}
+
+static rtx
+push_eh_entry (stack)
+ struct ehStack *stack;
+{
+ struct ehNode *node = (struct ehNode*)xmalloc (sizeof (struct ehNode));
+ struct ehEntry *entry = (struct ehEntry*)xmalloc (sizeof (struct ehEntry));
+
+ if (stack == NULL) {
+ free (node);
+ free (entry);
+ return NULL_RTX;
+ }
+
+ /* These are saved for the exception table. */
+ push_rtl_perm ();
+ entry->start_label = gen_label_rtx ();
+ entry->end_label = gen_label_rtx ();
+ entry->exception_handler_label = gen_label_rtx ();
+ pop_rtl_from_perm ();
+
+ LABEL_PRESERVE_P (entry->start_label) = 1;
+ LABEL_PRESERVE_P (entry->end_label) = 1;
+ LABEL_PRESERVE_P (entry->exception_handler_label) = 1;
+
+ entry->finalization = NULL_TREE;
+ entry->context = current_function_decl;
+
+ node->entry = entry;
+ node->chain = stack->top;
+ stack->top = node;
+
+ enqueue_eh_entry (&eh_table_output_queue, copy_eh_entry (entry));
+
+ return entry->start_label;
+}
+
+static struct ehEntry *
+pop_eh_entry (stack)
+ struct ehStack *stack;
+{
+ struct ehNode *tempnode;
+ struct ehEntry *tempentry;
+
+ if (stack && (tempnode = stack->top)) {
+ tempentry = tempnode->entry;
+ stack->top = stack->top->chain;
+ free (tempnode);
+
+ return tempentry;
+ }
+
+ return NULL;
+}
+
+static struct ehEntry *
+copy_eh_entry (entry)
+ struct ehEntry *entry;
+{
+ struct ehEntry *newentry;
+
+ newentry = (struct ehEntry*)xmalloc (sizeof (struct ehEntry));
+ memcpy ((void*)newentry, (void*)entry, sizeof (struct ehEntry));
+
+ return newentry;
+}
+
+static void
+enqueue_eh_entry (queue, entry)
+ struct ehQueue *queue;
+ struct ehEntry *entry;
+{
+ struct ehNode *node = (struct ehNode*)xmalloc (sizeof (struct ehNode));
+
+ node->entry = entry;
+ node->chain = NULL;
+
+ if (queue->head == NULL)
+ {
+ queue->head = node;
+ }
+ else
+ {
+ queue->tail->chain = node;
+ }
+ queue->tail = node;
+}
+
+static struct ehEntry *
+dequeue_eh_entry (queue)
+ struct ehQueue *queue;
+{
+ struct ehNode *tempnode;
+ struct ehEntry *tempentry;
+
+ if (queue->head == NULL)
+ return NULL;
+
+ tempnode = queue->head;
+ queue->head = queue->head->chain;
+
+ tempentry = tempnode->entry;
+ free (tempnode);
+
+ return tempentry;
+}
+
+static void
+new_eh_queue (queue)
+ struct ehQueue *queue;
+{
+ queue->head = queue->tail = NULL;
+}
+
+static void
+new_eh_stack (stack)
+ struct ehStack *stack;
+{
+ stack->top = NULL;
+}
+
+/* cheesyness to save some typing. returns the return value rtx */
+rtx
+do_function_call (func, params, return_type)
+ tree func, params, return_type;
+{
+ tree func_call;
+ func_call = build_function_call (func, params);
+ expand_call (func_call, NULL_RTX, 0);
+ if (return_type != NULL_TREE)
+ return hard_function_value (return_type, func_call);
+ return NULL_RTX;
+}
+
+static void
+expand_internal_throw (pc)
+ rtx pc;
+{
+ tree params;
+
+ emit_move_insn (DECL_RTL (saved_pc), pc);
+#ifdef JUMP_TO_THROW
+ emit_indirect_jump (gen_rtx (SYMBOL_REF, Pmode, "__throw"));
+#else
+ do_function_call (Throw, NULL_TREE, NULL_TREE);
+#endif
+ throw_used = 1;
+}
+
+/* ========================================================================= */
+
+void
+lang_interim_eh (finalization)
+ tree finalization;
+{
+ if (finalization)
+ end_protect (finalization);
+ else
+ start_protect ();
+}
+
+extern tree auto_function PROTO((tree, tree, enum built_in_function));
+
+/* sets up all the global eh stuff that needs to be initialized at the
+ start of compilation.
+
+ This includes:
+ - Setting up all the function call trees
+ - Initializing the ehqueue
+ - Initializing the eh_table_output_queue
+ - Initializing the ehstack
+*/
+
+void
+init_exception_processing ()
+{
+ extern tree define_function ();
+ tree unexpected_fndecl, terminate_fndecl;
+ tree set_unexpected_fndecl, set_terminate_fndecl;
+ tree catch_match_fndecl;
+ tree find_first_exception_match_fndecl;
+ tree unwind_fndecl;
+ tree declspecs;
+ tree d;
+
+ /* void (*)() */
+ tree PFV = build_pointer_type (build_function_type
+ (void_type_node, void_list_node));
+
+ /* arg list for the build_function_type call for set_terminate () and
+ set_unexpected () */
+ tree pfvlist = tree_cons (NULL_TREE, PFV, void_list_node);
+
+ /* void (*pfvtype (void (*) ()))() */
+ tree pfvtype = build_function_type (PFV, pfvlist);
+
+ /* void vtype () */
+ tree vtype = build_function_type (void_type_node, void_list_node);
+
+ set_terminate_fndecl = auto_function (get_identifier ("set_terminate"),
+ pfvtype, NOT_BUILT_IN);
+ set_unexpected_fndecl = auto_function (get_identifier ("set_unexpected"),
+ pfvtype, NOT_BUILT_IN);
+ unexpected_fndecl = auto_function (get_identifier ("unexpected"),
+ vtype, NOT_BUILT_IN);
+ terminate_fndecl = auto_function (get_identifier ("terminate"),
+ vtype, NOT_BUILT_IN);
+
+ interim_eh_hook = lang_interim_eh;
+
+ push_lang_context (lang_name_c);
+
+ catch_match_fndecl =
+ define_function (flag_rtti
+ ? "__throw_type_match_rtti"
+ : "__throw_type_match",
+ build_function_type (ptr_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ void_list_node)))),
+ NOT_BUILT_IN,
+ pushdecl,
+ 0);
+ find_first_exception_match_fndecl =
+ define_function ("__find_first_exception_table_match",
+ build_function_type (ptr_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ void_list_node)),
+ NOT_BUILT_IN,
+ pushdecl,
+ 0);
+ unwind_fndecl =
+ define_function ("__unwind_function",
+ build_function_type (void_type_node,
+ tree_cons (NULL_TREE, ptr_type_node,
+ void_list_node)),
+ NOT_BUILT_IN,
+ pushdecl,
+ 0);
+ throw_fndecl =
+ define_function ("__throw",
+ build_function_type (void_type_node, void_list_node),
+ NOT_BUILT_IN,
+ pushdecl,
+ 0);
+ DECL_EXTERNAL (throw_fndecl) = 0;
+ TREE_PUBLIC (throw_fndecl) = 0;
+
+ Unexpected = default_conversion (unexpected_fndecl);
+ Terminate = default_conversion (terminate_fndecl);
+ SetTerminate = default_conversion (set_terminate_fndecl);
+ SetUnexpected = default_conversion (set_unexpected_fndecl);
+ CatchMatch = default_conversion (catch_match_fndecl);
+ FirstExceptionMatch = default_conversion (find_first_exception_match_fndecl);
+ Unwind = default_conversion (unwind_fndecl);
+ Throw = default_conversion (throw_fndecl);
+ BuiltinReturnAddress = default_conversion (builtin_return_address_fndecl);
+
+ TerminateFunctionCall = build_function_call (Terminate, NULL_TREE);
+
+ pop_lang_context ();
+
+ new_eh_queue (&ehqueue);
+ new_eh_queue (&eh_table_output_queue);
+ new_eh_stack (&ehstack);
+
+ declspecs = tree_cons (NULL_TREE, get_identifier ("void"), NULL_TREE);
+ d = build_parse_node (INDIRECT_REF, get_identifier ("__eh_pc"));
+ d = start_decl (d, declspecs, 0, NULL_TREE);
+ DECL_COMMON (d) = 1;
+ cp_finish_decl (d, NULL_TREE, NULL_TREE, 0, 0);
+ saved_pc = lookup_name (get_identifier ("__eh_pc"), 0);
+
+ declspecs = tree_cons (NULL_TREE, get_identifier ("void"), NULL_TREE);
+ d = build_parse_node (INDIRECT_REF, get_identifier ("__eh_type"));
+ d = start_decl (d, declspecs, 0, NULL_TREE);
+ DECL_COMMON (d) = 1;
+ cp_finish_decl (d, NULL_TREE, NULL_TREE, 0, 0);
+ saved_throw_type = lookup_name (get_identifier ("__eh_type"), 0);
+
+ declspecs = tree_cons (NULL_TREE, get_identifier ("void"), NULL_TREE);
+ d = build_parse_node (INDIRECT_REF, get_identifier ("__eh_value"));
+ d = start_decl (d, declspecs, 0, NULL_TREE);
+ DECL_COMMON (d) = 1;
+ cp_finish_decl (d, NULL_TREE, NULL_TREE, 0, 0);
+ saved_throw_value = lookup_name (get_identifier ("__eh_value"), 0);
+}
+
+/* call this to begin a block of unwind protection (ie: when an object is
+ constructed) */
+void
+start_protect ()
+{
+ if (! doing_eh (0))
+ return;
+
+ emit_label (push_eh_entry (&ehstack));
+}
+
+/* call this to end a block of unwind protection. the finalization tree is
+ the finalization which needs to be run in order to cleanly unwind through
+ this level of protection. (ie: call this when a scope is exited)*/
+void
+end_protect (finalization)
+ tree finalization;
+{
+ struct ehEntry *entry;
+
+ if (! doing_eh (0))
+ return;
+
+ entry = pop_eh_entry (&ehstack);
+
+ emit_label (entry->end_label);
+ /* Put in something that takes up space, as otherwise the end
+ address for the EH region could have the exact same address as
+ the outer region, causing us to miss the fact that resuming
+ exception handling with this PC value would be inside the outer
+ region. */
+ emit_insn (gen_nop ());
+
+ entry->finalization = finalization;
+
+ enqueue_eh_entry (&ehqueue, entry);
+}
+
+/* call this on start of a try block. */
+void
+expand_start_try_stmts ()
+{
+ if (! doing_eh (1))
+ return;
+
+ start_protect ();
+}
+
+void
+expand_end_try_stmts ()
+{
+ end_protect (integer_zero_node);
+}
+
+
+/* call this to start processing of all the catch blocks. */
+void
+expand_start_all_catch ()
+{
+ struct ehEntry *entry;
+ rtx label;
+
+ if (! doing_eh (1))
+ return;
+
+ emit_line_note (input_filename, lineno);
+ label = gen_label_rtx ();
+
+ /* The label for the exception handling block we will save. This is
+ Lresume, in the documention. */
+ emit_label (label);
+
+ /* Put in something that takes up space, as otherwise the end
+ address for the EH region could have the exact same address as
+ the outer region, causing us to miss the fact that resuming
+ exception handling with this PC value would be inside the outer
+ region. */
+ emit_insn (gen_nop ());
+
+ push_label_entry (&caught_return_label_stack, label);
+
+ /* Start a new sequence for all the catch blocks. We will add this
+ to the gloabl sequence catch_clauses, when we have completed all
+ the handlers in this handler-seq. */
+ start_sequence ();
+
+ while (1)
+ {
+ entry = dequeue_eh_entry (&ehqueue);
+ emit_label (entry->exception_handler_label);
+
+ expand_expr (entry->finalization, const0_rtx, VOIDmode, 0);
+
+ /* When we get down to the matching entry, stop. */
+ if (entry->finalization == integer_zero_node)
+ break;
+
+ /* The below can be optimized away, and we could just fall into the
+ next EH handler, if we are certain they are nested. */
+ /* Code to throw out to outer context, if we fall off end of the
+ handler. */
+ expand_internal_throw (gen_rtx (LABEL_REF,
+ Pmode,
+ entry->end_label));
+ free (entry);
+ }
+}
+
+/* call this to end processing of all the catch blocks. */
+void
+expand_end_all_catch ()
+{
+ rtx new_catch_clause;
+
+ if (! doing_eh (1))
+ return;
+
+ /* Code to throw out to outer context, if we fall off end of catch
+ handlers. This is rethrow (Lresume, same id, same obj); in the
+ documentation. */
+ expand_internal_throw (gen_rtx (LABEL_REF,
+ Pmode,
+ top_label_entry (&caught_return_label_stack)));
+
+ /* Now we have the complete catch sequence. */
+ new_catch_clause = get_insns ();
+ end_sequence ();
+
+ /* this level of catch blocks is done, so set up the successful catch jump
+ label for the next layer of catch blocks. */
+ pop_label_entry (&caught_return_label_stack);
+
+ /* Add the new sequence of catchs to the main one for this
+ function. */
+ push_to_sequence (catch_clauses);
+ emit_insns (new_catch_clause);
+ catch_clauses = get_insns ();
+ end_sequence ();
+
+ /* Here we fall through into the continuation code. */
+}
+
+/* Build a type value for use at runtime for a type that is matched
+ against by the exception handling system. */
+static tree
+build_eh_type_type (type)
+ tree type;
+{
+ char *typestring;
+ tree exp;
+
+ if (type == error_mark_node)
+ return error_mark_node;
+
+ /* peel back references, so they match. */
+ if (TREE_CODE (type) == REFERENCE_TYPE)
+ type = TREE_TYPE (type);
+
+ /* Peel off cv qualifiers. */
+ type = TYPE_MAIN_VARIANT (type);
+
+ if (flag_rtti)
+ {
+ return build1 (ADDR_EXPR, ptr_type_node, get_typeid (type));
+ }
+
+ typestring = build_overload_name (type, 1, 1);
+ exp = combine_strings (build_string (strlen (typestring)+1, typestring));
+ return build1 (ADDR_EXPR, ptr_type_node, exp);
+}
+
+/* Build a type value for use at runtime for a exp that is thrown or
+ matched against by the exception handling system. */
+static tree
+build_eh_type (exp)
+ tree exp;
+{
+ if (flag_rtti)
+ {
+ exp = build_typeid (exp);
+ return build1 (ADDR_EXPR, ptr_type_node, exp);
+ }
+ return build_eh_type_type (TREE_TYPE (exp));
+}
+
+/* call this to start a catch block. Typename is the typename, and identifier
+ is the variable to place the object in or NULL if the variable doesn't
+ matter. If typename is NULL, that means its a "catch (...)" or catch
+ everything. In that case we don't need to do any type checking.
+ (ie: it ends up as the "else" clause rather than an "else if" clause) */
+void
+expand_start_catch_block (declspecs, declarator)
+ tree declspecs, declarator;
+{
+ rtx false_label_rtx;
+ rtx protect_label_rtx;
+ tree decl = NULL_TREE;
+ tree init;
+
+ if (! doing_eh (1))
+ return;
+
+ /* Create a binding level for the parm. */
+ expand_start_bindings (0);
+
+ false_label_rtx = gen_label_rtx ();
+ /* This is saved for the exception table. */
+ push_rtl_perm ();
+ protect_label_rtx = gen_label_rtx ();
+ pop_rtl_from_perm ();
+ push_label_entry (&false_label_stack, false_label_rtx);
+ push_label_entry (&false_label_stack, protect_label_rtx);
+
+ if (declspecs)
+ {
+ tree exp;
+ rtx call_rtx, return_value_rtx;
+ tree init_type;
+
+ decl = grokdeclarator (declarator, declspecs, CATCHPARM, 1,
+ NULL_TREE, NULL_TREE);
+
+ if (decl == NULL_TREE)
+ {
+ error ("invalid catch parameter");
+ return;
+ }
+
+ /* Figure out the type that the initializer is. */
+ init_type = TREE_TYPE (decl);
+ if (TREE_CODE (init_type) != REFERENCE_TYPE
+ && TREE_CODE (init_type) != POINTER_TYPE)
+ init_type = build_reference_type (init_type);
+
+ exp = saved_throw_value;
+ exp = tree_cons (NULL_TREE,
+ build_eh_type_type (TREE_TYPE (decl)),
+ tree_cons (NULL_TREE,
+ saved_throw_type,
+ tree_cons (NULL_TREE, exp, NULL_TREE)));
+ exp = build_function_call (CatchMatch, exp);
+ call_rtx = expand_call (exp, NULL_RTX, 0);
+ assemble_external (TREE_OPERAND (CatchMatch, 0));
+
+ return_value_rtx = hard_function_value (ptr_type_node, exp);
+
+ /* did the throw type match function return TRUE? */
+ emit_cmp_insn (return_value_rtx, const0_rtx, EQ, NULL_RTX,
+ GET_MODE (return_value_rtx), 0, 0);
+
+ /* if it returned FALSE, jump over the catch block, else fall into it */
+ emit_jump_insn (gen_beq (false_label_rtx));
+
+ init = convert_from_reference (save_expr (make_tree (init_type, call_rtx)));
+
+ /* Do we need the below two lines? */
+ /* Let `cp_finish_decl' know that this initializer is ok. */
+ DECL_INITIAL (decl) = init;
+ decl = pushdecl (decl);
+ cp_finish_decl (decl, init, NULL_TREE, 0, LOOKUP_ONLYCONVERTING);
+ }
+ else
+ {
+ /* Fall into the catch all section. */
+ }
+
+ /* This is the starting of something to protect. */
+ emit_label (protect_label_rtx);
+
+ emit_line_note (input_filename, lineno);
+}
+
+
+/* this is called from expand_exception_blocks and
+ expand_end_catch_block to expand the toplevel finalizations for a
+ function. We return the first label emitted, if any, otherwise
+ return NULL_RTX. */
+static rtx
+expand_leftover_cleanups ()
+{
+ struct ehEntry *entry;
+ rtx first_label = NULL_RTX;
+
+ while ((entry = dequeue_eh_entry (&ehqueue)) != 0)
+ {
+ if (! first_label)
+ first_label = entry->exception_handler_label;
+ emit_label (entry->exception_handler_label);
+
+ expand_expr (entry->finalization, const0_rtx, VOIDmode, 0);
+
+ /* The below can be optimized away, and we could just fall into the
+ next EH handler, if we are certain they are nested. */
+ /* Code to throw out to outer context, if we fall off end of the
+ handler. */
+ expand_internal_throw (gen_rtx (LABEL_REF,
+ Pmode,
+ entry->end_label));
+
+ /* leftover try block, opps. */
+ if (entry->finalization == integer_zero_node)
+ abort ();
+
+ free (entry);
+ }
+
+ return first_label;
+}
+
+/* Call this to end a catch block. Its responsible for emitting the
+ code to handle jumping back to the correct place, and for emitting
+ the label to jump to if this catch block didn't match. */
+void expand_end_catch_block ()
+{
+ rtx start_protect_label_rtx;
+ rtx end_protect_label_rtx;
+ tree decls;
+ struct ehEntry entry;
+
+ if (! doing_eh (1))
+ return;
+
+ /* fall to outside the try statement when done executing handler and
+ we fall off end of handler. This is jump Lresume in the
+ documentation. */
+ emit_jump (top_label_entry (&caught_return_label_stack));
+
+ /* We end the rethrow protection region as soon as we hit a label. */
+ end_protect_label_rtx = expand_leftover_cleanups ();
+
+ /* Code to throw out to outer context, if we get a throw from within
+ our catch handler. */
+ /* These are saved for the exception table. */
+ push_rtl_perm ();
+ entry.exception_handler_label = gen_label_rtx ();
+ pop_rtl_from_perm ();
+ /* This label is Lhandler in the documentation. */
+ emit_label (entry.exception_handler_label);
+ expand_internal_throw (gen_rtx (LABEL_REF,
+ Pmode,
+ top_label_entry (&caught_return_label_stack)));
+
+ /* No associated finalization. */
+ entry.finalization = NULL_TREE;
+ entry.context = current_function_decl;
+
+ if (end_protect_label_rtx == NULL_RTX)
+ end_protect_label_rtx = entry.exception_handler_label;
+
+ /* Because we are emitted out of line, we have to protect this. */
+ /* label for the start of the protection region. */
+ start_protect_label_rtx = pop_label_entry (&false_label_stack);
+
+ /* Cleanup the EH parameter. */
+ decls = getdecls ();
+ expand_end_bindings (decls, decls != NULL_TREE, 0);
+
+ /* label we emit to jump to if this catch block didn't match. */
+ /* This the closing } in the `if (eq) {' of the documentation. */
+ emit_label (pop_label_entry (&false_label_stack));
+
+ /* Because we are reordered out of line, we have to protect this. */
+ entry.start_label = start_protect_label_rtx;
+ entry.end_label = end_protect_label_rtx;
+
+ LABEL_PRESERVE_P (entry.start_label) = 1;
+ LABEL_PRESERVE_P (entry.end_label) = 1;
+ LABEL_PRESERVE_P (entry.exception_handler_label) = 1;
+
+ /* These set up a call to throw the caught exception into the outer
+ context. */
+ enqueue_eh_entry (&eh_table_output_queue, copy_eh_entry (&entry));
+}
+
+/* unwind the stack. */
+static void
+do_unwind (inner_throw_label)
+ rtx inner_throw_label;
+{
+#if defined(SPARC_STACK_ALIGN) /* was sparc */
+ tree fcall;
+ tree params;
+ rtx return_val_rtx;
+ rtx temp;
+
+ /* call to __builtin_return_address () */
+ params = tree_cons (NULL_TREE, integer_zero_node, NULL_TREE);
+ fcall = build_function_call (BuiltinReturnAddress, params);
+ return_val_rtx = expand_expr (fcall, NULL_RTX, Pmode, 0);
+ /* In the return, the new pc is pc+8, as the value coming in is
+ really the address of the call insn, not the next insn. */
+ temp = gen_reg_rtx (Pmode);
+ emit_move_insn (temp, inner_throw_label);
+ emit_move_insn (return_val_rtx, plus_constant (temp, -8));
+ easy_expand_asm ("ret");
+ easy_expand_asm ("restore");
+ emit_barrier ();
+#endif
+#if defined(ARM_FRAME_RTX) /* was __arm */
+ if (flag_omit_frame_pointer)
+ sorry ("this implementation of exception handling requires a frame pointer");
+
+ emit_move_insn (stack_pointer_rtx,
+ gen_rtx (MEM, Pmode, plus_constant (hard_frame_pointer_rtx, -8)));
+ emit_move_insn (hard_frame_pointer_rtx,
+ gen_rtx (MEM, Pmode, plus_constant (hard_frame_pointer_rtx, -12)));
+#endif
+#if defined(TARGET_88000) /* was m88k */
+ rtx temp_frame = frame_pointer_rtx;
+
+ temp_frame = memory_address (Pmode, temp_frame);
+ temp_frame = copy_to_reg (gen_rtx (MEM, Pmode, temp_frame));
+
+ /* hopefully this will successfully pop the frame! */
+ emit_move_insn (frame_pointer_rtx, temp_frame);
+ emit_move_insn (stack_pointer_rtx, frame_pointer_rtx);
+ emit_move_insn (arg_pointer_rtx, frame_pointer_rtx);
+ emit_insn (gen_add2_insn (stack_pointer_rtx, gen_rtx (CONST_INT, VOIDmode,
+ (HOST_WIDE_INT)m88k_debugger_offset (stack_pointer_rtx, 0))));
+
+#if 0
+ emit_insn (gen_add2_insn (arg_pointer_rtx, gen_rtx (CONST_INT, VOIDmode,
+ -(HOST_WIDE_INT)m88k_debugger_offset (arg_pointer_rtx, 0))));
+
+ emit_move_insn (stack_pointer_rtx, arg_pointer_rtx);
+
+ emit_insn (gen_add2_insn (stack_pointer_rtx, gen_rtx (CONST_INT, VOIDmode,
+ (HOST_WIDE_INT)m88k_debugger_offset (arg_pointer_rtx, 0))));
+#endif
+#endif
+#if !defined(TARGET_88000) && !defined(ARM_FRAME_RTX) && !defined(SPARC_STACK_ALIGN)
+ tree fcall;
+ tree params;
+ rtx return_val_rtx;
+
+ /* call to __builtin_return_address () */
+ params = tree_cons (NULL_TREE, integer_zero_node, NULL_TREE);
+ fcall = build_function_call (BuiltinReturnAddress, params);
+ return_val_rtx = expand_expr (fcall, NULL_RTX, Pmode, 0);
+#if 0
+ /* I would like to do this here, but doesn't seem to work. */
+ emit_move_insn (return_val_rtx, inner_throw_label);
+ /* So, for now, just pass throw label to stack unwinder. */
+#endif
+ params = tree_cons (NULL_TREE, make_tree (ptr_type_node,
+ inner_throw_label), NULL_TREE);
+
+ do_function_call (Unwind, params, NULL_TREE);
+ assemble_external (TREE_OPERAND (Unwind, 0));
+ emit_barrier ();
+#endif
+}
+
+
+/* is called from expand_exception_blocks () to generate the code in a function
+ to "throw" if anything in the function needs to perform a throw.
+
+ expands "throw" as the following pseudo code:
+
+ throw:
+ eh = find_first_exception_match (saved_pc);
+ if (!eh) goto gotta_rethrow_it;
+ goto eh;
+
+ gotta_rethrow_it:
+ saved_pc = __builtin_return_address (0);
+ pop_to_previous_level ();
+ goto throw;
+
+ */
+void
+expand_builtin_throw ()
+{
+ tree fcall;
+ tree params;
+ rtx return_val_rtx;
+ rtx gotta_rethrow_it;
+ rtx gotta_call_terminate;
+ rtx unwind_and_throw;
+ rtx goto_unwind_and_throw;
+ rtx top_of_loop;
+ rtx unwind_first;
+ tree t;
+
+ if (! doing_eh (0))
+ return;
+
+ if (! throw_used)
+ return;
+
+ params = void_list_node;
+ t = build_parse_node (CALL_EXPR, get_identifier ("__throw"), params, NULL_TREE);
+ start_function (decl_tree_cons (NULL_TREE, get_identifier ("static"),
+ void_list_node),
+ t, NULL_TREE, NULL_TREE, 0);
+ store_parm_decls ();
+ pushlevel (0);
+ clear_last_expr ();
+ push_momentary ();
+ expand_start_bindings (0);
+
+ gotta_rethrow_it = gen_label_rtx ();
+ gotta_call_terminate = gen_label_rtx ();
+ unwind_and_throw = gen_label_rtx ();
+ goto_unwind_and_throw = gen_label_rtx ();
+ top_of_loop = gen_label_rtx ();
+ unwind_first = gen_label_rtx ();
+
+ emit_jump (unwind_first);
+
+ emit_label (top_of_loop);
+
+ /* search for an exception handler for the saved_pc */
+ return_val_rtx = do_function_call (FirstExceptionMatch,
+ tree_cons (NULL_TREE, saved_pc, NULL_TREE),
+ ptr_type_node);
+ assemble_external (TREE_OPERAND (FirstExceptionMatch, 0));
+
+ /* did we find one? */
+ emit_cmp_insn (return_val_rtx, const0_rtx, EQ, NULL_RTX,
+ GET_MODE (return_val_rtx), 0, 0);
+
+ /* if not, jump to gotta_rethrow_it */
+ emit_jump_insn (gen_beq (gotta_rethrow_it));
+
+ /* we found it, so jump to it */
+ emit_indirect_jump (return_val_rtx);
+
+ /* code to deal with unwinding and looking for it again */
+ emit_label (gotta_rethrow_it);
+
+ /* call to __builtin_return_address () */
+#if defined(ARM_FRAME_RTX) /* was __arm */
+/* This replaces a 'call' to __builtin_return_address */
+ return_val_rtx = gen_reg_rtx (Pmode);
+ emit_move_insn (return_val_rtx, gen_rtx (MEM, Pmode, plus_constant (hard_frame_pointer_rtx, -4)));
+#else
+ params = tree_cons (NULL_TREE, integer_zero_node, NULL_TREE);
+ fcall = build_function_call (BuiltinReturnAddress, params);
+ return_val_rtx = expand_expr (fcall, NULL_RTX, Pmode, 0);
+#endif
+
+ /* did __builtin_return_address () return a valid address? */
+ emit_cmp_insn (return_val_rtx, const0_rtx, EQ, NULL_RTX,
+ GET_MODE (return_val_rtx), 0, 0);
+
+ emit_jump_insn (gen_beq (gotta_call_terminate));
+
+#if defined(ARM_FRAME_RTX) /* was __arm */
+ /* On the ARM, '__builtin_return_address', must have 4
+ subtracted from it. */
+ emit_insn (gen_add2_insn (return_val_rtx, GEN_INT (-4)));
+
+ /* If we are generating code for an ARM2/ARM3 machine or for an ARM6 in 26 bit
+ mode, the condition codes must be masked out of the return value, or else
+ they will confuse BuiltinReturnAddress. This does not apply to ARM6 and
+ later processors when running in 32 bit mode. */
+ if (!TARGET_6)
+ emit_insn (gen_rtx (SET, Pmode, return_val_rtx, gen_rtx (AND, Pmode, return_val_rtx, GEN_INT (0x03fffffc))));
+#else
+#if !defined(SPARC_STACK_ALIGN) /* was sparc */
+ /* On the SPARC, __builtin_return_address is already -8, no need to
+ subtract any more from it. */
+ return_val_rtx = plus_constant (return_val_rtx, -1);
+#endif
+#endif
+
+ /* yes it did */
+ t = build_modify_expr (saved_pc, NOP_EXPR, make_tree (ptr_type_node, return_val_rtx));
+ expand_expr (t, const0_rtx, VOIDmode, 0);
+
+ do_unwind (gen_rtx (LABEL_REF, Pmode, top_of_loop));
+ emit_jump (top_of_loop);
+
+ /* no it didn't --> therefore we need to call terminate */
+ emit_label (gotta_call_terminate);
+ do_function_call (Terminate, NULL_TREE, NULL_TREE);
+ assemble_external (TREE_OPERAND (Terminate, 0));
+
+ {
+ rtx ret_val, return_val_rtx;
+ emit_label (unwind_first);
+ ret_val = expand_builtin_return_addr (BUILT_IN_RETURN_ADDRESS,
+ 0, hard_frame_pointer_rtx);
+
+ /* Set it up so that we continue inside, at the top of the loop. */
+ emit_move_insn (ret_val, gen_rtx (LABEL_REF, Pmode, top_of_loop));
+#ifdef NORMAL_RETURN_ADDR_OFFSET
+ return_val_rtx = plus_constant (ret_val, -NORMAL_RETURN_ADDR_OFFSET);
+ if (return_val_rtx != ret_val)
+ emit_move_insn (ret_val, return_val_rtx);
+#endif
+
+ /* Fall into epilogue to unwind prologue. */
+ }
+
+ expand_end_bindings (getdecls(), 1, 0);
+ poplevel (1, 0, 0);
+ pop_momentary ();
+
+ finish_function (lineno, 0, 0);
+}
+
+
+void
+expand_start_eh_spec ()
+{
+ start_protect ();
+}
+
+void
+expand_end_eh_spec (raises)
+ tree raises;
+{
+ tree expr, second_try;
+ rtx check = gen_label_rtx ();
+ rtx cont;
+ rtx ret = gen_reg_rtx (Pmode);
+ rtx flag = gen_reg_rtx (TYPE_MODE (integer_type_node));
+ rtx end = gen_label_rtx ();
+
+ expr = make_node (RTL_EXPR);
+ TREE_TYPE (expr) = void_type_node;
+ RTL_EXPR_RTL (expr) = const0_rtx;
+ TREE_SIDE_EFFECTS (expr) = 1;
+ start_sequence_for_rtl_expr (expr);
+ cont = gen_label_rtx ();
+ emit_move_insn (ret, gen_rtx (LABEL_REF, Pmode, cont));
+ emit_jump (check);
+ emit_label (cont);
+ jumpif (make_tree (integer_type_node, flag), end);
+ do_function_call (Terminate, NULL_TREE, NULL_TREE);
+ assemble_external (TREE_OPERAND (Terminate, 0));
+ emit_barrier ();
+ RTL_EXPR_SEQUENCE (expr) = get_insns ();
+ end_sequence ();
+
+ second_try = expr;
+
+ expr = make_node (RTL_EXPR);
+ TREE_TYPE (expr) = void_type_node;
+ RTL_EXPR_RTL (expr) = const0_rtx;
+ TREE_SIDE_EFFECTS (expr) = 1;
+ start_sequence_for_rtl_expr (expr);
+
+ cont = gen_label_rtx ();
+ emit_move_insn (ret, gen_rtx (LABEL_REF, Pmode, cont));
+ emit_jump (check);
+ emit_label (cont);
+ jumpif (make_tree (integer_type_node, flag), end);
+ start_protect ();
+ do_function_call (Unexpected, NULL_TREE, NULL_TREE);
+ assemble_external (TREE_OPERAND (Unexpected, 0));
+ emit_barrier ();
+ end_protect (second_try);
+
+ emit_label (check);
+ emit_move_insn (flag, const1_rtx);
+ cont = gen_label_rtx ();
+ while (raises)
+ {
+ tree exp;
+ tree match_type = TREE_VALUE (raises);
+
+ if (match_type)
+ {
+ /* check TREE_VALUE (raises) here */
+ exp = saved_throw_value;
+ exp = tree_cons (NULL_TREE,
+ build_eh_type_type (match_type),
+ tree_cons (NULL_TREE,
+ saved_throw_type,
+ tree_cons (NULL_TREE, exp, NULL_TREE)));
+ exp = build_function_call (CatchMatch, exp);
+ assemble_external (TREE_OPERAND (CatchMatch, 0));
+
+ jumpif (exp, cont);
+ }
+
+ raises = TREE_CHAIN (raises);
+ }
+ emit_move_insn (flag, const0_rtx);
+ emit_label (cont);
+ emit_indirect_jump (ret);
+ emit_label (end);
+
+ RTL_EXPR_SEQUENCE (expr) = get_insns ();
+ end_sequence ();
+
+ end_protect (expr);
+}
+
+/* This is called to expand all the toplevel exception handling
+ finalization for a function. It should only be called once per
+ function. */
+void
+expand_exception_blocks ()
+{
+ static rtx funcend;
+ rtx insns;
+
+ start_sequence ();
+
+ funcend = gen_label_rtx ();
+ emit_jump (funcend);
+ /* expand_null_return (); */
+
+ start_sequence ();
+
+ /* Add all the catch clauses here. */
+ emit_insns (catch_clauses);
+ catch_clauses = NULL_RTX;
+
+ expand_leftover_cleanups ();
+
+ insns = get_insns ();
+ end_sequence ();
+
+ /* Do this after we expand leftover cleanups, so that the end_protect
+ that expand_end_eh_spec does will match the right start_protect,
+ and make sure it comes out before the terminate protected region. */
+ if (TYPE_RAISES_EXCEPTIONS (TREE_TYPE (current_function_decl)))
+ {
+ expand_end_eh_spec (TYPE_RAISES_EXCEPTIONS (TREE_TYPE (current_function_decl)));
+ push_to_sequence (insns);
+
+ /* Now expand any new ones. */
+ expand_leftover_cleanups ();
+
+ insns = get_insns ();
+ end_sequence ();
+ }
+
+ if (insns)
+ {
+ struct ehEntry entry;
+
+ /* These are saved for the exception table. */
+ push_rtl_perm ();
+ entry.start_label = gen_label_rtx ();
+ entry.end_label = gen_label_rtx ();
+ entry.exception_handler_label = gen_label_rtx ();
+ entry.finalization = TerminateFunctionCall;
+ entry.context = current_function_decl;
+ assemble_external (TREE_OPERAND (Terminate, 0));
+ pop_rtl_from_perm ();
+
+ LABEL_PRESERVE_P (entry.start_label) = 1;
+ LABEL_PRESERVE_P (entry.end_label) = 1;
+ LABEL_PRESERVE_P (entry.exception_handler_label) = 1;
+
+ emit_label (entry.start_label);
+ emit_insns (insns);
+
+ enqueue_eh_entry (&eh_table_output_queue, copy_eh_entry (&entry));
+
+ emit_label (entry.exception_handler_label);
+ expand_expr (entry.finalization, const0_rtx, VOIDmode, 0);
+ emit_label (entry.end_label);
+ emit_barrier ();
+ }
+
+ {
+ /* Mark the end of the stack unwinder. */
+ rtx unwind_insns;
+ start_sequence ();
+ end_eh_unwinder (funcend);
+ expand_leftover_cleanups ();
+ unwind_insns = get_insns ();
+ end_sequence ();
+ if (unwind_insns)
+ {
+ insns = unwind_insns;
+ emit_insns (insns);
+ }
+ }
+
+ emit_label (funcend);
+
+ /* Only if we had previous insns do we want to emit the jump around
+ them. If there weren't any, then insns will remain NULL_RTX. */
+ if (insns)
+ insns = get_insns ();
+ end_sequence ();
+
+ emit_insns (insns);
+}
+
+
+/* call this to expand a throw statement. This follows the following
+ algorithm:
+
+ 1. Allocate space to save the current PC onto the stack.
+ 2. Generate and emit a label and save its address into the
+ newly allocated stack space since we can't save the pc directly.
+ 3. If this is the first call to throw in this function:
+ generate a label for the throw block
+ 4. jump to the throw block label. */
+void
+expand_throw (exp)
+ tree exp;
+{
+ rtx label;
+
+ if (! doing_eh (1))
+ return;
+
+ /* This is the label that represents where in the code we were, when
+ we got an exception. This needs to be updated when we rethrow an
+ exception, so that the matching routine knows to search out. */
+ label = gen_label_rtx ();
+ emit_label (label);
+
+ if (exp)
+ {
+ tree throw_type;
+ tree e;
+
+ /* throw expression */
+ /* First, decay it. */
+ exp = decay_conversion (exp);
+
+ if (TREE_CODE (TREE_TYPE (exp)) == POINTER_TYPE)
+ {
+ throw_type = build_eh_type (exp);
+ exp = build_reinterpret_cast (ptr_type_node, exp);
+ }
+ else
+ {
+ /* Make a copy of the thrown object. WP 15.1.5 */
+ exp = build_new (NULL_TREE, TREE_TYPE (exp),
+ build_tree_list (NULL_TREE, exp),
+ 0);
+
+ if (exp == error_mark_node)
+ error (" in thrown expression");
+
+ throw_type = build_eh_type (build_indirect_ref (exp, NULL_PTR));
+ }
+
+ e = build_modify_expr (saved_throw_type, NOP_EXPR, throw_type);
+ expand_expr (e, const0_rtx, VOIDmode, 0);
+ e = build_modify_expr (saved_throw_value, NOP_EXPR, exp);
+ e = build1 (CLEANUP_POINT_EXPR, TREE_TYPE (e), e);
+ expand_expr (e, const0_rtx, VOIDmode, 0);
+ }
+ else
+ {
+ /* rethrow current exception */
+ /* This part is easy, as we don't have to do anything else. */
+ }
+
+ expand_internal_throw (gen_rtx (LABEL_REF, Pmode, label));
+}
+
+void
+end_protect_partials () {
+ while (protect_list)
+ {
+ end_protect (TREE_VALUE (protect_list));
+ protect_list = TREE_CHAIN (protect_list);
+ }
+}
+
+int
+might_have_exceptions_p ()
+{
+ if (eh_table_output_queue.head)
+ return 1;
+ return 0;
+}
+
+/* Output the exception table.
+ Return the number of handlers. */
+void
+emit_exception_table ()
+{
+ int count = 0;
+ extern FILE *asm_out_file;
+ struct ehEntry *entry;
+ tree eh_node_decl;
+
+ if (! doing_eh (0))
+ return;
+
+ exception_section ();
+
+ /* Beginning marker for table. */
+ assemble_align (GET_MODE_ALIGNMENT (Pmode));
+ assemble_label ("__EXCEPTION_TABLE__");
+ output_exception_table_entry (asm_out_file,
+ const0_rtx, const0_rtx, const0_rtx);
+
+ while (entry = dequeue_eh_entry (&eh_table_output_queue))
+ {
+ tree context = entry->context;
+
+ if (context && ! TREE_ASM_WRITTEN (context))
+ continue;
+
+ count++;
+ output_exception_table_entry (asm_out_file,
+ entry->start_label, entry->end_label,
+ entry->exception_handler_label);
+ }
+
+ /* Ending marker for table. */
+ assemble_label ("__EXCEPTION_END__");
+ output_exception_table_entry (asm_out_file,
+ constm1_rtx, constm1_rtx, constm1_rtx);
+}
+
+void
+register_exception_table ()
+{
+ emit_library_call (gen_rtx (SYMBOL_REF, Pmode, "__register_exceptions"), 0,
+ VOIDmode, 1,
+ gen_rtx (SYMBOL_REF, Pmode, "__EXCEPTION_TABLE__"),
+ Pmode);
+}
+
+/* Build a throw expression. */
+tree
+build_throw (e)
+ tree e;
+{
+ if (e != error_mark_node)
+ {
+ e = build1 (THROW_EXPR, void_type_node, e);
+ TREE_SIDE_EFFECTS (e) = 1;
+ TREE_USED (e) = 1;
+ }
+ return e;
+}
+
+start_eh_unwinder ()
+{
+ start_protect ();
+}
+
+end_eh_unwinder (end)
+ rtx end;
+{
+ tree expr;
+ rtx return_val_rtx, ret_val, label;
+
+ if (! doing_eh (0))
+ return;
+
+ expr = make_node (RTL_EXPR);
+ TREE_TYPE (expr) = void_type_node;
+ RTL_EXPR_RTL (expr) = const0_rtx;
+ TREE_SIDE_EFFECTS (expr) = 1;
+ start_sequence_for_rtl_expr (expr);
+
+ ret_val = expand_builtin_return_addr (BUILT_IN_RETURN_ADDRESS,
+ 0, hard_frame_pointer_rtx);
+ return_val_rtx = copy_to_reg (ret_val);
+#ifdef NORMAL_RETURN_ADDR_OFFSET
+ return_val_rtx = plus_constant (return_val_rtx, NORMAL_RETURN_ADDR_OFFSET-1);
+#else
+ return_val_rtx = plus_constant (return_val_rtx, -1);
+#endif
+ emit_move_insn (DECL_RTL (saved_pc), return_val_rtx);
+
+#ifdef JUMP_TO_THROW
+ emit_move_insn (ret_val, gen_rtx (SYMBOL_REF, Pmode, "__throw"));
+#else
+ label = gen_label_rtx ();
+ emit_move_insn (ret_val, gen_rtx (LABEL_REF, Pmode, label));
+#endif
+
+#ifdef NORMAL_RETURN_ADDR_OFFSET
+ return_val_rtx = plus_constant (ret_val, -NORMAL_RETURN_ADDR_OFFSET);
+ if (return_val_rtx != ret_val)
+ emit_move_insn (ret_val, return_val_rtx);
+#endif
+
+ emit_jump (end);
+
+#ifndef JUMP_TO_THROW
+ emit_label (label);
+ do_function_call (Throw, NULL_TREE, NULL_TREE);
+#endif
+
+ RTL_EXPR_SEQUENCE (expr) = get_insns ();
+ end_sequence ();
+ end_protect (expr);
+}
diff --git a/contrib/gcc/cp/expr.c b/contrib/gcc/cp/expr.c
new file mode 100644
index 0000000..99a611e
--- /dev/null
+++ b/contrib/gcc/cp/expr.c
@@ -0,0 +1,372 @@
+/* Convert language-specific tree expression to rtl instructions,
+ for GNU compiler.
+ Copyright (C) 1988, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+#include "config.h"
+#include "rtl.h"
+#include "tree.h"
+#include "flags.h"
+#include "expr.h"
+#include "cp-tree.h"
+
+#undef NULL
+#define NULL 0
+
+/* Hook used by expand_expr to expand language-specific tree codes. */
+
+rtx
+cplus_expand_expr (exp, target, tmode, modifier)
+ tree exp;
+ rtx target;
+ enum machine_mode tmode;
+ enum expand_modifier modifier;
+{
+ tree type = TREE_TYPE (exp);
+ register enum machine_mode mode = TYPE_MODE (type);
+ register enum tree_code code = TREE_CODE (exp);
+ rtx original_target = target;
+ int ignore = target == const0_rtx;
+
+ if (ignore)
+ target = 0, original_target = 0;
+
+ /* No sense saving up arithmetic to be done
+ if it's all in the wrong mode to form part of an address.
+ And force_operand won't know whether to sign-extend or zero-extend. */
+
+ if (mode != Pmode && modifier == EXPAND_SUM)
+ modifier = EXPAND_NORMAL;
+
+ switch (code)
+ {
+ case NEW_EXPR:
+ {
+ /* Something needs to be initialized, but we didn't know
+ where that thing was when building the tree. For example,
+ it could be the return value of a function, or a parameter
+ to a function which lays down in the stack, or a temporary
+ variable which must be passed by reference.
+
+ Cleanups are handled in a language-specific way: they
+ might be run by the called function (true in GNU C++
+ for parameters with cleanups), or they might be
+ run by the caller, after the call (true in GNU C++
+ for other cleanup needs). */
+
+ tree func = TREE_OPERAND (exp, 0);
+ tree args = TREE_OPERAND (exp, 1);
+ tree type = TREE_TYPE (exp), slot;
+ tree fn_type = TREE_TYPE (TREE_TYPE (func));
+ tree return_type = TREE_TYPE (fn_type);
+ tree call_exp;
+ rtx call_target, return_target;
+ int pcc_struct_return = 0;
+
+ /* The expression `init' wants to initialize what
+ `target' represents. SLOT holds the slot for TARGET. */
+ slot = TREE_OPERAND (exp, 2);
+
+ if (target == 0)
+ {
+ /* Should always be called with a target in BLKmode case. */
+ my_friendly_assert (mode != BLKmode, 205);
+ my_friendly_assert (DECL_RTL (slot) != 0, 206);
+
+ target = gen_reg_rtx (mode);
+ }
+
+ /* The target the initializer will initialize (CALL_TARGET)
+ must now be directed to initialize the target we are
+ supposed to initialize (TARGET). The semantics for
+ choosing what CALL_TARGET is is language-specific,
+ as is building the call which will perform the
+ initialization. It is left here to show the choices that
+ exist for C++. */
+
+ if (TREE_CODE (func) == ADDR_EXPR
+ && TREE_CODE (TREE_OPERAND (func, 0)) == FUNCTION_DECL
+ && DECL_CONSTRUCTOR_P (TREE_OPERAND (func, 0)))
+ {
+ type = build_pointer_type (type);
+ /* Don't clobber a value that might be part of a default
+ parameter value. */
+ mark_addressable (slot);
+ if (TREE_PERMANENT (args))
+ args = tree_cons (0, build1 (ADDR_EXPR, type, slot),
+ TREE_CHAIN (args));
+ else
+ TREE_VALUE (args) = build1 (ADDR_EXPR, type, slot);
+ call_target = 0;
+ }
+ else if (TREE_CODE (return_type) == REFERENCE_TYPE)
+ {
+ type = return_type;
+ call_target = 0;
+ }
+ else
+ {
+#ifdef PCC_STATIC_STRUCT_RETURN
+ pcc_struct_return = 1;
+ call_target = 0;
+#else
+ call_target = target;
+#endif
+ }
+ if (call_target)
+ {
+ /* Make this a valid memory address now. The code below assumes
+ that it can compare rtx and make assumptions based on the
+ result. The assumptions are true only if the address was
+ valid to begin with. */
+ call_target = validize_mem (call_target);
+ }
+
+ call_exp = build (CALL_EXPR, type, func, args, 0);
+ TREE_SIDE_EFFECTS (call_exp) = 1;
+ return_target = expand_call (call_exp, call_target, ignore);
+ if (call_target == 0)
+ {
+ if (pcc_struct_return)
+ {
+ extern int flag_access_control;
+ int old_ac = flag_access_control;
+
+ tree init = build_decl (VAR_DECL, 0, type);
+ TREE_ADDRESSABLE (init) = 1;
+ DECL_RTL (init) = return_target;
+
+ flag_access_control = 0;
+ expand_aggr_init (slot, init, 0, LOOKUP_ONLYCONVERTING);
+ flag_access_control = old_ac;
+
+ if (TYPE_NEEDS_DESTRUCTOR (type))
+ {
+ init = build_decl (VAR_DECL, 0,
+ build_reference_type (type));
+ DECL_RTL (init) = XEXP (return_target, 0);
+
+ init = maybe_build_cleanup (convert_from_reference (init));
+ if (init != NULL_TREE)
+ expand_expr (init, 0, 0, 0);
+ }
+ call_target = return_target = DECL_RTL (slot);
+ }
+ else
+ call_target = return_target;
+ }
+
+ if (call_target != return_target)
+ {
+ my_friendly_assert (TYPE_HAS_TRIVIAL_INIT_REF (type), 317);
+ if (GET_MODE (return_target) == BLKmode)
+ emit_block_move (call_target, return_target, expr_size (exp),
+ TYPE_ALIGN (type) / BITS_PER_UNIT);
+ else
+ emit_move_insn (call_target, return_target);
+ }
+
+ if (TREE_CODE (return_type) == REFERENCE_TYPE)
+ {
+ tree init;
+
+ if (GET_CODE (call_target) == REG
+ && REGNO (call_target) < FIRST_PSEUDO_REGISTER)
+ my_friendly_abort (39);
+
+ type = TREE_TYPE (exp);
+
+ init = build (RTL_EXPR, return_type, 0, call_target);
+ /* We got back a reference to the type we want. Now initialize
+ target with that. */
+ expand_aggr_init (slot, init, 0, LOOKUP_ONLYCONVERTING);
+ }
+
+ if (DECL_RTL (slot) != target)
+ emit_move_insn (DECL_RTL (slot), target);
+ return DECL_RTL (slot);
+ }
+
+ case OFFSET_REF:
+ {
+#if 1
+ return expand_expr (default_conversion (resolve_offset_ref (exp)),
+ target, tmode, EXPAND_NORMAL);
+#else
+ /* This is old crusty code, and does not handle all that the
+ resolve_offset_ref function does. (mrs) */
+ tree base = build_unary_op (ADDR_EXPR, TREE_OPERAND (exp, 0), 0);
+ tree offset = build_unary_op (ADDR_EXPR, TREE_OPERAND (exp, 1), 0);
+ return expand_expr (build (PLUS_EXPR, TREE_TYPE (exp), base, offset),
+ target, tmode, EXPAND_NORMAL);
+#endif
+ }
+
+ case THUNK_DECL:
+ return DECL_RTL (exp);
+
+ case THROW_EXPR:
+ expand_throw (TREE_OPERAND (exp, 0));
+ return NULL;
+
+ case UNSAVE_EXPR:
+ {
+ rtx temp;
+ temp = expand_expr (TREE_OPERAND (exp, 0), target, tmode, modifier);
+ TREE_OPERAND (exp, 0) = unsave_expr_now (TREE_OPERAND (exp, 0));
+ return temp;
+ }
+
+ default:
+ break;
+ }
+ my_friendly_abort (40);
+ /* NOTREACHED */
+ return NULL;
+}
+
+void
+init_cplus_expand ()
+{
+ lang_expand_expr = cplus_expand_expr;
+}
+
+/* If DECL had its rtl moved from where callers expect it
+ to be, fix it up. RESULT is the nominal rtl for the RESULT_DECL,
+ which may be a pseudo instead of a hard register. */
+
+void
+fixup_result_decl (decl, result)
+ tree decl;
+ rtx result;
+{
+ if (REG_P (result))
+ {
+ if (REGNO (result) >= FIRST_PSEUDO_REGISTER)
+ {
+ rtx real_decl_result;
+
+#ifdef FUNCTION_OUTGOING_VALUE
+ real_decl_result
+ = FUNCTION_OUTGOING_VALUE (TREE_TYPE (decl), current_function_decl);
+#else
+ real_decl_result
+ = FUNCTION_VALUE (TREE_TYPE (decl), current_function_decl);
+#endif
+ REG_FUNCTION_VALUE_P (real_decl_result) = 1;
+ result = real_decl_result;
+ }
+ store_expr (decl, result, 0);
+ emit_insn (gen_rtx (USE, VOIDmode, result));
+ }
+}
+
+/* Return nonzero iff DECL is memory-based. The DECL_RTL of
+ certain const variables might be a CONST_INT, or a REG
+ in some cases. We cannot use `memory_operand' as a test
+ here because on most RISC machines, a variable's address
+ is not, by itself, a legitimate address. */
+
+int
+decl_in_memory_p (decl)
+ tree decl;
+{
+ return DECL_RTL (decl) != 0 && GET_CODE (DECL_RTL (decl)) == MEM;
+}
+
+/* Expand this initialization inline and see if it's simple enough that
+ it can be done at compile-time. */
+
+static tree
+extract_aggr_init (decl, init)
+ tree decl, init;
+{
+ return 0;
+}
+
+static tree
+extract_scalar_init (decl, init)
+ tree decl, init;
+{
+ rtx value, insns, insn;
+ extern struct obstack temporary_obstack;
+ tree t = NULL_TREE;
+
+ push_obstacks (&temporary_obstack, &temporary_obstack);
+ start_sequence ();
+ value = expand_expr (init, NULL_RTX, VOIDmode, 0);
+ insns = get_insns ();
+ end_sequence ();
+ reg_scan (insns, max_reg_num (), 0);
+ jump_optimize (insns, 0, 0, 1);
+ pop_obstacks ();
+
+ for (insn = insns; insn; insn = NEXT_INSN (insn))
+ {
+ rtx r, to;
+
+ if (GET_CODE (insn) == NOTE)
+ continue;
+ else if (GET_CODE (insn) != INSN)
+ return 0;
+
+ r = PATTERN (insn);
+ if (GET_CODE (r) != SET)
+ return 0;
+
+ to = XEXP (r, 0);
+
+ if (! (to == value ||
+ (GET_CODE (to) == SUBREG && XEXP (to, 0) == value)))
+ return 0;
+
+ r = XEXP (r, 1);
+
+ switch (GET_CODE (r))
+ {
+ case CONST_INT:
+ t = build_int_2 (XEXP (r, 0), 0);
+ break;
+ default:
+ return 0;
+ }
+ }
+
+ return t;
+}
+
+int
+extract_init (decl, init)
+ tree decl, init;
+{
+ return 0;
+
+ if (IS_AGGR_TYPE (TREE_TYPE (decl))
+ || TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
+ init = extract_aggr_init (decl, init);
+ else
+ init = extract_scalar_init (decl, init);
+
+ if (init == NULL_TREE)
+ return 0;
+
+ DECL_INITIAL (decl) = init;
+ return 1;
+}
diff --git a/contrib/gcc/cp/g++.1 b/contrib/gcc/cp/g++.1
new file mode 100644
index 0000000..ae016fa
--- /dev/null
+++ b/contrib/gcc/cp/g++.1
@@ -0,0 +1,674 @@
+.\" Copyright (c) 1991, 1992 Free Software Foundation -*-Text-*-
+.\" See section COPYING for conditions for redistribution
+.\" FIXME: no info here on predefines. Should there be? extra for C++...
+.TH G++ 1 "30apr1993" "GNU Tools" "GNU Tools"
+.de BP
+.sp
+.ti \-.2i
+\(**
+..
+.SH NAME
+g++ \- GNU project C++ Compiler
+.SH SYNOPSIS
+.RB g++ " [" \c
+.IR option " | " filename " ].\|.\|.
+.SH DESCRIPTION
+The C and C++ compilers are integrated;
+.B g++
+is a script to call
+.B gcc with options to recognize C++.
+.B gcc
+processes input files
+through one or more of four stages: preprocessing, compilation,
+assembly, and linking. This man page contains full descriptions for
+.I only
+C++ specific aspects of the compiler, though it also contains
+summaries of some general-purpose options. For a fuller explanation
+of the compiler, see
+.BR gcc ( 1 ).
+
+C++ source files use one of the suffixes `\|\c
+.B .C\c
+\&\|', `\|\c
+.B .cc\c
+\&\|', `\|\c
+.B .cxx\c
+\&\|', `\|\c
+.B .cpp\c
+\&\|', or `\|\c
+.B .c++\c
+\&\|'; preprocessed C++ files use the suffix `\|\c
+.B .ii\c
+\&\|'.
+.SH OPTIONS
+There are many command-line options, including options to control
+details of optimization, warnings, and code generation, which are
+common to both
+.B gcc
+and
+.B g++\c
+\&. For full information on all options, see
+.BR gcc ( 1 ).
+
+Options must be separate: `\|\c
+.B \-dr\c
+\&\|' is quite different from `\|\c
+.B \-d \-r
+\&\|'.
+
+Most `\|\c
+.B \-f\c
+\&\|' and `\|\c
+.B \-W\c
+\&\|' options have two contrary forms:
+.BI \-f name
+and
+.BI \-fno\- name\c
+\& (or
+.BI \-W name
+and
+.BI \-Wno\- name\c
+\&). Only the non-default forms are shown here.
+
+.TP
+.B \-c
+Compile or assemble the source files, but do not link. The compiler
+output is an object file corresponding to each source file.
+.TP
+.BI \-D macro
+Define macro \c
+.I macro\c
+\& with the string `\|\c
+.B 1\c
+\&\|' as its definition.
+.TP
+.BI \-D macro = defn
+Define macro \c
+.I macro\c
+\& as \c
+.I defn\c
+\&.
+.TP
+.B \-E
+Stop after the preprocessing stage; do not run the compiler proper. The
+output is preprocessed source code, which is sent to the
+standard output.
+.TP
+.B \-fall\-virtual
+Treat all possible member functions as virtual, implicitly. All
+member functions (except for constructor functions and
+.B new
+or
+.B delete
+member operators) are treated as virtual functions of the class where
+they appear.
+
+This does not mean that all calls to these member functions will be
+made through the internal table of virtual functions. Under some
+circumstances, the compiler can determine that a call to a given
+virtual function can be made directly; in these cases the calls are
+direct in any case.
+.TP
+.B \-fdollars\-in\-identifiers
+Permit the use of `\|\c
+.B $\c
+\&\|' in identifiers.
+Traditional C allowed the character `\|\c
+.B $\c
+\&\|' to form part of identifiers; by default, GNU C also
+allows this. However, ANSI C forbids `\|\c
+.B $\c
+\&\|' in identifiers, and GNU C++ also forbids it by default on most
+platforms (though on some platforms it's enabled by default for GNU
+C++ as well).
+.TP
+.B \-felide\-constructors
+Use this option to instruct the compiler to be smarter about when it can
+elide constructors. Without this flag, GNU C++ and cfront both
+generate effectively the same code for:
+.sp
+.br
+A\ foo\ ();
+.br
+A\ x\ (foo\ ());\ \ \ //\ x\ initialized\ by\ `foo\ ()',\ no\ ctor\ called
+.br
+A\ y\ =\ foo\ ();\ \ \ //\ call\ to\ `foo\ ()'\ heads\ to\ temporary,
+.br
+\ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ //\ y\ is\ initialized\ from\ the\ temporary.
+.br
+.sp
+Note the difference! With this flag, GNU C++ initializes `\|\c
+.B y\c
+\&\|' directly
+from the call to
+.B foo ()
+without going through a temporary.
+.TP
+.B \-fenum\-int\-equiv
+Normally GNU C++ allows conversion of
+.B enum
+to
+.B int\c
+\&, but not the other way around. Use this option if you want GNU C++
+to allow conversion of
+.B int
+to
+.B enum
+as well.
+.TP
+.B \-fexternal\-templates
+Produce smaller code for template declarations, by generating only a
+single copy of each template function where it is defined.
+To use this option successfully, you must also mark all files that
+use templates with either `\|\c
+.B #pragma implementation\c
+\&\|' (the definition) or
+`\|\c
+.B #pragma interface\c
+\&\|' (declarations).
+
+When your code is compiled with `\|\c
+.B \-fexternal\-templates\c
+\&\|', all
+template instantiations are external. You must arrange for all
+necessary instantiations to appear in the implementation file; you can
+do this with a \c
+.B typedef\c
+\& that references each instantiation needed.
+Conversely, when you compile using the default option
+`\|\c
+.B \-fno\-external\-templates\c
+\&\|', all template instantiations are
+explicitly internal.
+.TP
+.B \-fno\-gnu\-linker
+Do not output global initializations (such as C++ constructors and
+destructors) in the form used by the GNU linker (on systems where the GNU
+linker is the standard method of handling them). Use this option when
+you want to use a non-GNU linker, which also requires using the
+.B collect2
+program to make sure the system linker includes
+constructors and destructors. (\c
+.B collect2
+is included in the GNU CC distribution.) For systems which
+.I must
+use
+.B collect2\c
+\&, the compiler driver
+.B gcc
+is configured to do this automatically.
+.TP
+.B \-fmemoize\-lookups
+.TP
+.B \-fsave\-memoized
+These flags are used to get the compiler to compile programs faster
+using heuristics. They are not on by default since they are only effective
+about half the time. The other half of the time programs compile more
+slowly (and take more memory).
+
+The first time the compiler must build a call to a member function (or
+reference to a data member), it must (1) determine whether the class
+implements member functions of that name; (2) resolve which member
+function to call (which involves figuring out what sorts of type
+conversions need to be made); and (3) check the visibility of the member
+function to the caller. All of this adds up to slower compilation.
+Normally, the second time a call is made to that member function (or
+reference to that data member), it must go through the same lengthy
+process again. This means that code like this
+.sp
+.br
+\ \ cout\ <<\ "This\ "\ <<\ p\ <<\ "\ has\ "\ <<\ n\ <<\ "\ legs.\en";
+.br
+.sp
+makes six passes through all three steps. By using a software cache,
+a ``hit'' significantly reduces this cost. Unfortunately, using the
+cache introduces another layer of mechanisms which must be implemented,
+and so incurs its own overhead. `\|\c
+.B \-fmemoize\-lookups\c
+\&\|' enables
+the software cache.
+
+Because access privileges (visibility) to members and member functions
+may differ from one function context to the next,
+.B g++
+may need to flush the cache. With the `\|\c
+.B \-fmemoize\-lookups\c
+\&\|' flag, the cache is flushed after every
+function that is compiled. The `\|\c
+\-fsave\-memoized\c
+\&\|' flag enables the same software cache, but when the compiler
+determines that the context of the last function compiled would yield
+the same access privileges of the next function to compile, it
+preserves the cache.
+This is most helpful when defining many member functions for the same
+class: with the exception of member functions which are friends of
+other classes, each member function has exactly the same access
+privileges as every other, and the cache need not be flushed.
+.TP
+.B \-fno\-default\-inline
+Do not make member functions inline by default merely because they are
+defined inside the class scope. Otherwise, when you specify
+.B \-O\c
+\&, member functions defined inside class scope are compiled
+inline by default; i.e., you don't need to add `\|\c
+.B inline\c
+\&\|' in front of
+the member function name.
+.TP
+.B \-fno\-strict\-prototype
+Consider the declaration \c
+.B int foo ();\c
+\&. In C++, this means that the
+function \c
+.B foo\c
+\& takes no arguments. In ANSI C, this is declared
+.B int foo(void);\c
+\&. With the flag `\|\c
+.B \-fno\-strict\-prototype\c
+\&\|',
+declaring functions with no arguments is equivalent to declaring its
+argument list to be untyped, i.e., \c
+.B int foo ();\c
+\& is equivalent to
+saying \c
+.B int foo (...);\c
+\&.
+.TP
+.B \-fnonnull\-objects
+Normally, GNU C++ makes conservative assumptions about objects reached
+through references. For example, the compiler must check that `\|\c
+.B a\c
+\&\|' is not null in code like the following:
+.br
+\ \ \ \ obj\ &a\ =\ g\ ();
+.br
+\ \ \ \ a.f\ (2);
+.br
+Checking that references of this sort have non-null values requires
+extra code, however, and it is unnecessary for many programs. You can
+use `\|\c
+.B \-fnonnull\-objects\c
+\&\|' to omit the checks for null, if your program doesn't require the
+default checking.
+.TP
+.B \-fhandle\-signatures
+.TP
+.B \-fno\-handle\-signatures
+These options control the recognition of the \c
+.B signature\c
+\& and \c
+.B sigof\c
+\& constructs for specifying abstract types. By default, these
+constructs are not recognized.
+.TP
+.B \-fthis\-is\-variable
+The incorporation of user-defined free store management into C++ has
+made assignment to \c
+.B this\c
+\& an anachronism. Therefore, by default GNU
+C++ treats the type of \c
+.B this\c
+\& in a member function of \c
+.B class X\c
+\&
+to be \c
+.B X *const\c
+\&. In other words, it is illegal to assign to
+\c
+.B this\c
+\& within a class member function. However, for backwards
+compatibility, you can invoke the old behavior by using
+\&`\|\c
+.B \-fthis\-is\-variable\c
+\&\|'.
+.TP
+.B \-g
+Produce debugging information in the operating system's native format
+(for DBX or SDB or DWARF). GDB also can work with this debugging
+information. On most systems that use DBX format, `\|\c
+.B \-g\c
+\&\|' enables use
+of extra debugging information that only GDB can use.
+
+Unlike most other C compilers, GNU CC allows you to use `\|\c
+.B \-g\c
+\&\|' with
+`\|\c
+.B \-O\c
+\&\|'. The shortcuts taken by optimized code may occasionally
+produce surprising results: some variables you declared may not exist
+at all; flow of control may briefly move where you did not expect it;
+some statements may not be executed because they compute constant
+results or their values were already at hand; some statements may
+execute in different places because they were moved out of loops.
+
+Nevertheless it proves possible to debug optimized output. This makes
+it reasonable to use the optimizer for programs that might have bugs.
+.TP
+.BI "\-I" "dir"\c
+\&
+Append directory \c
+.I dir\c
+\& to the list of directories searched for include files.
+.TP
+.BI "\-L" "dir"\c
+\&
+Add directory \c
+.I dir\c
+\& to the list of directories to be searched
+for `\|\c
+.B \-l\c
+\&\|'.
+.TP
+.BI \-l library\c
+\&
+Use the library named \c
+.I library\c
+\& when linking. (C++ programs often require `\|\c
+\-lg++\c
+\&\|' for successful linking.)
+.TP
+.B \-nostdinc
+Do not search the standard system directories for header files. Only
+the directories you have specified with
+.B \-I
+options (and the current directory, if appropriate) are searched.
+.TP
+.B \-nostdinc++
+Do not search for header files in the standard directories specific to
+C++, but do still search the other standard directories. (This option
+is used when building libg++.)
+.TP
+.B \-O
+Optimize. Optimizing compilation takes somewhat more time, and a lot
+more memory for a large function.
+.TP
+.BI "\-o " file\c
+\&
+Place output in file \c
+.I file\c
+\&.
+.TP
+.B \-S
+Stop after the stage of compilation proper; do not assemble. The output
+is an assembler code file for each non-assembler input
+file specified.
+.TP
+.B \-traditional
+Attempt to support some aspects of traditional C compilers.
+
+Specifically, for both C and C++ programs:
+.TP
+\ \ \ \(bu
+In the preprocessor, comments convert to nothing at all, rather than
+to a space. This allows traditional token concatenation.
+.TP
+\ \ \ \(bu
+In the preprocessor, macro arguments are recognized within string
+constants in a macro definition (and their values are stringified,
+though without additional quote marks, when they appear in such a
+context). The preprocessor always considers a string constant to end
+at a newline.
+.TP
+\ \ \ \(bu
+The preprocessor does not predefine the macro \c
+.B __STDC__\c
+\& when you use
+`\|\c
+.B \-traditional\c
+\&\|', but still predefines\c
+.B __GNUC__\c
+\& (since the GNU extensions indicated by
+.B __GNUC__\c
+\& are not affected by
+`\|\c
+.B \-traditional\c
+\&\|'). If you need to write header files that work
+differently depending on whether `\|\c
+.B \-traditional\c
+\&\|' is in use, by
+testing both of these predefined macros you can distinguish four
+situations: GNU C, traditional GNU C, other ANSI C compilers, and
+other old C compilers.
+.TP
+\ \ \ \(bu
+In the preprocessor, comments convert to nothing at all, rather than
+to a space. This allows traditional token concatenation.
+.TP
+\ \ \ \(bu
+In the preprocessor, macro arguments are recognized within string
+constants in a macro definition (and their values are stringified,
+though without additional quote marks, when they appear in such a
+context). The preprocessor always considers a string constant to end
+at a newline.
+.TP
+\ \ \ \(bu
+The preprocessor does not predefine the macro \c
+.B __STDC__\c
+\& when you use
+`\|\c
+.B \-traditional\c
+\&\|', but still predefines\c
+.B __GNUC__\c
+\& (since the GNU extensions indicated by
+.B __GNUC__\c
+\& are not affected by
+`\|\c
+.B \-traditional\c
+\&\|'). If you need to write header files that work
+differently depending on whether `\|\c
+.B \-traditional\c
+\&\|' is in use, by
+testing both of these predefined macros you can distinguish four
+situations: GNU C, traditional GNU C, other ANSI C compilers, and
+other old C compilers.
+.PP
+.TP
+\ \ \ \(bu
+String ``constants'' are not necessarily constant; they are stored in
+writable space, and identical looking constants are allocated
+separately.
+
+For C++ programs only (not C), `\|\c
+.B \-traditional\c
+\&\|' has one additional effect: assignment to
+.B this
+is permitted. This is the same as the effect of `\|\c
+.B \-fthis\-is\-variable\c
+\&\|'.
+.TP
+.BI \-U macro
+Undefine macro \c
+.I macro\c
+\&.
+.TP
+.B \-Wall
+Issue warnings for conditions which pertain to usage that we recommend
+avoiding and that we believe is easy to avoid, even in conjunction
+with macros.
+.TP
+.B \-Wenum\-clash
+Warn when converting between different enumeration types.
+.TP
+.B \-Woverloaded\-virtual
+In a derived class, the definitions of virtual functions must match
+the type signature of a virtual function declared in the base class.
+Use this option to request warnings when a derived class declares a
+function that may be an erroneous attempt to define a virtual
+function: that is, warn when a function with the same name as a
+virtual function in the base class, but with a type signature that
+doesn't match any virtual functions from the base class.
+.TP
+.B \-Wtemplate\-debugging
+When using templates in a C++ program, warn if debugging is not yet
+fully available.
+.TP
+.B \-w
+Inhibit all warning messages.
+.TP
+.BI +e N
+Control how virtual function definitions are used, in a fashion
+compatible with
+.B cfront
+1.x.
+.PP
+
+.SH PRAGMAS
+Two `\|\c
+.B #pragma\c
+\&\|' directives are supported for GNU C++, to permit using the same
+header file for two purposes: as a definition of interfaces to a given
+object class, and as the full definition of the contents of that object class.
+.TP
+.B #pragma interface
+Use this directive in header files that define object classes, to save
+space in most of the object files that use those classes. Normally,
+local copies of certain information (backup copies of inline member
+functions, debugging information, and the internal tables that
+implement virtual functions) must be kept in each object file that
+includes class definitions. You can use this pragma to avoid such
+duplication. When a header file containing `\|\c
+.B #pragma interface\c
+\&\|' is included in a compilation, this auxiliary information
+will not be generated (unless the main input source file itself uses
+`\|\c
+.B #pragma implementation\c
+\&\|'). Instead, the object files will contain references to be
+resolved at link time.
+.tr !"
+.TP
+.B #pragma implementation
+.TP
+.BI "#pragma implementation !" objects .h!
+Use this pragma in a main input file, when you want full output from
+included header files to be generated (and made globally visible).
+The included header file, in turn, should use `\|\c
+.B #pragma interface\c
+\&\|'.
+Backup copies of inline member functions, debugging information, and
+the internal tables used to implement virtual functions are all
+generated in implementation files.
+
+If you use `\|\c
+.B #pragma implementation\c
+\&\|' with no argument, it applies to an include file with the same
+basename as your source file; for example, in `\|\c
+.B allclass.cc\c
+\&\|', `\|\c
+.B #pragma implementation\c
+\&\|' by itself is equivalent to `\|\c
+.B
+#pragma implementation "allclass.h"\c
+\&\|'. Use the string argument if you want a single implementation
+file to include code from multiple header files.
+
+There is no way to split up the contents of a single header file into
+multiple implementation files.
+.SH FILES
+.ta \w'LIBDIR/g++\-include 'u
+file.h C header (preprocessor) file
+.br
+file.i preprocessed C source file
+.br
+file.C C++ source file
+.br
+file.cc C++ source file
+.br
+file.cxx C++ source file
+.br
+file.s assembly language file
+.br
+file.o object file
+.br
+a.out link edited output
+.br
+\fITMPDIR\fR/cc\(** temporary files
+.br
+\fILIBDIR\fR/cpp preprocessor
+.br
+\fILIBDIR\fR/cc1plus compiler
+.br
+\fILIBDIR\fR/collect linker front end needed on some machines
+.br
+\fILIBDIR\fR/libgcc.a GCC subroutine library
+.br
+/lib/crt[01n].o start-up routine
+.br
+\fILIBDIR\fR/ccrt0 additional start-up routine for C++
+.br
+/lib/libc.a standard C library, see
+.IR intro (3)
+.br
+/usr/include standard directory for
+.B #include
+files
+.br
+\fILIBDIR\fR/include standard gcc directory for
+.B #include
+files
+.br
+\fILIBDIR\fR/g++\-include additional g++ directory for
+.B #include
+.sp
+.I LIBDIR
+is usually
+.B /usr/local/lib/\c
+.IR machine / version .
+.br
+.I TMPDIR
+comes from the environment variable
+.B TMPDIR
+(default
+.B /usr/tmp
+if available, else
+.B /tmp\c
+\&).
+.SH "SEE ALSO"
+gcc(1), cpp(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1).
+.br
+.RB "`\|" gcc "\|', `\|" cpp \|',
+.RB `\| as \|', `\| ld \|',
+and
+.RB `\| gdb \|'
+entries in
+.B info\c
+\&.
+.br
+.I
+Using and Porting GNU CC (for version 2.0)\c
+, Richard M. Stallman;
+.I
+The C Preprocessor\c
+, Richard M. Stallman;
+.I
+Debugging with GDB: the GNU Source-Level Debugger\c
+, Richard M. Stallman and Roland H. Pesch;
+.I
+Using as: the GNU Assembler\c
+, Dean Elsner, Jay Fenlason & friends;
+.I
+gld: the GNU linker\c
+, Steve Chamberlain and Roland Pesch.
+
+.SH BUGS
+For instructions on how to report bugs, see the GCC manual.
+
+.SH COPYING
+Copyright (c) 1991, 1992, 1993 Free Software Foundation, Inc.
+.PP
+Permission is granted to make and distribute verbatim copies of
+this manual provided the copyright notice and this permission notice
+are preserved on all copies.
+.PP
+Permission is granted to copy and distribute modified versions of this
+manual under the conditions for verbatim copying, provided that the
+entire resulting derived work is distributed under the terms of a
+permission notice identical to this one.
+.PP
+Permission is granted to copy and distribute translations of this
+manual into another language, under the above conditions for modified
+versions, except that this permission notice may be included in
+translations approved by the Free Software Foundation instead of in
+the original English.
+.SH AUTHORS
+See the GNU CC Manual for the contributors to GNU CC.
diff --git a/contrib/gcc/cp/g++.c b/contrib/gcc/cp/g++.c
new file mode 100644
index 0000000..f694898
--- /dev/null
+++ b/contrib/gcc/cp/g++.c
@@ -0,0 +1,582 @@
+/* G++ preliminary semantic processing for the compiler driver.
+ Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
+ Contributed by Brendan Kehoe (brendan@cygnus.com).
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+/* This program is a wrapper to the main `gcc' driver. For GNU C++,
+ we need to do two special things: a) append `-lg++' in situations
+ where it's appropriate, to link in libg++, and b) add `-xc++'..`-xnone'
+ around file arguments named `foo.c' or `foo.i'. So, we do all of
+ this semantic processing then just exec gcc with the new argument
+ list.
+
+ We used to do all of this in a small shell script, but many users
+ found the performance of this as a shell script to be unacceptable.
+ In situations where your PATH has a lot of NFS-mounted directories,
+ using a script that runs sed and other things would be a nasty
+ performance hit. With this program, we never search the PATH at all. */
+
+#include "config.h"
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#include <stdio.h>
+#include <sys/types.h>
+#if !defined(_WIN32)
+#include <sys/file.h> /* May get R_OK, etc. on some systems. */
+#else
+#include <process.h>
+#endif
+#include <errno.h>
+
+/* Defined to the name of the compiler; if using a cross compiler, the
+ Makefile should compile this file with the proper name
+ (e.g., "i386-aout-gcc"). */
+#ifndef GCC_NAME
+#define GCC_NAME "gcc"
+#endif
+
+/* This bit is set if we saw a `-xfoo' language specification. */
+#define LANGSPEC (1<<1)
+/* This bit is set if they did `-lm' or `-lmath'. */
+#define MATHLIB (1<<2)
+
+#ifndef MATH_LIBRARY
+#define MATH_LIBRARY "-lm"
+#endif
+
+/* On MSDOS, write temp files in current dir
+ because there's no place else we can expect to use. */
+#ifdef __MSDOS__
+#ifndef P_tmpdir
+#define P_tmpdir "."
+#endif
+#ifndef R_OK
+#define R_OK 4
+#define W_OK 2
+#define X_OK 1
+#endif
+#endif
+
+#ifndef VPROTO
+#ifdef __STDC__
+#define PVPROTO(ARGS) ARGS
+#define VPROTO(ARGS) ARGS
+#define VA_START(va_list,var) va_start(va_list,var)
+#else
+#define PVPROTO(ARGS) ()
+#define VPROTO(ARGS) (va_alist) va_dcl
+#define VA_START(va_list,var) va_start(va_list)
+#endif
+#endif
+
+#ifndef errno
+extern int errno;
+#endif
+
+extern int sys_nerr;
+#ifndef HAVE_STRERROR
+#if defined(bsd4_4)
+extern const char *const sys_errlist[];
+#else
+extern char *sys_errlist[];
+#endif
+#else
+extern char *strerror();
+#endif
+
+/* Name with which this program was invoked. */
+static char *programname;
+
+char *
+my_strerror(e)
+ int e;
+{
+
+#ifdef HAVE_STRERROR
+ return strerror(e);
+
+#else
+
+ static char buffer[30];
+ if (!e)
+ return "";
+
+ if (e > 0 && e < sys_nerr)
+ return sys_errlist[e];
+
+ sprintf (buffer, "Unknown error %d", e);
+ return buffer;
+#endif
+}
+
+#ifdef HAVE_VPRINTF
+/* Output an error message and exit */
+
+static void
+fatal VPROTO((char *format, ...))
+{
+#ifndef __STDC__
+ char *format;
+#endif
+ va_list ap;
+
+ VA_START (ap, format);
+
+#ifndef __STDC__
+ format = va_arg (ap, char*);
+#endif
+
+ fprintf (stderr, "%s: ", programname);
+ vfprintf (stderr, format, ap);
+ va_end (ap);
+ fprintf (stderr, "\n");
+#if 0
+ /* XXX Not needed for g++ driver. */
+ delete_temp_files ();
+#endif
+ exit (1);
+}
+
+static void
+error VPROTO((char *format, ...))
+{
+#ifndef __STDC__
+ char *format;
+#endif
+ va_list ap;
+
+ VA_START (ap, format);
+
+#ifndef __STDC__
+ format = va_arg (ap, char*);
+#endif
+
+ fprintf (stderr, "%s: ", programname);
+ vfprintf (stderr, format, ap);
+ va_end (ap);
+
+ fprintf (stderr, "\n");
+}
+
+#else /* not HAVE_VPRINTF */
+
+static void
+error (msg, arg1, arg2)
+ char *msg, *arg1, *arg2;
+{
+ fprintf (stderr, "%s: ", programname);
+ fprintf (stderr, msg, arg1, arg2);
+ fprintf (stderr, "\n");
+}
+
+static void
+fatal (msg, arg1, arg2)
+ char *msg, *arg1, *arg2;
+{
+ error (msg, arg1, arg2);
+#if 0
+ /* XXX Not needed for g++ driver. */
+ delete_temp_files ();
+#endif
+ exit (1);
+}
+
+#endif /* not HAVE_VPRINTF */
+
+/* More 'friendly' abort that prints the line and file.
+ config.h can #define abort fancy_abort if you like that sort of thing. */
+
+void
+fancy_abort ()
+{
+ fatal ("Internal g++ abort.");
+}
+
+char *
+xmalloc (size)
+ unsigned size;
+{
+ register char *value = (char *) malloc (size);
+ if (value == 0)
+ fatal ("virtual memory exhausted");
+ return value;
+}
+
+/* Return a newly-allocated string whose contents concatenate those
+ of s1, s2, s3. */
+static char *
+concat (s1, s2, s3)
+ char *s1, *s2, *s3;
+{
+ int len1 = strlen (s1), len2 = strlen (s2), len3 = strlen (s3);
+ char *result = xmalloc (len1 + len2 + len3 + 1);
+
+ strcpy (result, s1);
+ strcpy (result + len1, s2);
+ strcpy (result + len1 + len2, s3);
+ *(result + len1 + len2 + len3) = 0;
+
+ return result;
+}
+
+static void
+pfatal_with_name (name)
+ char *name;
+{
+ fatal (concat ("%s: ", my_strerror (errno), ""), name);
+}
+
+#ifdef __MSDOS__
+/* This is the common prefix we use to make temp file names. */
+char *temp_filename;
+
+/* Length of the prefix. */
+int temp_filename_length;
+
+/* Compute a string to use as the base of all temporary file names. */
+static char *
+choose_temp_base_try (try, base)
+char *try;
+char *base;
+{
+ char *rv;
+ if (base)
+ rv = base;
+ else if (try == (char *)0)
+ rv = 0;
+ else if (access (try, R_OK | W_OK) != 0)
+ rv = 0;
+ else
+ rv = try;
+ return rv;
+}
+
+static void
+choose_temp_base ()
+{
+ char *base = 0;
+ int len;
+
+ base = choose_temp_base_try (getenv ("TMPDIR"), base);
+ base = choose_temp_base_try (getenv ("TMP"), base);
+ base = choose_temp_base_try (getenv ("TEMP"), base);
+
+#ifdef P_tmpdir
+ base = choose_temp_base_try (P_tmpdir, base);
+#endif
+
+ base = choose_temp_base_try ("/usr/tmp", base);
+ base = choose_temp_base_try ("/tmp", base);
+
+ /* If all else fails, use the current directory! */
+ if (base == (char *)0)
+ base = "./";
+
+ len = strlen (base);
+ temp_filename = xmalloc (len + sizeof("/ccXXXXXX"));
+ strcpy (temp_filename, base);
+ if (len > 0 && temp_filename[len-1] != '/')
+ temp_filename[len++] = '/';
+ strcpy (temp_filename + len, "ccXXXXXX");
+
+ mktemp (temp_filename);
+ temp_filename_length = strlen (temp_filename);
+ if (temp_filename_length == 0)
+ abort ();
+}
+
+static void
+perror_exec (name)
+ char *name;
+{
+ char *s;
+
+ if (errno < sys_nerr)
+ s = concat ("installation problem, cannot exec %s: ",
+ my_strerror( errno ), "");
+ else
+ s = "installation problem, cannot exec %s";
+ error (s, name);
+}
+
+/* This is almost exactly what's in gcc.c:pexecute for MSDOS. */
+void
+run_dos (program, argv)
+ char *program;
+ char *argv[];
+{
+ char *scmd, *rf;
+ FILE *argfile;
+ int i;
+
+ choose_temp_base (); /* not in gcc.c */
+
+ scmd = (char *) malloc (strlen (program) + strlen (temp_filename) + 10);
+ rf = scmd + strlen (program) + 6;
+ sprintf (scmd, "%s.exe @%s.gp", program, temp_filename);
+
+ argfile = fopen (rf, "w");
+ if (argfile == 0)
+ pfatal_with_name (rf);
+
+ for (i=1; argv[i]; i++)
+ {
+ char *cp;
+ for (cp = argv[i]; *cp; cp++)
+ {
+ if (*cp == '"' || *cp == '\'' || *cp == '\\' || isspace (*cp))
+ fputc ('\\', argfile);
+ fputc (*cp, argfile);
+ }
+ fputc ('\n', argfile);
+ }
+ fclose (argfile);
+
+ i = system (scmd);
+
+ remove (rf);
+
+ if (i == -1)
+ perror_exec (program);
+}
+#endif /* __MSDOS__ */
+
+int
+main (argc, argv)
+ int argc;
+ char **argv;
+{
+ register int i, j = 0;
+ register char *p;
+ int verbose = 0;
+
+ /* This will be 0 if we encounter a situation where we should not
+ link in libstdc++, or 2 if we should link in libg++ as well. */
+ int library = 1;
+
+ /* Used to track options that take arguments, so we don't go wrapping
+ those with -xc++/-xnone. */
+ char *quote = NULL;
+
+ /* The new argument list will be contained in this. */
+ char **arglist;
+
+ /* The name of the compiler we will want to run---by default, it
+ will be the definition of `GCC_NAME', e.g., `gcc'. */
+ char *gcc = GCC_NAME;
+
+ /* Non-zero if we saw a `-xfoo' language specification on the
+ command line. Used to avoid adding our own -xc++ if the user
+ already gave a language for the file. */
+ int saw_speclang = 0;
+
+ /* Non-zero if we saw `-lm' or `-lmath' on the command line. */
+ char *saw_math = 0;
+
+ /* The number of arguments being added to what's in argv, other than
+ libraries. We use this to track the number of times we've inserted
+ -xc++/-xnone. */
+ int added = 0;
+
+ /* An array used to flag each argument that needs a bit set for
+ LANGSPEC or MATHLIB. */
+ int *args;
+
+ p = argv[0] + strlen (argv[0]);
+
+ /* If we're called as g++ (or i386-aout-g++), link in libg++ as well. */
+
+ if (strcmp (p - 3, "g++") == 0)
+ {
+ library = 2;
+ }
+
+ while (p != argv[0] && p[-1] != '/')
+ --p;
+ programname = p;
+
+ if (argc == 1)
+ fatal ("No input files specified.\n");
+
+#ifndef __MSDOS__
+ /* We do a little magic to find out where the main gcc executable
+ is. If they ran us as /usr/local/bin/g++, then we will look
+ for /usr/local/bin/gcc; similarly, if they just ran us as `g++',
+ we'll just look for `gcc'. */
+ if (p != argv[0])
+ {
+ *--p = '\0';
+ gcc = (char *) malloc ((strlen (argv[0]) + 1 + strlen (GCC_NAME) + 1)
+ * sizeof (char));
+ sprintf (gcc, "%s/%s", argv[0], GCC_NAME);
+ }
+#endif
+
+ args = (int *) malloc (argc * sizeof (int));
+ bzero ((char *) args, argc * sizeof (int));
+
+ for (i = 1; i < argc; i++)
+ {
+ /* If the previous option took an argument, we swallow it here. */
+ if (quote)
+ {
+ quote = NULL;
+ continue;
+ }
+
+ if (argv[i][0] == '\0' || argv[i][1] == '\0')
+ continue;
+
+ if (argv[i][0] == '-')
+ {
+ if (library != 0 && strcmp (argv[i], "-nostdlib") == 0)
+ {
+ library = 0;
+ }
+ else if (strcmp (argv[i], "-lm") == 0
+ || strcmp (argv[i], "-lmath") == 0)
+ args[i] |= MATHLIB;
+ else if (strcmp (argv[i], "-v") == 0)
+ {
+ verbose = 1;
+ if (argc == 2)
+ {
+ /* If they only gave us `-v', don't try to link
+ in libg++. */
+ library = 0;
+ }
+ }
+ else if (strncmp (argv[i], "-x", 2) == 0)
+ saw_speclang = 1;
+ else if (((argv[i][2] == '\0'
+ && (char *)strchr ("bBVDUoeTuIYmLiA", argv[i][1]) != NULL)
+ || strcmp (argv[i], "-Tdata") == 0))
+ quote = argv[i];
+ else if (library != 0 && ((argv[i][2] == '\0'
+ && (char *) strchr ("cSEM", argv[i][1]) != NULL)
+ || strcmp (argv[i], "-MM") == 0))
+ {
+ /* Don't specify libraries if we won't link, since that would
+ cause a warning. */
+ library = 0;
+ }
+ else
+ /* Pass other options through. */
+ continue;
+ }
+ else
+ {
+ int len;
+
+ if (saw_speclang)
+ {
+ saw_speclang = 0;
+ continue;
+ }
+
+ /* If the filename ends in .c or .i, put options around it.
+ But not if a specified -x option is currently active. */
+ len = strlen (argv[i]);
+ if (len > 2
+ && (argv[i][len - 1] == 'c' || argv[i][len - 1] == 'i')
+ && argv[i][len - 2] == '.')
+ {
+ args[i] |= LANGSPEC;
+ added += 2;
+ }
+ }
+ }
+
+ if (quote)
+ fatal ("argument to `%s' missing\n", quote);
+
+ if (added || library)
+ {
+ arglist = (char **) malloc ((argc + added + 4) * sizeof (char *));
+
+ for (i = 1, j = 1; i < argc; i++, j++)
+ {
+ arglist[j] = argv[i];
+
+ /* Make sure -lg++ is before the math library, since libg++
+ itself uses those math routines. */
+ if (!saw_math && (args[i] & MATHLIB) && library)
+ {
+ --j;
+ saw_math = argv[i];
+ }
+
+ /* Wrap foo.c and foo.i files in a language specification to
+ force the gcc compiler driver to run cc1plus on them. */
+ if (args[i] & LANGSPEC)
+ {
+ int len = strlen (argv[i]);
+ if (argv[i][len - 1] == 'i')
+ arglist[j++] = "-xc++-cpp-output";
+ else
+ arglist[j++] = "-xc++";
+ arglist[j++] = argv[i];
+ arglist[j] = "-xnone";
+ }
+ }
+
+ /* Add `-lg++' if we haven't already done so. */
+ if (library == 2)
+ arglist[j++] = "-lg++";
+ if (library)
+ arglist[j++] = "-lstdc++";
+ if (saw_math)
+ arglist[j++] = saw_math;
+ else if (library)
+ arglist[j++] = MATH_LIBRARY;
+
+ arglist[j] = NULL;
+ }
+ else
+ /* No need to copy 'em all. */
+ arglist = argv;
+
+ arglist[0] = gcc;
+
+ if (verbose)
+ {
+ if (j == 0)
+ j = argc;
+
+ for (i = 0; i < j; i++)
+ fprintf (stderr, " %s", arglist[i]);
+ fprintf (stderr, "\n");
+ }
+#if !defined(OS2) && !defined (_WIN32)
+#ifdef __MSDOS__
+ run_dos (gcc, arglist);
+#else /* !__MSDOS__ */
+ if (execvp (gcc, arglist) < 0)
+ pfatal_with_name (gcc);
+#endif /* __MSDOS__ */
+#else /* OS2 or _WIN32 */
+ if (spawnvp (1, gcc, arglist) < 0)
+ pfatal_with_name (gcc);
+#endif
+
+ return 0;
+}
diff --git a/contrib/gcc/cp/gc.c b/contrib/gcc/cp/gc.c
new file mode 100644
index 0000000..cff1635
--- /dev/null
+++ b/contrib/gcc/cp/gc.c
@@ -0,0 +1,1550 @@
+/* Garbage collection primitives for GNU C++.
+ Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+ Contributed by Michael Tiemann (tiemann@cygnus.com)
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+#include "config.h"
+#include "tree.h"
+#include "cp-tree.h"
+#include "flags.h"
+#include "output.h"
+
+#undef NULL
+#define NULL 0
+
+extern tree define_function ();
+extern tree build_t_desc_overload ();
+extern struct obstack *permanent_obstack;
+
+/* This is the function decl for the (pseudo-builtin) __gc_protect
+ function. Args are (class *value, int index); Returns value. */
+tree gc_protect_fndecl;
+
+/* This is the function decl for the (pseudo-builtin) __gc_unprotect
+ function. Args are (int index); void return. */
+tree gc_unprotect_fndecl;
+
+/* This is the function decl for the (pseudo-builtin) __gc_push
+ function. Args are (int length); void return. */
+tree gc_push_fndecl;
+
+/* This is the function decl for the (pseudo-builtin) __gc_pop
+ function. Args are void; void return. */
+tree gc_pop_fndecl;
+
+/* Special integers that are used to represent bits in gc-safe objects. */
+tree gc_nonobject;
+tree gc_visible;
+tree gc_white;
+tree gc_offwhite;
+tree gc_grey;
+tree gc_black;
+
+/* in c-common.c */
+extern tree combine_strings PROTO((tree));
+
+/* Predicate that returns non-zero if TYPE needs some kind of
+ entry for the GC. Returns zero otherwise. */
+int
+type_needs_gc_entry (type)
+ tree type;
+{
+ tree ttype = type;
+
+ if (! flag_gc || type == error_mark_node)
+ return 0;
+
+ /* Aggregate types need gc entries if any of their members
+ need gc entries. */
+ if (IS_AGGR_TYPE (type))
+ {
+ tree binfos;
+ tree fields = TYPE_FIELDS (type);
+ int i;
+
+ /* We don't care about certain pointers. Pointers
+ to virtual baseclasses are always up front. We also
+ cull out virtual function table pointers because it's
+ easy, and it simplifies the logic.*/
+ while (fields
+ && (DECL_NAME (fields) == NULL_TREE
+ || VFIELD_NAME_P (DECL_NAME (fields))
+ || VBASE_NAME_P (DECL_NAME (fields))
+ || !strcmp (IDENTIFIER_POINTER (DECL_NAME (fields)), "__bits")))
+ fields = TREE_CHAIN (fields);
+
+ while (fields)
+ {
+ if (type_needs_gc_entry (TREE_TYPE (fields)))
+ return 1;
+ fields = TREE_CHAIN (fields);
+ }
+
+ binfos = TYPE_BINFO_BASETYPES (type);
+ if (binfos)
+ for (i = TREE_VEC_LENGTH (binfos)-1; i >= 0; i--)
+ if (type_needs_gc_entry (BINFO_TYPE (TREE_VEC_ELT (binfos, i))))
+ return 1;
+
+ return 0;
+ }
+
+ while (TREE_CODE (ttype) == ARRAY_TYPE
+ && TREE_CODE (TREE_TYPE (ttype)) == ARRAY_TYPE)
+ ttype = TREE_TYPE (ttype);
+ if ((TREE_CODE (ttype) == POINTER_TYPE
+ || TREE_CODE (ttype) == ARRAY_TYPE
+ || TREE_CODE (ttype) == REFERENCE_TYPE)
+ && IS_AGGR_TYPE (TREE_TYPE (ttype))
+ && CLASSTYPE_RTTI (TREE_TYPE (ttype)))
+ return 1;
+
+ return 0;
+}
+
+/* Predicate that returns non-zero iff FROM is safe from the GC.
+
+ If TO is nonzero, it means we know that FROM is being stored
+ in TO, which make make it safe. */
+int
+value_safe_from_gc (to, from)
+ tree to, from;
+{
+ /* First, return non-zero for easy cases: parameters,
+ static variables. */
+ if (TREE_CODE (from) == PARM_DECL
+ || (TREE_CODE (from) == VAR_DECL
+ && TREE_STATIC (from)))
+ return 1;
+
+ /* If something has its address taken, it cannot be
+ in the heap, so it doesn't need to be protected. */
+ if (TREE_CODE (from) == ADDR_EXPR || TREE_REFERENCE_EXPR (from))
+ return 1;
+
+ /* If we are storing into a static variable, then what
+ we store will be safe from the gc. */
+ if (to && TREE_CODE (to) == VAR_DECL
+ && TREE_STATIC (to))
+ return 1;
+
+ /* Now recurse on structure of FROM. */
+ switch (TREE_CODE (from))
+ {
+ case COMPONENT_REF:
+ /* These guys are special, and safe. */
+ if (TREE_CODE (TREE_OPERAND (from, 1)) == FIELD_DECL
+ && (VFIELD_NAME_P (DECL_NAME (TREE_OPERAND (from, 1)))
+ || VBASE_NAME_P (DECL_NAME (TREE_OPERAND (from, 1)))))
+ return 1;
+ /* fall through... */
+ case NOP_EXPR:
+ case CONVERT_EXPR:
+ case NON_LVALUE_EXPR:
+ case WITH_CLEANUP_EXPR:
+ case SAVE_EXPR:
+ case PREDECREMENT_EXPR:
+ case PREINCREMENT_EXPR:
+ case POSTDECREMENT_EXPR:
+ case POSTINCREMENT_EXPR:
+ if (value_safe_from_gc (to, TREE_OPERAND (from, 0)))
+ return 1;
+ break;
+
+ case VAR_DECL:
+ case PARM_DECL:
+ /* We can safely pass these things as parameters to functions. */
+ if (to == 0)
+ return 1;
+
+ case ARRAY_REF:
+ case INDIRECT_REF:
+ case RESULT_DECL:
+ case OFFSET_REF:
+ case CALL_EXPR:
+ case METHOD_CALL_EXPR:
+ break;
+
+ case COMPOUND_EXPR:
+ case TARGET_EXPR:
+ if (value_safe_from_gc (to, TREE_OPERAND (from, 1)))
+ return 1;
+ break;
+
+ case COND_EXPR:
+ if (value_safe_from_gc (to, TREE_OPERAND (from, 1))
+ && value_safe_from_gc (to, TREE_OPERAND (from, 2)))
+ return 1;
+ break;
+
+ case PLUS_EXPR:
+ case MINUS_EXPR:
+ if ((type_needs_gc_entry (TREE_TYPE (TREE_OPERAND (from, 0)))
+ || value_safe_from_gc (to, TREE_OPERAND (from, 0)))
+ && (type_needs_gc_entry (TREE_TYPE (TREE_OPERAND (from, 1))) == 0
+ || value_safe_from_gc (to, TREE_OPERAND (from, 1))))
+ return 1;
+ break;
+
+ case RTL_EXPR:
+ /* Every time we build an RTL_EXPR in the front-end, we must
+ ensure that everything in it is safe from the garbage collector.
+ ??? This has only been done for `build_new'. */
+ return 1;
+
+ default:
+ my_friendly_abort (41);
+ }
+
+ if (to == 0)
+ return 0;
+
+ /* FROM wasn't safe. But other properties of TO might make it safe. */
+ switch (TREE_CODE (to))
+ {
+ case VAR_DECL:
+ case PARM_DECL:
+ /* We already culled out static VAR_DECLs above. */
+ return 0;
+
+ case COMPONENT_REF:
+ /* These guys are special, and safe. */
+ if (TREE_CODE (TREE_OPERAND (to, 1)) == FIELD_DECL
+ && (VFIELD_NAME_P (DECL_NAME (TREE_OPERAND (to, 1)))
+ || VBASE_NAME_P (DECL_NAME (TREE_OPERAND (to, 1)))))
+ return 1;
+ /* fall through... */
+
+ case NOP_EXPR:
+ case NON_LVALUE_EXPR:
+ case WITH_CLEANUP_EXPR:
+ case SAVE_EXPR:
+ case PREDECREMENT_EXPR:
+ case PREINCREMENT_EXPR:
+ case POSTDECREMENT_EXPR:
+ case POSTINCREMENT_EXPR:
+ return value_safe_from_gc (TREE_OPERAND (to, 0), from);
+
+ case COMPOUND_EXPR:
+ case TARGET_EXPR:
+ return value_safe_from_gc (TREE_OPERAND (to, 1), from);
+
+ case COND_EXPR:
+ return (value_safe_from_gc (TREE_OPERAND (to, 1), from)
+ && value_safe_from_gc (TREE_OPERAND (to, 2), from));
+
+ case INDIRECT_REF:
+ case ARRAY_REF:
+ /* This used to be 0, but our current restricted model
+ allows this to be 1. We'll never get arrays this way. */
+ return 1;
+
+ default:
+ my_friendly_abort (42);
+ }
+
+ /* Catch-all case is that TO/FROM is not safe. */
+ return 0;
+}
+
+/* Function to build a static GC entry for DECL. TYPE is DECL's type.
+
+ For objects of type `class *', this is just an entry in the
+ static vector __PTR_LIST__.
+
+ For objects of type `class[]', this requires building an entry
+ in the static vector __ARR_LIST__.
+
+ For aggregates, this records all fields of type `class *'
+ and `class[]' in the respective lists above. */
+void
+build_static_gc_entry (decl, type)
+ tree decl;
+ tree type;
+{
+ /* Now, figure out what sort of entry to build. */
+ if (TREE_CODE (type) == POINTER_TYPE
+ || TREE_CODE (type) == REFERENCE_TYPE)
+ assemble_gc_entry (IDENTIFIER_POINTER (DECL_NAME (decl)));
+ else if (TREE_CODE (type) == RECORD_TYPE)
+ {
+ tree ref = get_temp_name (build_reference_type (type), 1);
+ DECL_INITIAL (ref) = build1 (ADDR_EXPR, TREE_TYPE (ref), decl);
+ TREE_CONSTANT (DECL_INITIAL (ref)) = 1;
+ cp_finish_decl (ref, DECL_INITIAL (ref), NULL_TREE, 0, 0);
+ }
+ else
+ {
+ /* Not yet implemented.
+
+ Cons up a static variable that holds address and length info
+ and add that to ___ARR_LIST__. */
+ my_friendly_abort (43);
+ }
+}
+
+/* Protect FROM from the GC, assuming FROM is going to be
+ stored into TO. We handle three cases for TO here:
+
+ case 1: TO is a stack variable.
+ case 2: TO is zero (which means it is a parameter).
+ case 3: TO is a return value. */
+
+tree
+protect_value_from_gc (to, from)
+ tree to, from;
+{
+ if (to == 0)
+ {
+ tree cleanup;
+
+ to = get_temp_regvar (TREE_TYPE (from), from);
+
+ /* Convert from integer to list form since we'll use it twice. */
+ DECL_GC_OFFSET (to) = build_tree_list (NULL_TREE, DECL_GC_OFFSET (to));
+ cleanup = build_function_call (gc_unprotect_fndecl,
+ DECL_GC_OFFSET (to));
+
+ if (! cp_expand_decl_cleanup (to, cleanup))
+ {
+ compiler_error ("cannot unprotect parameter in this scope");
+ return error_mark_node;
+ }
+ }
+
+ /* Should never need to protect a value that's headed for static storage. */
+ if (TREE_STATIC (to))
+ my_friendly_abort (44);
+
+ switch (TREE_CODE (to))
+ {
+ case COMPONENT_REF:
+ case INDIRECT_REF:
+ return protect_value_from_gc (TREE_OPERAND (to, 0), from);
+
+ case VAR_DECL:
+ case PARM_DECL:
+ {
+ tree rval;
+ if (DECL_GC_OFFSET (to) == NULL_TREE)
+ {
+ /* Because of a cast or a conversion, we might stick
+ a value into a variable that would not normally
+ have a GC entry. */
+ DECL_GC_OFFSET (to) = size_int (++current_function_obstack_index);
+ }
+
+ if (TREE_CODE (DECL_GC_OFFSET (to)) != TREE_LIST)
+ {
+ DECL_GC_OFFSET (to)
+ = build_tree_list (NULL_TREE, DECL_GC_OFFSET (to));
+ }
+
+ current_function_obstack_usage = 1;
+ rval = build_function_call (gc_protect_fndecl,
+ tree_cons (NULL_TREE, from,
+ DECL_GC_OFFSET (to)));
+ TREE_TYPE (rval) = TREE_TYPE (from);
+ return rval;
+ }
+ }
+
+ /* If we fall through the switch, assume we lost. */
+ my_friendly_abort (45);
+ /* NOTREACHED */
+ return NULL_TREE;
+}
+
+/* Given the expression EXP of type `class *', return the head
+ of the object pointed to by EXP. */
+tree
+build_headof (exp)
+ tree exp;
+{
+ tree type = TREE_TYPE (exp);
+ tree vptr, offset;
+
+ if (TREE_CODE (type) != POINTER_TYPE)
+ {
+ error ("`headof' applied to non-pointer type");
+ return error_mark_node;
+ }
+ type = TREE_TYPE (type);
+
+ if (!TYPE_VIRTUAL_P (type) || CLASSTYPE_VFIELD (type) == NULL_TREE)
+ return exp;
+
+ vptr = fold (size_binop (PLUS_EXPR,
+ size_binop (FLOOR_DIV_EXPR,
+ DECL_FIELD_BITPOS (CLASSTYPE_VFIELD (type)),
+ size_int (BITS_PER_UNIT)),
+ exp));
+ vptr = build1 (INDIRECT_REF, build_pointer_type (vtable_entry_type), vptr);
+
+ if (flag_vtable_thunks)
+ offset = build_array_ref (vptr, integer_zero_node);
+ else
+ offset = build_component_ref (build_array_ref (vptr, integer_zero_node),
+ delta_identifier,
+ NULL_TREE, 0);
+
+ type = build_type_variant (ptr_type_node, TREE_READONLY (exp),
+ TREE_THIS_VOLATILE (exp));
+ return build (PLUS_EXPR, type, exp,
+ convert (ptrdiff_type_node, offset));
+}
+
+/* Return the type_info node associated with the expression EXP. If EXP is
+ a reference to a polymorphic class, return the dynamic type; otherwise
+ return the static type of the expression. */
+tree
+build_typeid (exp)
+ tree exp;
+{
+ tree type;
+
+ if (!flag_rtti)
+ cp_error ("cannot take typeid of object when -frtti is not specified");
+
+ if (exp == error_mark_node)
+ return error_mark_node;
+
+ type = TREE_TYPE (exp);
+
+ /* Strip top-level cv-qualifiers. */
+ type = TYPE_MAIN_VARIANT (type);
+
+ /* if b is an instance of B, typeid(b) == typeid(B). Do this before
+ reference trickiness. */
+ if (TREE_CODE (exp) == VAR_DECL && TREE_CODE (type) == RECORD_TYPE)
+ return get_typeid (type);
+
+ /* peel back references, so they match. */
+ if (TREE_CODE (type) == REFERENCE_TYPE)
+ type = TREE_TYPE (type);
+
+ /* Peel off cv qualifiers. */
+ type = TYPE_MAIN_VARIANT (type);
+
+ /* Apply trivial conversion T -> T& for dereferenced ptrs. */
+ if (TREE_CODE (type) == RECORD_TYPE)
+ type = build_reference_type (type);
+
+ /* If exp is a reference to polymorphic type, get the real type_info. */
+ if (TREE_CODE (type) == REFERENCE_TYPE && TYPE_VIRTUAL_P (TREE_TYPE (type)))
+ {
+ /* build reference to type_info from vtable. */
+ tree t;
+
+ if (flag_vtable_thunks)
+ t = build_vfn_ref ((tree *) NULL_TREE, exp, integer_one_node);
+ else
+ t = build_vfn_ref ((tree *) NULL_TREE, exp, integer_zero_node);
+
+ TREE_TYPE (t) = build_pointer_type (__class_desc_type_node);
+ t = build_indirect_ref (t, NULL);
+ return t;
+ }
+
+ /* otherwise return the type_info for the static type of the expr. */
+ return get_typeid (type);
+}
+
+/* Return the type_info object for TYPE, creating it if necessary. */
+tree
+get_typeid (type)
+ tree type;
+{
+ tree t, td;
+
+ if (type == error_mark_node)
+ return error_mark_node;
+
+ /* Is it useful (and/or correct) to have different typeids for `T &'
+ and `T'? */
+ if (TREE_CODE (type) == REFERENCE_TYPE)
+ type = TREE_TYPE (type);
+
+ td = build_t_desc (type, 1);
+ if (td == error_mark_node)
+ return error_mark_node;
+
+ t = TREE_OPERAND (td, 0);
+ return t;
+}
+
+/* Get a bad_cast node for the program to throw...
+
+ See libstdc++::exception{,.cc} for __bad_cast_object */
+tree
+get_bad_cast_node ()
+{
+ static tree t;
+ if (t == NULL_TREE
+ && (t = lookup_name (get_identifier ("__bad_cast_object"), 0))
+ == NULL_TREE)
+ {
+ error ("you must #include <typeinfo>");
+ return error_mark_node;
+ }
+ return t;
+}
+
+/* Execute a dynamic cast, as described in section 5.2.6 of the 9/93 working
+ paper. */
+tree
+build_dynamic_cast (type, expr)
+ tree type, expr;
+{
+ enum tree_code tc = TREE_CODE (type);
+ tree exprtype = TREE_TYPE (expr);
+ enum tree_code ec = TREE_CODE (exprtype);
+ tree retval;
+
+ if (type == error_mark_node || expr == error_mark_node)
+ return error_mark_node;
+
+ switch (tc)
+ {
+ case POINTER_TYPE:
+ if (ec == REFERENCE_TYPE)
+ {
+ expr = convert_from_reference (expr);
+ exprtype = TREE_TYPE (expr);
+ ec = TREE_CODE (exprtype);
+ }
+ if (ec != POINTER_TYPE)
+ goto fail;
+ if (TREE_CODE (TREE_TYPE (exprtype)) != RECORD_TYPE)
+ goto fail;
+ if (TYPE_SIZE (TREE_TYPE (exprtype)) == 0)
+ goto fail;
+ if (TREE_READONLY (TREE_TYPE (exprtype)) &&
+ ! TYPE_READONLY (TREE_TYPE (type)))
+ goto fail;
+ if (TYPE_MAIN_VARIANT (TREE_TYPE (type)) == void_type_node)
+ break;
+ /* else fall through */
+ case REFERENCE_TYPE:
+ if (TREE_CODE (TREE_TYPE (type)) == RECORD_TYPE
+ && TYPE_SIZE (TREE_TYPE (type)) != NULL_TREE)
+ break;
+ /* else fall through */
+ default:
+ goto fail;
+ }
+
+ /* Apply trivial conversion T -> T& for dereferenced ptrs. */
+ if (ec == RECORD_TYPE)
+ {
+ exprtype = build_type_variant (exprtype, TREE_READONLY (expr),
+ TREE_THIS_VOLATILE (expr));
+ exprtype = build_reference_type (exprtype);
+ expr = convert_to_reference (exprtype, expr, CONV_IMPLICIT,
+ LOOKUP_NORMAL, NULL_TREE);
+ ec = REFERENCE_TYPE;
+ }
+
+ if (tc == REFERENCE_TYPE)
+ {
+ if (ec != REFERENCE_TYPE)
+ goto fail;
+ if (TREE_CODE (TREE_TYPE (exprtype)) != RECORD_TYPE)
+ goto fail;
+ if (TYPE_SIZE (TREE_TYPE (exprtype)) == 0)
+ goto fail;
+ }
+
+ /* If *type is an unambiguous accessible base class of *exprtype,
+ convert statically. */
+ {
+ int distance;
+ tree path;
+
+ distance = get_base_distance (TREE_TYPE (type), TREE_TYPE (exprtype), 1,
+ &path);
+ if (distance >= 0)
+ return build_vbase_path (PLUS_EXPR, type, expr, path, 0);
+ }
+
+ /* Otherwise *exprtype must be a polymorphic class (have a vtbl). */
+ if (TYPE_VIRTUAL_P (TREE_TYPE (exprtype)))
+ {
+ /* if TYPE is `void *', return pointer to complete object. */
+ if (tc == POINTER_TYPE
+ && TYPE_MAIN_VARIANT (TREE_TYPE (type)) == void_type_node)
+ {
+ /* if b is an object, dynamic_cast<void *>(&b) == (void *)&b. */
+ if (TREE_CODE (expr) == ADDR_EXPR
+ && TREE_CODE (TREE_OPERAND (expr, 0)) == VAR_DECL
+ && TREE_CODE (TREE_TYPE (TREE_OPERAND (expr, 0))) == RECORD_TYPE)
+ return build1 (NOP_EXPR, type, expr);
+
+ return build_headof (expr);
+ }
+ else
+ {
+ tree retval;
+ tree result, td1, td2, elems, tmp1, expr1;
+
+ /* If we got here, we can't convert statically. Therefore,
+ dynamic_cast<D&>(b) (b an object) cannot succeed. */
+ if (ec == REFERENCE_TYPE)
+ {
+ if (TREE_CODE (expr) == VAR_DECL
+ && TREE_CODE (TREE_TYPE (expr)) == RECORD_TYPE)
+ {
+ cp_warning ("dynamic_cast of `%#D' to `%#T' can never succeed",
+ expr, type);
+ return build_throw (get_bad_cast_node ());
+ }
+ }
+ /* Ditto for dynamic_cast<D*>(&b). */
+ else if (TREE_CODE (expr) == ADDR_EXPR)
+ {
+ tree op = TREE_OPERAND (expr, 0);
+ if (TREE_CODE (op) == VAR_DECL
+ && TREE_CODE (TREE_TYPE (op)) == RECORD_TYPE)
+ {
+ cp_warning ("dynamic_cast of `%#D' to `%#T' can never succeed",
+ expr, type);
+ retval = build_int_2 (0, 0);
+ TREE_TYPE (retval) = type;
+ return retval;
+ }
+ }
+
+ expr1 = expr;
+ if (tc == REFERENCE_TYPE)
+ expr1 = build_unary_op (ADDR_EXPR, expr1, 0);
+
+ /* Build run-time conversion. */
+ expr1 = build_headof (expr1);
+
+ if (ec == POINTER_TYPE)
+ td1 = build_typeid (build_indirect_ref (expr, NULL_PTR));
+ else
+ td1 = build_typeid (expr);
+
+ if (tc == POINTER_TYPE)
+ td2 = get_typeid (TREE_TYPE (type));
+ else
+ td2 = get_typeid (type);
+
+ elems = tree_cons (NULL_TREE, td2,
+ tree_cons (NULL_TREE, build_int_2 (1, 0),
+ tree_cons (NULL_TREE, expr1, NULL_TREE)));
+ result = build_method_call (td1,
+ get_identifier ("__rtti_match"), elems, NULL_TREE, LOOKUP_NORMAL);
+
+ if (tc == REFERENCE_TYPE)
+ {
+ expr1 = build_throw (get_bad_cast_node ());
+ expr1 = build_compound_expr (tree_cons (NULL_TREE, expr1,
+ build_tree_list (NULL_TREE, convert (type, integer_zero_node))));
+ TREE_TYPE (expr1) = type;
+ return build (COND_EXPR, type, result, result, expr1);
+ }
+
+ /* Now back to the type we want from a void*. */
+ result = convert (type, result);
+ return result;
+ }
+ }
+
+ fail:
+ cp_error ("cannot dynamic_cast `%E' (of type `%#T') to type `%#T'",
+ expr, exprtype, type);
+ return error_mark_node;
+}
+
+/* Build and initialize various sorts of descriptors. Every descriptor
+ node has a name associated with it (the name created by mangling).
+ For this reason, we use the identifier as our access to the __*_desc
+ nodes, instead of sticking them directly in the types. Otherwise we
+ would burden all built-in types (and pointer types) with slots that
+ we don't necessarily want to use.
+
+ For each descriptor we build, we build a variable that contains
+ the descriptor's information. When we need this info at runtime,
+ all we need is access to these variables.
+
+ Note: these constructors always return the address of the descriptor
+ info, since that is simplest for their mutual interaction. */
+
+static tree
+build_generic_desc (tdecl, type, elems)
+ tree tdecl;
+ tree type;
+ tree elems;
+{
+ tree init = elems;
+ int toplev = global_bindings_p ();
+
+ TREE_CONSTANT (init) = 1;
+ TREE_STATIC (init) = 1;
+ TREE_READONLY (init) = 1;
+
+ TREE_TYPE (tdecl) = type;
+ DECL_INITIAL (tdecl) = init;
+ TREE_STATIC (tdecl) = 1;
+ DECL_SIZE (tdecl) = NULL_TREE;
+ layout_decl (tdecl, 0);
+ if (! toplev)
+ push_to_top_level ();
+ cp_finish_decl (tdecl, init, NULL_TREE, 0, 0);
+ if (! toplev)
+ pop_from_top_level ();
+
+ if (! TREE_USED (tdecl))
+ {
+ assemble_external (tdecl);
+ TREE_USED (tdecl) = 1;
+ }
+
+ return IDENTIFIER_AS_DESC (DECL_NAME (tdecl));
+}
+
+/* Build an initializer for a __bltn_desc node. */
+static tree
+build_bltn_desc (tdecl, type)
+ tree tdecl;
+ tree type;
+{
+ tree elems, t;
+
+ if (type == boolean_type_node)
+ t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_BOOL"),
+ 0, 0);
+ else if (type == char_type_node)
+ t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_CHAR"),
+ 0, 0);
+ else if (type == short_integer_type_node)
+ t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_SHORT"),
+ 0, 0);
+ else if (type == integer_type_node)
+ t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_INT"),
+ 0, 0);
+ else if (type == long_integer_type_node)
+ t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_LONG"),
+ 0, 0);
+ else if (type == long_long_integer_type_node)
+ t = lookup_field (__bltn_desc_type_node,
+ get_identifier("_RTTI_BI_LONGLONG"), 0, 0);
+ else if (type == float_type_node)
+ t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_FLOAT"),
+ 0, 0);
+ else if (type == double_type_node)
+ t = lookup_field (__bltn_desc_type_node,
+ get_identifier("_RTTI_BI_DOUBLE"), 0, 0);
+ else if (type == long_double_type_node)
+ t = lookup_field (__bltn_desc_type_node,
+ get_identifier("_RTTI_BI_LDOUBLE"), 0, 0);
+ else if (type == unsigned_char_type_node)
+ t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_UCHAR"),
+ 0, 0);
+ else if (type == short_unsigned_type_node)
+ t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_USHORT"),
+ 0, 0);
+ else if (type == unsigned_type_node)
+ t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_UINT"),
+ 0, 0);
+ else if (type == long_unsigned_type_node)
+ t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_ULONG"),
+ 0, 0);
+ else if (type == long_long_unsigned_type_node)
+ t = lookup_field (__bltn_desc_type_node,
+ get_identifier("_RTTI_BI_ULONGLONG"), 0, 0);
+ else if (type == signed_char_type_node)
+ t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_SCHAR"),
+ 0, 0);
+ else if (type == wchar_type_node)
+ t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_WCHAR"),
+ 0, 0);
+ else if (type == void_type_node)
+ t = lookup_field (__bltn_desc_type_node, get_identifier("_RTTI_BI_VOID"),
+ 0, 0);
+ else
+ {
+ cp_compiler_error ("type `%T' not handled as a built-in type");
+ }
+
+ elems = tree_cons (NULL_TREE, t, NULL_TREE);
+ return build_generic_desc (tdecl, __bltn_desc_type_node, elems);
+}
+
+/* Build an initializer for a __user_desc node. */
+static tree
+build_user_desc (tdecl)
+ tree tdecl;
+{
+ tree elems, name_string, t;
+ tree tname = DECL_NAME (tdecl);
+
+ name_string = combine_strings (build_string
+ (IDENTIFIER_LENGTH (tname)+1, IDENTIFIER_POINTER (tname)));
+ elems = name_string;
+ return build_generic_desc (tdecl, __user_desc_type_node, elems);
+}
+
+/* Build an initializer for a __class_type_info node. */
+static tree
+build_class_desc (tdecl, type)
+ tree tdecl;
+ tree type;
+{
+ tree tname = DECL_NAME (tdecl);
+ tree name_string;
+
+ int i = CLASSTYPE_N_BASECLASSES (type);
+ int n_base = i;
+ int base_cnt = 0;
+ tree binfos = TYPE_BINFO_BASETYPES (type);
+ tree vb = CLASSTYPE_VBASECLASSES (type);
+ tree base, elems, access, offset, isvir;
+ tree base_list, off_list, acc_list, isvir_list;
+ tree t;
+ static tree acc_pub = NULL_TREE;
+ static tree acc_pro = NULL_TREE;
+ static tree acc_pri = NULL_TREE;
+
+ if (acc_pub == NULL_TREE)
+ {
+ acc_pub = lookup_field (__class_desc_type_node,
+ get_identifier("_RTTI_ACCESS_PUBLIC"), 0, 0);
+ acc_pro = lookup_field (__class_desc_type_node,
+ get_identifier("_RTTI_ACCESS_PROTECTED"), 0, 0);
+ acc_pri = lookup_field (__class_desc_type_node,
+ get_identifier("_RTTI_ACCESS_PRIVATE"), 0, 0);
+ }
+
+ base_list = build_tree_list (NULL_TREE, integer_zero_node);
+ off_list = build_tree_list (NULL_TREE, integer_zero_node);
+ acc_list = build_tree_list (NULL_TREE, integer_zero_node);
+ isvir_list = build_tree_list (NULL_TREE, integer_zero_node);
+ while (--i >= 0)
+ {
+ tree binfo = TREE_VEC_ELT (binfos, i);
+
+ base = build_t_desc (BINFO_TYPE (binfo), 1);
+ if (TREE_VIA_VIRTUAL (binfo))
+ {
+ tree t = BINFO_TYPE (binfo);
+ char *name;
+ tree field;
+ int off;
+
+ name = (char *) alloca (TYPE_NAME_LENGTH (t)+sizeof (VBASE_NAME)+1);
+ sprintf (name, VBASE_NAME_FORMAT, TYPE_NAME_STRING (t));
+ field = lookup_field (type, get_identifier (name), 0, 0);
+ offset = size_binop (FLOOR_DIV_EXPR,
+ DECL_FIELD_BITPOS (field), size_int (BITS_PER_UNIT));
+ }
+ else
+ offset = BINFO_OFFSET (binfo);
+
+ if (TREE_VIA_PUBLIC (binfo))
+ access = acc_pub;
+ else if (TREE_VIA_PROTECTED (binfo))
+ access = acc_pro;
+ else
+ access = acc_pri;
+ if (TREE_VIA_VIRTUAL (binfo))
+ isvir = build_int_2 (1, 0);
+ else
+ isvir = build_int_2 (0, 0);
+
+ base_list = tree_cons (NULL_TREE, base, base_list);
+ isvir_list = tree_cons (NULL_TREE, isvir, isvir_list);
+ acc_list = tree_cons (NULL_TREE, access, acc_list);
+ off_list = tree_cons (NULL_TREE, offset, off_list);
+ base_cnt++;
+ }
+#if 0
+ i = n_base;
+ while (vb)
+ {
+ tree b;
+ access = acc_pub;
+ while (--i >= 0)
+ {
+ b = TREE_VEC_ELT (binfos, i);
+ if (BINFO_TYPE (vb) == BINFO_TYPE (b) && TREE_VIA_VIRTUAL (b))
+ {
+ if (TREE_VIA_PUBLIC (b))
+ access = acc_pub;
+ else if (TREE_VIA_PROTECTED (b))
+ access = acc_pro;
+ else
+ access = acc_pri;
+ break;
+ }
+ }
+ base = build_t_desc (BINFO_TYPE (vb), 1);
+ offset = BINFO_OFFSET (vb);
+ isvir = build_int_2 (1, 0);
+
+ base_list = tree_cons (NULL_TREE, base, base_list);
+ isvir_list = tree_cons (NULL_TREE, isvir, isvir_list);
+ acc_list = tree_cons (NULL_TREE, access, acc_list);
+ off_list = tree_cons (NULL_TREE, offset, off_list);
+
+ base_cnt++;
+ vb = TREE_CHAIN (vb);
+ }
+#endif
+ base_list = finish_table (NULL_TREE, build_pointer_type (__t_desc_type_node),
+ base_list, 0);
+ off_list = finish_table (NULL_TREE, integer_type_node,
+ off_list, 0);
+ isvir_list = finish_table (NULL_TREE, integer_type_node,
+ isvir_list, 0);
+ acc_list = finish_table (NULL_TREE, __access_mode_type_node,
+ acc_list, 0);
+
+
+ name_string = combine_strings (build_string (IDENTIFIER_LENGTH (tname)+1, IDENTIFIER_POINTER (tname)));
+
+ elems = tree_cons (NULL_TREE, name_string,
+ tree_cons (NULL_TREE, default_conversion (base_list),
+ tree_cons (NULL_TREE, default_conversion (off_list),
+ tree_cons (NULL_TREE, default_conversion (isvir_list),
+ tree_cons (NULL_TREE, default_conversion (acc_list),
+ tree_cons (NULL_TREE, build_int_2 (base_cnt, 0), NULL_TREE))))));
+
+ return build_generic_desc (tdecl, __class_desc_type_node, elems);
+}
+
+/* Build an initializer for a __pointer_type_info node. */
+static tree
+build_ptr_desc (tdecl, type)
+ tree tdecl;
+ tree type;
+{
+ tree t, elems;
+
+ t = TREE_TYPE (type);
+ t = build_t_desc (t, 1);
+ t = build_indirect_ref (t, NULL);
+ elems = tree_cons (NULL_TREE, t, NULL_TREE);
+ return build_generic_desc (tdecl, __ptr_desc_type_node, elems);
+}
+
+/* Build an initializer for a __attr_type_info node. */
+static tree
+build_attr_desc (tdecl, type)
+ tree tdecl;
+ tree type;
+{
+ tree elems, t, attrval;
+
+ if (TYPE_READONLY (type))
+ {
+ if (TYPE_VOLATILE (type))
+ attrval = lookup_field (__attr_desc_type_node,
+ get_identifier("_RTTI_ATTR_CONSTVOL"), 0, 0);
+ else
+ attrval = lookup_field (__attr_desc_type_node,
+ get_identifier("_RTTI_ATTR_CONST"), 0, 0);
+ }
+ else
+ {
+ if (TYPE_VOLATILE (type))
+ attrval = lookup_field (__attr_desc_type_node,
+ get_identifier("_RTTI_ATTR_VOLATILE"), 0, 0);
+ }
+ t = build_t_desc (TYPE_MAIN_VARIANT (type), 1);
+ t = build_indirect_ref (t , NULL);
+ elems = tree_cons (NULL_TREE, attrval, tree_cons (NULL_TREE, t, NULL_TREE));
+ return build_generic_desc (tdecl, __attr_desc_type_node, elems);
+}
+
+/* Build an initializer for a __func_type_info node. */
+static tree
+build_func_desc (tdecl)
+ tree tdecl;
+{
+ tree elems, name_string;
+ tree tname = DECL_NAME (tdecl);
+
+ name_string = combine_strings (build_string
+ (IDENTIFIER_LENGTH (tname)+1, IDENTIFIER_POINTER (tname)));
+ elems = name_string;
+ return build_generic_desc (tdecl, __func_desc_type_node, elems);
+}
+
+/* Build an initializer for a __ptmf_type_info node. */
+static tree
+build_ptmf_desc (tdecl, type)
+ tree tdecl;
+ tree type;
+{
+ tree elems, name_string;
+ tree tname = DECL_NAME (tdecl);
+
+ name_string = combine_strings (build_string
+ (IDENTIFIER_LENGTH (tname)+1, IDENTIFIER_POINTER (tname)));
+ elems = name_string;
+ return build_generic_desc (tdecl, __ptmf_desc_type_node, elems);
+}
+
+/* Build an initializer for a __ptmd_type_info node. */
+static tree
+build_ptmd_desc (tdecl, type)
+ tree tdecl;
+ tree type;
+{
+ tree tc, t, elems;
+ tc = build_t_desc (TYPE_OFFSET_BASETYPE (type), 1);
+ tc = build_indirect_ref (tc , NULL);
+ t = build_t_desc (TREE_TYPE (type), 1);
+ t = build_indirect_ref (t , NULL);
+ elems = tree_cons (NULL_TREE, tc,
+ tree_cons (NULL_TREE, t, NULL_TREE));
+ return build_generic_desc (tdecl, __ptmd_desc_type_node, elems);
+}
+
+struct uninst_st {
+ tree type;
+ struct uninst_st *next;
+};
+typedef struct uninst_st uninst_node;
+static uninst_node * uninst_desc = (uninst_node *)NULL;
+
+static void
+add_uninstantiated_desc (type)
+ tree type;
+{
+ uninst_node *t;
+
+ t = (uninst_node *) xmalloc (sizeof (struct uninst_st));
+ t->type = type;
+ t->next = uninst_desc;
+ uninst_desc = t;
+}
+
+/* We may choose to link the emitting of certain high use TDs for certain
+ objects, we do that here. Return the type to link against if such a
+ link exists, otherwise just return TYPE. */
+
+tree
+get_def_to_follow (type)
+ tree type;
+{
+#if 0
+ /* For now we don't lay out T&, T* TDs with the main TD for the object. */
+ /* Let T* and T& be written only when T is written (if T is an aggr).
+ We do this for const, but not for volatile, since volatile
+ is rare and const is not. */
+ if (!TYPE_VOLATILE (taggr)
+ && (TREE_CODE (taggr) == POINTER_TYPE
+ || TREE_CODE (taggr) == REFERENCE_TYPE)
+ && IS_AGGR_TYPE (TREE_TYPE (taggr)))
+ taggr = TREE_TYPE (taggr);
+#endif
+ return type;
+}
+
+/* build a general type_info node. */
+tree
+build_t_desc (type, definition)
+ tree type;
+ int definition;
+{
+ tree tdecl;
+ tree tname, name_string;
+ tree elems;
+ tree t, tt, taggr;
+
+ if (__ptmd_desc_type_node == NULL_TREE)
+ {
+ init_type_desc();
+ if (__ptmd_desc_type_node)
+ {
+ for ( ; uninst_desc; uninst_desc = uninst_desc->next )
+ build_t_desc (uninst_desc->type, 1);
+ }
+ }
+ if (__t_desc_type_node == NULL_TREE)
+ {
+ static int warned = 0;
+ if (! warned)
+ {
+ cp_error ("failed to build type descriptor node of '%T', maybe typeinfo.h not included", type);
+ }
+ warned = 1;
+ return error_mark_node;
+ }
+ if (__ptmd_desc_type_node == NULL_TREE)
+ {
+ add_uninstantiated_desc (type);
+ definition = 0;
+ }
+
+ push_obstacks (&permanent_obstack, &permanent_obstack);
+ tname = build_t_desc_overload (type);
+
+ if (!IDENTIFIER_AS_DESC (tname))
+ {
+ tdecl = build_decl (VAR_DECL, tname, __t_desc_type_node);
+ DECL_EXTERNAL (tdecl) = 1;
+ TREE_PUBLIC (tdecl) = 1;
+ tdecl = pushdecl_top_level (tdecl);
+ SET_IDENTIFIER_AS_DESC (tname, build_unary_op (ADDR_EXPR, tdecl, 0));
+ if (!definition)
+ cp_finish_decl (tdecl, NULL_TREE, NULL_TREE, 0, 0);
+ }
+ else
+ tdecl = TREE_OPERAND (IDENTIFIER_AS_DESC (tname), 0);
+
+ /* If it's not a definition, don't do anything more. */
+ if (!definition)
+ return IDENTIFIER_AS_DESC (tname);
+
+ /* If it has already been written, don't to anything more. */
+ /* Should this be on tdecl? */
+ if (TREE_ASM_WRITTEN (IDENTIFIER_AS_DESC (tname)))
+ return IDENTIFIER_AS_DESC (tname);
+
+ /* If we previously defined it, return the defined result. */
+ if (DECL_INITIAL (tdecl))
+ return IDENTIFIER_AS_DESC (tname);
+
+ taggr = get_def_to_follow (type);
+
+ /* If we know that we don't need to write out this type's
+ vtable, then don't write out it's type_info. Somebody
+ else will take care of that. */
+ if (IS_AGGR_TYPE (taggr) && CLASSTYPE_VFIELD (taggr))
+ {
+ /* Let's play follow the vtable. */
+ TREE_PUBLIC (tdecl) = CLASSTYPE_INTERFACE_KNOWN (taggr);
+ DECL_EXTERNAL (tdecl) = CLASSTYPE_INTERFACE_ONLY (taggr);
+ }
+ else
+ {
+ DECL_EXTERNAL (tdecl) = 0;
+ TREE_PUBLIC (tdecl) = (definition > 1);
+ }
+
+ if (DECL_EXTERNAL (tdecl))
+ return IDENTIFIER_AS_DESC (tname);
+
+ /* Show that we are defining the t_desc for this type. */
+ DECL_INITIAL (tdecl) = error_mark_node;
+ t = DECL_CONTEXT (tdecl);
+ if ( t && TREE_CODE_CLASS (TREE_CODE (t)) == 't')
+ pushclass (t, 2);
+
+ if (TYPE_VOLATILE (type) || TYPE_READONLY (type))
+ t = build_attr_desc (tdecl, type);
+ else if (TREE_CODE (type) == ARRAY_TYPE)
+ t = build_ptr_desc (tdecl, type);
+ else if (TREE_CODE (type) == POINTER_TYPE)
+ {
+ if (TREE_CODE (TREE_TYPE (type)) == OFFSET_TYPE)
+ {
+ type = TREE_TYPE (type);
+ t = build_ptmd_desc (tdecl, type);
+ }
+ else
+ {
+ t = build_ptr_desc (tdecl, type);
+ }
+ }
+ else if (TYPE_BUILT_IN (type))
+ t = build_bltn_desc (tdecl, type);
+ else if (IS_AGGR_TYPE (type))
+ {
+ if (TYPE_PTRMEMFUNC_P (type))
+ {
+ t = build_ptmf_desc (tdecl, type);
+ }
+ else
+ {
+ t = build_class_desc (tdecl, type);
+ }
+ }
+ else if (TREE_CODE (type) == FUNCTION_TYPE)
+ t = build_func_desc (tdecl);
+ else
+ t = build_user_desc (tdecl);
+
+ pop_obstacks ();
+ return t;
+}
+
+#if 0
+/* This is the old dossier type descriptor generation code, it's much
+ more extended than rtti. It's reserved for later use. */
+/* Build an initializer for a __t_desc node. So that we can take advantage
+ of recursion, we accept NULL for TYPE.
+ DEFINITION is greater than zero iff we must define the type descriptor
+ (as opposed to merely referencing it). 1 means treat according to
+ #pragma interface/#pragma implementation rules. 2 means define as
+ global and public, no matter what. */
+tree
+build_t_desc (type, definition)
+ tree type;
+ int definition;
+{
+ tree tdecl;
+ tree tname, name_string;
+ tree elems, fields;
+ tree parents, vbases, offsets, ivars, methods, target_type;
+ int method_count = 0, field_count = 0;
+
+ if (type == NULL_TREE)
+ return NULL_TREE;
+
+ tname = build_t_desc_overload (type);
+ if (IDENTIFIER_AS_DESC (tname)
+ && (!definition || TREE_ASM_WRITTEN (IDENTIFIER_AS_DESC (tname))))
+ return IDENTIFIER_AS_DESC (tname);
+
+ tdecl = lookup_name (tname, 0);
+ if (tdecl == NULL_TREE)
+ {
+ tdecl = build_decl (VAR_DECL, tname, __t_desc_type_node);
+ DECL_EXTERNAL (tdecl) = 1;
+ TREE_PUBLIC (tdecl) = 1;
+ tdecl = pushdecl_top_level (tdecl);
+ }
+ /* If we previously defined it, return the defined result. */
+ else if (definition && DECL_INITIAL (tdecl))
+ return IDENTIFIER_AS_DESC (tname);
+
+ if (definition)
+ {
+ tree taggr = type;
+ /* Let T* and T& be written only when T is written (if T is an aggr).
+ We do this for const, but not for volatile, since volatile
+ is rare and const is not. */
+ if (!TYPE_VOLATILE (taggr)
+ && (TREE_CODE (taggr) == POINTER_TYPE
+ || TREE_CODE (taggr) == REFERENCE_TYPE)
+ && IS_AGGR_TYPE (TREE_TYPE (taggr)))
+ taggr = TREE_TYPE (taggr);
+
+ /* If we know that we don't need to write out this type's
+ vtable, then don't write out it's dossier. Somebody
+ else will take care of that. */
+ if (IS_AGGR_TYPE (taggr) && CLASSTYPE_VFIELD (taggr))
+ {
+ if (CLASSTYPE_VTABLE_NEEDS_WRITING (taggr))
+ {
+ TREE_PUBLIC (tdecl) = ! CLASSTYPE_INTERFACE_ONLY (taggr)
+ && CLASSTYPE_INTERFACE_KNOWN (taggr);
+ DECL_EXTERNAL (tdecl) = 0;
+ }
+ else
+ {
+ if (write_virtuals != 0)
+ TREE_PUBLIC (tdecl) = 1;
+ }
+ }
+ else
+ {
+ DECL_EXTERNAL (tdecl) = 0;
+ TREE_PUBLIC (tdecl) = (definition > 1);
+ }
+ }
+ SET_IDENTIFIER_AS_DESC (tname, build_unary_op (ADDR_EXPR, tdecl, 0));
+
+ if (!definition || DECL_EXTERNAL (tdecl))
+ {
+ /* That's it! */
+ cp_finish_decl (tdecl, NULL_TREE, NULL_TREE, 0, 0);
+ return IDENTIFIER_AS_DESC (tname);
+ }
+
+ /* Show that we are defining the t_desc for this type. */
+ DECL_INITIAL (tdecl) = error_mark_node;
+
+ parents = build_tree_list (NULL_TREE, integer_zero_node);
+ vbases = build_tree_list (NULL_TREE, integer_zero_node);
+ offsets = build_tree_list (NULL_TREE, integer_zero_node);
+ methods = NULL_TREE;
+ ivars = NULL_TREE;
+
+ if (TYPE_LANG_SPECIFIC (type))
+ {
+ int i = CLASSTYPE_N_BASECLASSES (type);
+ tree method_vec = CLASSTYPE_METHOD_VEC (type);
+ tree *meth, *end;
+ tree binfos = TYPE_BINFO_BASETYPES (type);
+ tree vb = CLASSTYPE_VBASECLASSES (type);
+
+ while (--i >= 0)
+ parents = tree_cons (NULL_TREE, build_t_desc (BINFO_TYPE (TREE_VEC_ELT (binfos, i)), 0), parents);
+
+ while (vb)
+ {
+ vbases = tree_cons (NULL_TREE, build_t_desc (BINFO_TYPE (vb), 0), vbases);
+ offsets = tree_cons (NULL_TREE, BINFO_OFFSET (vb), offsets);
+ vb = TREE_CHAIN (vb);
+ }
+
+ if (method_vec)
+ for (meth = TREE_VEC_END (method_vec),
+ end = &TREE_VEC_ELT (method_vec, 0); meth-- != end; )
+ if (*meth)
+ {
+ methods = tree_cons (NULL_TREE, build_m_desc (*meth), methods);
+ method_count++;
+ }
+ }
+
+ if (IS_AGGR_TYPE (type))
+ {
+ for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields))
+ if (TREE_CODE (fields) == FIELD_DECL
+ || TREE_CODE (fields) == VAR_DECL)
+ {
+ ivars = tree_cons (NULL_TREE, build_i_desc (fields), ivars);
+ field_count++;
+ }
+ ivars = nreverse (ivars);
+ }
+
+ parents = finish_table (NULL_TREE, build_pointer_type (__t_desc_type_node), parents, 0);
+ vbases = finish_table (NULL_TREE, build_pointer_type (__t_desc_type_node), vbases, 0);
+ offsets = finish_table (NULL_TREE, integer_type_node, offsets, 0);
+ if (methods == NULL_TREE)
+ methods = null_pointer_node;
+ else
+ methods = build_unary_op (ADDR_EXPR,
+ finish_table (NULL_TREE, __m_desc_type_node, methods, 0),
+ 0);
+ if (ivars == NULL_TREE)
+ ivars = null_pointer_node;
+ else
+ ivars = build_unary_op (ADDR_EXPR,
+ finish_table (NULL_TREE, __i_desc_type_node, ivars, 0),
+ 0);
+ if (TREE_TYPE (type))
+ target_type = build_t_desc (TREE_TYPE (type), definition);
+ else
+ target_type = integer_zero_node;
+
+ name_string = combine_strings (build_string (IDENTIFIER_LENGTH (tname)+1, IDENTIFIER_POINTER (tname)));
+
+ elems = tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, name_string, 0),
+ tree_cons (NULL_TREE,
+ TYPE_SIZE(type)? size_in_bytes(type) : integer_zero_node,
+ /* really should use bitfield initialization here. */
+ tree_cons (NULL_TREE, integer_zero_node,
+ tree_cons (NULL_TREE, target_type,
+ tree_cons (NULL_TREE, build_int_2 (field_count, 2),
+ tree_cons (NULL_TREE, build_int_2 (method_count, 2),
+ tree_cons (NULL_TREE, ivars,
+ tree_cons (NULL_TREE, methods,
+ tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, parents, 0),
+ tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, vbases, 0),
+ build_tree_list (NULL_TREE, build_unary_op (ADDR_EXPR, offsets, 0))))))))))));
+ return build_generic_desc (tdecl, elems);
+}
+
+/* Build an initializer for a __i_desc node. */
+tree
+build_i_desc (decl)
+ tree decl;
+{
+ tree elems, name_string;
+ tree taggr;
+
+ name_string = DECL_NAME (decl);
+ name_string = combine_strings (build_string (IDENTIFIER_LENGTH (name_string)+1, IDENTIFIER_POINTER (name_string)));
+
+ /* Now decide whether this ivar should cause it's type to get
+ def'd or ref'd in this file. If the type we are looking at
+ has a proxy definition, we look at the proxy (i.e., a
+ `foo *' is equivalent to a `foo'). */
+ taggr = TREE_TYPE (decl);
+
+ if ((TREE_CODE (taggr) == POINTER_TYPE
+ || TREE_CODE (taggr) == REFERENCE_TYPE)
+ && TYPE_VOLATILE (taggr) == 0)
+ taggr = TREE_TYPE (taggr);
+
+ elems = tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, name_string, 0),
+ tree_cons (NULL_TREE, DECL_FIELD_BITPOS (decl),
+ build_tree_list (NULL_TREE, build_t_desc (TREE_TYPE (decl),
+ ! IS_AGGR_TYPE (taggr)))));
+ taggr = build (CONSTRUCTOR, __i_desc_type_node, NULL_TREE, elems);
+ TREE_CONSTANT (taggr) = 1;
+ TREE_STATIC (taggr) = 1;
+ TREE_READONLY (taggr) = 1;
+ return taggr;
+}
+
+/* Build an initializer for a __m_desc node. */
+tree
+build_m_desc (decl)
+ tree decl;
+{
+ tree taggr, elems, name_string;
+ tree parm_count, req_count, vindex, vcontext;
+ tree parms;
+ int p_count, r_count;
+ tree parm_types = NULL_TREE;
+
+ for (parms = TYPE_ARG_TYPES (TREE_TYPE (decl)), p_count = 0, r_count = 0;
+ parms != NULL_TREE; parms = TREE_CHAIN (parms), p_count++)
+ {
+ taggr = TREE_VALUE (parms);
+ if ((TREE_CODE (taggr) == POINTER_TYPE
+ || TREE_CODE (taggr) == REFERENCE_TYPE)
+ && TYPE_VOLATILE (taggr) == 0)
+ taggr = TREE_TYPE (taggr);
+
+ parm_types = tree_cons (NULL_TREE, build_t_desc (TREE_VALUE (parms),
+ ! IS_AGGR_TYPE (taggr)),
+ parm_types);
+ if (TREE_PURPOSE (parms) == NULL_TREE)
+ r_count++;
+ }
+
+ parm_types = finish_table (NULL_TREE, build_pointer_type (__t_desc_type_node),
+ nreverse (parm_types), 0);
+ parm_count = build_int_2 (p_count, 0);
+ req_count = build_int_2 (r_count, 0);
+
+ if (DECL_VINDEX (decl))
+ vindex = DECL_VINDEX (decl);
+ else
+ vindex = integer_zero_node;
+ if (DECL_CONTEXT (decl)
+ && TREE_CODE_CLASS (TREE_CODE (DECL_CONTEXT (decl))) == 't')
+ vcontext = build_t_desc (DECL_CONTEXT (decl), 0);
+ else
+ vcontext = integer_zero_node;
+ name_string = DECL_NAME (decl);
+ if (name_string == NULL)
+ name_string = DECL_ASSEMBLER_NAME (decl);
+ name_string = combine_strings (build_string (IDENTIFIER_LENGTH (name_string)+1, IDENTIFIER_POINTER (name_string)));
+
+ /* Now decide whether the return type of this mvar
+ should cause it's type to get def'd or ref'd in this file.
+ If the type we are looking at has a proxy definition,
+ we look at the proxy (i.e., a `foo *' is equivalent to a `foo'). */
+ taggr = TREE_TYPE (TREE_TYPE (decl));
+
+ if ((TREE_CODE (taggr) == POINTER_TYPE
+ || TREE_CODE (taggr) == REFERENCE_TYPE)
+ && TYPE_VOLATILE (taggr) == 0)
+ taggr = TREE_TYPE (taggr);
+
+ elems = tree_cons (NULL_TREE, build_unary_op (ADDR_EXPR, name_string, 0),
+ tree_cons (NULL_TREE, vindex,
+ tree_cons (NULL_TREE, vcontext,
+ tree_cons (NULL_TREE, build_t_desc (TREE_TYPE (TREE_TYPE (decl)),
+ ! IS_AGGR_TYPE (taggr)),
+ tree_cons (NULL_TREE, build_c_cast (build_pointer_type (default_function_type), build_unary_op (ADDR_EXPR, decl, 0), 0),
+ tree_cons (NULL_TREE, parm_count,
+ tree_cons (NULL_TREE, req_count,
+ build_tree_list (NULL_TREE, build_unary_op (ADDR_EXPR, parm_types, 0)))))))));
+
+ taggr = build (CONSTRUCTOR, __m_desc_type_node, NULL_TREE, elems);
+ TREE_CONSTANT (taggr) = 1;
+ TREE_STATIC (taggr) = 1;
+ TREE_READONLY (taggr) = 1;
+ return taggr;
+}
+#endif /* dossier */
+
+
+/* Conditionally emit code to set up an unwind-protect for the
+ garbage collector. If this function doesn't do anything that involves
+ the garbage collector, then do nothing. Otherwise, call __gc_push
+ at the beginning and __gc_pop at the end.
+
+ NOTE! The __gc_pop function must operate transparently, since
+ it comes where the logical return label lies. This means that
+ at runtime *it* must preserve any return value registers. */
+
+void
+expand_gc_prologue_and_epilogue ()
+{
+ extern tree maybe_gc_cleanup;
+ struct rtx_def *last_parm_insn, *mark;
+ extern struct rtx_def *get_last_insn ();
+ extern struct rtx_def *get_first_nonparm_insn ();
+ extern struct rtx_def *previous_insn ();
+ tree action;
+
+ /* If we didn't need the obstack, don't cons any space. */
+ if (current_function_obstack_index == 0
+ || current_function_obstack_usage == 0)
+ return;
+
+ mark = get_last_insn ();
+ last_parm_insn = get_first_nonparm_insn ();
+ if (last_parm_insn == 0) last_parm_insn = mark;
+ else last_parm_insn = previous_insn (last_parm_insn);
+
+ action = build_function_call (gc_push_fndecl,
+ build_tree_list (NULL_TREE, size_int (++current_function_obstack_index)));
+ expand_expr_stmt (action);
+
+ reorder_insns (next_insn (mark), get_last_insn (), last_parm_insn);
+
+ /* This will be expanded as a cleanup. */
+ TREE_VALUE (maybe_gc_cleanup)
+ = build_function_call (gc_pop_fndecl, NULL_TREE);
+}
+
+/* Some day we'll use this function as a call-back and clean
+ up all the unnecessary gc dribble that we otherwise create. */
+void
+lang_expand_end_bindings (first, last)
+ struct rtx_def *first, *last;
+{
+}
+
+void
+init_gc_processing ()
+{
+ tree parmtypes = hash_tree_chain (class_star_type_node,
+ hash_tree_chain (integer_type_node, NULL_TREE));
+ gc_protect_fndecl = define_function ("__gc_protect",
+ build_function_type (class_star_type_node, parmtypes),
+ NOT_BUILT_IN, 0, 0);
+
+ parmtypes = hash_tree_chain (integer_type_node, NULL_TREE);
+ gc_unprotect_fndecl = define_function ("__gc_unprotect",
+ build_function_type (void_type_node, parmtypes),
+ NOT_BUILT_IN, 0, 0);
+
+ gc_push_fndecl = define_function ("__gc_push",
+ TREE_TYPE (gc_unprotect_fndecl),
+ NOT_BUILT_IN, 0, 0);
+
+ gc_pop_fndecl = define_function ("__gc_pop",
+ build_function_type (void_type_node,
+ void_list_node),
+ NOT_BUILT_IN, 0, 0);
+ gc_nonobject = build_int_2 (0x80000000, 0);
+ gc_visible = build_int_2 (0x40000000, 0);
+ gc_white = integer_zero_node;
+ gc_offwhite = build_int_2 (0x10000000, 0);
+ gc_grey = build_int_2 (0x20000000, 0);
+ gc_black = build_int_2 (0x30000000, 0);
+}
diff --git a/contrib/gcc/cp/gpcompare.texi b/contrib/gcc/cp/gpcompare.texi
new file mode 100644
index 0000000..7b0d573
--- /dev/null
+++ b/contrib/gcc/cp/gpcompare.texi
@@ -0,0 +1,236 @@
+@node ANSI
+@chapter @sc{gnu} C++ Conformance to @sc{ansi} C++
+
+These changes in the @sc{gnu} C++ compiler were made to comply more
+closely with the @sc{ansi} base document, @cite{The Annotated C++
+Reference Manual} (the @sc{arm}). Further reducing the divergences from
+@sc{ansi} C++ is a continued goal of the @sc{gnu} C++ Renovation
+Project.
+
+@b{Section 3.4}, @i{Start and Termination}. It is now invalid to take
+the address of the function @samp{main()}.
+
+@b{Section 4.8}, @i{Pointers to Members}. The compiler produces
+an error for trying to convert between a pointer to a member and the type
+@samp{void *}.
+
+@b{Section 5.2.5}, @i{Increment and Decrement}. It is an error to use
+the increment and decrement operators on an enumerated type.
+
+@b{Section 5.3.2}, @i{Sizeof}. Doing @code{sizeof} on a function is now
+an error.
+
+@b{Section 5.3.4}, @i{Delete}. The syntax of a @i{cast-expression} is
+now more strictly controlled.
+
+@b{Section 7.1.1}, @i{Storage Class Specifiers}. Using the
+@code{static} and @code{extern} specifiers can now only be applied to
+names of objects, functions, and anonymous unions.
+
+@b{Section 7.1.1}, @i{Storage Class Specifiers}. The compiler no longer complains
+about taking the address of a variable which has been declared to have @code{register}
+storage.
+
+@b{Section 7.1.2}, @i{Function Specifiers}. The compiler produces an
+error when the @code{inline} or @code{virtual} specifiers are
+used on anything other than a function.
+
+@b{Section 8.3}, @i{Function Definitions}. It is now an error to shadow
+a parameter name with a local variable; in the past, the compiler only
+gave a warning in such a situation.
+
+@b{Section 8.4.1}, @i{Aggregates}. The rules concerning declaration of
+an aggregate are now all checked in the @sc{gnu} C++ compiler; they
+include having no private or protected members and no base classes.
+
+@b{Section 8.4.3}, @i{References}. Declaring an array of references is
+now forbidden. Initializing a reference with an initializer list is
+also considered an error.
+
+@b{Section 9.5}, @i{Unions}. Global anonymous unions must be declared
+@code{static}.
+
+@b{Section 11.4}, @i{Friends}. Declaring a member to be a friend of a
+type that has not yet been defined is an error.
+
+@b{Section 12.1}, @i{Constructors}. The compiler generates a
+default copy constructor for a class if no constructor has been declared.
+
+@ignore
+@b{Section 12.4}, @i{Destructors}. In accordance with the @sc{ansi} C++
+draft standard working paper, a pure virtual destructor must now be
+defined.
+@end ignore
+
+@b{Section 12.6.2}, @i{Special Member Functions}. When using a
+@i{mem-initializer} list, the compiler will now initialize class members
+in declaration order, not in the order in which you specify them.
+Also, the compiler enforces the rule that non-static @code{const}
+and reference members must be initialized with a @i{mem-initializer}
+list when their class does not have a constructor.
+
+@b{Section 12.8}, @i{Copying Class Objects}. The compiler generates
+default copy constructors correctly, and supplies default assignment
+operators compatible with user-defined ones.
+
+@b{Section 13.4}, @i{Overloaded Operators}. An overloaded operator may
+no longer have default arguments.
+
+@b{Section 13.4.4}, @i{Function Call}. An overloaded @samp{operator ()}
+must be a non-static member function.
+
+@b{Section 13.4.5}, @i{Subscripting}. An overloaded @samp{operator []}
+must be a non-static member function.
+
+@b{Section 13.4.6}, @i{Class Member Access}. An overloaded @samp{operator ->}
+must be a non-static member function.
+
+@b{Section 13.4.7}, @i{Increment and Decrement}. The compiler will now
+make sure a postfix @samp{@w{operator ++}} or @samp{@w{operator --}} has an
+@code{int} as its second argument.
+
+
+@node Encoding
+@chapter Name Encoding in @sc{gnu} C++
+
+@c FIXME!! rewrite name encoding section
+@c ...to give complete rules rather than diffs from ARM.
+@c To avoid plagiarism, invent some different way of structuring the
+@c description of the rules than what ARM uses.
+
+@cindex mangling
+@cindex name encoding
+@cindex encoding information in names
+In order to support its strong typing rules and the ability to provide
+function overloading, the C++ programming language @dfn{encodes}
+information about functions and objects, so that conflicts across object
+files can be detected during linking. @footnote{This encoding is also
+sometimes called, whimsically enough, @dfn{mangling}; the corresponding
+decoding is sometimes called @dfn{demangling}.} These rules tend to be
+unique to each individual implementation of C++.
+
+The scheme detailed in the commentary for 7.2.1 of @cite{The Annotated
+Reference Manual} offers a description of a possible implementation
+which happens to closely resemble the @code{cfront} compiler. The
+design used in @sc{gnu} C++ differs from this model in a number of ways:
+
+@itemize @bullet
+@item
+In addition to the basic types @code{void}, @code{char}, @code{short},
+@code{int}, @code{long}, @code{float}, @code{double}, and @code{long
+double}, @sc{gnu} C++ supports two additional types: @code{wchar_t}, the wide
+character type, and @code{long long} (if the host supports it). The
+encodings for these are @samp{w} and @samp{x} respectively.
+
+@item
+According to the @sc{arm}, qualified names (e.g., @samp{foo::bar::baz}) are
+encoded with a leading @samp{Q}. Followed by the number of
+qualifications (in this case, three) and the respective names, this
+might be encoded as @samp{Q33foo3bar3baz}. @sc{gnu} C++ adds a leading
+underscore to the list, producing @samp{_Q33foo3bar3baz}.
+
+@item
+The operator @samp{*=} is encoded as @samp{__aml}, not @samp{__amu}, to
+match the normal @samp{*} operator, which is encoded as @samp{__ml}.
+
+@c XXX left out ->(), __wr
+@item
+In addition to the normal operators, @sc{gnu} C++ also offers the minimum and
+maximum operators @samp{>?} and @samp{<?}, encoded as @samp{__mx} and
+@samp{__mn}, and the conditional operator @samp{?:}, encoded as @samp{__cn}.
+
+@cindex destructors, encoding of
+@cindex constructors, encoding of
+@item
+Constructors are encoded as simply @samp{__@var{name}}, where @var{name}
+is the encoded name (e.g., @code{3foo} for the @code{foo} class
+constructor). Destructors are encoded as two leading underscores
+separated by either a period or a dollar sign, depending on the
+capabilities of the local host, followed by the encoded name. For
+example, the destructor @samp{foo::~foo} is encoded as @samp{_$_3foo}.
+
+@item
+Virtual tables are encoded with a prefix of @samp{_vt}, rather than
+@samp{__vtbl}. The names of their classes are separated by dollar signs
+(or periods), and not encoded as normal: the virtual table for
+@code{foo} is @samp{__vt$foo}, and the table for @code{foo::bar} is
+named @samp{__vt$foo$bar}.
+
+@item
+Static members are encoded as a leading underscore, followed by the
+encoded name of the class in which they appear, a separating dollar sign
+or period, and finally the unencoded name of the variable. For example,
+if the class @code{foo} contains a static member @samp{bar}, its
+encoding would be @samp{_3foo$bar}.
+
+@item
+@sc{gnu} C++ is not as aggressive as other compilers when it comes to always
+generating @samp{Fv} for functions with no arguments. In particular,
+the compiler does not add the sequence to conversion operators. The
+function @samp{foo::bar()} is encoded as @samp{bar__3foo}, not
+@samp{bar__3fooFv}.
+
+@item
+The argument list for methods is not prefixed by a leading @samp{F}; it
+is considered implied.
+
+@item
+@sc{gnu} C++ approaches the task of saving space in encodings
+differently from that noted in the @sc{arm}. It does use the
+@samp{T@var{n}} and @samp{N@var{x}@var{y}} codes to signify copying the
+@var{n}th argument's type, and making the next @var{x} arguments be the
+type of the @var{y}th argument, respectively. However, the values for
+@var{n} and @var{y} begin at zero with @sc{gnu} C++, whereas the
+@sc{arm} describes them as starting at one. For the function @samp{foo
+(bartype, bartype)}, @sc{gnu} C++ uses @samp{foo__7bartypeT0}, while
+compilers following the @sc{arm} example generate @samp{foo__7bartypeT1}.
+
+@c Note it loses on `foo (int, int, int, int, int)'.
+@item
+@sc{gnu} C++ does not bother using the space-saving methods for types whose
+encoding is a single character (like an integer, encoded as @samp{i}).
+This is useful in the most common cases (two @code{int}s would result in
+using three letters, instead of just @samp{ii}).
+@end itemize
+
+@c @node Cfront
+@c @chapter @code{cfront} Compared to @sc{gnu} C++
+@c
+@c
+@c FIXME!! Fill in. Consider points in the following:
+@c
+@c @display
+@c Date: Thu, 2 Jan 92 21:35:20 EST
+@c From: raeburn@@cygnus.com
+@c Message-Id: <9201030235.AA10999@@cambridge.cygnus.com>
+@c To: mrs@@charlie.secs.csun.edu
+@c Cc: g++@@cygnus.com
+@c Subject: Re: ARM and GNU C++ incompatabilities
+@c
+@c Along with that, we should probably describe how g++ differs from
+@c cfront, in ways that the users will notice. (E.g., cfront supposedly
+@c allows "free (new char[10])"; does g++? How do the template
+@c implementations differ? "New" placement syntax?)
+@c @end display
+@c
+@c XXX For next revision.
+@c
+@c GNU C++:
+@c * supports expanding inline functions in many situations,
+@c including those which have static objects, use `for' statements,
+@c and other situations. Part of this versatility is due to is
+@c ability to not always generate temporaries for assignments.
+@c * deliberately allows divide by 0 and mod 0, since [according
+@c to Wilson] there are actually situations where you'd like to allow
+@c such things. Note on most systems it will cause some sort of trap
+@c or bus error. Cfront considers it an error.
+@c * does [appear to] support nested classes within templates.
+@c * conversion functions among baseclasses are all usable by
+@c a class that's derived from all of those bases.
+@c * sizeof works even when the class is defined within its ()'s
+@c * conditional expressions work with member fns and pointers to
+@c members.
+@c * can handle non-trivial declarations of variables within switch
+@c statements.
+@c
+@c Cfront:
diff --git a/contrib/gcc/cp/gxx.gperf b/contrib/gcc/cp/gxx.gperf
new file mode 100644
index 0000000..e5465e8
--- /dev/null
+++ b/contrib/gcc/cp/gxx.gperf
@@ -0,0 +1,102 @@
+%{
+/* Command-line: gperf -p -j1 -g -o -t -N is_reserved_word -k1,4,$,7 gplus.gperf */
+%}
+struct resword { char *name; short token; enum rid rid;};
+%%
+__alignof, ALIGNOF, NORID
+__alignof__, ALIGNOF, NORID
+__asm, GCC_ASM_KEYWORD, NORID
+__asm__, GCC_ASM_KEYWORD, NORID
+__attribute, ATTRIBUTE, NORID
+__attribute__, ATTRIBUTE, NORID
+__const, TYPE_QUAL, RID_CONST
+__const__, TYPE_QUAL, RID_CONST
+__extension__, EXTENSION, NORID
+__inline, SCSPEC, RID_INLINE
+__inline__, SCSPEC, RID_INLINE
+__label__, LABEL, NORID
+__signature__, AGGR, RID_SIGNATURE /* Extension */,
+__signed, TYPESPEC, RID_SIGNED
+__signed__, TYPESPEC, RID_SIGNED
+__sigof__, SIGOF, NORID /* Extension */,
+__typeof, TYPEOF, NORID
+__typeof__, TYPEOF, NORID
+__volatile, TYPE_QUAL, RID_VOLATILE
+__volatile__, TYPE_QUAL, RID_VOLATILE
+__wchar_t, TYPESPEC, RID_WCHAR /* Unique to ANSI C++ */,
+asm, ASM_KEYWORD, NORID,
+and, ANDAND, NORID,
+and_eq, ASSIGN, NORID,
+auto, SCSPEC, RID_AUTO,
+bitand, '&', NORID,
+bitor, '|', NORID,
+bool, TYPESPEC, RID_BOOL,
+break, BREAK, NORID,
+case, CASE, NORID,
+catch, CATCH, NORID,
+char, TYPESPEC, RID_CHAR,
+class, AGGR, RID_CLASS,
+compl, '~', NORID,
+const, TYPE_QUAL, RID_CONST,
+const_cast, CONST_CAST, NORID,
+continue, CONTINUE, NORID,
+default, DEFAULT, NORID,
+delete, DELETE, NORID,
+do, DO, NORID,
+double, TYPESPEC, RID_DOUBLE,
+dynamic_cast, DYNAMIC_CAST, NORID,
+else, ELSE, NORID,
+enum, ENUM, NORID,
+explicit, SCSPEC, RID_EXPLICIT,
+extern, SCSPEC, RID_EXTERN,
+false, CXX_FALSE, NORID,
+float, TYPESPEC, RID_FLOAT,
+for, FOR, NORID,
+friend, SCSPEC, RID_FRIEND,
+goto, GOTO, NORID,
+if, IF, NORID,
+inline, SCSPEC, RID_INLINE,
+int, TYPESPEC, RID_INT,
+long, TYPESPEC, RID_LONG,
+mutable, SCSPEC, RID_MUTABLE,
+namespace, NAMESPACE, NORID,
+new, NEW, NORID,
+not, '!', NORID,
+not_eq, EQCOMPARE, NORID,
+operator, OPERATOR, NORID,
+or, OROR, NORID,
+or_eq, ASSIGN, NORID,
+overload, OVERLOAD, NORID,
+private, VISSPEC, RID_PRIVATE,
+protected, VISSPEC, RID_PROTECTED,
+public, VISSPEC, RID_PUBLIC,
+register, SCSPEC, RID_REGISTER,
+reinterpret_cast, REINTERPRET_CAST, NORID,
+return, RETURN, NORID,
+short, TYPESPEC, RID_SHORT,
+signature, AGGR, RID_SIGNATURE /* Extension */,
+signed, TYPESPEC, RID_SIGNED,
+sigof, SIGOF, NORID /* Extension */,
+sizeof, SIZEOF, NORID,
+static, SCSPEC, RID_STATIC,
+static_cast, STATIC_CAST, NORID,
+struct, AGGR, RID_RECORD,
+switch, SWITCH, NORID,
+template, TEMPLATE, RID_TEMPLATE,
+this, THIS, NORID,
+throw, THROW, NORID,
+true, CXX_TRUE, NORID,
+try, TRY, NORID,
+typedef, SCSPEC, RID_TYPEDEF,
+typename, TYPENAME_KEYWORD, NORID,
+typeid, TYPEID, NORID,
+typeof, TYPEOF, NORID,
+union, AGGR, RID_UNION,
+unsigned, TYPESPEC, RID_UNSIGNED,
+using, USING, NORID,
+virtual, SCSPEC, RID_VIRTUAL,
+void, TYPESPEC, RID_VOID,
+volatile, TYPE_QUAL, RID_VOLATILE,
+while, WHILE, NORID,
+xor, '^', NORID,
+xor_eq, ASSIGN, NORID,
diff --git a/contrib/gcc/cp/gxxint.texi b/contrib/gcc/cp/gxxint.texi
new file mode 100644
index 0000000..015a33c
--- /dev/null
+++ b/contrib/gcc/cp/gxxint.texi
@@ -0,0 +1,1585 @@
+\input texinfo @c -*-texinfo-*-
+@c %**start of header
+@setfilename g++int.info
+@settitle G++ internals
+@setchapternewpage odd
+@c %**end of header
+
+@node Top, Limitations of g++, (dir), (dir)
+@chapter Internal Architecture of the Compiler
+
+This is meant to describe the C++ front-end for gcc in detail.
+Questions and comments to mrs@@cygnus.com.
+
+@menu
+* Limitations of g++::
+* Routines::
+* Implementation Specifics::
+* Glossary::
+* Macros::
+* Typical Behavior::
+* Coding Conventions::
+* Templates::
+* Access Control::
+* Error Reporting::
+* Parser::
+* Copying Objects::
+* Exception Handling::
+* Free Store::
+* Concept Index::
+@end menu
+
+@node Limitations of g++, Routines, Top, Top
+@section Limitations of g++
+
+@itemize @bullet
+@item
+Limitations on input source code: 240 nesting levels with the parser
+stacksize (YYSTACKSIZE) set to 500 (the default), and requires around
+16.4k swap space per nesting level. The parser needs about 2.09 *
+number of nesting levels worth of stackspace.
+
+@cindex pushdecl_class_level
+@item
+I suspect there are other uses of pushdecl_class_level that do not call
+set_identifier_type_value in tandem with the call to
+pushdecl_class_level. It would seem to be an omission.
+
+@cindex access checking
+@item
+Access checking is unimplemented for nested types.
+
+@cindex @code{volatile}
+@item
+@code{volatile} is not implemented in general.
+
+@cindex pointers to members
+@item
+Pointers to members are only minimally supported, and there are places
+where the grammar doesn't even properly accept them yet.
+
+@cindex multiple inheritance
+@item
+@code{this} will be wrong in virtual members functions defined in a
+virtual base class, when they are overridden in a derived class, when
+called via a non-left most object.
+
+An example would be:
+
+@example
+extern "C" int printf(const char*, ...);
+struct A @{ virtual void f() @{ @} @};
+struct B : virtual A @{ int b; B() : b(0) @{@} void f() @{ b++; @} @};
+struct C : B @{@};
+struct D : B @{@};
+struct E : C, D @{@};
+int main()
+@{
+ E e;
+ C& c = e; D& d = e;
+ c.f(); d.f();
+ printf ("C::b = %d, D::b = %d\n", e.C::b, e.D::b);
+ return 0;
+@}
+@end example
+
+This will print out 2, 0, instead of 1,1.
+
+@end itemize
+
+@node Routines, Implementation Specifics, Limitations of g++, Top
+@section Routines
+
+This section describes some of the routines used in the C++ front-end.
+
+@code{build_vtable} and @code{prepare_fresh_vtable} is used only within
+the @file{cp-class.c} file, and only in @code{finish_struct} and
+@code{modify_vtable_entries}.
+
+@code{build_vtable}, @code{prepare_fresh_vtable}, and
+@code{finish_struct} are the only routines that set @code{DECL_VPARENT}.
+
+@code{finish_struct} can steal the virtual function table from parents,
+this prohibits related_vslot from working. When finish_struct steals,
+we know that
+
+@example
+get_binfo (DECL_FIELD_CONTEXT (CLASSTYPE_VFIELD (t)), t, 0)
+@end example
+
+@noindent
+will get the related binfo.
+
+@code{layout_basetypes} does something with the VIRTUALS.
+
+Supposedly (according to Tiemann) most of the breadth first searching
+done, like in @code{get_base_distance} and in @code{get_binfo} was not
+because of any design decision. I have since found out the at least one
+part of the compiler needs the notion of depth first binfo searching, I
+am going to try and convert the whole thing, it should just work. The
+term left-most refers to the depth first left-most node. It uses
+@code{MAIN_VARIANT == type} as the condition to get left-most, because
+the things that have @code{BINFO_OFFSET}s of zero are shared and will
+have themselves as their own @code{MAIN_VARIANT}s. The non-shared right
+ones, are copies of the left-most one, hence if it is its own
+@code{MAIN_VARIANT}, we know it IS a left-most one, if it is not, it is
+a non-left-most one.
+
+@code{get_base_distance}'s path and distance matters in its use in:
+
+@itemize @bullet
+@item
+@code{prepare_fresh_vtable} (the code is probably wrong)
+@item
+@code{init_vfields} Depends upon distance probably in a safe way,
+build_offset_ref might use partial paths to do further lookups,
+hack_identifier is probably not properly checking access.
+
+@item
+@code{get_first_matching_virtual} probably should check for
+@code{get_base_distance} returning -2.
+
+@item
+@code{resolve_offset_ref} should be called in a more deterministic
+manner. Right now, it is called in some random contexts, like for
+arguments at @code{build_method_call} time, @code{default_conversion}
+time, @code{convert_arguments} time, @code{build_unary_op} time,
+@code{build_c_cast} time, @code{build_modify_expr} time,
+@code{convert_for_assignment} time, and
+@code{convert_for_initialization} time.
+
+But, there are still more contexts it needs to be called in, one was the
+ever simple:
+
+@example
+if (obj.*pmi != 7)
+ @dots{}
+@end example
+
+Seems that the problems were due to the fact that @code{TREE_TYPE} of
+the @code{OFFSET_REF} was not a @code{OFFSET_TYPE}, but rather the type
+of the referent (like @code{INTEGER_TYPE}). This problem was fixed by
+changing @code{default_conversion} to check @code{TREE_CODE (x)},
+instead of only checking @code{TREE_CODE (TREE_TYPE (x))} to see if it
+was @code{OFFSET_TYPE}.
+
+@end itemize
+
+@node Implementation Specifics, Glossary, Routines, Top
+@section Implementation Specifics
+
+@itemize @bullet
+@item Explicit Initialization
+
+The global list @code{current_member_init_list} contains the list of
+mem-initializers specified in a constructor declaration. For example:
+
+@example
+foo::foo() : a(1), b(2) @{@}
+@end example
+
+@noindent
+will initialize @samp{a} with 1 and @samp{b} with 2.
+@code{expand_member_init} places each initialization (a with 1) on the
+global list. Then, when the fndecl is being processed,
+@code{emit_base_init} runs down the list, initializing them. It used to
+be the case that g++ first ran down @code{current_member_init_list},
+then ran down the list of members initializing the ones that weren't
+explicitly initialized. Things were rewritten to perform the
+initializations in order of declaration in the class. So, for the above
+example, @samp{a} and @samp{b} will be initialized in the order that
+they were declared:
+
+@example
+class foo @{ public: int b; int a; foo (); @};
+@end example
+
+@noindent
+Thus, @samp{b} will be initialized with 2 first, then @samp{a} will be
+initialized with 1, regardless of how they're listed in the mem-initializer.
+
+@item Argument Matching
+
+In early 1993, the argument matching scheme in @sc{gnu} C++ changed
+significantly. The original code was completely replaced with a new
+method that will, hopefully, be easier to understand and make fixing
+specific cases much easier.
+
+The @samp{-fansi-overloading} option is used to enable the new code; at
+some point in the future, it will become the default behavior of the
+compiler.
+
+The file @file{cp-call.c} contains all of the new work, in the functions
+@code{rank_for_overload}, @code{compute_harshness},
+@code{compute_conversion_costs}, and @code{ideal_candidate}.
+
+Instead of using obscure numerical values, the quality of an argument
+match is now represented by clear, individual codes. The new data
+structure @code{struct harshness} (it used to be an @code{unsigned}
+number) contains:
+
+@enumerate a
+@item the @samp{code} field, to signify what was involved in matching two
+arguments;
+@item the @samp{distance} field, used in situations where inheritance
+decides which function should be called (one is ``closer'' than
+another);
+@item and the @samp{int_penalty} field, used by some codes as a tie-breaker.
+@end enumerate
+
+The @samp{code} field is a number with a given bit set for each type of
+code, OR'd together. The new codes are:
+
+@itemize @bullet
+@item @code{EVIL_CODE}
+The argument was not a permissible match.
+
+@item @code{CONST_CODE}
+Currently, this is only used by @code{compute_conversion_costs}, to
+distinguish when a non-@code{const} member function is called from a
+@code{const} member function.
+
+@item @code{ELLIPSIS_CODE}
+A match against an ellipsis @samp{...} is considered worse than all others.
+
+@item @code{USER_CODE}
+Used for a match involving a user-defined conversion.
+
+@item @code{STD_CODE}
+A match involving a standard conversion.
+
+@item @code{PROMO_CODE}
+A match involving an integral promotion. For these, the
+@code{int_penalty} field is used to handle the ARM's rule (XXX cite)
+that a smaller @code{unsigned} type should promote to a @code{int}, not
+to an @code{unsigned int}.
+
+@item @code{QUAL_CODE}
+Used to mark use of qualifiers like @code{const} and @code{volatile}.
+
+@item @code{TRIVIAL_CODE}
+Used for trivial conversions. The @samp{int_penalty} field is used by
+@code{convert_harshness} to communicate further penalty information back
+to @code{build_overload_call_real} when deciding which function should
+be call.
+@end itemize
+
+The functions @code{convert_to_aggr} and @code{build_method_call} use
+@code{compute_conversion_costs} to rate each argument's suitability for
+a given candidate function (that's how we get the list of candidates for
+@code{ideal_candidate}).
+
+@end itemize
+
+@node Glossary, Macros, Implementation Specifics, Top
+@section Glossary
+
+@table @r
+@item binfo
+The main data structure in the compiler used to represent the
+inheritance relationships between classes. The data in the binfo can be
+accessed by the BINFO_ accessor macros.
+
+@item vtable
+@itemx virtual function table
+
+The virtual function table holds information used in virtual function
+dispatching. In the compiler, they are usually referred to as vtables,
+or vtbls. The first index is not used in the normal way, I believe it
+is probably used for the virtual destructor.
+
+@item vfield
+
+vfields can be thought of as the base information needed to build
+vtables. For every vtable that exists for a class, there is a vfield.
+See also vtable and virtual function table pointer. When a type is used
+as a base class to another type, the virtual function table for the
+derived class can be based upon the vtable for the base class, just
+extended to include the additional virtual methods declared in the
+derived class. The virtual function table from a virtual base class is
+never reused in a derived class. @code{is_normal} depends upon this.
+
+@item virtual function table pointer
+
+These are @code{FIELD_DECL}s that are pointer types that point to
+vtables. See also vtable and vfield.
+@end table
+
+@node Macros, Typical Behavior, Glossary, Top
+@section Macros
+
+This section describes some of the macros used on trees. The list
+should be alphabetical. Eventually all macros should be documented
+here. There are some postscript drawings that can be used to better
+understand from of the more complex data structures, contact Mike Stump
+(@code{mrs@@cygnus.com}) for information about them.
+
+@table @code
+@item BINFO_BASETYPES
+A vector of additional binfos for the types inherited by this basetype.
+The binfos are fully unshared (except for virtual bases, in which
+case the binfo structure is shared).
+
+ If this basetype describes type D as inherited in C,
+ and if the basetypes of D are E anf F,
+ then this vector contains binfos for inheritance of E and F by C.
+
+Has values of:
+
+ TREE_VECs
+
+
+@item BINFO_INHERITANCE_CHAIN
+Temporarily used to represent specific inheritances. It usually points
+to the binfo associated with the lesser derived type, but it can be
+reversed by reverse_path. For example:
+
+@example
+ Z ZbY least derived
+ |
+ Y YbX
+ |
+ X Xb most derived
+
+TYPE_BINFO (X) == Xb
+BINFO_INHERITANCE_CHAIN (Xb) == YbX
+BINFO_INHERITANCE_CHAIN (Yb) == ZbY
+BINFO_INHERITANCE_CHAIN (Zb) == 0
+@end example
+
+Not sure is the above is really true, get_base_distance has is point
+towards the most derived type, opposite from above.
+
+Set by build_vbase_path, recursive_bounded_basetype_p,
+get_base_distance, lookup_field, lookup_fnfields, and reverse_path.
+
+What things can this be used on:
+
+ TREE_VECs that are binfos
+
+
+@item BINFO_OFFSET
+The offset where this basetype appears in its containing type.
+BINFO_OFFSET slot holds the offset (in bytes) from the base of the
+complete object to the base of the part of the object that is allocated
+on behalf of this `type'. This is always 0 except when there is
+multiple inheritance.
+
+Used on TREE_VEC_ELTs of the binfos BINFO_BASETYPES (...) for example.
+
+
+@item BINFO_VIRTUALS
+A unique list of functions for the virtual function table. See also
+TYPE_BINFO_VIRTUALS.
+
+What things can this be used on:
+
+ TREE_VECs that are binfos
+
+
+@item BINFO_VTABLE
+Used to find the VAR_DECL that is the virtual function table associated
+with this binfo. See also TYPE_BINFO_VTABLE. To get the virtual
+function table pointer, see CLASSTYPE_VFIELD.
+
+What things can this be used on:
+
+ TREE_VECs that are binfos
+
+Has values of:
+
+ VAR_DECLs that are virtual function tables
+
+
+@item BLOCK_SUPERCONTEXT
+In the outermost scope of each function, it points to the FUNCTION_DECL
+node. It aids in better DWARF support of inline functions.
+
+
+@item CLASSTYPE_TAGS
+CLASSTYPE_TAGS is a linked (via TREE_CHAIN) list of member classes of a
+class. TREE_PURPOSE is the name, TREE_VALUE is the type (pushclass scans
+these and calls pushtag on them.)
+
+finish_struct scans these to produce TYPE_DECLs to add to the
+TYPE_FIELDS of the type.
+
+It is expected that name found in the TREE_PURPOSE slot is unique,
+resolve_scope_to_name is one such place that depends upon this
+uniqueness.
+
+
+@item CLASSTYPE_METHOD_VEC
+The following is true after finish_struct has been called (on the
+class?) but not before. Before finish_struct is called, things are
+different to some extent. Contains a TREE_VEC of methods of the class.
+The TREE_VEC_LENGTH is the number of differently named methods plus one
+for the 0th entry. The 0th entry is always allocated, and reserved for
+ctors and dtors. If there are none, TREE_VEC_ELT(N,0) == NULL_TREE.
+Each entry of the TREE_VEC is a FUNCTION_DECL. For each FUNCTION_DECL,
+there is a DECL_CHAIN slot. If the FUNCTION_DECL is the last one with a
+given name, the DECL_CHAIN slot is NULL_TREE. Otherwise it is the next
+method that has the same name (but a different signature). It would
+seem that it is not true that because the DECL_CHAIN slot is used in
+this way, we cannot call pushdecl to put the method in the global scope
+(cause that would overwrite the TREE_CHAIN slot), because they use
+different _CHAINs. finish_struct_methods setups up one version of the
+TREE_CHAIN slots on the FUNCTION_DECLs.
+
+friends are kept in TREE_LISTs, so that there's no need to use their
+TREE_CHAIN slot for anything.
+
+Has values of:
+
+ TREE_VECs
+
+
+@item CLASSTYPE_VFIELD
+Seems to be in the process of being renamed TYPE_VFIELD. Use on types
+to get the main virtual function table pointer. To get the virtual
+function table use BINFO_VTABLE (TYPE_BINFO ()).
+
+Has values of:
+
+ FIELD_DECLs that are virtual function table pointers
+
+What things can this be used on:
+
+ RECORD_TYPEs
+
+
+@item DECL_CLASS_CONTEXT
+Identifies the context that the _DECL was found in. For virtual function
+tables, it points to the type associated with the virtual function
+table. See also DECL_CONTEXT, DECL_FIELD_CONTEXT and DECL_FCONTEXT.
+
+The difference between this and DECL_CONTEXT, is that for virtuals
+functions like:
+
+@example
+struct A
+@{
+ virtual int f ();
+@};
+
+struct B : A
+@{
+ int f ();
+@};
+
+DECL_CONTEXT (A::f) == A
+DECL_CLASS_CONTEXT (A::f) == A
+
+DECL_CONTEXT (B::f) == A
+DECL_CLASS_CONTEXT (B::f) == B
+@end example
+
+Has values of:
+
+ RECORD_TYPEs, or UNION_TYPEs
+
+What things can this be used on:
+
+ TYPE_DECLs, _DECLs
+
+
+@item DECL_CONTEXT
+Identifies the context that the _DECL was found in. Can be used on
+virtual function tables to find the type associated with the virtual
+function table, but since they are FIELD_DECLs, DECL_FIELD_CONTEXT is a
+better access method. Internally the same as DECL_FIELD_CONTEXT, so
+don't us both. See also DECL_FIELD_CONTEXT, DECL_FCONTEXT and
+DECL_CLASS_CONTEXT.
+
+Has values of:
+
+ RECORD_TYPEs
+
+
+What things can this be used on:
+
+@display
+VAR_DECLs that are virtual function tables
+_DECLs
+@end display
+
+
+@item DECL_FIELD_CONTEXT
+Identifies the context that the FIELD_DECL was found in. Internally the
+same as DECL_CONTEXT, so don't us both. See also DECL_CONTEXT,
+DECL_FCONTEXT and DECL_CLASS_CONTEXT.
+
+Has values of:
+
+ RECORD_TYPEs
+
+What things can this be used on:
+
+@display
+FIELD_DECLs that are virtual function pointers
+FIELD_DECLs
+@end display
+
+
+@item DECL_NESTED_TYPENAME
+Holds the fully qualified type name. Example, Base::Derived.
+
+Has values of:
+
+ IDENTIFIER_NODEs
+
+What things can this be used on:
+
+ TYPE_DECLs
+
+
+@item DECL_NAME
+
+Has values of:
+
+@display
+0 for things that don't have names
+IDENTIFIER_NODEs for TYPE_DECLs
+@end display
+
+@item DECL_IGNORED_P
+A bit that can be set to inform the debug information output routines in
+the back-end that a certain _DECL node should be totally ignored.
+
+Used in cases where it is known that the debugging information will be
+output in another file, or where a sub-type is known not to be needed
+because the enclosing type is not needed.
+
+A compiler constructed virtual destructor in derived classes that do not
+define an explicit destructor that was defined explicit in a base class
+has this bit set as well. Also used on __FUNCTION__ and
+__PRETTY_FUNCTION__ to mark they are ``compiler generated.'' c-decl and
+c-lex.c both want DECL_IGNORED_P set for ``internally generated vars,''
+and ``user-invisible variable.''
+
+Functions built by the C++ front-end such as default destructors,
+virtual destructors and default constructors want to be marked that
+they are compiler generated, but unsure why.
+
+Currently, it is used in an absolute way in the C++ front-end, as an
+optimization, to tell the debug information output routines to not
+generate debugging information that will be output by another separately
+compiled file.
+
+
+@item DECL_VIRTUAL_P
+A flag used on FIELD_DECLs and VAR_DECLs. (Documentation in tree.h is
+wrong.) Used in VAR_DECLs to indicate that the variable is a vtable.
+It is also used in FIELD_DECLs for vtable pointers.
+
+What things can this be used on:
+
+ FIELD_DECLs and VAR_DECLs
+
+
+@item DECL_VPARENT
+Used to point to the parent type of the vtable if there is one, else it
+is just the type associated with the vtable. Because of the sharing of
+virtual function tables that goes on, this slot is not very useful, and
+is in fact, not used in the compiler at all. It can be removed.
+
+What things can this be used on:
+
+ VAR_DECLs that are virtual function tables
+
+Has values of:
+
+ RECORD_TYPEs maybe UNION_TYPEs
+
+
+@item DECL_FCONTEXT
+Used to find the first baseclass in which this FIELD_DECL is defined.
+See also DECL_CONTEXT, DECL_FIELD_CONTEXT and DECL_CLASS_CONTEXT.
+
+How it is used:
+
+ Used when writing out debugging information about vfield and
+ vbase decls.
+
+What things can this be used on:
+
+ FIELD_DECLs that are virtual function pointers
+ FIELD_DECLs
+
+
+@item DECL_REFERENCE_SLOT
+Used to hold the initialize for the reference.
+
+What things can this be used on:
+
+ PARM_DECLs and VAR_DECLs that have a reference type
+
+
+@item DECL_VINDEX
+Used for FUNCTION_DECLs in two different ways. Before the structure
+containing the FUNCTION_DECL is laid out, DECL_VINDEX may point to a
+FUNCTION_DECL in a base class which is the FUNCTION_DECL which this
+FUNCTION_DECL will replace as a virtual function. When the class is
+laid out, this pointer is changed to an INTEGER_CST node which is
+suitable to find an index into the virtual function table. See
+get_vtable_entry as to how one can find the right index into the virtual
+function table. The first index 0, of a virtual function table it not
+used in the normal way, so the first real index is 1.
+
+DECL_VINDEX may be a TREE_LIST, that would seem to be a list of
+overridden FUNCTION_DECLs. add_virtual_function has code to deal with
+this when it uses the variable base_fndecl_list, but it would seem that
+somehow, it is possible for the TREE_LIST to pursist until method_call,
+and it should not.
+
+
+What things can this be used on:
+
+ FUNCTION_DECLs
+
+
+@item DECL_SOURCE_FILE
+Identifies what source file a particular declaration was found in.
+
+Has values of:
+
+ "<built-in>" on TYPE_DECLs to mean the typedef is built in
+
+
+@item DECL_SOURCE_LINE
+Identifies what source line number in the source file the declaration
+was found at.
+
+Has values of:
+
+@display
+0 for an undefined label
+
+0 for TYPE_DECLs that are internally generated
+
+0 for FUNCTION_DECLs for functions generated by the compiler
+ (not yet, but should be)
+
+0 for ``magic'' arguments to functions, that the user has no
+ control over
+@end display
+
+
+@item TREE_USED
+
+Has values of:
+
+ 0 for unused labels
+
+
+@item TREE_ADDRESSABLE
+A flag that is set for any type that has a constructor.
+
+
+@item TREE_COMPLEXITY
+They seem a kludge way to track recursion, poping, and pushing. They only
+appear in cp-decl.c and cp-decl2.c, so the are a good candidate for
+proper fixing, and removal.
+
+
+@item TREE_PRIVATE
+Set for FIELD_DECLs by finish_struct. But not uniformly set.
+
+The following routines do something with PRIVATE access:
+build_method_call, alter_access, finish_struct_methods,
+finish_struct, convert_to_aggr, CWriteLanguageDecl, CWriteLanguageType,
+CWriteUseObject, compute_access, lookup_field, dfs_pushdecl,
+GNU_xref_member, dbxout_type_fields, dbxout_type_method_1
+
+
+@item TREE_PROTECTED
+The following routines do something with PROTECTED access:
+build_method_call, alter_access, finish_struct, convert_to_aggr,
+CWriteLanguageDecl, CWriteLanguageType, CWriteUseObject,
+compute_access, lookup_field, GNU_xref_member, dbxout_type_fields,
+dbxout_type_method_1
+
+
+@item TYPE_BINFO
+Used to get the binfo for the type.
+
+Has values of:
+
+ TREE_VECs that are binfos
+
+What things can this be used on:
+
+ RECORD_TYPEs
+
+
+@item TYPE_BINFO_BASETYPES
+See also BINFO_BASETYPES.
+
+@item TYPE_BINFO_VIRTUALS
+A unique list of functions for the virtual function table. See also
+BINFO_VIRTUALS.
+
+What things can this be used on:
+
+ RECORD_TYPEs
+
+
+@item TYPE_BINFO_VTABLE
+Points to the virtual function table associated with the given type.
+See also BINFO_VTABLE.
+
+What things can this be used on:
+
+ RECORD_TYPEs
+
+Has values of:
+
+ VAR_DECLs that are virtual function tables
+
+
+@item TYPE_NAME
+Names the type.
+
+Has values of:
+
+@display
+0 for things that don't have names.
+should be IDENTIFIER_NODE for RECORD_TYPEs UNION_TYPEs and
+ ENUM_TYPEs.
+TYPE_DECL for RECORD_TYPEs, UNION_TYPEs and ENUM_TYPEs, but
+ shouldn't be.
+TYPE_DECL for typedefs, unsure why.
+@end display
+
+What things can one use this on:
+
+@display
+TYPE_DECLs
+RECORD_TYPEs
+UNION_TYPEs
+ENUM_TYPEs
+@end display
+
+History:
+
+ It currently points to the TYPE_DECL for RECORD_TYPEs,
+ UNION_TYPEs and ENUM_TYPEs, but it should be history soon.
+
+
+@item TYPE_METHODS
+Synonym for @code{CLASSTYPE_METHOD_VEC}. Chained together with
+@code{TREE_CHAIN}. @file{dbxout.c} uses this to get at the methods of a
+class.
+
+
+@item TYPE_DECL
+Used to represent typedefs, and used to represent bindings layers.
+
+Components:
+
+ DECL_NAME is the name of the typedef. For example, foo would
+ be found in the DECL_NAME slot when @code{typedef int foo;} is
+ seen.
+
+ DECL_SOURCE_LINE identifies what source line number in the
+ source file the declaration was found at. A value of 0
+ indicates that this TYPE_DECL is just an internal binding layer
+ marker, and does not correspond to a user supplied typedef.
+
+ DECL_SOURCE_FILE
+
+@item TYPE_FIELDS
+A linked list (via @code{TREE_CHAIN}) of member types of a class. The
+list can contain @code{TYPE_DECL}s, but there can also be other things
+in the list apparently. See also @code{CLASSTYPE_TAGS}.
+
+
+@item TYPE_VIRTUAL_P
+A flag used on a @code{FIELD_DECL} or a @code{VAR_DECL}, indicates it is
+a virtual function table or a pointer to one. When used on a
+@code{FUNCTION_DECL}, indicates that it is a virtual function. When
+used on an @code{IDENTIFIER_NODE}, indicates that a function with this
+same name exists and has been declared virtual.
+
+When used on types, it indicates that the type has virtual functions, or
+is derived from one that does.
+
+Not sure if the above about virtual function tables is still true. See
+also info on @code{DECL_VIRTUAL_P}.
+
+What things can this be used on:
+
+ FIELD_DECLs, VAR_DECLs, FUNCTION_DECLs, IDENTIFIER_NODEs
+
+
+@item VF_BASETYPE_VALUE
+Get the associated type from the binfo that caused the given vfield to
+exist. This is the least derived class (the most parent class) that
+needed a virtual function table. It is probably the case that all uses
+of this field are misguided, but they need to be examined on a
+case-by-case basis. See history for more information on why the
+previous statement was made.
+
+Set at @code{finish_base_struct} time.
+
+What things can this be used on:
+
+ TREE_LISTs that are vfields
+
+History:
+
+ This field was used to determine if a virtual function table's
+ slot should be filled in with a certain virtual function, by
+ checking to see if the type returned by VF_BASETYPE_VALUE was a
+ parent of the context in which the old virtual function existed.
+ This incorrectly assumes that a given type _could_ not appear as
+ a parent twice in a given inheritance lattice. For single
+ inheritance, this would in fact work, because a type could not
+ possibly appear more than once in an inheritance lattice, but
+ with multiple inheritance, a type can appear more than once.
+
+
+@item VF_BINFO_VALUE
+Identifies the binfo that caused this vfield to exist. If this vfield
+is from the first direct base class that has a virtual function table,
+then VF_BINFO_VALUE is NULL_TREE, otherwise it will be the binfo of the
+direct base where the vfield came from. Can use @code{TREE_VIA_VIRTUAL}
+on result to find out if it is a virtual base class. Related to the
+binfo found by
+
+@example
+get_binfo (VF_BASETYPE_VALUE (vfield), t, 0)
+@end example
+
+@noindent
+where @samp{t} is the type that has the given vfield.
+
+@example
+get_binfo (VF_BASETYPE_VALUE (vfield), t, 0)
+@end example
+
+@noindent
+will return the binfo for the the given vfield.
+
+May or may not be set at @code{modify_vtable_entries} time. Set at
+@code{finish_base_struct} time.
+
+What things can this be used on:
+
+ TREE_LISTs that are vfields
+
+
+@item VF_DERIVED_VALUE
+Identifies the type of the most derived class of the vfield, excluding
+the the class this vfield is for.
+
+Set at @code{finish_base_struct} time.
+
+What things can this be used on:
+
+ TREE_LISTs that are vfields
+
+
+@item VF_NORMAL_VALUE
+Identifies the type of the most derived class of the vfield, including
+the class this vfield is for.
+
+Set at @code{finish_base_struct} time.
+
+What things can this be used on:
+
+ TREE_LISTs that are vfields
+
+
+@item WRITABLE_VTABLES
+This is a option that can be defined when building the compiler, that
+will cause the compiler to output vtables into the data segment so that
+the vtables maybe written. This is undefined by default, because
+normally the vtables should be unwritable. People that implement object
+I/O facilities may, or people that want to change the dynamic type of
+objects may want to have the vtables writable. Another way of achieving
+this would be to make a copy of the vtable into writable memory, but the
+drawback there is that that method only changes the type for one object.
+
+@end table
+
+@node Typical Behavior, Coding Conventions, Macros, Top
+@section Typical Behavior
+
+@cindex parse errors
+
+Whenever seemingly normal code fails with errors like
+@code{syntax error at `\@{'}, it's highly likely that grokdeclarator is
+returning a NULL_TREE for whatever reason.
+
+@node Coding Conventions, Templates, Typical Behavior, Top
+@section Coding Conventions
+
+It should never be that case that trees are modified in-place by the
+back-end, @emph{unless} it is guaranteed that the semantics are the same
+no matter how shared the tree structure is. @file{fold-const.c} still
+has some cases where this is not true, but rms hypothesizes that this
+will never be a problem.
+
+@node Templates, Access Control, Coding Conventions, Top
+@section Templates
+
+A template is represented by a @code{TEMPLATE_DECL}. The specific
+fields used are:
+
+@table @code
+@item DECL_TEMPLATE_RESULT
+The generic decl on which instantiations are based. This looks just
+like any other decl.
+
+@item DECL_TEMPLATE_PARMS
+The parameters to this template.
+@end table
+
+The generic decl is parsed as much like any other decl as possible,
+given the parameterization. The template decl is not built up until the
+generic decl has been completed. For template classes, a template decl
+is generated for each member function and static data member, as well.
+
+Template members of template classes are represented by a TEMPLATE_DECL
+for the class' parameters around another TEMPLATE_DECL for the member's
+parameters.
+
+All declarations that are instantiations or specializations of templates
+refer to their template and parameters through DECL_TEMPLATE_INFO.
+
+How should I handle parsing member functions with the proper param
+decls? Set them up again or try to use the same ones? Currently we do
+the former. We can probably do this without any extra machinery in
+store_pending_inline, by deducing the parameters from the decl in
+do_pending_inlines. PRE_PARSED_TEMPLATE_DECL?
+
+If a base is a parm, we can't check anything about it. If a base is not
+a parm, we need to check it for name binding. Do finish_base_struct if
+no bases are parameterized (only if none, including indirect, are
+parms). Nah, don't bother trying to do any of this until instantiation
+-- we only need to do name binding in advance.
+
+Always set up method vec and fields, inc. synthesized methods. Really?
+We can't know the types of the copy folks, or whether we need a
+destructor, or can have a default ctor, until we know our bases and
+fields. Otherwise, we can assume and fix ourselves later. Hopefully.
+
+@node Access Control, Error Reporting, Templates, Top
+@section Access Control
+The function compute_access returns one of three values:
+
+@table @code
+@item access_public
+means that the field can be accessed by the current lexical scope.
+
+@item access_protected
+means that the field cannot be accessed by the current lexical scope
+because it is protected.
+
+@item access_private
+means that the field cannot be accessed by the current lexical scope
+because it is private.
+@end table
+
+DECL_ACCESS is used for access declarations; alter_access creates a list
+of types and accesses for a given decl.
+
+Formerly, DECL_@{PUBLIC,PROTECTED,PRIVATE@} corresponded to the return
+codes of compute_access and were used as a cache for compute_access.
+Now they are not used at all.
+
+TREE_PROTECTED and TREE_PRIVATE are used to record the access levels
+granted by the containing class. BEWARE: TREE_PUBLIC means something
+completely unrelated to access control!
+
+@node Error Reporting, Parser, Access Control, Top
+@section Error Reporting
+
+The C++ front-end uses a call-back mechanism to allow functions to print
+out reasonable strings for types and functions without putting extra
+logic in the functions where errors are found. The interface is through
+the @code{cp_error} function (or @code{cp_warning}, etc.). The
+syntax is exactly like that of @code{error}, except that a few more
+conversions are supported:
+
+@itemize @bullet
+@item
+%C indicates a value of `enum tree_code'.
+@item
+%D indicates a *_DECL node.
+@item
+%E indicates a *_EXPR node.
+@item
+%L indicates a value of `enum languages'.
+@item
+%P indicates the name of a parameter (i.e. "this", "1", "2", ...)
+@item
+%T indicates a *_TYPE node.
+@item
+%O indicates the name of an operator (MODIFY_EXPR -> "operator =").
+
+@end itemize
+
+There is some overlap between these; for instance, any of the node
+options can be used for printing an identifier (though only @code{%D}
+tries to decipher function names).
+
+For a more verbose message (@code{class foo} as opposed to just @code{foo},
+including the return type for functions), use @code{%#c}.
+To have the line number on the error message indicate the line of the
+DECL, use @code{cp_error_at} and its ilk; to indicate which argument you want,
+use @code{%+D}, or it will default to the first.
+
+@node Parser, Copying Objects, Error Reporting, Top
+@section Parser
+
+Some comments on the parser:
+
+The @code{after_type_declarator} / @code{notype_declarator} hack is
+necessary in order to allow redeclarations of @code{TYPENAME}s, for
+instance
+
+@example
+typedef int foo;
+class A @{
+ char *foo;
+@};
+@end example
+
+In the above, the first @code{foo} is parsed as a @code{notype_declarator},
+and the second as a @code{after_type_declarator}.
+
+Ambiguities:
+
+There are currently four reduce/reduce ambiguities in the parser. They are:
+
+1) Between @code{template_parm} and
+@code{named_class_head_sans_basetype}, for the tokens @code{aggr
+identifier}. This situation occurs in code looking like
+
+@example
+template <class T> class A @{ @};
+@end example
+
+It is ambiguous whether @code{class T} should be parsed as the
+declaration of a template type parameter named @code{T} or an unnamed
+constant parameter of type @code{class T}. Section 14.6, paragraph 3 of
+the January '94 working paper states that the first interpretation is
+the correct one. This ambiguity results in two reduce/reduce conflicts.
+
+2) Between @code{primary} and @code{type_id} for code like @samp{int()}
+in places where both can be accepted, such as the argument to
+@code{sizeof}. Section 8.1 of the pre-San Diego working paper specifies
+that these ambiguous constructs will be interpreted as @code{typename}s.
+This ambiguity results in six reduce/reduce conflicts between
+@samp{absdcl} and @samp{functional_cast}.
+
+3) Between @code{functional_cast} and
+@code{complex_direct_notype_declarator}, for various token strings.
+This situation occurs in code looking like
+
+@example
+int (*a);
+@end example
+
+This code is ambiguous; it could be a declaration of the variable
+@samp{a} as a pointer to @samp{int}, or it could be a functional cast of
+@samp{*a} to @samp{int}. Section 6.8 specifies that the former
+interpretation is correct. This ambiguity results in 7 reduce/reduce
+conflicts. Another aspect of this ambiguity is code like 'int (x[2]);',
+which is resolved at the '[' and accounts for 6 reduce/reduce conflicts
+between @samp{direct_notype_declarator} and
+@samp{primary}/@samp{overqualified_id}. Finally, there are 4 r/r
+conflicts between @samp{expr_or_declarator} and @samp{primary} over code
+like 'int (a);', which could probably be resolved but would also
+probably be more trouble than it's worth. In all, this situation
+accounts for 17 conflicts. Ack!
+
+The second case above is responsible for the failure to parse 'LinppFile
+ppfile (String (argv[1]), &outs, argc, argv);' (from Rogue Wave
+Math.h++) as an object declaration, and must be fixed so that it does
+not resolve until later.
+
+4) Indirectly between @code{after_type_declarator} and @code{parm}, for
+type names. This occurs in (as one example) code like
+
+@example
+typedef int foo, bar;
+class A @{
+ foo (bar);
+@};
+@end example
+
+What is @code{bar} inside the class definition? We currently interpret
+it as a @code{parm}, as does Cfront, but IBM xlC interprets it as an
+@code{after_type_declarator}. I believe that xlC is correct, in light
+of 7.1p2, which says "The longest sequence of @i{decl-specifiers} that
+could possibly be a type name is taken as the @i{decl-specifier-seq} of
+a @i{declaration}." However, it seems clear that this rule must be
+violated in the case of constructors. This ambiguity accounts for 8
+conflicts.
+
+Unlike the others, this ambiguity is not recognized by the Working Paper.
+
+@node Copying Objects, Exception Handling, Parser, Top
+@section Copying Objects
+
+The generated copy assignment operator in g++ does not currently do the
+right thing for multiple inheritance involving virtual bases; it just
+calls the copy assignment operators for its direct bases. What it
+should probably do is:
+
+1) Split up the copy assignment operator for all classes that have
+vbases into "copy my vbases" and "copy everything else" parts. Or do
+the trickiness that the constructors do to ensure that vbases don't get
+initialized by intermediate bases.
+
+2) Wander through the class lattice, find all vbases for which no
+intermediate base has a user-defined copy assignment operator, and call
+their "copy everything else" routines. If not all of my vbases satisfy
+this criterion, warn, because this may be surprising behavior.
+
+3) Call the "copy everything else" routine for my direct bases.
+
+If we only have one direct base, we can just foist everything off onto
+them.
+
+This issue is currently under discussion in the core reflector
+(2/28/94).
+
+@node Exception Handling, Free Store, Copying Objects, Top
+@section Exception Handling
+
+Note, exception handling in g++ is still under development.
+
+This section describes the mapping of C++ exceptions in the C++
+front-end, into the back-end exception handling framework.
+
+The basic mechanism of exception handling in the back-end is
+unwind-protect a la elisp. This is a general, robust, and language
+independent representation for exceptions.
+
+The C++ front-end exceptions are mapping into the unwind-protect
+semantics by the C++ front-end. The mapping is describe below.
+
+When -frtti is used, rtti is used to do exception object type checking,
+when it isn't used, the encoded name for the type of the object being
+thrown is used instead. All code that originates exceptions, even code
+that throws exceptions as a side effect, like dynamic casting, and all
+code that catches exceptions must be compiled with either -frtti, or
+-fno-rtti. It is not possible to mix rtti base exception handling
+objects with code that doesn't use rtti. The exceptions to this, are
+code that doesn't catch or throw exceptions, catch (...), and code that
+just rethrows an exception.
+
+Currently we use the normal mangling used in building functions names
+(int's are "i", const char * is PCc) to build the non-rtti base type
+descriptors for exception handling. These descriptors are just plain
+NULL terminated strings, and internally they are passed around as char
+*.
+
+In C++, all cleanups should be protected by exception regions. The
+region starts just after the reason why the cleanup is created has
+ended. For example, with an automatic variable, that has a constructor,
+it would be right after the constructor is run. The region ends just
+before the finalization is expanded. Since the backend may expand the
+cleanup multiple times along different paths, once for normal end of the
+region, once for non-local gotos, once for returns, etc, the backend
+must take special care to protect the finalization expansion, if the
+expansion is for any other reason than normal region end, and it is
+`inline' (it is inside the exception region). The backend can either
+choose to move them out of line, or it can created an exception region
+over the finalization to protect it, and in the handler associated with
+it, it would not run the finalization as it otherwise would have, but
+rather just rethrow to the outer handler, careful to skip the normal
+handler for the original region.
+
+In Ada, they will use the more runtime intensive approach of having
+fewer regions, but at the cost of additional work at run time, to keep a
+list of things that need cleanups. When a variable has finished
+construction, they add the cleanup to the list, when the come to the end
+of the lifetime of the variable, the run the list down. If the take a
+hit before the section finishes normally, they examine the list for
+actions to perform. I hope they add this logic into the back-end, as it
+would be nice to get that alternative approach in C++.
+
+On an rs6000, xlC stores exception objects on that stack, under the try
+block. When is unwinds down into a handler, the frame pointer is
+adjusted back to the normal value for the frame in which the handler
+resides, and the stack pointer is left unchanged from the time at which
+the object was thrown. This is so that there is always someplace for
+the exception object, and nothing can overwrite it, once we start
+throwing. The only bad part, is that the stack remains large.
+
+The below points out some things that work in g++'s exception handling.
+
+All completely constructed temps and local variables are cleaned up in
+all unwinded scopes. Completely constructed parts of partially
+constructed objects are cleaned up. This includes partially built
+arrays. Exception specifications are now handled.
+
+The below points out some flaws in g++'s exception handling, as it now
+stands.
+
+Only exact type matching or reference matching of throw types works when
+-fno-rtti is used. Only works on a SPARC (like Suns), i386, arm and
+rs6000 machines. Partial support is in for all other machines, but a
+stack unwinder called __unwind_function has to be written, and added to
+libgcc2 for them. See below for details on __unwind_function. Don't
+expect exception handling to work right if you optimize, in fact the
+compiler will probably core dump. RTL_EXPRs for EH cond variables for
+&& and || exprs should probably be wrapped in UNSAVE_EXPRs, and
+RTL_EXPRs tweaked so that they can be unsaved, and the UNSAVE_EXPR code
+should be in the backend, or alternatively, UNSAVE_EXPR should be ripped
+out and exactly one finalization allowed to be expanded by the backend.
+I talked with kenner about this, and we have to allow multiple
+expansions.
+
+We only do pointer conversions on exception matching a la 15.3 p2 case
+3: `A handler with type T, const T, T&, or const T& is a match for a
+throw-expression with an object of type E if [3]T is a pointer type and
+E is a pointer type that can be converted to T by a standard pointer
+conversion (_conv.ptr_) not involving conversions to pointers to private
+or protected base classes.' when -frtti is given.
+
+We don't call delete on new expressions that die because the ctor threw
+an exception. See except/18 for a test case.
+
+15.2 para 13: The exception being handled should be rethrown if control
+reaches the end of a handler of the function-try-block of a constructor
+or destructor, right now, it is not.
+
+15.2 para 12: If a return statement appears in a handler of
+function-try-block of a constructor, the program is ill-formed, but this
+isn't diagnosed.
+
+15.2 para 11: If the handlers of a function-try-block contain a jump
+into the body of a constructor or destructor, the program is ill-formed,
+but this isn't diagnosed.
+
+15.2 para 9: Check that the fully constructed base classes and members
+of an object are destroyed before entering the handler of a
+function-try-block of a constructor or destructor for that object.
+
+build_exception_variant should sort the incoming list, so that it
+implements set compares, not exact list equality. Type smashing should
+smash exception specifications using set union.
+
+Thrown objects are usually allocated on the heap, in the usual way, but
+they are never deleted. They should be deleted by the catch clauses.
+If one runs out of heap space, throwing an object will probably never
+work. This could be relaxed some by passing an __in_chrg parameter to
+track who has control over the exception object. Thrown objects are not
+allocated on the heap when they are pointer to object types.
+
+When the backend returns a value, it can create new exception regions
+that need protecting. The new region should rethrow the object in
+context of the last associated cleanup that ran to completion.
+
+The structure of the code that is generated for C++ exception handling
+code is shown below:
+
+@example
+Ln: throw value;
+ copy value onto heap
+ jump throw (Ln, id, address of copy of value on heap)
+
+ try {
++Lstart: the start of the main EH region
+|... ...
++Lend: the end of the main EH region
+ } catch (T o) {
+ ...1
+ }
+Lresume:
+ nop used to make sure there is something before
+ the next region ends, if there is one
+... ...
+
+ jump Ldone
+[
+Lmainhandler: handler for the region Lstart-Lend
+ cleanup
+] zero or more, depending upon automatic vars with dtors
++Lpartial:
+| jump Lover
++Lhere:
+ rethrow (Lhere, same id, same obj);
+Lterm: handler for the region Lpartial-Lhere
+ call terminate
+Lover:
+[
+ [
+ call throw_type_match
+ if (eq) {
+ ] these lines disappear when there is no catch condition
++Lsregion2:
+| ...1
+| jump Lresume
+|Lhandler: handler for the region Lsregion2-Leregion2
+| rethrow (Lresume, same id, same obj);
++Leregion2
+ }
+] there are zero or more of these sections, depending upon how many
+ catch clauses there are
+----------------------------- expand_end_all_catch --------------------------
+ here we have fallen off the end of all catch
+ clauses, so we rethrow to outer
+ rethrow (Lresume, same id, same obj);
+----------------------------- expand_end_all_catch --------------------------
+[
+L1: maybe throw routine
+] depending upon if we have expanded it or not
+Ldone:
+ ret
+
+start_all_catch emits labels: Lresume,
+
+#end example
+
+The __unwind_function takes a pointer to the throw handler, and is
+expected to pop the stack frame that was built to call it, as well as
+the frame underneath and then jump to the throw handler. It must
+restore all registers to their proper values as well as all other
+machine state as determined by the context in which we are unwinding
+into. The way I normally start is to compile:
+
+ void *g;
+ foo(void* a) { g = a; }
+
+with -S, and change the thing that alters the PC (return, or ret
+usually) to not alter the PC, making sure to leave all other semantics
+(like adjusting the stack pointer, or frame pointers) in. After that,
+replicate the prologue once more at the end, again, changing the PC
+altering instructions, and finally, at the very end, jump to `g'.
+
+It takes about a week to write this routine, if someone wants to
+volunteer to write this routine for any architecture, exception support
+for that architecture will be added to g++. Please send in those code
+donations. One other thing that needs to be done, is to double check
+that __builtin_return_address (0) works.
+
+@subsection Specific Targets
+
+For the alpha, the __unwind_function will be something resembling:
+
+@example
+void
+__unwind_function(void *ptr)
+@{
+ /* First frame */
+ asm ("ldq $15, 8($30)"); /* get the saved frame ptr; 15 is fp, 30 is sp */
+ asm ("bis $15, $15, $30"); /* reload sp with the fp we found */
+
+ /* Second frame */
+ asm ("ldq $15, 8($30)"); /* fp */
+ asm ("bis $15, $15, $30"); /* reload sp with the fp we found */
+
+ /* Return */
+ asm ("ret $31, ($16), 1"); /* return to PTR, stored in a0 */
+@}
+@end example
+
+@noindent
+However, there are a few problems preventing it from working. First of
+all, the gcc-internal function @code{__builtin_return_address} needs to
+work given an argument of 0 for the alpha. As it stands as of August
+30th, 1995, the code for @code{BUILT_IN_RETURN_ADDRESS} in @file{expr.c}
+will definitely not work on the alpha. Instead, we need to define
+the macros @code{DYNAMIC_CHAIN_ADDRESS} (maybe),
+@code{RETURN_ADDR_IN_PREVIOUS_FRAME}, and definitely need a new
+definition for @code{RETURN_ADDR_RTX}.
+
+In addition (and more importantly), we need a way to reliably find the
+frame pointer on the alpha. The use of the value 8 above to restore the
+frame pointer (register 15) is incorrect. On many systems, the frame
+pointer is consistently offset to a specific point on the stack. On the
+alpha, however, the frame pointer is pushed last. First the return
+address is stored, then any other registers are saved (e.g., @code{s0}),
+and finally the frame pointer is put in place. So @code{fp} could have
+an offset of 8, but if the calling function saved any registers at all,
+they add to the offset.
+
+The only places the frame size is noted are with the @samp{.frame}
+directive, for use by the debugger and the OSF exception handling model
+(useless to us), and in the initial computation of the new value for
+@code{sp}, the stack pointer. For example, the function may start with:
+
+@example
+lda $30,-32($30)
+.frame $15,32,$26,0
+@end example
+
+@noindent
+The 32 above is exactly the value we need. With this, we can be sure
+that the frame pointer is stored 8 bytes less---in this case, at 24(sp)).
+The drawback is that there is no way that I (Brendan) have found to let
+us discover the size of a previous frame @emph{inside} the definition
+of @code{__unwind_function}.
+
+So to accomplish exception handling support on the alpha, we need two
+things: first, a way to figure out where the frame pointer was stored,
+and second, a functional @code{__builtin_return_address} implementation
+for except.c to be able to use it.
+
+@subsection Backend Exception Support
+
+The backend must be extended to fully support exceptions. Right now
+there are a few hooks into the alpha exception handling backend that
+resides in the C++ frontend from that backend that allows exception
+handling to work in g++. An exception region is a segment of generated
+code that has a handler associated with it. The exception regions are
+denoted in the generated code as address ranges denoted by a starting PC
+value and an ending PC value of the region. Some of the limitations
+with this scheme are:
+
+@itemize @bullet
+@item
+The backend replicates insns for such things as loop unrolling and
+function inlining. Right now, there are no hooks into the frontend's
+exception handling backend to handle the replication of insns. When
+replication happens, a new exception region descriptor needs to be
+generated for the new region.
+
+@item
+The backend expects to be able to rearrange code, for things like jump
+optimization. Any rearranging of the code needs have exception region
+descriptors updated appropriately.
+
+@item
+The backend can eliminate dead code. Any associated exception region
+descriptor that refers to fully contained code that has been eliminated
+should also be removed, although not doing this is harmless in terms of
+semantics.
+
+#end itemize
+
+The above is not meant to be exhaustive, but does include all things I
+have thought of so far. I am sure other limitations exist.
+
+Below are some notes on the migration of the exception handling code
+backend from the C++ frontend to the backend.
+
+NOTEs are to be used to denote the start of an exception region, and the
+end of the region. I presume that the interface used to generate these
+notes in the backend would be two functions, start_exception_region and
+end_exception_region (or something like that). The frontends are
+required to call them in pairs. When marking the end of a region, an
+argument can be passed to indicate the handler for the marked region.
+This can be passed in many ways, currently a tree is used. Another
+possibility would be insns for the handler, or a label that denotes a
+handler. I have a feeling insns might be the the best way to pass it.
+Semantics are, if an exception is thrown inside the region, control is
+transfered unconditionally to the handler. If control passes through
+the handler, then the backend is to rethrow the exception, in the
+context of the end of the original region. The handler is protected by
+the conventional mechanisms; it is the frontend's responsibility to
+protect the handler, if special semantics are required.
+
+This is a very low level view, and it would be nice is the backend
+supported a somewhat higher level view in addition to this view. This
+higher level could include source line number, name of the source file,
+name of the language that threw the exception and possibly the name of
+the exception. Kenner may want to rope you into doing more than just
+the basics required by C++. You will have to resolve this. He may want
+you to do support for non-local gotos, first scan for exception handler,
+if none is found, allow the debugger to be entered, without any cleanups
+being done. To do this, the backend would have to know the difference
+between a cleanup-rethrower, and a real handler, if would also have to
+have a way to know if a handler `matches' a thrown exception, and this
+is frontend specific.
+
+The UNSAVE_EXPR tree code has to be migrated to the backend. Exprs such
+as TARGET_EXPRs, WITH_CLEANUP_EXPRs, CALL_EXPRs and RTL_EXPRs have to be
+changed to support unsaving. This is meant to be a complete list.
+SAVE_EXPRs can be unsaved already. expand_decl_cleanup should be
+changed to unsave it's argument, if needed. See
+cp/tree.c:cp_expand_decl_cleanup, unsave_expr_now, unsave_expr, and
+cp/expr.c:cplus_expand_expr(case UNSAVE_EXPR:) for the UNSAVE_EXPR code.
+Now, as to why... because kenner already tripped over the exact same
+problem in Ada, we talked about it, he didn't like any of the solution,
+but yet, didn't like no solution either. He was willing to live with
+the drawbacks of this solution. The drawback is unsave_expr_now. It
+should have a callback into the frontend, to allow the unsaveing of
+frontend special codes. The callback goes in, inplace of the call to
+my_friendly_abort.
+
+The stack unwinder is one of the hardest parts to do. It is highly
+machine dependent. The form that kenner seems to like was a couple of
+macros, that would do the machine dependent grunt work. One preexisting
+function that might be of some use is __builtin_return_address (). One
+macro he seemed to want was __builtin_return_address, and the other
+would do the hard work of fixing up the registers, adjusting the stack
+pointer, frame pointer, arg pointer and so on.
+
+The eh archive (~mrs/eh) might be good reading for understanding the Ada
+perspective, and some of kenners mindset, and a detailed explanation
+(Message-Id: <9308301130.AA10543@vlsi1.ultra.nyu.edu>) of the concepts
+involved.
+
+Here is a guide to existing backend type code. It is all in
+cp/except.c. Check out do_unwind, and expand_builtin_throw for current
+code on how to figure out what handler matches an exception,
+emit_exception_table for code on emitting the PC range table that is
+built during compilation, expand_exception_blocks for code that emits
+all the handlers at the end of a functions, end_protect to mark the end
+of an exception region, start_protect to mark the start of an exception
+region, lang_interim_eh is the master hook used by the backend into the
+EH backend that now exists in the frontend, and expand_internal_throw to
+raise an exception.
+
+
+@node Free Store, Concept Index, Exception Handling, Top
+@section Free Store
+
+operator new [] adds a magic cookie to the beginning of arrays for which
+the number of elements will be needed by operator delete []. These are
+arrays of objects with destructors and arrays of objects that define
+operator delete [] with the optional size_t argument. This cookie can
+be examined from a program as follows:
+
+@example
+typedef unsigned long size_t;
+extern "C" int printf (const char *, ...);
+
+size_t nelts (void *p)
+@{
+ struct cookie @{
+ size_t nelts __attribute__ ((aligned (sizeof (double))));
+ @};
+
+ cookie *cp = (cookie *)p;
+ --cp;
+
+ return cp->nelts;
+@}
+
+struct A @{
+ ~A() @{ @}
+@};
+
+main()
+@{
+ A *ap = new A[3];
+ printf ("%ld\n", nelts (ap));
+@}
+@end example
+
+@section Linkage
+The linkage code in g++ is horribly twisted in order to meet two design goals:
+
+1) Avoid unnecessary emission of inlines and vtables.
+
+2) Support pedantic assemblers like the one in AIX.
+
+To meet the first goal, we defer emission of inlines and vtables until
+the end of the translation unit, where we can decide whether or not they
+are needed, and how to emit them if they are.
+
+@node Concept Index, , Free Store, Top
+@section Concept Index
+
+@printindex cp
+
+@bye
diff --git a/contrib/gcc/cp/init.c b/contrib/gcc/cp/init.c
new file mode 100644
index 0000000..9752a9b
--- /dev/null
+++ b/contrib/gcc/cp/init.c
@@ -0,0 +1,4180 @@
+/* Handle initialization things in C++.
+ Copyright (C) 1987, 89, 92, 93, 94, 1995 Free Software Foundation, Inc.
+ Contributed by Michael Tiemann (tiemann@cygnus.com)
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+/* High-level class interface. */
+
+#include "config.h"
+#include "tree.h"
+#include "rtl.h"
+#include "cp-tree.h"
+#include "flags.h"
+#include "output.h"
+
+#undef NULL
+#define NULL 0
+
+/* In C++, structures with well-defined constructors are initialized by
+ those constructors, unasked. CURRENT_BASE_INIT_LIST
+ holds a list of stmts for a BASE_INIT term in the grammar.
+ This list has one element for each base class which must be
+ initialized. The list elements are [basename, init], with
+ type basetype. This allows the possibly anachronistic form
+ (assuming d : a, b, c) "d (int a) : c(a+5), b (a-4), a (a+3)"
+ where each successive term can be handed down the constructor
+ line. Perhaps this was not intended. */
+tree current_base_init_list, current_member_init_list;
+
+void emit_base_init ();
+void check_base_init ();
+static void expand_aggr_vbase_init ();
+void expand_member_init ();
+void expand_aggr_init ();
+
+static void expand_aggr_init_1 ();
+static void expand_recursive_init_1 ();
+static void expand_recursive_init ();
+static void expand_virtual_init PROTO((tree, tree));
+tree expand_vec_init ();
+
+static void add_friend (), add_friends ();
+
+/* Cache _builtin_new and _builtin_delete exprs. */
+static tree BIN, BID, BIVN, BIVD;
+
+/* Cache the identifier nodes for the two magic field of a new cookie. */
+static tree nc_nelts_field_id;
+#if 0
+static tree nc_ptr_2comp_field_id;
+#endif
+
+static tree minus_one;
+
+/* Set up local variable for this file. MUST BE CALLED AFTER
+ INIT_DECL_PROCESSING. */
+
+tree BI_header_type, BI_header_size;
+
+void init_init_processing ()
+{
+ tree fields[1];
+
+ /* Define implicit `operator new' and `operator delete' functions. */
+ BIN = default_conversion (get_first_fn (IDENTIFIER_GLOBAL_VALUE (ansi_opname[(int) NEW_EXPR])));
+ TREE_USED (TREE_OPERAND (BIN, 0)) = 0;
+ BID = default_conversion (get_first_fn (IDENTIFIER_GLOBAL_VALUE (ansi_opname[(int) DELETE_EXPR])));
+ TREE_USED (TREE_OPERAND (BID, 0)) = 0;
+ BIVN = default_conversion (get_first_fn (IDENTIFIER_GLOBAL_VALUE (ansi_opname[(int) VEC_NEW_EXPR])));
+ TREE_USED (TREE_OPERAND (BIVN, 0)) = 0;
+ BIVD = default_conversion (get_first_fn (IDENTIFIER_GLOBAL_VALUE (ansi_opname[(int) VEC_DELETE_EXPR])));
+ TREE_USED (TREE_OPERAND (BIVD, 0)) = 0;
+ minus_one = build_int_2 (-1, -1);
+
+ /* Define the structure that holds header information for
+ arrays allocated via operator new. */
+ BI_header_type = make_lang_type (RECORD_TYPE);
+ nc_nelts_field_id = get_identifier ("nelts");
+ fields[0] = build_lang_field_decl (FIELD_DECL, nc_nelts_field_id, sizetype);
+ finish_builtin_type (BI_header_type, "__new_cookie", fields,
+ 0, double_type_node);
+ BI_header_size = size_in_bytes (BI_header_type);
+}
+
+/* Subroutine of emit_base_init. For BINFO, initialize all the
+ virtual function table pointers, except those that come from
+ virtual base classes. Initialize binfo's vtable pointer, if
+ INIT_SELF is true. CAN_ELIDE is true when we know that all virtual
+ function table pointers in all bases have been initialized already,
+ probably because their constructors have just be run. ADDR is the
+ pointer to the object whos vtables we are going to initialize.
+
+ REAL_BINFO is usually the same as BINFO, except when addr is not of
+ pointer to the type of the real derived type that we want to
+ initialize for. This is the case when addr is a pointer to a sub
+ object of a complete object, and we only want to do part of the
+ complete object's initialization of vtable pointers. This is done
+ for all virtual table pointers in virtual base classes. REAL_BINFO
+ is used to find the BINFO_VTABLE that we initialize with. BINFO is
+ used for conversions of addr to subobjects.
+
+ BINFO_TYPE (real_binfo) must be BINFO_TYPE (binfo).
+
+ Relies upon binfo being inside TYPE_BINFO (TREE_TYPE (TREE_TYPE
+ (addr))). */
+void
+expand_direct_vtbls_init (real_binfo, binfo, init_self, can_elide, addr)
+ tree real_binfo, binfo, addr;
+ int init_self, can_elide;
+{
+ tree real_binfos = BINFO_BASETYPES (real_binfo);
+ tree binfos = BINFO_BASETYPES (binfo);
+ int i, n_baselinks = real_binfos ? TREE_VEC_LENGTH (real_binfos) : 0;
+
+ for (i = 0; i < n_baselinks; i++)
+ {
+ tree real_base_binfo = TREE_VEC_ELT (real_binfos, i);
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ int is_not_base_vtable =
+ i != CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (real_binfo));
+ if (! TREE_VIA_VIRTUAL (real_base_binfo))
+ expand_direct_vtbls_init (real_base_binfo, base_binfo,
+ is_not_base_vtable, can_elide, addr);
+ }
+#if 0
+ /* Before turning this on, make sure it is correct. */
+ if (can_elide && ! BINFO_MODIFIED (binfo))
+ return;
+#endif
+ /* Should we use something besides CLASSTYPE_VFIELDS? */
+ if (init_self && CLASSTYPE_VFIELDS (BINFO_TYPE (real_binfo)))
+ {
+ tree base_ptr = convert_pointer_to_real (binfo, addr);
+ expand_virtual_init (real_binfo, base_ptr);
+ }
+}
+
+/* 348 - 351 */
+/* Subroutine of emit_base_init. */
+static void
+perform_member_init (member, name, init, explicit, protect_list)
+ tree member, name, init, *protect_list;
+ int explicit;
+{
+ tree decl;
+ tree type = TREE_TYPE (member);
+
+ if (TYPE_NEEDS_CONSTRUCTING (type)
+ || (init && TYPE_HAS_CONSTRUCTOR (type)))
+ {
+ /* Since `init' is already a TREE_LIST on the current_member_init_list,
+ only build it into one if we aren't already a list. */
+ if (init != NULL_TREE && TREE_CODE (init) != TREE_LIST)
+ init = build_tree_list (NULL_TREE, init);
+
+ decl = build_component_ref (C_C_D, name, 0, explicit);
+
+ if (explicit
+ && TREE_CODE (type) == ARRAY_TYPE
+ && init != NULL_TREE
+ && TREE_CHAIN (init) == NULL_TREE
+ && TREE_CODE (TREE_TYPE (TREE_VALUE (init))) == ARRAY_TYPE)
+ {
+ /* Initialization of one array from another. */
+ expand_vec_init (TREE_OPERAND (decl, 1), decl,
+ array_type_nelts (type), TREE_VALUE (init), 1);
+ }
+ else
+ expand_aggr_init (decl, init, 0, 0);
+ }
+ else
+ {
+ if (init == NULL_TREE)
+ {
+ if (explicit)
+ {
+ cp_error ("incomplete initializer for member `%D' of class `%T' which has no constructor",
+ member, current_class_type);
+ init = error_mark_node;
+ }
+ /* member traversal: note it leaves init NULL */
+ else if (TREE_CODE (TREE_TYPE (member)) == REFERENCE_TYPE)
+ cp_pedwarn ("uninitialized reference member `%D'", member);
+ }
+ else if (TREE_CODE (init) == TREE_LIST)
+ {
+ /* There was an explicit member initialization. Do some
+ work in that case. */
+ if (TREE_CHAIN (init))
+ {
+ warning ("initializer list treated as compound expression");
+ init = build_compound_expr (init);
+ }
+ else
+ init = TREE_VALUE (init);
+ }
+
+ /* We only build this with a null init if we got it from the
+ current_member_init_list. */
+ if (init || explicit)
+ {
+ decl = build_component_ref (C_C_D, name, 0, explicit);
+ expand_expr_stmt (build_modify_expr (decl, INIT_EXPR, init));
+ }
+ }
+ expand_cleanups_to (NULL_TREE);
+
+ if (TYPE_NEEDS_DESTRUCTOR (type))
+ {
+ tree expr = build_component_ref (C_C_D, name, 0, explicit);
+ expr = build_delete (type, expr, integer_zero_node,
+ LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR, 0);
+
+ if (expr != error_mark_node)
+ {
+ start_protect ();
+ *protect_list = tree_cons (NULL_TREE, expr, *protect_list);
+ }
+ }
+}
+
+extern int warn_reorder;
+
+/* Subroutine of emit_member_init. */
+static tree
+sort_member_init (t)
+ tree t;
+{
+ tree x, member, name, field, init;
+ tree init_list = NULL_TREE;
+ tree fields_to_unmark = NULL_TREE;
+ int last_pos = 0;
+ tree last_field;
+
+ for (member = TYPE_FIELDS (t); member ; member = TREE_CHAIN (member))
+ {
+ int pos;
+
+ /* member could be, for example, a CONST_DECL for an enumerated
+ tag; we don't want to try to initialize that, since it already
+ has a value. */
+ if (TREE_CODE (member) != FIELD_DECL || !DECL_NAME (member))
+ continue;
+
+ for (x = current_member_init_list, pos = 0; x; x = TREE_CHAIN (x), ++pos)
+ {
+ /* If we cleared this out, then pay no attention to it. */
+ if (TREE_PURPOSE (x) == NULL_TREE)
+ continue;
+ name = TREE_PURPOSE (x);
+
+#if 0
+ field = (TREE_CODE (name) == COMPONENT_REF
+ ? TREE_OPERAND (name, 1) : IDENTIFIER_CLASS_VALUE (name));
+#else
+ /* Let's find out when this happens. */
+ my_friendly_assert (TREE_CODE (name) != COMPONENT_REF, 348);
+ field = IDENTIFIER_CLASS_VALUE (name);
+#endif
+
+ /* If one member shadows another, get the outermost one. */
+ if (TREE_CODE (field) == TREE_LIST)
+ field = TREE_VALUE (field);
+
+ if (field == member)
+ {
+ if (warn_reorder)
+ {
+ if (pos < last_pos)
+ {
+ cp_warning_at ("member initializers for `%#D'", last_field);
+ cp_warning_at (" and `%#D'", field);
+ warning (" will be re-ordered to match declaration order");
+ }
+ last_pos = pos;
+ last_field = field;
+ }
+
+ /* Make sure we won't try to work on this init again. */
+ TREE_PURPOSE (x) = NULL_TREE;
+ x = build_tree_list (name, TREE_VALUE (x));
+ goto got_it;
+ }
+ }
+
+ /* If we didn't find MEMBER in the list, create a dummy entry
+ so the two lists (INIT_LIST and the list of members) will be
+ symmetrical. */
+ x = build_tree_list (NULL_TREE, NULL_TREE);
+ got_it:
+ init_list = chainon (init_list, x);
+ }
+
+ /* Initializers for base members go at the end. */
+ for (x = current_member_init_list ; x ; x = TREE_CHAIN (x))
+ {
+ name = TREE_PURPOSE (x);
+ if (name)
+ {
+ if (purpose_member (name, init_list))
+ {
+ cp_error ("multiple initializations given for member `%D'",
+ IDENTIFIER_CLASS_VALUE (name));
+ continue;
+ }
+
+ init_list = chainon (init_list,
+ build_tree_list (name, TREE_VALUE (x)));
+ TREE_PURPOSE (x) = NULL_TREE;
+ }
+ }
+
+ return init_list;
+}
+
+static void
+sort_base_init (t, rbase_ptr, vbase_ptr)
+ tree t, *rbase_ptr, *vbase_ptr;
+{
+ tree binfos = BINFO_BASETYPES (TYPE_BINFO (t));
+ int n_baseclasses = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+
+ int i;
+ tree x;
+ tree last;
+
+ /* For warn_reorder. */
+ int last_pos = 0;
+ tree last_base = NULL_TREE;
+
+ tree rbases = NULL_TREE;
+ tree vbases = NULL_TREE;
+
+ /* First walk through and splice out vbase and invalid initializers.
+ Also replace names with binfos. */
+
+ last = tree_cons (NULL_TREE, NULL_TREE, current_base_init_list);
+ for (x = TREE_CHAIN (last); x; x = TREE_CHAIN (x))
+ {
+ tree basename = TREE_PURPOSE (x);
+ tree binfo;
+
+ if (basename == NULL_TREE)
+ {
+ /* Initializer for single base class. Must not
+ use multiple inheritance or this is ambiguous. */
+ switch (n_baseclasses)
+ {
+ case 0:
+ cp_error ("`%T' does not have a base class to initialize",
+ current_class_type);
+ return;
+ case 1:
+ break;
+ default:
+ cp_error ("unnamed initializer ambiguous for `%T' which uses multiple inheritance",
+ current_class_type);
+ return;
+ }
+ binfo = TREE_VEC_ELT (binfos, 0);
+ }
+ else if (is_aggr_typedef (basename, 1))
+ {
+ binfo = binfo_or_else (IDENTIFIER_TYPE_VALUE (basename), t);
+ if (binfo == NULL_TREE)
+ continue;
+
+ /* Virtual base classes are special cases. Their initializers
+ are recorded with this constructor, and they are used when
+ this constructor is the top-level constructor called. */
+ if (TREE_VIA_VIRTUAL (binfo))
+ {
+ tree v = CLASSTYPE_VBASECLASSES (t);
+ while (BINFO_TYPE (v) != BINFO_TYPE (binfo))
+ v = TREE_CHAIN (v);
+
+ vbases = tree_cons (v, TREE_VALUE (x), vbases);
+ continue;
+ }
+ else
+ {
+ /* Otherwise, if it is not an immediate base class, complain. */
+ for (i = n_baseclasses-1; i >= 0; i--)
+ if (BINFO_TYPE (binfo) == BINFO_TYPE (TREE_VEC_ELT (binfos, i)))
+ break;
+ if (i < 0)
+ {
+ cp_error ("`%T' is not an immediate base class of `%T'",
+ IDENTIFIER_TYPE_VALUE (basename),
+ current_class_type);
+ continue;
+ }
+ }
+ }
+ else
+ my_friendly_abort (365);
+
+ TREE_PURPOSE (x) = binfo;
+ TREE_CHAIN (last) = x;
+ last = x;
+ }
+ TREE_CHAIN (last) = NULL_TREE;
+
+ /* Now walk through our regular bases and make sure they're initialized. */
+
+ for (i = 0; i < n_baseclasses; ++i)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ int pos;
+
+ if (TREE_VIA_VIRTUAL (base_binfo))
+ continue;
+
+ for (x = current_base_init_list, pos = 0; x; x = TREE_CHAIN (x), ++pos)
+ {
+ tree binfo = TREE_PURPOSE (x);
+
+ if (binfo == NULL_TREE)
+ continue;
+
+ if (binfo == base_binfo)
+ {
+ if (warn_reorder)
+ {
+ if (pos < last_pos)
+ {
+ cp_warning_at ("base initializers for `%#T'", last_base);
+ cp_warning_at (" and `%#T'", BINFO_TYPE (binfo));
+ warning (" will be re-ordered to match inheritance order");
+ }
+ last_pos = pos;
+ last_base = BINFO_TYPE (binfo);
+ }
+
+ /* Make sure we won't try to work on this init again. */
+ TREE_PURPOSE (x) = NULL_TREE;
+ x = build_tree_list (binfo, TREE_VALUE (x));
+ goto got_it;
+ }
+ }
+
+ /* If we didn't find BASE_BINFO in the list, create a dummy entry
+ so the two lists (RBASES and the list of bases) will be
+ symmetrical. */
+ x = build_tree_list (NULL_TREE, NULL_TREE);
+ got_it:
+ rbases = chainon (rbases, x);
+ }
+
+ *rbase_ptr = rbases;
+ *vbase_ptr = vbases;
+}
+
+/* Perform partial cleanups for a base for exception handling. */
+static tree
+build_partial_cleanup_for (binfo)
+ tree binfo;
+{
+ tree expr = convert_pointer_to_real (binfo,
+ build_unary_op (ADDR_EXPR, C_C_D, 0));
+
+ return build_delete (TREE_TYPE (expr),
+ expr,
+ integer_zero_node,
+ LOOKUP_NONVIRTUAL|LOOKUP_DESTRUCTOR, 0);
+}
+
+/* Perform whatever initializations have yet to be done on the base
+ class of the class variable. These actions are in the global
+ variable CURRENT_BASE_INIT_LIST. Such an action could be
+ NULL_TREE, meaning that the user has explicitly called the base
+ class constructor with no arguments.
+
+ If there is a need for a call to a constructor, we must surround
+ that call with a pushlevel/poplevel pair, since we are technically
+ at the PARM level of scope.
+
+ Argument IMMEDIATELY, if zero, forces a new sequence to be
+ generated to contain these new insns, so it can be emitted later.
+ This sequence is saved in the global variable BASE_INIT_EXPR.
+ Otherwise, the insns are emitted into the current sequence.
+
+ Note that emit_base_init does *not* initialize virtual base
+ classes. That is done specially, elsewhere. */
+
+extern tree base_init_expr, rtl_expr_chain;
+
+void
+emit_base_init (t, immediately)
+ tree t;
+ int immediately;
+{
+ extern tree in_charge_identifier;
+
+ tree member, x;
+ tree mem_init_list;
+ tree rbase_init_list, vbase_init_list;
+ tree t_binfo = TYPE_BINFO (t);
+ tree binfos = BINFO_BASETYPES (t_binfo);
+ int i, n_baseclasses = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+ tree expr = NULL_TREE;
+
+ my_friendly_assert (protect_list == NULL_TREE, 999);
+
+ if (! immediately)
+ {
+ int momentary;
+ do_pending_stack_adjust ();
+ /* Make the RTL_EXPR node temporary, not momentary,
+ so that rtl_expr_chain doesn't become garbage. */
+ momentary = suspend_momentary ();
+ expr = make_node (RTL_EXPR);
+ resume_momentary (momentary);
+ start_sequence_for_rtl_expr (expr);
+ }
+
+ if (write_symbols == NO_DEBUG)
+ /* As a matter of principle, `start_sequence' should do this. */
+ emit_note (0, -1);
+ else
+ /* Always emit a line number note so we can step into constructors. */
+ emit_line_note_force (DECL_SOURCE_FILE (current_function_decl),
+ DECL_SOURCE_LINE (current_function_decl));
+
+ mem_init_list = sort_member_init (t);
+ current_member_init_list = NULL_TREE;
+
+ sort_base_init (t, &rbase_init_list, &vbase_init_list);
+ current_base_init_list = NULL_TREE;
+
+ if (TYPE_USES_VIRTUAL_BASECLASSES (t))
+ {
+ tree first_arg = TREE_CHAIN (DECL_ARGUMENTS (current_function_decl));
+
+ expand_start_cond (first_arg, 0);
+ expand_aggr_vbase_init (t_binfo, C_C_D, current_class_decl,
+ vbase_init_list);
+ expand_end_cond ();
+ }
+
+ /* Now, perform initialization of non-virtual base classes. */
+ for (i = 0; i < n_baseclasses; i++)
+ {
+ tree base = current_class_decl;
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ tree init = void_list_node;
+
+ if (TREE_VIA_VIRTUAL (base_binfo))
+ continue;
+
+#if 0 /* Once unsharing happens soon enough. */
+ my_friendly_assert (BINFO_INHERITANCE_CHAIN (base_binfo) == t_binfo);
+#else
+ BINFO_INHERITANCE_CHAIN (base_binfo) = t_binfo;
+#endif
+
+ if (TREE_PURPOSE (rbase_init_list))
+ init = TREE_VALUE (rbase_init_list);
+ else if (TYPE_NEEDS_CONSTRUCTING (BINFO_TYPE (base_binfo)))
+ init = NULL_TREE;
+
+ if (init != void_list_node)
+ {
+ member = convert_pointer_to_real (base_binfo, current_class_decl);
+ expand_aggr_init_1 (base_binfo, 0,
+ build_indirect_ref (member, NULL_PTR), init,
+ BINFO_OFFSET_ZEROP (base_binfo), LOOKUP_NORMAL);
+ expand_cleanups_to (NULL_TREE);
+ }
+
+ if (TYPE_NEEDS_DESTRUCTOR (BINFO_TYPE (base_binfo)))
+ {
+ start_protect ();
+ protect_list = tree_cons (NULL_TREE,
+ build_partial_cleanup_for (base_binfo),
+ protect_list);
+ }
+
+ rbase_init_list = TREE_CHAIN (rbase_init_list);
+ }
+
+ /* Initialize all the virtual function table fields that
+ do come from virtual base classes. */
+ if (TYPE_USES_VIRTUAL_BASECLASSES (t))
+ expand_indirect_vtbls_init (t_binfo, C_C_D, current_class_decl, 0);
+
+ /* Initialize all the virtual function table fields that
+ do not come from virtual base classes. */
+ expand_direct_vtbls_init (t_binfo, t_binfo, 1, 1, current_class_decl);
+
+ for (member = TYPE_FIELDS (t); member; member = TREE_CHAIN (member))
+ {
+ tree init, name;
+ int from_init_list;
+
+ /* member could be, for example, a CONST_DECL for an enumerated
+ tag; we don't want to try to initialize that, since it already
+ has a value. */
+ if (TREE_CODE (member) != FIELD_DECL || !DECL_NAME (member))
+ continue;
+
+ /* See if we had a user-specified member initialization. */
+ if (TREE_PURPOSE (mem_init_list))
+ {
+ name = TREE_PURPOSE (mem_init_list);
+ init = TREE_VALUE (mem_init_list);
+ from_init_list = 1;
+
+ /* Also see if it's ever a COMPONENT_REF here. If it is, we
+ need to do `expand_assignment (name, init, 0, 0);' and
+ a continue. */
+ my_friendly_assert (TREE_CODE (name) != COMPONENT_REF, 349);
+ }
+ else
+ {
+ name = DECL_NAME (member);
+ init = DECL_INITIAL (member);
+
+ from_init_list = 0;
+ }
+
+ perform_member_init (member, name, init, from_init_list, &protect_list);
+ mem_init_list = TREE_CHAIN (mem_init_list);
+ }
+
+ /* Now initialize any members from our bases. */
+ while (mem_init_list)
+ {
+ tree name, init, field;
+
+ if (TREE_PURPOSE (mem_init_list))
+ {
+ name = TREE_PURPOSE (mem_init_list);
+ init = TREE_VALUE (mem_init_list);
+ /* XXX: this may need the COMPONENT_REF operand 0 check if
+ it turns out we actually get them. */
+ field = IDENTIFIER_CLASS_VALUE (name);
+
+ /* If one member shadows another, get the outermost one. */
+ if (TREE_CODE (field) == TREE_LIST)
+ {
+ field = TREE_VALUE (field);
+ if (decl_type_context (field) != current_class_type)
+ cp_error ("field `%D' not in immediate context", field);
+ }
+
+#if 0
+ /* It turns out if you have an anonymous union in the
+ class, a member from it can end up not being on the
+ list of fields (rather, the type is), and therefore
+ won't be seen by the for loop above. */
+
+ /* The code in this for loop is derived from a general loop
+ which had this check in it. Theoretically, we've hit
+ every initialization for the list of members in T, so
+ we shouldn't have anything but these left in this list. */
+ my_friendly_assert (DECL_FIELD_CONTEXT (field) != t, 351);
+#endif
+
+ perform_member_init (field, name, init, 1, &protect_list);
+ }
+ mem_init_list = TREE_CHAIN (mem_init_list);
+ }
+
+ if (! immediately)
+ {
+ do_pending_stack_adjust ();
+ my_friendly_assert (base_init_expr == 0, 207);
+ base_init_expr = expr;
+ TREE_TYPE (expr) = void_type_node;
+ RTL_EXPR_RTL (expr) = const0_rtx;
+ RTL_EXPR_SEQUENCE (expr) = get_insns ();
+ rtl_expr_chain = tree_cons (NULL_TREE, expr, rtl_expr_chain);
+ end_sequence ();
+ TREE_SIDE_EFFECTS (expr) = 1;
+ }
+
+ /* All the implicit try blocks we built up will be zapped
+ when we come to a real binding contour boundary. */
+}
+
+/* Check that all fields are properly initialized after
+ an assignment to `this'. */
+void
+check_base_init (t)
+ tree t;
+{
+ tree member;
+ for (member = TYPE_FIELDS (t); member; member = TREE_CHAIN (member))
+ if (DECL_NAME (member) && TREE_USED (member))
+ cp_error ("field `%D' used before initialized (after assignment to `this')",
+ member);
+}
+
+/* This code sets up the virtual function tables appropriate for
+ the pointer DECL. It is a one-ply initialization.
+
+ BINFO is the exact type that DECL is supposed to be. In
+ multiple inheritance, this might mean "C's A" if C : A, B. */
+static void
+expand_virtual_init (binfo, decl)
+ tree binfo, decl;
+{
+ tree type = BINFO_TYPE (binfo);
+ tree vtbl, vtbl_ptr;
+ tree vtype, vtype_binfo;
+
+ /* This code is crusty. Should be simple, like:
+ vtbl = BINFO_VTABLE (binfo);
+ */
+ vtype = DECL_CONTEXT (CLASSTYPE_VFIELD (type));
+ vtype_binfo = get_binfo (vtype, TREE_TYPE (TREE_TYPE (decl)), 0);
+ vtbl = BINFO_VTABLE (binfo_value (DECL_FIELD_CONTEXT (CLASSTYPE_VFIELD (type)), binfo));
+ assemble_external (vtbl);
+ TREE_USED (vtbl) = 1;
+ vtbl = build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (vtbl)), vtbl);
+ decl = convert_pointer_to_real (vtype_binfo, decl);
+ vtbl_ptr = build_vfield_ref (build_indirect_ref (decl, NULL_PTR), vtype);
+ if (vtbl_ptr == error_mark_node)
+ return;
+
+ /* Have to convert VTBL since array sizes may be different. */
+ vtbl = convert_force (TREE_TYPE (vtbl_ptr), vtbl, 0);
+ expand_expr_stmt (build_modify_expr (vtbl_ptr, NOP_EXPR, vtbl));
+}
+
+/* Subroutine of `expand_aggr_vbase_init'.
+ BINFO is the binfo of the type that is being initialized.
+ INIT_LIST is the list of initializers for the virtual baseclass. */
+static void
+expand_aggr_vbase_init_1 (binfo, exp, addr, init_list)
+ tree binfo, exp, addr, init_list;
+{
+ tree init = purpose_member (binfo, init_list);
+ tree ref = build_indirect_ref (addr, NULL_PTR);
+ if (init)
+ init = TREE_VALUE (init);
+ /* Call constructors, but don't set up vtables. */
+ expand_aggr_init_1 (binfo, exp, ref, init, 0, LOOKUP_COMPLAIN);
+ expand_cleanups_to (NULL_TREE);
+}
+
+/* Initialize this object's virtual base class pointers. This must be
+ done only at the top-level of the object being constructed.
+
+ INIT_LIST is list of initialization for constructor to perform. */
+static void
+expand_aggr_vbase_init (binfo, exp, addr, init_list)
+ tree binfo;
+ tree exp;
+ tree addr;
+ tree init_list;
+{
+ tree type = BINFO_TYPE (binfo);
+
+ if (TYPE_USES_VIRTUAL_BASECLASSES (type))
+ {
+ tree result = init_vbase_pointers (type, addr);
+ tree vbases;
+
+ if (result)
+ expand_expr_stmt (build_compound_expr (result));
+
+ for (vbases = CLASSTYPE_VBASECLASSES (type); vbases;
+ vbases = TREE_CHAIN (vbases))
+ {
+ tree tmp = purpose_member (vbases, result);
+ expand_aggr_vbase_init_1 (vbases, exp,
+ TREE_OPERAND (TREE_VALUE (tmp), 0),
+ init_list);
+ }
+ }
+}
+
+/* Subroutine to perform parser actions for member initialization.
+ S_ID is the scoped identifier.
+ NAME is the name of the member.
+ INIT is the initializer, or `void_type_node' if none. */
+void
+do_member_init (s_id, name, init)
+ tree s_id, name, init;
+{
+ tree binfo, base;
+
+ if (current_class_type == NULL_TREE
+ || ! is_aggr_typedef (s_id, 1))
+ return;
+ binfo = get_binfo (IDENTIFIER_TYPE_VALUE (s_id),
+ current_class_type, 1);
+ if (binfo == error_mark_node)
+ return;
+ if (binfo == 0)
+ {
+ error_not_base_type (IDENTIFIER_TYPE_VALUE (s_id), current_class_type);
+ return;
+ }
+
+ base = convert_pointer_to (binfo, current_class_decl);
+ expand_member_init (build_indirect_ref (base, NULL_PTR), name, init);
+}
+
+/* Function to give error message if member initialization specification
+ is erroneous. FIELD is the member we decided to initialize.
+ TYPE is the type for which the initialization is being performed.
+ FIELD must be a member of TYPE, or the base type from which FIELD
+ comes must not need a constructor.
+
+ MEMBER_NAME is the name of the member. */
+
+static int
+member_init_ok_or_else (field, type, member_name)
+ tree field;
+ tree type;
+ char *member_name;
+{
+ if (field == error_mark_node)
+ return 0;
+ if (field == NULL_TREE)
+ {
+ cp_error ("class `%T' does not have any field named `%s'", type,
+ member_name);
+ return 0;
+ }
+ if (DECL_CONTEXT (field) != type
+ && TYPE_NEEDS_CONSTRUCTING (DECL_CONTEXT (field)))
+ {
+ if (current_function_decl && DECL_CONSTRUCTOR_P (current_function_decl))
+ cp_error ("initialization of `%D' inside constructor for `%T'",
+ field, type);
+ else
+ cp_error ("member `%D' comes from base class needing constructor",
+ field);
+ return 0;
+ }
+ if (TREE_STATIC (field))
+ {
+ cp_error ("field `%#D' is static; only point of initialization is its declaration",
+ field);
+ return 0;
+ }
+
+ return 1;
+}
+
+/* If NAME is a viable field name for the aggregate DECL,
+ and PARMS is a viable parameter list, then expand an _EXPR
+ which describes this initialization.
+
+ Note that we do not need to chase through the class's base classes
+ to look for NAME, because if it's in that list, it will be handled
+ by the constructor for that base class.
+
+ We do not yet have a fixed-point finder to instantiate types
+ being fed to overloaded constructors. If there is a unique
+ constructor, then argument types can be got from that one.
+
+ If INIT is non-NULL, then it the initialization should
+ be placed in `current_base_init_list', where it will be processed
+ by `emit_base_init'. */
+void
+expand_member_init (exp, name, init)
+ tree exp, name, init;
+{
+ extern tree ptr_type_node; /* should be in tree.h */
+
+ tree basetype = NULL_TREE, field;
+ tree parm;
+ tree rval, type;
+ tree actual_name;
+
+ if (exp == NULL_TREE)
+ return; /* complain about this later */
+
+ type = TYPE_MAIN_VARIANT (TREE_TYPE (exp));
+
+ if (name == NULL_TREE && IS_AGGR_TYPE (type))
+ switch (CLASSTYPE_N_BASECLASSES (type))
+ {
+ case 0:
+ error ("base class initializer specified, but no base class to initialize");
+ return;
+ case 1:
+ basetype = TYPE_BINFO_BASETYPE (type, 0);
+ break;
+ default:
+ error ("initializer for unnamed base class ambiguous");
+ cp_error ("(type `%T' uses multiple inheritance)", type);
+ return;
+ }
+
+ if (init)
+ {
+ /* The grammar should not allow fields which have names
+ that are TYPENAMEs. Therefore, if the field has
+ a non-NULL TREE_TYPE, we may assume that this is an
+ attempt to initialize a base class member of the current
+ type. Otherwise, it is an attempt to initialize a
+ member field. */
+
+ if (init == void_type_node)
+ init = NULL_TREE;
+
+ if (name == NULL_TREE || IDENTIFIER_HAS_TYPE_VALUE (name))
+ {
+ tree base_init;
+
+ if (name == NULL_TREE)
+ {
+/*
+ if (basetype)
+ name = TYPE_IDENTIFIER (basetype);
+ else
+ {
+ error ("no base class to initialize");
+ return;
+ }
+*/
+ }
+ else
+ {
+ basetype = IDENTIFIER_TYPE_VALUE (name);
+ if (basetype != type
+ && ! binfo_member (basetype, TYPE_BINFO (type))
+ && ! binfo_member (basetype, CLASSTYPE_VBASECLASSES (type)))
+ {
+ if (IDENTIFIER_CLASS_VALUE (name))
+ goto try_member;
+ if (TYPE_USES_VIRTUAL_BASECLASSES (type))
+ error ("type `%s' is not an immediate or virtual basetype for `%s'",
+ IDENTIFIER_POINTER (name),
+ TYPE_NAME_STRING (type));
+ else
+ error ("type `%s' is not an immediate basetype for `%s'",
+ IDENTIFIER_POINTER (name),
+ TYPE_NAME_STRING (type));
+ return;
+ }
+ }
+
+ if (purpose_member (name, current_base_init_list))
+ {
+ error ("base class `%s' already initialized",
+ IDENTIFIER_POINTER (name));
+ return;
+ }
+
+ base_init = build_tree_list (name, init);
+ TREE_TYPE (base_init) = basetype;
+ current_base_init_list = chainon (current_base_init_list, base_init);
+ }
+ else
+ {
+ tree member_init;
+
+ try_member:
+ field = lookup_field (type, name, 1, 0);
+
+ if (! member_init_ok_or_else (field, type, IDENTIFIER_POINTER (name)))
+ return;
+
+ if (purpose_member (name, current_member_init_list))
+ {
+ error ("field `%s' already initialized", IDENTIFIER_POINTER (name));
+ return;
+ }
+
+ member_init = build_tree_list (name, init);
+ TREE_TYPE (member_init) = TREE_TYPE (field);
+ current_member_init_list = chainon (current_member_init_list, member_init);
+ }
+ return;
+ }
+ else if (name == NULL_TREE)
+ {
+ compiler_error ("expand_member_init: name == NULL_TREE");
+ return;
+ }
+
+ basetype = type;
+ field = lookup_field (basetype, name, 0, 0);
+
+ if (! member_init_ok_or_else (field, basetype, IDENTIFIER_POINTER (name)))
+ return;
+
+ /* now see if there is a constructor for this type
+ which will take these args. */
+
+ if (TYPE_HAS_CONSTRUCTOR (TREE_TYPE (field)))
+ {
+ tree parmtypes, fndecl;
+
+ if (TREE_CODE (exp) == VAR_DECL || TREE_CODE (exp) == PARM_DECL)
+ {
+ /* just know that we've seen something for this node */
+ DECL_INITIAL (exp) = error_mark_node;
+ TREE_USED (exp) = 1;
+ }
+ type = TYPE_MAIN_VARIANT (TREE_TYPE (field));
+ actual_name = TYPE_IDENTIFIER (type);
+ parm = build_component_ref (exp, name, 0, 0);
+
+ /* Now get to the constructor. */
+ fndecl = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), 0);
+ /* Get past destructor, if any. */
+ if (TYPE_HAS_DESTRUCTOR (type))
+ fndecl = DECL_CHAIN (fndecl);
+
+ if (fndecl)
+ my_friendly_assert (TREE_CODE (fndecl) == FUNCTION_DECL, 209);
+
+ /* If the field is unique, we can use the parameter
+ types to guide possible type instantiation. */
+ if (DECL_CHAIN (fndecl) == NULL_TREE)
+ {
+ /* There was a confusion here between
+ FIELD and FNDECL. The following code
+ should be correct, but abort is here
+ to make sure. */
+ my_friendly_abort (48);
+ parmtypes = FUNCTION_ARG_CHAIN (fndecl);
+ }
+ else
+ {
+ parmtypes = NULL_TREE;
+ fndecl = NULL_TREE;
+ }
+
+ init = convert_arguments (parm, parmtypes, NULL_TREE, fndecl, LOOKUP_NORMAL);
+ if (init == NULL_TREE || TREE_TYPE (init) != error_mark_node)
+ rval = build_method_call (NULL_TREE, actual_name, init, NULL_TREE, LOOKUP_NORMAL);
+ else
+ return;
+
+ if (rval != error_mark_node)
+ {
+ /* Now, fill in the first parm with our guy */
+ TREE_VALUE (TREE_OPERAND (rval, 1))
+ = build_unary_op (ADDR_EXPR, parm, 0);
+ TREE_TYPE (rval) = ptr_type_node;
+ TREE_SIDE_EFFECTS (rval) = 1;
+ }
+ }
+ else if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (field)))
+ {
+ parm = build_component_ref (exp, name, 0, 0);
+ expand_aggr_init (parm, NULL_TREE, 0, 0);
+ rval = error_mark_node;
+ }
+
+ /* Now initialize the member. It does not have to
+ be of aggregate type to receive initialization. */
+ if (rval != error_mark_node)
+ expand_expr_stmt (rval);
+}
+
+/* This is like `expand_member_init', only it stores one aggregate
+ value into another.
+
+ INIT comes in two flavors: it is either a value which
+ is to be stored in EXP, or it is a parameter list
+ to go to a constructor, which will operate on EXP.
+ If INIT is not a parameter list for a constructor, then set
+ LOOKUP_ONLYCONVERTING.
+ If FLAGS is LOOKUP_ONLYCONVERTING then it is the = init form of
+ the initializer, if FLAGS is 0, then it is the (init) form.
+ If `init' is a CONSTRUCTOR, then we emit a warning message,
+ explaining that such initializations are invalid.
+
+ ALIAS_THIS is nonzero iff we are initializing something which is
+ essentially an alias for C_C_D. In this case, the base constructor
+ may move it on us, and we must keep track of such deviations.
+
+ If INIT resolves to a CALL_EXPR which happens to return
+ something of the type we are looking for, then we know
+ that we can safely use that call to perform the
+ initialization.
+
+ The virtual function table pointer cannot be set up here, because
+ we do not really know its type.
+
+ Virtual baseclass pointers are also set up here.
+
+ This never calls operator=().
+
+ When initializing, nothing is CONST.
+
+ A default copy constructor may have to be used to perform the
+ initialization.
+
+ A constructor or a conversion operator may have to be used to
+ perform the initialization, but not both, as it would be ambiguous.
+ */
+
+void
+expand_aggr_init (exp, init, alias_this, flags)
+ tree exp, init;
+ int alias_this;
+ int flags;
+{
+ tree type = TREE_TYPE (exp);
+ int was_const = TREE_READONLY (exp);
+ int was_volatile = TREE_THIS_VOLATILE (exp);
+
+ if (init == error_mark_node)
+ return;
+
+ TREE_READONLY (exp) = 0;
+ TREE_THIS_VOLATILE (exp) = 0;
+
+ if (init && TREE_CODE (init) != TREE_LIST)
+ flags |= LOOKUP_ONLYCONVERTING;
+
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ {
+ /* Must arrange to initialize each element of EXP
+ from elements of INIT. */
+ tree itype = init ? TREE_TYPE (init) : NULL_TREE;
+ if (TYPE_READONLY (TREE_TYPE (type)) || TYPE_VOLATILE (TREE_TYPE (type)))
+ {
+ TREE_TYPE (exp) = TYPE_MAIN_VARIANT (type);
+ if (init)
+ TREE_TYPE (init) = TYPE_MAIN_VARIANT (itype);
+ }
+ if (init && TREE_TYPE (init) == NULL_TREE)
+ {
+ /* Handle bad initializers like:
+ class COMPLEX {
+ public:
+ double re, im;
+ COMPLEX(double r = 0.0, double i = 0.0) {re = r; im = i;};
+ ~COMPLEX() {};
+ };
+
+ int main(int argc, char **argv) {
+ COMPLEX zees(1.0, 0.0)[10];
+ }
+ */
+ error ("bad array initializer");
+ return;
+ }
+ expand_vec_init (exp, exp, array_type_nelts (type), init,
+ init && comptypes (TREE_TYPE (init), TREE_TYPE (exp), 1));
+ TREE_READONLY (exp) = was_const;
+ TREE_THIS_VOLATILE (exp) = was_volatile;
+ TREE_TYPE (exp) = type;
+ if (init)
+ TREE_TYPE (init) = itype;
+ return;
+ }
+
+ if (TREE_CODE (exp) == VAR_DECL || TREE_CODE (exp) == PARM_DECL)
+ /* just know that we've seen something for this node */
+ TREE_USED (exp) = 1;
+
+#if 0
+ /* If initializing from a GNU C CONSTRUCTOR, consider the elts in the
+ constructor as parameters to an implicit GNU C++ constructor. */
+ if (init && TREE_CODE (init) == CONSTRUCTOR
+ && TYPE_HAS_CONSTRUCTOR (type)
+ && TREE_TYPE (init) == type)
+ init = CONSTRUCTOR_ELTS (init);
+#endif
+
+ TREE_TYPE (exp) = TYPE_MAIN_VARIANT (type);
+ expand_aggr_init_1 (TYPE_BINFO (type), exp, exp,
+ init, alias_this, LOOKUP_NORMAL|flags);
+ TREE_TYPE (exp) = type;
+ TREE_READONLY (exp) = was_const;
+ TREE_THIS_VOLATILE (exp) = was_volatile;
+}
+
+static void
+expand_default_init (binfo, true_exp, exp, type, init, alias_this, flags)
+ tree binfo;
+ tree true_exp, exp;
+ tree type;
+ tree init;
+ int alias_this;
+ int flags;
+{
+ /* It fails because there may not be a constructor which takes
+ its own type as the first (or only parameter), but which does
+ take other types via a conversion. So, if the thing initializing
+ the expression is a unit element of type X, first try X(X&),
+ followed by initialization by X. If neither of these work
+ out, then look hard. */
+ tree rval;
+ tree parms;
+
+ if (init == NULL_TREE
+ || (TREE_CODE (init) == TREE_LIST && ! TREE_TYPE (init)))
+ {
+ parms = init;
+ if (parms)
+ init = TREE_VALUE (parms);
+ }
+ else if (TREE_CODE (init) == INDIRECT_REF && TREE_HAS_CONSTRUCTOR (init)
+ && TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (init)))
+ {
+ rval = convert_for_initialization (exp, type, init, 0, 0, 0, 0);
+ TREE_USED (rval) = 1;
+ expand_expr_stmt (rval);
+ return;
+ }
+ else
+ parms = build_tree_list (NULL_TREE, init);
+
+ if (TYPE_USES_VIRTUAL_BASECLASSES (type))
+ {
+ if (true_exp == exp)
+ parms = tree_cons (NULL_TREE, integer_one_node, parms);
+ else
+ parms = tree_cons (NULL_TREE, integer_zero_node, parms);
+ flags |= LOOKUP_HAS_IN_CHARGE;
+ }
+
+ if (init && TREE_CHAIN (parms) == NULL_TREE
+ && TYPE_HAS_TRIVIAL_INIT_REF (type)
+ && TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (init)))
+ {
+ rval = build (INIT_EXPR, type, exp, init);
+ TREE_SIDE_EFFECTS (rval) = 1;
+ expand_expr_stmt (rval);
+ }
+ else
+ {
+ if (flags & LOOKUP_ONLYCONVERTING)
+ flags |= LOOKUP_NO_CONVERSION;
+ rval = build_method_call (exp, constructor_name_full (type),
+ parms, binfo, flags);
+
+ /* Private, protected, or otherwise unavailable. */
+ if (rval == error_mark_node)
+ {
+ if (flags & LOOKUP_COMPLAIN)
+ cp_error ("in base initialization for %sclass `%T'",
+ TREE_VIA_VIRTUAL (binfo) ? "virtual base " : "",
+ binfo);
+ }
+ else if (rval == NULL_TREE)
+ my_friendly_abort (361);
+ else
+ {
+ /* p. 222: if the base class assigns to `this', then that
+ value is used in the derived class. */
+ if ((flag_this_is_variable & 1) && alias_this)
+ {
+ TREE_TYPE (rval) = TREE_TYPE (current_class_decl);
+ expand_assignment (current_class_decl, rval, 0, 0);
+ }
+ else
+ expand_expr_stmt (rval);
+ }
+ }
+}
+
+/* This function is responsible for initializing EXP with INIT
+ (if any).
+
+ BINFO is the binfo of the type for who we are performing the
+ initialization. For example, if W is a virtual base class of A and B,
+ and C : A, B.
+ If we are initializing B, then W must contain B's W vtable, whereas
+ were we initializing C, W must contain C's W vtable.
+
+ TRUE_EXP is nonzero if it is the true expression being initialized.
+ In this case, it may be EXP, or may just contain EXP. The reason we
+ need this is because if EXP is a base element of TRUE_EXP, we
+ don't necessarily know by looking at EXP where its virtual
+ baseclass fields should really be pointing. But we do know
+ from TRUE_EXP. In constructors, we don't know anything about
+ the value being initialized.
+
+ ALIAS_THIS serves the same purpose it serves for expand_aggr_init.
+
+ FLAGS is just passes to `build_method_call'. See that function for
+ its description. */
+
+static void
+expand_aggr_init_1 (binfo, true_exp, exp, init, alias_this, flags)
+ tree binfo;
+ tree true_exp, exp;
+ tree init;
+ int alias_this;
+ int flags;
+{
+ tree type = TREE_TYPE (exp);
+ tree init_type = NULL_TREE;
+
+ my_friendly_assert (init != error_mark_node && type != error_mark_node, 211);
+
+ /* Use a function returning the desired type to initialize EXP for us.
+ If the function is a constructor, and its first argument is
+ NULL_TREE, know that it was meant for us--just slide exp on
+ in and expand the constructor. Constructors now come
+ as TARGET_EXPRs. */
+ if (init)
+ {
+ tree init_list = NULL_TREE;
+
+ if (TREE_CODE (init) == TREE_LIST)
+ {
+ init_list = init;
+ if (TREE_CHAIN (init) == NULL_TREE)
+ init = TREE_VALUE (init);
+ }
+
+ init_type = TREE_TYPE (init);
+
+ if (TREE_CODE (init) != TREE_LIST)
+ {
+ if (TREE_CODE (init_type) == ERROR_MARK)
+ return;
+
+#if 0
+ /* These lines are found troublesome 5/11/89. */
+ if (TREE_CODE (init_type) == REFERENCE_TYPE)
+ init_type = TREE_TYPE (init_type);
+#endif
+
+ /* This happens when we use C++'s functional cast notation.
+ If the types match, then just use the TARGET_EXPR
+ directly. Otherwise, we need to create the initializer
+ separately from the object being initialized. */
+ if (TREE_CODE (init) == TARGET_EXPR)
+ {
+ if (TYPE_MAIN_VARIANT (init_type) == TYPE_MAIN_VARIANT (type))
+ {
+ if (TREE_CODE (exp) == VAR_DECL
+ || TREE_CODE (exp) == RESULT_DECL)
+ /* Unify the initialization targets. */
+ DECL_RTL (TREE_OPERAND (init, 0)) = DECL_RTL (exp);
+ else
+ DECL_RTL (TREE_OPERAND (init, 0)) = expand_expr (exp, NULL_RTX, 0, 0);
+
+ expand_expr_stmt (init);
+ return;
+ }
+ else
+ {
+ init = TREE_OPERAND (init, 1);
+ init = build (CALL_EXPR, init_type,
+ TREE_OPERAND (init, 0), TREE_OPERAND (init, 1), 0);
+ TREE_SIDE_EFFECTS (init) = 1;
+ if (init_list)
+ TREE_VALUE (init_list) = init;
+ }
+ }
+
+ if (init_type == type && TREE_CODE (init) == CALL_EXPR
+#if 0
+ /* It is valid to directly initialize from a CALL_EXPR
+ without going through X(X&), apparently. */
+ && ! TYPE_GETS_INIT_REF (type)
+#endif
+ )
+ {
+ /* A CALL_EXPR is a legitimate form of initialization, so
+ we should not print this warning message. */
+#if 0
+ /* Should have gone away due to 5/11/89 change. */
+ if (TREE_CODE (TREE_TYPE (init)) == REFERENCE_TYPE)
+ init = convert_from_reference (init);
+#endif
+ expand_assignment (exp, init, 0, 0);
+ if (exp == DECL_RESULT (current_function_decl))
+ {
+ /* Failing this assertion means that the return value
+ from receives multiple initializations. */
+ my_friendly_assert (DECL_INITIAL (exp) == NULL_TREE
+ || DECL_INITIAL (exp) == error_mark_node,
+ 212);
+ DECL_INITIAL (exp) = init;
+ }
+ return;
+ }
+ else if (init_type == type
+ && TREE_CODE (init) == COND_EXPR)
+ {
+ /* Push value to be initialized into the cond, where possible.
+ Avoid spurious warning messages when initializing the
+ result of this function. */
+ TREE_OPERAND (init, 1)
+ = build_modify_expr (exp, INIT_EXPR, TREE_OPERAND (init, 1));
+ if (exp == DECL_RESULT (current_function_decl))
+ DECL_INITIAL (exp) = NULL_TREE;
+ TREE_OPERAND (init, 2)
+ = build_modify_expr (exp, INIT_EXPR, TREE_OPERAND (init, 2));
+ if (exp == DECL_RESULT (current_function_decl))
+ DECL_INITIAL (exp) = init;
+ TREE_SIDE_EFFECTS (init) = 1;
+ expand_expr (init, const0_rtx, VOIDmode, 0);
+ free_temp_slots ();
+ return;
+ }
+ }
+
+ /* We did not know what we were initializing before. Now we do. */
+ if (TREE_CODE (init) == TARGET_EXPR)
+ {
+ tree tmp = TREE_OPERAND (TREE_OPERAND (init, 1), 1);
+
+ if (TREE_CODE (TREE_VALUE (tmp)) == NOP_EXPR
+ && TREE_OPERAND (TREE_VALUE (tmp), 0) == integer_zero_node)
+ {
+ /* In order for this to work for RESULT_DECLs, if their
+ type has a constructor, then they must be BLKmode
+ so that they will be meaningfully addressable. */
+ tree arg = build_unary_op (ADDR_EXPR, exp, 0);
+ init = TREE_OPERAND (init, 1);
+ init = build (CALL_EXPR, build_pointer_type (TREE_TYPE (init)),
+ TREE_OPERAND (init, 0), TREE_OPERAND (init, 1), 0);
+ TREE_SIDE_EFFECTS (init) = 1;
+ TREE_VALUE (TREE_OPERAND (init, 1))
+ = convert_pointer_to (TREE_TYPE (TREE_TYPE (TREE_VALUE (tmp))), arg);
+
+ if (alias_this)
+ {
+ expand_assignment (current_function_decl, init, 0, 0);
+ return;
+ }
+ if (exp == DECL_RESULT (current_function_decl))
+ {
+ if (DECL_INITIAL (DECL_RESULT (current_function_decl)))
+ fatal ("return value from function receives multiple initializations");
+ DECL_INITIAL (exp) = init;
+ }
+ expand_expr_stmt (init);
+ return;
+ }
+ }
+
+ if (TREE_CODE (exp) == VAR_DECL
+ && TREE_CODE (init) == CONSTRUCTOR
+ && TREE_HAS_CONSTRUCTOR (init))
+ {
+ tree t = store_init_value (exp, init);
+ if (!t)
+ {
+ expand_decl_init (exp);
+ return;
+ }
+ t = build (INIT_EXPR, type, exp, init);
+ TREE_SIDE_EFFECTS (t) = 1;
+ expand_expr_stmt (t);
+ return;
+ }
+
+ /* Handle this case: when calling a constructor: xyzzy foo(bar);
+ which really means: xyzzy foo = bar; Ugh!
+
+ More useful for this case: xyzzy *foo = new xyzzy (bar); */
+
+ if (! TYPE_NEEDS_CONSTRUCTING (type) && ! IS_AGGR_TYPE (type))
+ {
+ if (init_list && TREE_CHAIN (init_list))
+ {
+ warning ("initializer list being treated as compound expression");
+ init = convert (type, build_compound_expr (init_list));
+ if (init == error_mark_node)
+ return;
+ }
+
+ expand_assignment (exp, init, 0, 0);
+
+ return;
+ }
+ /* See whether we can go through a type conversion operator.
+ This wins over going through a non-existent constructor. If
+ there is a constructor, it is ambiguous. */
+ if (TREE_CODE (init) != TREE_LIST)
+ {
+ tree ttype = TREE_CODE (init_type) == REFERENCE_TYPE
+ ? TREE_TYPE (init_type) : init_type;
+
+ if (ttype != type && IS_AGGR_TYPE (ttype))
+ {
+ tree rval = build_type_conversion (CONVERT_EXPR, type, init, 0);
+
+ if (rval)
+ {
+ /* See if there is a constructor for``type'' that takes a
+ ``ttype''-typed object. */
+ tree parms = build_tree_list (NULL_TREE, init);
+ tree as_cons = NULL_TREE;
+ if (TYPE_HAS_CONSTRUCTOR (type))
+ as_cons = build_method_call (exp, constructor_name_full (type),
+ parms, binfo,
+ LOOKUP_SPECULATIVELY|LOOKUP_NO_CONVERSION);
+ if (as_cons != NULL_TREE && as_cons != error_mark_node)
+ /* ANSI C++ June 5 1992 WP 12.3.2.6.1 */
+ cp_error ("ambiguity between conversion to `%T' and constructor",
+ type);
+ else
+ expand_assignment (exp, rval, 0, 0);
+ return;
+ }
+ }
+ }
+ }
+
+ /* Handle default copy constructors here, does not matter if there is
+ a constructor or not. */
+ if (type == init_type && IS_AGGR_TYPE (type)
+ && init && TREE_CODE (init) != TREE_LIST)
+ expand_default_init (binfo, true_exp, exp, type, init, alias_this, flags);
+ /* Not sure why this is here... */
+ else if (TYPE_HAS_CONSTRUCTOR (type))
+ expand_default_init (binfo, true_exp, exp, type, init, alias_this, flags);
+ else if (TREE_CODE (type) == ARRAY_TYPE)
+ {
+ if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (type)))
+ expand_vec_init (exp, exp, array_type_nelts (type), init, 0);
+ else if (TYPE_VIRTUAL_P (TREE_TYPE (type)))
+ sorry ("arrays of objects with virtual functions but no constructors");
+ }
+ else
+ expand_recursive_init (binfo, true_exp, exp, init,
+ CLASSTYPE_BASE_INIT_LIST (type), alias_this);
+}
+
+/* A pointer which holds the initializer. First call to
+ expand_aggr_init gets this value pointed to, and sets it to init_null. */
+static tree *init_ptr, init_null;
+
+/* Subroutine of expand_recursive_init:
+
+ ADDR is the address of the expression being initialized.
+ INIT_LIST is the cons-list of initializations to be performed.
+ ALIAS_THIS is its same, lovable self. */
+static void
+expand_recursive_init_1 (binfo, true_exp, addr, init_list, alias_this)
+ tree binfo, true_exp, addr;
+ tree init_list;
+ int alias_this;
+{
+ while (init_list)
+ {
+ if (TREE_PURPOSE (init_list))
+ {
+ if (TREE_CODE (TREE_PURPOSE (init_list)) == FIELD_DECL)
+ {
+ tree member = TREE_PURPOSE (init_list);
+ tree subexp = build_indirect_ref (convert_pointer_to (TREE_VALUE (init_list), addr), NULL_PTR);
+ tree member_base = build (COMPONENT_REF, TREE_TYPE (member), subexp, member);
+ if (IS_AGGR_TYPE (TREE_TYPE (member)))
+ expand_aggr_init (member_base, DECL_INITIAL (member), 0, 0);
+ else if (TREE_CODE (TREE_TYPE (member)) == ARRAY_TYPE
+ && TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (member)))
+ {
+ member_base = save_expr (default_conversion (member_base));
+ expand_vec_init (member, member_base,
+ array_type_nelts (TREE_TYPE (member)),
+ DECL_INITIAL (member), 0);
+ }
+ else
+ expand_expr_stmt (build_modify_expr (member_base, INIT_EXPR, DECL_INITIAL (member)));
+ }
+ else if (TREE_CODE (TREE_PURPOSE (init_list)) == TREE_LIST)
+ {
+ expand_recursive_init_1 (binfo, true_exp, addr, TREE_PURPOSE (init_list), alias_this);
+ expand_recursive_init_1 (binfo, true_exp, addr, TREE_VALUE (init_list), alias_this);
+ }
+ else if (TREE_CODE (TREE_PURPOSE (init_list)) == ERROR_MARK)
+ {
+ /* Only initialize the virtual function tables if we
+ are initializing the ultimate users of those vtables. */
+ if (TREE_VALUE (init_list))
+ {
+ /* We have to ensure that the first argment to
+ expand_virtual_init is in binfo's hierarchy. */
+ /* Is it the case that this is exactly the right binfo? */
+ /* If it is ok, then fixup expand_virtual_init, to make
+ it much simpler. */
+ expand_virtual_init (get_binfo (TREE_VALUE (init_list), binfo, 0),
+ addr);
+ if (TREE_VALUE (init_list) == binfo
+ && TYPE_USES_VIRTUAL_BASECLASSES (BINFO_TYPE (binfo)))
+ expand_indirect_vtbls_init (binfo, true_exp, addr, 1);
+ }
+ }
+ else
+ my_friendly_abort (49);
+ }
+ else if (TREE_VALUE (init_list)
+ && TREE_CODE (TREE_VALUE (init_list)) == TREE_VEC)
+ {
+ tree subexp = build_indirect_ref (convert_pointer_to (TREE_VALUE (init_list), addr), NULL_PTR);
+ expand_aggr_init_1 (binfo, true_exp, subexp, *init_ptr,
+ alias_this && BINFO_OFFSET_ZEROP (TREE_VALUE (init_list)),
+ LOOKUP_COMPLAIN);
+
+ /* INIT_PTR is used up. */
+ init_ptr = &init_null;
+ }
+ else
+ my_friendly_abort (50);
+ init_list = TREE_CHAIN (init_list);
+ }
+}
+
+/* Initialize EXP with INIT. Type EXP does not have a constructor,
+ but it has a baseclass with a constructor or a virtual function
+ table which needs initializing.
+
+ INIT_LIST is a cons-list describing what parts of EXP actually
+ need to be initialized. INIT is given to the *unique*, first
+ constructor within INIT_LIST. If there are multiple first
+ constructors, such as with multiple inheritance, INIT must
+ be zero or an ambiguity error is reported.
+
+ ALIAS_THIS is passed from `expand_aggr_init'. See comments
+ there. */
+
+static void
+expand_recursive_init (binfo, true_exp, exp, init, init_list, alias_this)
+ tree binfo, true_exp, exp, init;
+ tree init_list;
+ int alias_this;
+{
+ tree *old_init_ptr = init_ptr;
+ tree addr = build_unary_op (ADDR_EXPR, exp, 0);
+ init_ptr = &init;
+
+ if (true_exp == exp && TYPE_USES_VIRTUAL_BASECLASSES (BINFO_TYPE (binfo)))
+ {
+ expand_aggr_vbase_init (binfo, exp, addr, init_list);
+ expand_indirect_vtbls_init (binfo, true_exp, addr, 1);
+ }
+ expand_recursive_init_1 (binfo, true_exp, addr, init_list, alias_this);
+
+ if (*init_ptr)
+ {
+ tree type = TREE_TYPE (exp);
+
+ if (TREE_CODE (type) == REFERENCE_TYPE)
+ type = TREE_TYPE (type);
+ if (IS_AGGR_TYPE (type))
+ cp_error ("unexpected argument to constructor `%T'", type);
+ else
+ error ("unexpected argument to constructor");
+ }
+ init_ptr = old_init_ptr;
+}
+
+/* Report an error if NAME is not the name of a user-defined,
+ aggregate type. If OR_ELSE is nonzero, give an error message. */
+int
+is_aggr_typedef (name, or_else)
+ tree name;
+ int or_else;
+{
+ tree type;
+
+ if (name == error_mark_node)
+ return 0;
+
+ if (IDENTIFIER_HAS_TYPE_VALUE (name))
+ type = IDENTIFIER_TYPE_VALUE (name);
+ else
+ {
+ if (or_else)
+ cp_error ("`%T' is not an aggregate typedef", name);
+ return 0;
+ }
+
+ if (! IS_AGGR_TYPE (type)
+ && TREE_CODE (type) != TEMPLATE_TYPE_PARM)
+ {
+ if (or_else)
+ cp_error ("`%T' is not an aggregate type", type);
+ return 0;
+ }
+ return 1;
+}
+
+/* Like is_aggr_typedef, but returns typedef if successful. */
+tree
+get_aggr_from_typedef (name, or_else)
+ tree name;
+ int or_else;
+{
+ tree type;
+
+ if (name == error_mark_node)
+ return NULL_TREE;
+
+ if (IDENTIFIER_HAS_TYPE_VALUE (name))
+ type = IDENTIFIER_TYPE_VALUE (name);
+ else
+ {
+ if (or_else)
+ cp_error ("`%T' fails to be an aggregate typedef", name);
+ return NULL_TREE;
+ }
+
+ if (! IS_AGGR_TYPE (type)
+ && TREE_CODE (type) != TEMPLATE_TYPE_PARM)
+ {
+ if (or_else)
+ cp_error ("type `%T' is of non-aggregate type", type);
+ return NULL_TREE;
+ }
+ return type;
+}
+
+tree
+get_type_value (name)
+ tree name;
+{
+ if (name == error_mark_node)
+ return NULL_TREE;
+
+ if (IDENTIFIER_HAS_TYPE_VALUE (name))
+ return IDENTIFIER_TYPE_VALUE (name);
+ else
+ return NULL_TREE;
+}
+
+
+/* This code could just as well go in `class.c', but is placed here for
+ modularity. */
+
+/* For an expression of the form CNAME :: NAME (PARMLIST), build
+ the appropriate function call. */
+tree
+build_member_call (cname, name, parmlist)
+ tree cname, name, parmlist;
+{
+ tree type, t;
+ tree method_name = name;
+ int dtor = 0;
+ int dont_use_this = 0;
+ tree basetype_path, decl;
+
+ if (TREE_CODE (method_name) == BIT_NOT_EXPR)
+ {
+ method_name = TREE_OPERAND (method_name, 0);
+ dtor = 1;
+ }
+
+ if (TREE_CODE (cname) == SCOPE_REF)
+ cname = resolve_scope_to_name (NULL_TREE, cname);
+
+ /* This shouldn't be here, and build_member_call shouldn't appear in
+ parse.y! (mrs) */
+ if (cname && get_aggr_from_typedef (cname, 0) == 0
+ && TREE_CODE (cname) == IDENTIFIER_NODE)
+ {
+ tree ns = lookup_name (cname, 0);
+ if (ns && TREE_CODE (ns) == NAMESPACE_DECL)
+ {
+ return build_x_function_call (build_offset_ref (cname, name), parmlist, current_class_decl);
+ }
+ }
+
+ if (cname == NULL_TREE || ! (type = get_aggr_from_typedef (cname, 1)))
+ return error_mark_node;
+
+ /* An operator we did not like. */
+ if (name == NULL_TREE)
+ return error_mark_node;
+
+ if (dtor)
+ {
+#if 0
+ /* Everything can explicitly call a destructor; see 12.4 */
+ if (! TYPE_HAS_DESTRUCTOR (type))
+ cp_error ("type `%#T' does not have a destructor", type);
+ else
+#endif
+ cp_error ("cannot call destructor `%T::~%T' without object", type,
+ method_name);
+ return error_mark_node;
+ }
+
+ /* No object? Then just fake one up, and let build_method_call
+ figure out what to do. */
+ if (current_class_type == 0
+ || get_base_distance (type, current_class_type, 0, &basetype_path) == -1)
+ dont_use_this = 1;
+
+ if (dont_use_this)
+ {
+ basetype_path = TYPE_BINFO (type);
+ decl = build1 (NOP_EXPR, build_pointer_type (type), error_mark_node);
+ }
+ else if (current_class_decl == 0)
+ {
+ dont_use_this = 1;
+ decl = build1 (NOP_EXPR, build_pointer_type (type), error_mark_node);
+ }
+ else
+ {
+ tree olddecl = current_class_decl;
+ tree oldtype = TREE_TYPE (TREE_TYPE (olddecl));
+ if (oldtype != type)
+ {
+ tree newtype = build_type_variant (type, TYPE_READONLY (oldtype),
+ TYPE_VOLATILE (oldtype));
+ decl = convert_force (build_pointer_type (newtype), olddecl, 0);
+ }
+ else
+ decl = olddecl;
+ }
+
+ decl = build_indirect_ref (decl, NULL_PTR);
+
+ if (method_name == constructor_name (type)
+ || method_name == constructor_name_full (type))
+ return build_functional_cast (type, parmlist);
+ if (t = lookup_fnfields (basetype_path, method_name, 0))
+ return build_method_call (decl, method_name, parmlist, basetype_path,
+ LOOKUP_NORMAL|LOOKUP_NONVIRTUAL);
+ if (TREE_CODE (name) == IDENTIFIER_NODE
+ && ((t = lookup_field (TYPE_BINFO (type), name, 1, 0))))
+ {
+ if (t == error_mark_node)
+ return error_mark_node;
+ if (TREE_CODE (t) == FIELD_DECL)
+ {
+ if (dont_use_this)
+ {
+ cp_error ("invalid use of non-static field `%D'", t);
+ return error_mark_node;
+ }
+ decl = build (COMPONENT_REF, TREE_TYPE (t), decl, t);
+ }
+ else if (TREE_CODE (t) == VAR_DECL)
+ decl = t;
+ else
+ {
+ cp_error ("invalid use of member `%D'", t);
+ return error_mark_node;
+ }
+ if (TYPE_LANG_SPECIFIC (TREE_TYPE (decl))
+ && TYPE_OVERLOADS_CALL_EXPR (TREE_TYPE (decl)))
+ return build_opfncall (CALL_EXPR, LOOKUP_NORMAL, decl, parmlist, NULL_TREE);
+ return build_function_call (decl, parmlist);
+ }
+ else
+ {
+ cp_error ("no method `%T::%D'", type, name);
+ return error_mark_node;
+ }
+}
+
+/* Build a reference to a member of an aggregate. This is not a
+ C++ `&', but really something which can have its address taken,
+ and then act as a pointer to member, for example CNAME :: FIELD
+ can have its address taken by saying & CNAME :: FIELD.
+
+ @@ Prints out lousy diagnostics for operator <typename>
+ @@ fields.
+
+ @@ This function should be rewritten and placed in search.c. */
+tree
+build_offset_ref (cname, name)
+ tree cname, name;
+{
+ tree decl, type, fnfields, fields, t = error_mark_node;
+ tree basetypes = NULL_TREE;
+ int dtor = 0;
+
+ if (TREE_CODE (cname) == SCOPE_REF)
+ cname = resolve_scope_to_name (NULL_TREE, cname);
+
+ /* Handle namespace names fully here. */
+ if (TREE_CODE (cname) == IDENTIFIER_NODE
+ && get_aggr_from_typedef (cname, 0) == 0)
+ {
+ tree ns = lookup_name (cname, 0);
+ tree val;
+ if (ns && TREE_CODE (ns) == NAMESPACE_DECL)
+ {
+ val = lookup_namespace_name (ns, name);
+ if (val)
+ return val;
+ cp_error ("namespace `%D' has no member named `%D'", ns, name);
+ return error_mark_node;
+ }
+ }
+
+ if (cname == NULL_TREE || ! is_aggr_typedef (cname, 1))
+ return error_mark_node;
+
+ type = IDENTIFIER_TYPE_VALUE (cname);
+
+ if (TREE_CODE (name) == BIT_NOT_EXPR)
+ {
+ dtor = 1;
+ name = TREE_OPERAND (name, 0);
+ }
+
+ if (TYPE_SIZE (type) == 0)
+ {
+ t = IDENTIFIER_CLASS_VALUE (name);
+ if (t == 0)
+ {
+ cp_error ("incomplete type `%T' does not have member `%D'", type,
+ name);
+ return error_mark_node;
+ }
+ if (TREE_CODE (t) == TYPE_DECL || TREE_CODE (t) == VAR_DECL
+ || TREE_CODE (t) == CONST_DECL)
+ {
+ TREE_USED (t) = 1;
+ return t;
+ }
+ if (TREE_CODE (t) == FIELD_DECL)
+ sorry ("use of member in incomplete aggregate type");
+ else if (TREE_CODE (t) == FUNCTION_DECL)
+ sorry ("use of member function in incomplete aggregate type");
+ else
+ my_friendly_abort (52);
+ return error_mark_node;
+ }
+
+#if 0
+ if (TREE_CODE (name) == TYPE_EXPR)
+ /* Pass a TYPE_DECL to build_component_type_expr. */
+ return build_component_type_expr (TYPE_NAME (TREE_TYPE (cname)),
+ name, NULL_TREE, 1);
+#endif
+
+ if (current_class_type == 0
+ || get_base_distance (type, current_class_type, 0, &basetypes) == -1)
+ {
+ basetypes = TYPE_BINFO (type);
+ decl = build1 (NOP_EXPR,
+ IDENTIFIER_TYPE_VALUE (cname),
+ error_mark_node);
+ }
+ else if (current_class_decl == 0)
+ decl = build1 (NOP_EXPR, IDENTIFIER_TYPE_VALUE (cname),
+ error_mark_node);
+ else
+ decl = C_C_D;
+
+ fnfields = lookup_fnfields (basetypes, name, 1);
+ fields = lookup_field (basetypes, name, 0, 0);
+
+ if (fields == error_mark_node || fnfields == error_mark_node)
+ return error_mark_node;
+
+ /* A lot of this logic is now handled in lookup_field and
+ lookup_fnfield. */
+ if (fnfields)
+ {
+ basetypes = TREE_PURPOSE (fnfields);
+
+ /* Go from the TREE_BASELINK to the member function info. */
+ t = TREE_VALUE (fnfields);
+
+ if (fields)
+ {
+ if (DECL_FIELD_CONTEXT (fields) == DECL_FIELD_CONTEXT (t))
+ {
+ error ("ambiguous member reference: member `%s' defined as both field and function",
+ IDENTIFIER_POINTER (name));
+ return error_mark_node;
+ }
+ if (UNIQUELY_DERIVED_FROM_P (DECL_FIELD_CONTEXT (fields), DECL_FIELD_CONTEXT (t)))
+ ;
+ else if (UNIQUELY_DERIVED_FROM_P (DECL_FIELD_CONTEXT (t), DECL_FIELD_CONTEXT (fields)))
+ t = fields;
+ else
+ {
+ error ("ambiguous member reference: member `%s' derives from distinct classes in multiple inheritance lattice");
+ return error_mark_node;
+ }
+ }
+
+ if (t == TREE_VALUE (fnfields))
+ {
+ extern int flag_save_memoized_contexts;
+
+ if (DECL_CHAIN (t) == NULL_TREE || dtor)
+ {
+ enum access_type access;
+
+ /* unique functions are handled easily. */
+ unique:
+ access = compute_access (basetypes, t);
+ if (access == access_protected)
+ {
+ cp_error_at ("member function `%#D' is protected", t);
+ error ("in this context");
+ return error_mark_node;
+ }
+ if (access == access_private)
+ {
+ cp_error_at ("member function `%#D' is private", t);
+ error ("in this context");
+ return error_mark_node;
+ }
+ assemble_external (t);
+ return build (OFFSET_REF, TREE_TYPE (t), decl, t);
+ }
+
+ /* overloaded functions may need more work. */
+ if (cname == name)
+ {
+ if (TYPE_HAS_DESTRUCTOR (type)
+ && DECL_CHAIN (DECL_CHAIN (t)) == NULL_TREE)
+ {
+ t = DECL_CHAIN (t);
+ goto unique;
+ }
+ }
+ /* FNFIELDS is most likely allocated on the search_obstack,
+ which will go away after this class scope. If we need
+ to save this value for later (either for memoization
+ or for use as an initializer for a static variable), then
+ do so here.
+
+ ??? The smart thing to do for the case of saving initializers
+ is to resolve them before we're done with this scope. */
+ if (!TREE_PERMANENT (fnfields)
+ && ((flag_save_memoized_contexts && global_bindings_p ())
+ || ! allocation_temporary_p ()))
+ fnfields = copy_list (fnfields);
+
+ for (t = TREE_VALUE (fnfields); t; t = DECL_CHAIN (t))
+ assemble_external (t);
+
+ t = build_tree_list (error_mark_node, fnfields);
+ TREE_TYPE (t) = build_offset_type (type, unknown_type_node);
+ return t;
+ }
+ }
+
+ /* Now that we know we are looking for a field, see if we
+ have access to that field. Lookup_field will give us the
+ error message. */
+
+ t = lookup_field (basetypes, name, 1, 0);
+
+ if (t == error_mark_node)
+ return error_mark_node;
+
+ if (t == NULL_TREE)
+ {
+ cp_error ("`%D' is not a member of type `%T'", name, type);
+ return error_mark_node;
+ }
+
+ if (TREE_CODE (t) == TYPE_DECL)
+ {
+ TREE_USED (t) = 1;
+ return t;
+ }
+ /* static class members and class-specific enum
+ values can be returned without further ado. */
+ if (TREE_CODE (t) == VAR_DECL || TREE_CODE (t) == CONST_DECL)
+ {
+ assemble_external (t);
+ TREE_USED (t) = 1;
+ return t;
+ }
+
+ if (TREE_CODE (t) == FIELD_DECL && DECL_BIT_FIELD (t))
+ {
+ cp_error ("illegal pointer to bit field `%D'", t);
+ return error_mark_node;
+ }
+
+ /* static class functions too. */
+ if (TREE_CODE (t) == FUNCTION_DECL && TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE)
+ my_friendly_abort (53);
+
+ /* In member functions, the form `cname::name' is no longer
+ equivalent to `this->cname::name'. */
+ return build (OFFSET_REF, build_offset_type (type, TREE_TYPE (t)), decl, t);
+}
+
+/* Given an object EXP and a member function reference MEMBER,
+ return the address of the actual member function. */
+tree
+get_member_function (exp_addr_ptr, exp, member)
+ tree *exp_addr_ptr;
+ tree exp, member;
+{
+ tree ctype = TREE_TYPE (exp);
+ tree function = save_expr (build_unary_op (ADDR_EXPR, member, 0));
+
+ if (TYPE_VIRTUAL_P (ctype)
+ || (flag_all_virtual == 1 && TYPE_OVERLOADS_METHOD_CALL_EXPR (ctype)))
+ {
+ tree e0, e1, e3;
+ tree exp_addr;
+
+ /* Save away the unadulterated `this' pointer. */
+ exp_addr = save_expr (*exp_addr_ptr);
+
+ /* Cast function to signed integer. */
+ e0 = build1 (NOP_EXPR, integer_type_node, function);
+
+ /* There is a hack here that takes advantage of
+ twos complement arithmetic, and the fact that
+ there are more than one UNITS to the WORD.
+ If the high bit is set for the `function',
+ then we pretend it is a virtual function,
+ and the array indexing will knock this bit
+ out the top, leaving a valid index. */
+ if (UNITS_PER_WORD <= 1)
+ my_friendly_abort (54);
+
+ e1 = build (GT_EXPR, boolean_type_node, e0, integer_zero_node);
+ e1 = build_compound_expr (tree_cons (NULL_TREE, exp_addr,
+ build_tree_list (NULL_TREE, e1)));
+ e1 = save_expr (e1);
+
+ if (TREE_SIDE_EFFECTS (*exp_addr_ptr))
+ {
+ exp = build_indirect_ref (exp_addr, NULL_PTR);
+ *exp_addr_ptr = exp_addr;
+ }
+
+ /* This is really hairy: if the function pointer is a pointer
+ to a non-virtual member function, then we can't go mucking
+ with the `this' pointer (any more than we already have to
+ this point). If it is a pointer to a virtual member function,
+ then we have to adjust the `this' pointer according to
+ what the virtual function table tells us. */
+
+ e3 = build_vfn_ref (exp_addr_ptr, exp, e0);
+ my_friendly_assert (e3 != error_mark_node, 213);
+
+ /* Change this pointer type from `void *' to the
+ type it is really supposed to be. */
+ TREE_TYPE (e3) = TREE_TYPE (function);
+
+ /* If non-virtual, use what we had originally. Otherwise,
+ use the value we get from the virtual function table. */
+ *exp_addr_ptr = build_conditional_expr (e1, exp_addr, *exp_addr_ptr);
+
+ function = build_conditional_expr (e1, function, e3);
+ }
+ return build_indirect_ref (function, NULL_PTR);
+}
+
+/* If a OFFSET_REF made it through to here, then it did
+ not have its address taken. */
+
+tree
+resolve_offset_ref (exp)
+ tree exp;
+{
+ tree type = TREE_TYPE (exp);
+ tree base = NULL_TREE;
+ tree member;
+ tree basetype, addr;
+
+ if (TREE_CODE (exp) == TREE_LIST)
+ return build_unary_op (ADDR_EXPR, exp, 0);
+
+ if (TREE_CODE (exp) != OFFSET_REF)
+ {
+ my_friendly_assert (TREE_CODE (type) == OFFSET_TYPE, 214);
+ if (TYPE_OFFSET_BASETYPE (type) != current_class_type)
+ {
+ error ("object missing in use of pointer-to-member construct");
+ return error_mark_node;
+ }
+ member = exp;
+ type = TREE_TYPE (type);
+ base = C_C_D;
+ }
+ else
+ {
+ member = TREE_OPERAND (exp, 1);
+ base = TREE_OPERAND (exp, 0);
+ }
+
+ if ((TREE_CODE (member) == VAR_DECL
+ && ! TYPE_PTRMEMFUNC_P (TREE_TYPE (member)))
+ || TREE_CODE (TREE_TYPE (member)) == FUNCTION_TYPE)
+ {
+ /* These were static members. */
+ if (mark_addressable (member) == 0)
+ return error_mark_node;
+ return member;
+ }
+
+ /* Syntax error can cause a member which should
+ have been seen as static to be grok'd as non-static. */
+ if (TREE_CODE (member) == FIELD_DECL && C_C_D == NULL_TREE)
+ {
+ if (TREE_ADDRESSABLE (member) == 0)
+ {
+ cp_error_at ("member `%D' is non-static but referenced as a static member",
+ member);
+ error ("at this point in file");
+ TREE_ADDRESSABLE (member) = 1;
+ }
+ return error_mark_node;
+ }
+
+ /* The first case is really just a reference to a member of `this'. */
+ if (TREE_CODE (member) == FIELD_DECL
+ && (base == C_C_D
+ || (TREE_CODE (base) == NOP_EXPR
+ && TREE_OPERAND (base, 0) == error_mark_node)))
+ {
+ tree basetype_path;
+ enum access_type access;
+
+ if (TREE_CODE (exp) == OFFSET_REF && TREE_CODE (type) == OFFSET_TYPE)
+ basetype = TYPE_OFFSET_BASETYPE (type);
+ else
+ basetype = DECL_CONTEXT (member);
+
+ base = current_class_decl;
+
+ if (get_base_distance (basetype, TREE_TYPE (TREE_TYPE (base)), 0, &basetype_path) < 0)
+ {
+ error_not_base_type (basetype, TREE_TYPE (TREE_TYPE (base)));
+ return error_mark_node;
+ }
+ addr = convert_pointer_to (basetype, base);
+ access = compute_access (basetype_path, member);
+ if (access == access_public)
+ return build (COMPONENT_REF, TREE_TYPE (member),
+ build_indirect_ref (addr, NULL_PTR), member);
+ if (access == access_protected)
+ {
+ cp_error_at ("member `%D' is protected", member);
+ error ("in this context");
+ return error_mark_node;
+ }
+ if (access == access_private)
+ {
+ cp_error_at ("member `%D' is private", member);
+ error ("in this context");
+ return error_mark_node;
+ }
+ my_friendly_abort (55);
+ }
+
+ /* If this is a reference to a member function, then return
+ the address of the member function (which may involve going
+ through the object's vtable), otherwise, return an expression
+ for the dereferenced pointer-to-member construct. */
+ addr = build_unary_op (ADDR_EXPR, base, 0);
+
+ if (TREE_CODE (TREE_TYPE (member)) == METHOD_TYPE)
+ {
+ basetype = DECL_CLASS_CONTEXT (member);
+ addr = convert_pointer_to (basetype, addr);
+ return build_unary_op (ADDR_EXPR, get_member_function (&addr, build_indirect_ref (addr, NULL_PTR), member), 0);
+ }
+ else if (TREE_CODE (TREE_TYPE (member)) == OFFSET_TYPE)
+ {
+ basetype = TYPE_OFFSET_BASETYPE (TREE_TYPE (member));
+ addr = convert_pointer_to (basetype, addr);
+ member = convert (ptrdiff_type_node,
+ build_unary_op (ADDR_EXPR, member, 0));
+ return build1 (INDIRECT_REF, type,
+ build (PLUS_EXPR, build_pointer_type (type),
+ addr, member));
+ }
+ else if (TYPE_PTRMEMFUNC_P (TREE_TYPE (member)))
+ {
+ return get_member_function_from_ptrfunc (&addr, member);
+ }
+ my_friendly_abort (56);
+ /* NOTREACHED */
+ return NULL_TREE;
+}
+
+/* Return either DECL or its known constant value (if it has one). */
+
+tree
+decl_constant_value (decl)
+ tree decl;
+{
+ if (! TREE_THIS_VOLATILE (decl)
+#if 0
+ /* These may be necessary for C, but they break C++. */
+ ! TREE_PUBLIC (decl)
+ /* Don't change a variable array bound or initial value to a constant
+ in a place where a variable is invalid. */
+ && ! pedantic
+#endif /* 0 */
+ && DECL_INITIAL (decl) != 0
+ && TREE_CODE (DECL_INITIAL (decl)) != ERROR_MARK
+ /* This is invalid if initial value is not constant.
+ If it has either a function call, a memory reference,
+ or a variable, then re-evaluating it could give different results. */
+ && TREE_CONSTANT (DECL_INITIAL (decl))
+ /* Check for cases where this is sub-optimal, even though valid. */
+ && TREE_CODE (DECL_INITIAL (decl)) != CONSTRUCTOR
+#if 0
+ /* We must allow this to work outside of functions so that
+ static constants can be used for array sizes. */
+ && current_function_decl != 0
+ && DECL_MODE (decl) != BLKmode
+#endif
+ )
+ return DECL_INITIAL (decl);
+ return decl;
+}
+
+/* Friend handling routines. */
+/* Friend data structures:
+
+ Lists of friend functions come from TYPE_DECL nodes. Since all
+ aggregate types are automatically typedef'd, these nodes are guaranteed
+ to exist.
+
+ The TREE_PURPOSE of a friend list is the name of the friend,
+ and its TREE_VALUE is another list.
+
+ For each element of that list, either the TREE_VALUE or the TREE_PURPOSE
+ will be filled in, but not both. The TREE_VALUE of that list is an
+ individual function which is a friend. The TREE_PURPOSE of that list
+ indicates a type in which all functions by that name are friends.
+
+ Lists of friend classes come from _TYPE nodes. Love that consistency
+ thang. */
+
+int
+is_friend_type (type1, type2)
+ tree type1, type2;
+{
+ return is_friend (type1, type2);
+}
+
+int
+is_friend (type, supplicant)
+ tree type, supplicant;
+{
+ int declp;
+ register tree list;
+
+ if (supplicant == NULL_TREE || type == NULL_TREE)
+ return 0;
+
+ declp = (TREE_CODE_CLASS (TREE_CODE (supplicant)) == 'd');
+
+ if (declp)
+ /* It's a function decl. */
+ {
+ tree list = DECL_FRIENDLIST (TYPE_NAME (type));
+ tree name = DECL_NAME (supplicant);
+ tree ctype;
+
+ if (DECL_FUNCTION_MEMBER_P (supplicant))
+ ctype = DECL_CLASS_CONTEXT (supplicant);
+ else
+ ctype = NULL_TREE;
+
+ for (; list ; list = TREE_CHAIN (list))
+ {
+ if (name == TREE_PURPOSE (list))
+ {
+ tree friends = TREE_VALUE (list);
+ name = DECL_ASSEMBLER_NAME (supplicant);
+ for (; friends ; friends = TREE_CHAIN (friends))
+ {
+ if (ctype == TREE_PURPOSE (friends))
+ return 1;
+ if (name == DECL_ASSEMBLER_NAME (TREE_VALUE (friends)))
+ return 1;
+ }
+ break;
+ }
+ }
+ }
+ else
+ /* It's a type. */
+ {
+ if (type == supplicant)
+ return 1;
+
+ list = CLASSTYPE_FRIEND_CLASSES (TREE_TYPE (TYPE_NAME (type)));
+ for (; list ; list = TREE_CHAIN (list))
+ if (supplicant == TREE_VALUE (list))
+ return 1;
+ }
+
+ {
+ tree context;
+
+ if (! declp)
+ context = DECL_CONTEXT (TYPE_NAME (supplicant));
+ else if (DECL_FUNCTION_MEMBER_P (supplicant))
+ context = DECL_CLASS_CONTEXT (supplicant);
+ else
+ context = NULL_TREE;
+
+ if (context)
+ return is_friend (type, context);
+ }
+
+ return 0;
+}
+
+/* Add a new friend to the friends of the aggregate type TYPE.
+ DECL is the FUNCTION_DECL of the friend being added. */
+static void
+add_friend (type, decl)
+ tree type, decl;
+{
+ tree typedecl = TYPE_NAME (type);
+ tree list = DECL_FRIENDLIST (typedecl);
+ tree name = DECL_NAME (decl);
+
+ while (list)
+ {
+ if (name == TREE_PURPOSE (list))
+ {
+ tree friends = TREE_VALUE (list);
+ for (; friends ; friends = TREE_CHAIN (friends))
+ {
+ if (decl == TREE_VALUE (friends))
+ {
+ cp_warning ("`%D' is already a friend of class `%T'",
+ decl, type);
+ cp_warning_at ("previous friend declaration of `%D'",
+ TREE_VALUE (friends));
+ return;
+ }
+ }
+ TREE_VALUE (list) = tree_cons (error_mark_node, decl,
+ TREE_VALUE (list));
+ return;
+ }
+ list = TREE_CHAIN (list);
+ }
+ DECL_FRIENDLIST (typedecl)
+ = tree_cons (DECL_NAME (decl), build_tree_list (error_mark_node, decl),
+ DECL_FRIENDLIST (typedecl));
+ if (DECL_NAME (decl) == ansi_opname[(int) MODIFY_EXPR])
+ {
+ tree parmtypes = TYPE_ARG_TYPES (TREE_TYPE (decl));
+ TYPE_HAS_ASSIGNMENT (TREE_TYPE (typedecl)) = 1;
+ if (parmtypes && TREE_CHAIN (parmtypes))
+ {
+ tree parmtype = TREE_VALUE (TREE_CHAIN (parmtypes));
+ if (TREE_CODE (parmtype) == REFERENCE_TYPE
+ && TREE_TYPE (parmtypes) == TREE_TYPE (typedecl))
+ TYPE_HAS_ASSIGN_REF (TREE_TYPE (typedecl)) = 1;
+ }
+ }
+}
+
+/* Declare that every member function NAME in FRIEND_TYPE
+ (which may be NULL_TREE) is a friend of type TYPE. */
+static void
+add_friends (type, name, friend_type)
+ tree type, name, friend_type;
+{
+ tree typedecl = TYPE_NAME (type);
+ tree list = DECL_FRIENDLIST (typedecl);
+
+ while (list)
+ {
+ if (name == TREE_PURPOSE (list))
+ {
+ tree friends = TREE_VALUE (list);
+ while (friends && TREE_PURPOSE (friends) != friend_type)
+ friends = TREE_CHAIN (friends);
+ if (friends)
+ if (friend_type)
+ warning ("method `%s::%s' is already a friend of class",
+ TYPE_NAME_STRING (friend_type),
+ IDENTIFIER_POINTER (name));
+ else
+ warning ("function `%s' is already a friend of class `%s'",
+ IDENTIFIER_POINTER (name),
+ IDENTIFIER_POINTER (DECL_NAME (typedecl)));
+ else
+ TREE_VALUE (list) = tree_cons (friend_type, NULL_TREE,
+ TREE_VALUE (list));
+ return;
+ }
+ list = TREE_CHAIN (list);
+ }
+ DECL_FRIENDLIST (typedecl) =
+ tree_cons (name,
+ build_tree_list (friend_type, NULL_TREE),
+ DECL_FRIENDLIST (typedecl));
+ if (! strncmp (IDENTIFIER_POINTER (name),
+ IDENTIFIER_POINTER (ansi_opname[(int) MODIFY_EXPR]),
+ strlen (IDENTIFIER_POINTER (ansi_opname[(int) MODIFY_EXPR]))))
+ {
+ TYPE_HAS_ASSIGNMENT (TREE_TYPE (typedecl)) = 1;
+ sorry ("declaring \"friend operator =\" will not find \"operator = (X&)\" if it exists");
+ }
+}
+
+/* Set up a cross reference so that type TYPE will make member function
+ CTYPE::DECL a friend when CTYPE is finally defined. For more than
+ one, set up a cross reference so that functions with the name DECL
+ and type CTYPE know that they are friends of TYPE. */
+static void
+xref_friend (type, decl, ctype)
+ tree type, decl, ctype;
+{
+ tree friend_decl = TYPE_NAME (ctype);
+#if 0
+ tree typedecl = TYPE_NAME (type);
+ tree t = tree_cons (NULL_TREE, ctype, DECL_UNDEFINED_FRIENDS (typedecl));
+
+ DECL_UNDEFINED_FRIENDS (typedecl) = t;
+#else
+ tree t = 0;
+#endif
+ SET_DECL_WAITING_FRIENDS (friend_decl,
+ tree_cons (type, t,
+ DECL_WAITING_FRIENDS (friend_decl)));
+ TREE_TYPE (DECL_WAITING_FRIENDS (friend_decl)) = decl;
+}
+
+/* Make FRIEND_TYPE a friend class to TYPE. If FRIEND_TYPE has already
+ been defined, we make all of its member functions friends of
+ TYPE. If not, we make it a pending friend, which can later be added
+ when its definition is seen. If a type is defined, then its TYPE_DECL's
+ DECL_UNDEFINED_FRIENDS contains a (possibly empty) list of friend
+ classes that are not defined. If a type has not yet been defined,
+ then the DECL_WAITING_FRIENDS contains a list of types
+ waiting to make it their friend. Note that these two can both
+ be in use at the same time! */
+void
+make_friend_class (type, friend_type)
+ tree type, friend_type;
+{
+ tree classes;
+
+ if (IS_SIGNATURE (type))
+ {
+ error ("`friend' declaration in signature definition");
+ return;
+ }
+ if (IS_SIGNATURE (friend_type))
+ {
+ error ("signature type `%s' declared `friend'",
+ IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (friend_type))));
+ return;
+ }
+ if (type == friend_type)
+ {
+ pedwarn ("class `%s' is implicitly friends with itself",
+ TYPE_NAME_STRING (type));
+ return;
+ }
+
+ GNU_xref_hier (TYPE_NAME_STRING (type),
+ TYPE_NAME_STRING (friend_type), 0, 0, 1);
+
+ classes = CLASSTYPE_FRIEND_CLASSES (type);
+ while (classes && TREE_VALUE (classes) != friend_type)
+ classes = TREE_CHAIN (classes);
+ if (classes)
+ warning ("class `%s' is already friends with class `%s'",
+ TYPE_NAME_STRING (TREE_VALUE (classes)), TYPE_NAME_STRING (type));
+ else
+ {
+ CLASSTYPE_FRIEND_CLASSES (type)
+ = tree_cons (NULL_TREE, friend_type, CLASSTYPE_FRIEND_CLASSES (type));
+ }
+}
+
+/* Main friend processor. This is large, and for modularity purposes,
+ has been removed from grokdeclarator. It returns `void_type_node'
+ to indicate that something happened, though a FIELD_DECL is
+ not returned.
+
+ CTYPE is the class this friend belongs to.
+
+ DECLARATOR is the name of the friend.
+
+ DECL is the FUNCTION_DECL that the friend is.
+
+ In case we are parsing a friend which is part of an inline
+ definition, we will need to store PARM_DECL chain that comes
+ with it into the DECL_ARGUMENTS slot of the FUNCTION_DECL.
+
+ FLAGS is just used for `grokclassfn'.
+
+ QUALS say what special qualifies should apply to the object
+ pointed to by `this'. */
+tree
+do_friend (ctype, declarator, decl, parmdecls, flags, quals)
+ tree ctype, declarator, decl, parmdecls;
+ enum overload_flags flags;
+ tree quals;
+{
+ /* Every decl that gets here is a friend of something. */
+ DECL_FRIEND_P (decl) = 1;
+
+ if (ctype)
+ {
+ tree cname = TYPE_NAME (ctype);
+ if (TREE_CODE (cname) == TYPE_DECL)
+ cname = DECL_NAME (cname);
+
+ /* A method friend. */
+ if (TREE_CODE (decl) == FUNCTION_DECL)
+ {
+ if (flags == NO_SPECIAL && ctype && declarator == cname)
+ DECL_CONSTRUCTOR_P (decl) = 1;
+
+ /* This will set up DECL_ARGUMENTS for us. */
+ grokclassfn (ctype, cname, decl, flags, quals);
+ if (TYPE_SIZE (ctype) != 0)
+ check_classfn (ctype, cname, decl);
+
+ if (TREE_TYPE (decl) != error_mark_node)
+ {
+ if (TYPE_SIZE (ctype))
+ {
+ /* We don't call pushdecl here yet, or ever on this
+ actual FUNCTION_DECL. We must preserve its TREE_CHAIN
+ until the end. */
+ make_decl_rtl (decl, NULL_PTR, 1);
+ add_friend (current_class_type, decl);
+ }
+ else
+ {
+ register char *classname
+ = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (ctype)));
+
+ error ("member declared as friend before type `%s' defined",
+ classname);
+ }
+ }
+ }
+ else
+ {
+ /* Possibly a bunch of method friends. */
+
+ /* Get the class they belong to. */
+ tree ctype = IDENTIFIER_TYPE_VALUE (cname);
+
+ /* This class is defined, use its methods now. */
+ if (TYPE_SIZE (ctype))
+ {
+ tree fields = lookup_fnfields (TYPE_BINFO (ctype), declarator, 0);
+ if (fields)
+ add_friends (current_class_type, declarator, ctype);
+ else
+ error ("method `%s' is not a member of class `%s'",
+ IDENTIFIER_POINTER (declarator),
+ IDENTIFIER_POINTER (cname));
+ }
+ else
+ /* Note: DECLARATOR actually has more than one; in this
+ case, we're making sure that fns with the name DECLARATOR
+ and type CTYPE know they are friends of the current
+ class type. */
+ xref_friend (current_class_type, declarator, ctype);
+ decl = void_type_node;
+ }
+ }
+ else if (TREE_CODE (decl) == FUNCTION_DECL
+ && ((IDENTIFIER_LENGTH (declarator) == 4
+ && IDENTIFIER_POINTER (declarator)[0] == 'm'
+ && ! strcmp (IDENTIFIER_POINTER (declarator), "main"))
+ || (IDENTIFIER_LENGTH (declarator) > 10
+ && IDENTIFIER_POINTER (declarator)[0] == '_'
+ && IDENTIFIER_POINTER (declarator)[1] == '_'
+ && strncmp (IDENTIFIER_POINTER (declarator)+2,
+ "builtin_", 8) == 0)))
+ {
+ /* raw "main", and builtin functions never gets overloaded,
+ but they can become friends. */
+ add_friend (current_class_type, decl);
+ DECL_FRIEND_P (decl) = 1;
+ decl = void_type_node;
+ }
+ /* A global friend.
+ @@ or possibly a friend from a base class ?!? */
+ else if (TREE_CODE (decl) == FUNCTION_DECL)
+ {
+ /* Friends must all go through the overload machinery,
+ even though they may not technically be overloaded.
+
+ Note that because classes all wind up being top-level
+ in their scope, their friend wind up in top-level scope as well. */
+ DECL_ASSEMBLER_NAME (decl)
+ = build_decl_overload (declarator, TYPE_ARG_TYPES (TREE_TYPE (decl)),
+ TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE);
+ DECL_ARGUMENTS (decl) = parmdecls;
+ DECL_CLASS_CONTEXT (decl) = current_class_type;
+
+ /* We can call pushdecl here, because the TREE_CHAIN of this
+ FUNCTION_DECL is not needed for other purposes. */
+ decl = pushdecl (decl);
+
+ make_decl_rtl (decl, NULL_PTR, 1);
+ add_friend (current_class_type, decl);
+
+ DECL_FRIEND_P (decl) = 1;
+#if 0
+ TREE_OVERLOADED (declarator) = 1;
+#endif
+ }
+ else
+ {
+ /* @@ Should be able to ingest later definitions of this function
+ before use. */
+ tree decl = lookup_name_nonclass (declarator);
+ if (decl == NULL_TREE)
+ {
+ warning ("implicitly declaring `%s' as struct",
+ IDENTIFIER_POINTER (declarator));
+ decl = xref_tag (record_type_node, declarator, NULL_TREE, 1);
+ decl = TYPE_NAME (decl);
+ }
+
+ /* Allow abbreviated declarations of overloaded functions,
+ but not if those functions are really class names. */
+ if (TREE_CODE (decl) == TREE_LIST && TREE_TYPE (TREE_PURPOSE (decl)))
+ {
+ warning ("`friend %s' archaic, use `friend class %s' instead",
+ IDENTIFIER_POINTER (declarator),
+ IDENTIFIER_POINTER (declarator));
+ decl = TREE_TYPE (TREE_PURPOSE (decl));
+ }
+
+ if (TREE_CODE (decl) == TREE_LIST)
+ add_friends (current_class_type, TREE_PURPOSE (decl), NULL_TREE);
+ else
+ make_friend_class (current_class_type, TREE_TYPE (decl));
+ decl = void_type_node;
+ }
+ return decl;
+}
+
+/* TYPE has now been defined. It may, however, have a number of things
+ waiting make make it their friend. We resolve these references
+ here. */
+void
+embrace_waiting_friends (type)
+ tree type;
+{
+ tree decl = TYPE_NAME (type);
+ tree waiters;
+
+ if (TREE_CODE (decl) != TYPE_DECL)
+ return;
+
+ for (waiters = DECL_WAITING_FRIENDS (decl); waiters;
+ waiters = TREE_CHAIN (waiters))
+ {
+ tree waiter = TREE_PURPOSE (waiters);
+#if 0
+ tree waiter_prev = TREE_VALUE (waiters);
+#endif
+ tree decl = TREE_TYPE (waiters);
+ tree name = decl ? (TREE_CODE (decl) == IDENTIFIER_NODE
+ ? decl : DECL_NAME (decl)) : NULL_TREE;
+ if (name)
+ {
+ /* @@ There may be work to be done since we have not verified
+ @@ consistency between original and friend declarations
+ @@ of the functions waiting to become friends. */
+ tree field = lookup_fnfields (TYPE_BINFO (type), name, 0);
+ if (field)
+ if (decl == name)
+ add_friends (waiter, name, type);
+ else
+ add_friend (waiter, decl);
+ else
+ error_with_file_and_line (DECL_SOURCE_FILE (TYPE_NAME (waiter)),
+ DECL_SOURCE_LINE (TYPE_NAME (waiter)),
+ "no method `%s' defined in class `%s' to be friend",
+ IDENTIFIER_POINTER (DECL_NAME (TREE_TYPE (waiters))),
+ TYPE_NAME_STRING (type));
+ }
+ else
+ make_friend_class (type, waiter);
+
+#if 0
+ if (TREE_CHAIN (waiter_prev))
+ TREE_CHAIN (waiter_prev) = TREE_CHAIN (TREE_CHAIN (waiter_prev));
+ else
+ DECL_UNDEFINED_FRIENDS (TYPE_NAME (waiter)) = NULL_TREE;
+#endif
+ }
+}
+
+/* Common subroutines of build_new and build_vec_delete. */
+
+/* Common interface for calling "builtin" functions that are not
+ really builtin. */
+
+tree
+build_builtin_call (type, node, arglist)
+ tree type;
+ tree node;
+ tree arglist;
+{
+ tree rval = build (CALL_EXPR, type, node, arglist, 0);
+ TREE_SIDE_EFFECTS (rval) = 1;
+ assemble_external (TREE_OPERAND (node, 0));
+ TREE_USED (TREE_OPERAND (node, 0)) = 1;
+ return rval;
+}
+
+/* Generate a C++ "new" expression. DECL is either a TREE_LIST
+ (which needs to go through some sort of groktypename) or it
+ is the name of the class we are newing. INIT is an initialization value.
+ It is either an EXPRLIST, an EXPR_NO_COMMAS, or something in braces.
+ If INIT is void_type_node, it means do *not* call a constructor
+ for this instance.
+
+ For types with constructors, the data returned is initialized
+ by the appropriate constructor.
+
+ Whether the type has a constructor or not, if it has a pointer
+ to a virtual function table, then that pointer is set up
+ here.
+
+ Unless I am mistaken, a call to new () will return initialized
+ data regardless of whether the constructor itself is private or
+ not. NOPE; new fails if the constructor is private (jcm).
+
+ Note that build_new does nothing to assure that any special
+ alignment requirements of the type are met. Rather, it leaves
+ it up to malloc to do the right thing. Otherwise, folding to
+ the right alignment cal cause problems if the user tries to later
+ free the memory returned by `new'.
+
+ PLACEMENT is the `placement' list for user-defined operator new (). */
+
+extern int flag_check_new;
+
+tree
+build_new (placement, decl, init, use_global_new)
+ tree placement;
+ tree decl, init;
+ int use_global_new;
+{
+ tree type, true_type, size, rval;
+ tree nelts;
+ tree alloc_expr, alloc_temp;
+ int has_array = 0;
+ enum tree_code code = NEW_EXPR;
+
+ tree pending_sizes = NULL_TREE;
+
+ if (decl == error_mark_node)
+ return error_mark_node;
+
+ if (TREE_CODE (decl) == TREE_LIST)
+ {
+ tree absdcl = TREE_VALUE (decl);
+ tree last_absdcl = NULL_TREE;
+ int old_immediate_size_expand;
+
+ if (current_function_decl
+ && DECL_CONSTRUCTOR_P (current_function_decl))
+ {
+ old_immediate_size_expand = immediate_size_expand;
+ immediate_size_expand = 0;
+ }
+
+ nelts = integer_one_node;
+
+ if (absdcl && TREE_CODE (absdcl) == CALL_EXPR)
+ my_friendly_abort (215);
+ while (absdcl && TREE_CODE (absdcl) == INDIRECT_REF)
+ {
+ last_absdcl = absdcl;
+ absdcl = TREE_OPERAND (absdcl, 0);
+ }
+
+ if (absdcl && TREE_CODE (absdcl) == ARRAY_REF)
+ {
+ /* probably meant to be a vec new */
+ tree this_nelts;
+
+ while (TREE_OPERAND (absdcl, 0)
+ && TREE_CODE (TREE_OPERAND (absdcl, 0)) == ARRAY_REF)
+ {
+ last_absdcl = absdcl;
+ absdcl = TREE_OPERAND (absdcl, 0);
+ }
+
+ has_array = 1;
+ this_nelts = TREE_OPERAND (absdcl, 1);
+ if (this_nelts != error_mark_node)
+ {
+ if (this_nelts == NULL_TREE)
+ error ("new of array type fails to specify size");
+ else
+ {
+ this_nelts = save_expr (convert (sizetype, this_nelts));
+ absdcl = TREE_OPERAND (absdcl, 0);
+ if (this_nelts == integer_zero_node)
+ {
+ warning ("zero size array reserves no space");
+ nelts = integer_zero_node;
+ }
+ else
+ nelts = build_binary_op (MULT_EXPR, nelts, this_nelts, 1);
+ }
+ }
+ else
+ nelts = integer_zero_node;
+ }
+
+ if (last_absdcl)
+ TREE_OPERAND (last_absdcl, 0) = absdcl;
+ else
+ TREE_VALUE (decl) = absdcl;
+
+ type = true_type = groktypename (decl);
+ if (! type || type == error_mark_node)
+ {
+ immediate_size_expand = old_immediate_size_expand;
+ return error_mark_node;
+ }
+
+ if (current_function_decl
+ && DECL_CONSTRUCTOR_P (current_function_decl))
+ {
+ pending_sizes = get_pending_sizes ();
+ immediate_size_expand = old_immediate_size_expand;
+ }
+ }
+ else if (TREE_CODE (decl) == IDENTIFIER_NODE)
+ {
+ if (IDENTIFIER_HAS_TYPE_VALUE (decl))
+ {
+ /* An aggregate type. */
+ type = IDENTIFIER_TYPE_VALUE (decl);
+ decl = TYPE_NAME (type);
+ }
+ else
+ {
+ /* A builtin type. */
+ decl = lookup_name (decl, 1);
+ my_friendly_assert (TREE_CODE (decl) == TYPE_DECL, 215);
+ type = TREE_TYPE (decl);
+ }
+ true_type = type;
+ }
+ else if (TREE_CODE (decl) == TYPE_DECL)
+ {
+ type = TREE_TYPE (decl);
+ true_type = type;
+ }
+ else
+ {
+ type = decl;
+ true_type = type;
+ decl = TYPE_NAME (type);
+ }
+
+ /* ``A reference cannot be created by the new operator. A reference
+ is not an object (8.2.2, 8.4.3), so a pointer to it could not be
+ returned by new.'' ARM 5.3.3 */
+ if (TREE_CODE (type) == REFERENCE_TYPE)
+ {
+ error ("new cannot be applied to a reference type");
+ type = true_type = TREE_TYPE (type);
+ }
+
+ if (TREE_CODE (type) == FUNCTION_TYPE)
+ {
+ error ("new cannot be applied to a function type");
+ return error_mark_node;
+ }
+
+ /* When the object being created is an array, the new-expression yields a
+ pointer to the initial element (if any) of the array. For example,
+ both new int and new int[10] return an int*. 5.3.4. */
+ if (TREE_CODE (type) == ARRAY_TYPE && has_array == 0)
+ {
+ nelts = array_type_nelts_top (type);
+ has_array = 1;
+ type = true_type = TREE_TYPE (type);
+ }
+
+ if (TYPE_READONLY (type) || TYPE_VOLATILE (type))
+ type = TYPE_MAIN_VARIANT (type);
+
+ /* If our base type is an array, then make sure we know how many elements
+ it has. */
+ while (TREE_CODE (true_type) == ARRAY_TYPE)
+ {
+ tree this_nelts = array_type_nelts_top (true_type);
+ nelts = build_binary_op (MULT_EXPR, nelts, this_nelts, 1);
+ true_type = TREE_TYPE (true_type);
+ }
+ if (has_array)
+ size = fold (build_binary_op (MULT_EXPR, size_in_bytes (true_type),
+ nelts, 1));
+ else
+ size = size_in_bytes (type);
+
+ if (true_type == void_type_node)
+ {
+ error ("invalid type `void' for new");
+ return error_mark_node;
+ }
+
+ if (TYPE_SIZE (true_type) == 0)
+ {
+ incomplete_type_error (0, true_type);
+ return error_mark_node;
+ }
+
+ if (TYPE_LANG_SPECIFIC (true_type)
+ && CLASSTYPE_ABSTRACT_VIRTUALS (true_type))
+ {
+ abstract_virtuals_error (NULL_TREE, true_type);
+ return error_mark_node;
+ }
+
+ if (TYPE_LANG_SPECIFIC (true_type) && IS_SIGNATURE (true_type))
+ {
+ signature_error (NULL_TREE, true_type);
+ return error_mark_node;
+ }
+
+ /* Get a little extra space to store a couple of things before the new'ed
+ array. */
+ if (has_array && TYPE_VEC_NEW_USES_COOKIE (true_type))
+ {
+ tree extra = BI_header_size;
+
+ size = size_binop (PLUS_EXPR, size, extra);
+ }
+
+ if (has_array)
+ code = VEC_NEW_EXPR;
+
+ /* Allocate the object. */
+ if (! use_global_new && TYPE_LANG_SPECIFIC (true_type)
+ && (TYPE_GETS_NEW (true_type) & (1 << has_array)))
+ rval = build_opfncall (code, LOOKUP_NORMAL,
+ build_pointer_type (true_type), size, placement);
+ else if (placement)
+ {
+ rval = build_opfncall (code, LOOKUP_GLOBAL|LOOKUP_COMPLAIN,
+ ptr_type_node, size, placement);
+ rval = convert (build_pointer_type (true_type), rval);
+ }
+ else if (! has_array && flag_this_is_variable > 0
+ && TYPE_NEEDS_CONSTRUCTING (true_type) && init != void_type_node)
+ {
+ if (init == NULL_TREE || TREE_CODE (init) == TREE_LIST)
+ rval = NULL_TREE;
+ else
+ {
+ error ("constructors take parameter lists");
+ return error_mark_node;
+ }
+ }
+ else
+ {
+ rval = build_builtin_call (build_pointer_type (true_type),
+ has_array ? BIVN : BIN,
+ build_tree_list (NULL_TREE, size));
+#if 0
+ /* See comment above as to why this is disabled. */
+ if (alignment)
+ {
+ rval = build (PLUS_EXPR, build_pointer_type (true_type), rval,
+ alignment);
+ rval = build (BIT_AND_EXPR, build_pointer_type (true_type),
+ rval, build1 (BIT_NOT_EXPR, integer_type_node,
+ alignment));
+ }
+#endif
+ TREE_CALLS_NEW (rval) = 1;
+ }
+
+ if (flag_check_new && rval)
+ {
+ /* For array new, we need to make sure that the call to new is
+ not expanded as part of the RTL_EXPR for the initialization,
+ so we can't just use save_expr here. */
+
+ alloc_temp = get_temp_name (TREE_TYPE (rval), 0);
+ alloc_expr = build (MODIFY_EXPR, TREE_TYPE (rval), alloc_temp, rval);
+ TREE_SIDE_EFFECTS (alloc_expr) = 1;
+ rval = alloc_temp;
+ }
+ else
+ alloc_expr = NULL_TREE;
+
+ /* if rval is NULL_TREE I don't have to allocate it, but are we totally
+ sure we have some extra bytes in that case for the BI_header_size
+ cookies? And how does that interact with the code below? (mrs) */
+ /* Finish up some magic for new'ed arrays */
+ if (has_array && TYPE_VEC_NEW_USES_COOKIE (true_type) && rval != NULL_TREE)
+ {
+ tree extra = BI_header_size;
+ tree cookie, exp1;
+ rval = convert (ptr_type_node, rval); /* convert to void * first */
+ rval = convert (string_type_node, rval); /* lets not add void* and ints */
+ rval = save_expr (build_binary_op (PLUS_EXPR, rval, extra, 1));
+ /* Store header info. */
+ cookie = build_indirect_ref (build (MINUS_EXPR, build_pointer_type (BI_header_type),
+ rval, extra), NULL_PTR);
+ exp1 = build (MODIFY_EXPR, void_type_node,
+ build_component_ref (cookie, nc_nelts_field_id, 0, 0),
+ nelts);
+ TREE_SIDE_EFFECTS (exp1) = 1;
+ rval = convert (build_pointer_type (true_type), rval);
+ TREE_CALLS_NEW (rval) = 1;
+ TREE_SIDE_EFFECTS (rval) = 1;
+ rval = build_compound_expr (tree_cons (NULL_TREE, exp1,
+ build_tree_list (NULL_TREE, rval)));
+ }
+
+ if (rval == error_mark_node)
+ return error_mark_node;
+
+ /* Don't call any constructors or do any initialization. */
+ if (init == void_type_node)
+ goto done;
+
+ if (TYPE_NEEDS_CONSTRUCTING (type) || init)
+ {
+ if (! TYPE_NEEDS_CONSTRUCTING (type)
+ && ! IS_AGGR_TYPE (type) && ! has_array)
+ {
+ /* New 2.0 interpretation: `new int (10)' means
+ allocate an int, and initialize it with 10. */
+ tree deref;
+
+ rval = save_expr (rval);
+ deref = build_indirect_ref (rval, NULL_PTR);
+ TREE_READONLY (deref) = 0;
+
+ if (TREE_CHAIN (init) != NULL_TREE)
+ pedwarn ("initializer list being treated as compound expression");
+ else if (TREE_CODE (init) == CONSTRUCTOR)
+ {
+ pedwarn ("initializer list appears where operand should be used");
+ init = TREE_OPERAND (init, 1);
+ }
+ init = build_compound_expr (init);
+
+ init = convert_for_initialization (deref, type, init, LOOKUP_NORMAL,
+ "new", NULL_TREE, 0);
+ rval = build (COMPOUND_EXPR, TREE_TYPE (rval),
+ build_modify_expr (deref, NOP_EXPR, init),
+ rval);
+ TREE_NO_UNUSED_WARNING (rval) = 1;
+ TREE_SIDE_EFFECTS (rval) = 1;
+ TREE_CALLS_NEW (rval) = 1;
+ }
+ else if (! has_array)
+ {
+ tree newrval;
+ /* Constructors are never virtual. If it has an initialization, we
+ need to complain if we aren't allowed to use the ctor that took
+ that argument. */
+ int flags = LOOKUP_NORMAL|LOOKUP_NONVIRTUAL|LOOKUP_COMPLAIN;
+
+ if (rval && TYPE_USES_VIRTUAL_BASECLASSES (true_type))
+ {
+ init = tree_cons (NULL_TREE, integer_one_node, init);
+ flags |= LOOKUP_HAS_IN_CHARGE;
+ }
+
+ newrval = rval;
+
+ if (newrval && TREE_CODE (TREE_TYPE (newrval)) == POINTER_TYPE)
+ newrval = build_indirect_ref (newrval, NULL_PTR);
+
+ newrval = build_method_call (newrval, constructor_name_full (true_type),
+ init, NULL_TREE, flags);
+
+ if (newrval)
+ {
+ rval = newrval;
+ TREE_HAS_CONSTRUCTOR (rval) = 1;
+ }
+ else
+ rval = error_mark_node;
+ }
+ else if (current_function_decl == NULL_TREE)
+ {
+ extern tree static_aggregates;
+
+ /* In case of static initialization, SAVE_EXPR is good enough. */
+ rval = save_expr (rval);
+ rval = copy_to_permanent (rval);
+ init = copy_to_permanent (init);
+ init = expand_vec_init (decl, rval,
+ build_binary_op (MINUS_EXPR, nelts,
+ integer_one_node, 1),
+ init, 0);
+ init = copy_to_permanent (init);
+ static_aggregates = perm_tree_cons (init, rval, static_aggregates);
+ }
+ else
+ {
+ /* Have to wrap this in RTL_EXPR for two cases:
+ in base or member initialization and if we
+ are a branch of a ?: operator. Since we
+ can't easily know the latter, just do it always. */
+ tree xval = make_node (RTL_EXPR);
+
+ /* If we want to check the value of the allocation expression,
+ and the number of elements in the array is not a constant, we
+ *must* expand the SAVE_EXPR for nelts in alloc_expr before we
+ expand it in the actual initialization. So we need to build up
+ an RTL_EXPR for alloc_expr. Sigh. */
+ if (alloc_expr && ! TREE_CONSTANT (nelts))
+ {
+ tree xval = make_node (RTL_EXPR);
+ rtx rtxval;
+ TREE_TYPE (xval) = TREE_TYPE (alloc_expr);
+ do_pending_stack_adjust ();
+ start_sequence_for_rtl_expr (xval);
+ emit_note (0, -1);
+ rtxval = expand_expr (alloc_expr, NULL, VOIDmode, 0);
+ do_pending_stack_adjust ();
+ TREE_SIDE_EFFECTS (xval) = 1;
+ RTL_EXPR_SEQUENCE (xval) = get_insns ();
+ end_sequence ();
+ RTL_EXPR_RTL (xval) = rtxval;
+ TREE_TYPE (xval) = TREE_TYPE (alloc_expr);
+ alloc_expr = xval;
+ }
+
+ TREE_TYPE (xval) = TREE_TYPE (rval);
+ do_pending_stack_adjust ();
+ start_sequence_for_rtl_expr (xval);
+
+ /* As a matter of principle, `start_sequence' should do this. */
+ emit_note (0, -1);
+
+ rval = save_expr (rval);
+ rval = expand_vec_init (decl, rval,
+ build_binary_op (MINUS_EXPR, nelts,
+ integer_one_node, 1),
+ init, 0);
+
+ do_pending_stack_adjust ();
+
+ TREE_SIDE_EFFECTS (xval) = 1;
+ TREE_CALLS_NEW (xval) = 1;
+ RTL_EXPR_SEQUENCE (xval) = get_insns ();
+ end_sequence ();
+
+ if (TREE_CODE (rval) == SAVE_EXPR)
+ {
+ /* Errors may cause this to not get evaluated. */
+ if (SAVE_EXPR_RTL (rval) == 0)
+ SAVE_EXPR_RTL (rval) = const0_rtx;
+ RTL_EXPR_RTL (xval) = SAVE_EXPR_RTL (rval);
+ }
+ else
+ {
+ my_friendly_assert (TREE_CODE (rval) == VAR_DECL, 217);
+ RTL_EXPR_RTL (xval) = DECL_RTL (rval);
+ }
+ rval = xval;
+ }
+ }
+ else if (TYPE_READONLY (true_type))
+ cp_error ("uninitialized const in `new' of `%#T'", true_type);
+
+ done:
+
+ if (alloc_expr)
+ {
+ /* Did we modify the storage? */
+ if (rval != alloc_temp)
+ {
+ tree ifexp = build_binary_op (NE_EXPR, alloc_expr,
+ integer_zero_node, 1);
+ rval = build_conditional_expr (ifexp, rval, alloc_temp);
+ }
+ else
+ rval = alloc_expr;
+ }
+
+ if (rval && TREE_TYPE (rval) != build_pointer_type (type))
+ {
+ /* The type of new int [3][3] is not int *, but int [3] * */
+ rval = build_c_cast (build_pointer_type (type), rval, 0);
+ }
+
+ if (pending_sizes)
+ rval = build_compound_expr (chainon (pending_sizes,
+ build_tree_list (NULL_TREE, rval)));
+
+ if (flag_gc)
+ {
+ extern tree gc_visible;
+ tree objbits;
+ tree update_expr;
+
+ rval = save_expr (rval);
+ /* We don't need a `headof' operation to do this because
+ we know where the object starts. */
+ objbits = build1 (INDIRECT_REF, unsigned_type_node,
+ build (MINUS_EXPR, ptr_type_node,
+ rval, c_sizeof_nowarn (unsigned_type_node)));
+ update_expr = build_modify_expr (objbits, BIT_IOR_EXPR, gc_visible);
+ rval = build_compound_expr (tree_cons (NULL_TREE, rval,
+ tree_cons (NULL_TREE, update_expr,
+ build_tree_list (NULL_TREE, rval))));
+ }
+
+ return rval;
+}
+
+static tree
+build_vec_delete_1 (base, maxindex, type, auto_delete_vec, auto_delete,
+ use_global_delete)
+ tree base, maxindex, type;
+ tree auto_delete_vec, auto_delete;
+ int use_global_delete;
+{
+ tree virtual_size;
+ tree ptype = build_pointer_type (type);
+ tree size_exp = size_in_bytes (type);
+
+ /* Temporary variables used by the loop. */
+ tree tbase, tbase_init;
+
+ /* This is the body of the loop that implements the deletion of a
+ single element, and moves temp variables to next elements. */
+ tree body;
+
+ /* This is the LOOP_EXPR that governs the deletion of the elements. */
+ tree loop;
+
+ /* This is the thing that governs what to do after the loop has run. */
+ tree deallocate_expr = 0;
+
+ /* This is the BIND_EXPR which holds the outermost iterator of the
+ loop. It is convenient to set this variable up and test it before
+ executing any other code in the loop.
+ This is also the containing expression returned by this function. */
+ tree controller = NULL_TREE;
+
+ /* This is the BLOCK to record the symbol binding for debugging. */
+ tree block;
+
+ if (! IS_AGGR_TYPE (type) || ! TYPE_NEEDS_DESTRUCTOR (type))
+ {
+ loop = integer_zero_node;
+ goto no_destructor;
+ }
+
+ /* The below is short by BI_header_size */
+ virtual_size = fold (size_binop (MULT_EXPR, size_exp, maxindex));
+
+ tbase = build_decl (VAR_DECL, NULL_TREE, ptype);
+ tbase_init = build_modify_expr (tbase, NOP_EXPR,
+ fold (build (PLUS_EXPR, ptype,
+ base,
+ virtual_size)));
+ DECL_REGISTER (tbase) = 1;
+ controller = build (BIND_EXPR, void_type_node, tbase, 0, 0);
+ TREE_SIDE_EFFECTS (controller) = 1;
+ block = build_block (tbase, 0, 0, 0, 0);
+ add_block_current_level (block);
+
+ if (auto_delete != integer_zero_node
+ && auto_delete != integer_two_node)
+ {
+ tree base_tbd = convert (ptype,
+ build_binary_op (MINUS_EXPR,
+ convert (ptr_type_node, base),
+ BI_header_size,
+ 1));
+ /* This is the real size */
+ virtual_size = size_binop (PLUS_EXPR, virtual_size, BI_header_size);
+ body = build_tree_list (NULL_TREE,
+ build_x_delete (ptype, base_tbd,
+ 2 | use_global_delete,
+ virtual_size));
+ body = build (COND_EXPR, void_type_node,
+ build (BIT_AND_EXPR, integer_type_node,
+ auto_delete, integer_one_node),
+ body, integer_zero_node);
+ }
+ else
+ body = NULL_TREE;
+
+ body = tree_cons (NULL_TREE,
+ build_delete (ptype, tbase, auto_delete,
+ LOOKUP_NORMAL|LOOKUP_DESTRUCTOR, 1),
+ body);
+
+ body = tree_cons (NULL_TREE,
+ build_modify_expr (tbase, NOP_EXPR, build (MINUS_EXPR, ptype, tbase, size_exp)),
+ body);
+
+ body = tree_cons (NULL_TREE,
+ build (EXIT_EXPR, void_type_node,
+ build (EQ_EXPR, boolean_type_node, base, tbase)),
+ body);
+
+ loop = build (LOOP_EXPR, void_type_node, build_compound_expr (body));
+
+ loop = tree_cons (NULL_TREE, tbase_init,
+ tree_cons (NULL_TREE, loop, NULL_TREE));
+ loop = build_compound_expr (loop);
+
+ no_destructor:
+ /* If the delete flag is one, or anything else with the low bit set,
+ delete the storage. */
+ if (auto_delete_vec == integer_zero_node
+ || auto_delete_vec == integer_two_node)
+ deallocate_expr = integer_zero_node;
+ else
+ {
+ tree base_tbd;
+
+ /* The below is short by BI_header_size */
+ virtual_size = fold (size_binop (MULT_EXPR, size_exp, maxindex));
+
+ if (! TYPE_VEC_NEW_USES_COOKIE (type))
+ /* no header */
+ base_tbd = base;
+ else
+ {
+ base_tbd = convert (ptype,
+ build_binary_op (MINUS_EXPR,
+ convert (string_type_node, base),
+ BI_header_size,
+ 1));
+ /* True size with header. */
+ virtual_size = size_binop (PLUS_EXPR, virtual_size, BI_header_size);
+ }
+ deallocate_expr = build_x_delete (ptype, base_tbd,
+ 2 | use_global_delete,
+ virtual_size);
+ if (auto_delete_vec != integer_one_node)
+ deallocate_expr = build (COND_EXPR, void_type_node,
+ build (BIT_AND_EXPR, integer_type_node,
+ auto_delete_vec, integer_one_node),
+ deallocate_expr, integer_zero_node);
+ }
+
+ if (loop && deallocate_expr != integer_zero_node)
+ {
+ body = tree_cons (NULL_TREE, loop,
+ tree_cons (NULL_TREE, deallocate_expr, NULL_TREE));
+ body = build_compound_expr (body);
+ }
+ else
+ body = loop;
+
+ /* Outermost wrapper: If pointer is null, punt. */
+ body = build (COND_EXPR, void_type_node,
+ build (NE_EXPR, boolean_type_node, base, integer_zero_node),
+ body, integer_zero_node);
+ body = build1 (NOP_EXPR, void_type_node, body);
+
+ if (controller)
+ {
+ TREE_OPERAND (controller, 1) = body;
+ return controller;
+ }
+ else
+ return convert (void_type_node, body);
+}
+
+/* Build a tree to cleanup partially built arrays.
+ BASE is that starting address of the array.
+ COUNT is the count of objects that have been built, that need destroying.
+ TYPE is the type of elements in the array. */
+static tree
+build_array_eh_cleanup (base, count, type)
+ tree base, count, type;
+{
+ tree expr = build_vec_delete_1 (base, count, type, integer_two_node,
+ integer_zero_node, 0);
+ return expr;
+}
+
+/* `expand_vec_init' performs initialization of a vector of aggregate
+ types.
+
+ DECL is passed only for error reporting, and provides line number
+ and source file name information.
+ BASE is the space where the vector will be.
+ MAXINDEX is the maximum index of the array (one less than the
+ number of elements).
+ INIT is the (possibly NULL) initializer.
+
+ FROM_ARRAY is 0 if we should init everything with INIT
+ (i.e., every element initialized from INIT).
+ FROM_ARRAY is 1 if we should index into INIT in parallel
+ with initialization of DECL.
+ FROM_ARRAY is 2 if we should index into INIT in parallel,
+ but use assignment instead of initialization. */
+
+tree
+expand_vec_init (decl, base, maxindex, init, from_array)
+ tree decl, base, maxindex, init;
+ int from_array;
+{
+ tree rval;
+ tree iterator, base2 = NULL_TREE;
+ tree type = TREE_TYPE (TREE_TYPE (base));
+ tree size;
+
+ maxindex = convert (integer_type_node, maxindex);
+ if (maxindex == error_mark_node)
+ return error_mark_node;
+
+ if (current_function_decl == NULL_TREE)
+ {
+ rval = make_tree_vec (3);
+ TREE_VEC_ELT (rval, 0) = base;
+ TREE_VEC_ELT (rval, 1) = maxindex;
+ TREE_VEC_ELT (rval, 2) = init;
+ return rval;
+ }
+
+ size = size_in_bytes (type);
+
+ /* Set to zero in case size is <= 0. Optimizer will delete this if
+ it is not needed. */
+ rval = get_temp_regvar (build_pointer_type (type),
+ convert (build_pointer_type (type), null_pointer_node));
+ base = default_conversion (base);
+ base = convert (build_pointer_type (type), base);
+ expand_assignment (rval, base, 0, 0);
+ base = get_temp_regvar (build_pointer_type (type), base);
+
+ if (init != NULL_TREE
+ && TREE_CODE (init) == CONSTRUCTOR
+ && TREE_TYPE (init) == TREE_TYPE (decl))
+ {
+ /* Initialization of array from {...}. */
+ tree elts = CONSTRUCTOR_ELTS (init);
+ tree baseref = build1 (INDIRECT_REF, type, base);
+ tree baseinc = build (PLUS_EXPR, build_pointer_type (type), base, size);
+ int host_i = TREE_INT_CST_LOW (maxindex);
+
+ if (IS_AGGR_TYPE (type))
+ {
+ while (elts)
+ {
+ host_i -= 1;
+ expand_aggr_init (baseref, TREE_VALUE (elts), 0, 0);
+
+ expand_assignment (base, baseinc, 0, 0);
+ elts = TREE_CHAIN (elts);
+ }
+ /* Initialize any elements by default if possible. */
+ if (host_i >= 0)
+ {
+ if (TYPE_NEEDS_CONSTRUCTING (type) == 0)
+ {
+ if (obey_regdecls)
+ use_variable (DECL_RTL (base));
+ goto done_init;
+ }
+
+ iterator = get_temp_regvar (integer_type_node,
+ build_int_2 (host_i, 0));
+ init = NULL_TREE;
+ goto init_by_default;
+ }
+ }
+ else
+ while (elts)
+ {
+ expand_assignment (baseref, TREE_VALUE (elts), 0, 0);
+
+ expand_assignment (base, baseinc, 0, 0);
+ elts = TREE_CHAIN (elts);
+ }
+
+ if (obey_regdecls)
+ use_variable (DECL_RTL (base));
+ }
+ else
+ {
+ tree itype;
+
+ iterator = get_temp_regvar (integer_type_node, maxindex);
+
+ init_by_default:
+
+ /* If initializing one array from another,
+ initialize element by element. */
+ if (from_array)
+ {
+ /* We rely upon the below calls the do argument checking */
+ if (decl == NULL_TREE)
+ {
+ sorry ("initialization of array from dissimilar array type");
+ return error_mark_node;
+ }
+ if (init)
+ {
+ base2 = default_conversion (init);
+ itype = TREE_TYPE (base2);
+ base2 = get_temp_regvar (itype, base2);
+ itype = TREE_TYPE (itype);
+ }
+ else if (TYPE_LANG_SPECIFIC (type)
+ && TYPE_NEEDS_CONSTRUCTING (type)
+ && ! TYPE_HAS_DEFAULT_CONSTRUCTOR (type))
+ {
+ error ("initializer ends prematurely");
+ return error_mark_node;
+ }
+ }
+
+ expand_start_cond (build (GE_EXPR, boolean_type_node,
+ iterator, integer_zero_node), 0);
+ if (TYPE_NEEDS_DESTRUCTOR (type))
+ start_protect ();
+ expand_start_loop_continue_elsewhere (1);
+
+ if (from_array)
+ {
+ tree to = build1 (INDIRECT_REF, type, base);
+ tree from;
+
+ if (base2)
+ from = build1 (INDIRECT_REF, itype, base2);
+ else
+ from = NULL_TREE;
+
+ if (from_array == 2)
+ expand_expr_stmt (build_modify_expr (to, NOP_EXPR, from));
+ else if (TYPE_NEEDS_CONSTRUCTING (type))
+ expand_aggr_init (to, from, 0, 0);
+ else if (from)
+ expand_assignment (to, from, 0, 0);
+ else
+ my_friendly_abort (57);
+ }
+ else if (TREE_CODE (type) == ARRAY_TYPE)
+ {
+ if (init != 0)
+ sorry ("cannot initialize multi-dimensional array with initializer");
+ expand_vec_init (decl, build1 (NOP_EXPR, build_pointer_type (TREE_TYPE (type)), base),
+ array_type_nelts (type), 0, 0);
+ }
+ else
+ expand_aggr_init (build1 (INDIRECT_REF, type, base), init, 0, 0);
+
+ expand_assignment (base,
+ build (PLUS_EXPR, build_pointer_type (type), base, size),
+ 0, 0);
+ if (base2)
+ expand_assignment (base2,
+ build (PLUS_EXPR, build_pointer_type (type), base2, size), 0, 0);
+ expand_loop_continue_here ();
+ expand_exit_loop_if_false (0, build (NE_EXPR, boolean_type_node,
+ build (PREDECREMENT_EXPR, integer_type_node, iterator, integer_one_node), minus_one));
+
+ if (obey_regdecls)
+ {
+ use_variable (DECL_RTL (base));
+ if (base2)
+ use_variable (DECL_RTL (base2));
+ }
+ expand_end_loop ();
+ if (TYPE_NEEDS_DESTRUCTOR (type))
+ end_protect (build_array_eh_cleanup (rval,
+ build_binary_op (MINUS_EXPR,
+ maxindex,
+ iterator,
+ 1),
+ type));
+ expand_end_cond ();
+ if (obey_regdecls)
+ use_variable (DECL_RTL (iterator));
+ }
+ done_init:
+
+ if (obey_regdecls)
+ use_variable (DECL_RTL (rval));
+ return rval;
+}
+
+/* Free up storage of type TYPE, at address ADDR.
+
+ TYPE is a POINTER_TYPE and can be ptr_type_node for no special type
+ of pointer.
+
+ VIRTUAL_SIZE is the amount of storage that was allocated, and is
+ used as the second argument to operator delete. It can include
+ things like padding and magic size cookies. It has virtual in it,
+ because if you have a base pointer and you delete through a virtual
+ destructor, it should be the size of the dynamic object, not the
+ static object, see Free Store 12.5 ANSI C++ WP.
+
+ This does not call any destructors. */
+tree
+build_x_delete (type, addr, which_delete, virtual_size)
+ tree type, addr;
+ int which_delete;
+ tree virtual_size;
+{
+ int use_global_delete = which_delete & 1;
+ int use_vec_delete = !!(which_delete & 2);
+ tree rval;
+ enum tree_code code = use_vec_delete ? VEC_DELETE_EXPR : DELETE_EXPR;
+
+ if (! use_global_delete && TYPE_LANG_SPECIFIC (TREE_TYPE (type))
+ && (TYPE_GETS_DELETE (TREE_TYPE (type)) & (1 << use_vec_delete)))
+ rval = build_opfncall (code, LOOKUP_NORMAL, addr, virtual_size, NULL_TREE);
+ else
+ rval = build_builtin_call (void_type_node, use_vec_delete ? BIVD : BID,
+ build_tree_list (NULL_TREE, addr));
+ return rval;
+}
+
+/* Generate a call to a destructor. TYPE is the type to cast ADDR to.
+ ADDR is an expression which yields the store to be destroyed.
+ AUTO_DELETE is nonzero if a call to DELETE should be made or not.
+ If in the program, (AUTO_DELETE & 2) is non-zero, we tear down the
+ virtual baseclasses.
+ If in the program, (AUTO_DELETE & 1) is non-zero, then we deallocate.
+
+ FLAGS is the logical disjunction of zero or more LOOKUP_
+ flags. See cp-tree.h for more info.
+
+ This function does not delete an object's virtual base classes. */
+tree
+build_delete (type, addr, auto_delete, flags, use_global_delete)
+ tree type, addr;
+ tree auto_delete;
+ int flags;
+ int use_global_delete;
+{
+ tree function, parms;
+ tree member;
+ tree expr;
+ tree ref;
+ int ptr;
+
+ if (addr == error_mark_node)
+ return error_mark_node;
+
+ /* Can happen when CURRENT_EXCEPTION_OBJECT gets its type
+ set to `error_mark_node' before it gets properly cleaned up. */
+ if (type == error_mark_node)
+ return error_mark_node;
+
+ type = TYPE_MAIN_VARIANT (type);
+
+ if (TREE_CODE (type) == POINTER_TYPE)
+ {
+ type = TYPE_MAIN_VARIANT (TREE_TYPE (type));
+ if (TYPE_SIZE (type) == 0)
+ {
+ incomplete_type_error (0, type);
+ return error_mark_node;
+ }
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ goto handle_array;
+ if (! IS_AGGR_TYPE (type))
+ {
+ /* Call the builtin operator delete. */
+ return build_builtin_call (void_type_node, BID,
+ build_tree_list (NULL_TREE, addr));
+ }
+ if (TREE_SIDE_EFFECTS (addr))
+ addr = save_expr (addr);
+
+ /* throw away const and volatile on target type of addr */
+ addr = convert_force (build_pointer_type (type), addr, 0);
+ ref = build_indirect_ref (addr, NULL_PTR);
+ ptr = 1;
+ }
+ else if (TREE_CODE (type) == ARRAY_TYPE)
+ {
+ handle_array:
+ if (TREE_SIDE_EFFECTS (addr))
+ addr = save_expr (addr);
+ if (TYPE_DOMAIN (type) == NULL_TREE)
+ {
+ error ("unknown array size in delete");
+ return error_mark_node;
+ }
+ return build_vec_delete (addr, array_type_nelts (type),
+ c_sizeof_nowarn (TREE_TYPE (type)),
+ auto_delete, integer_two_node,
+ use_global_delete);
+ }
+ else
+ {
+ /* Don't check PROTECT here; leave that decision to the
+ destructor. If the destructor is accessible, call it,
+ else report error. */
+ addr = build_unary_op (ADDR_EXPR, addr, 0);
+ if (TREE_SIDE_EFFECTS (addr))
+ addr = save_expr (addr);
+
+ if (TREE_CONSTANT (addr))
+ addr = convert_pointer_to (type, addr);
+ else
+ addr = convert_force (build_pointer_type (type), addr, 0);
+
+ if (TREE_CODE (addr) == NOP_EXPR
+ && TREE_OPERAND (addr, 0) == current_class_decl)
+ ref = C_C_D;
+ else
+ ref = build_indirect_ref (addr, NULL_PTR);
+ ptr = 0;
+ }
+
+ my_friendly_assert (IS_AGGR_TYPE (type), 220);
+
+ if (! TYPE_NEEDS_DESTRUCTOR (type))
+ {
+ if (auto_delete == integer_zero_node)
+ return void_zero_node;
+
+ /* Pass the size of the object down to the operator delete() in
+ addition to the ADDR. */
+ if (TYPE_GETS_REG_DELETE (type) && !use_global_delete)
+ {
+ tree virtual_size = c_sizeof_nowarn (type);
+ return build_opfncall (DELETE_EXPR, LOOKUP_NORMAL, addr,
+ virtual_size, NULL_TREE);
+ }
+
+ /* Call the builtin operator delete. */
+ return build_builtin_call (void_type_node, BID,
+ build_tree_list (NULL_TREE, addr));
+ }
+ parms = build_tree_list (NULL_TREE, addr);
+
+ /* Below, we will reverse the order in which these calls are made.
+ If we have a destructor, then that destructor will take care
+ of the base classes; otherwise, we must do that here. */
+ if (TYPE_HAS_DESTRUCTOR (type))
+ {
+ tree dtor = DECL_MAIN_VARIANT (TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), 0));
+ tree basetypes = TYPE_BINFO (type);
+ tree passed_auto_delete;
+ tree do_delete = NULL_TREE;
+
+ if (use_global_delete)
+ {
+ tree cond = fold (build (BIT_AND_EXPR, integer_type_node,
+ auto_delete, integer_one_node));
+ tree call = build_builtin_call
+ (void_type_node, BID, build_tree_list (NULL_TREE, addr));
+
+ cond = fold (build (COND_EXPR, void_type_node, cond,
+ call, void_zero_node));
+ if (cond != void_zero_node)
+ do_delete = cond;
+
+ passed_auto_delete = fold (build (BIT_AND_EXPR, integer_type_node,
+ auto_delete, integer_two_node));
+ }
+ else
+ passed_auto_delete = auto_delete;
+
+ if (flags & LOOKUP_PROTECT)
+ {
+ enum access_type access = compute_access (basetypes, dtor);
+
+ if (access == access_private)
+ {
+ if (flags & LOOKUP_COMPLAIN)
+ cp_error ("destructor for type `%T' is private in this scope", type);
+ return error_mark_node;
+ }
+ else if (access == access_protected)
+ {
+ if (flags & LOOKUP_COMPLAIN)
+ cp_error ("destructor for type `%T' is protected in this scope", type);
+ return error_mark_node;
+ }
+ }
+
+ /* Once we are in a destructor, try not going through
+ the virtual function table to find the next destructor. */
+ if (DECL_VINDEX (dtor)
+ && ! (flags & LOOKUP_NONVIRTUAL)
+ && TREE_CODE (auto_delete) != PARM_DECL
+ && (ptr == 1 || ! resolves_to_fixed_type_p (ref, 0)))
+ {
+ tree binfo, basetype;
+ /* The code below is probably all broken. See call.c for the
+ complete right way to do this. this offsets may not be right
+ in the below. (mrs) */
+ /* This destructor must be called via virtual function table. */
+ dtor = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (DECL_CONTEXT (dtor)), 0);
+ basetype = DECL_CLASS_CONTEXT (dtor);
+ binfo = get_binfo (basetype,
+ TREE_TYPE (TREE_TYPE (TREE_VALUE (parms))),
+ 0);
+ expr = convert_pointer_to_real (binfo, TREE_VALUE (parms));
+ if (expr != TREE_VALUE (parms))
+ {
+ expr = fold (expr);
+ ref = build_indirect_ref (expr, NULL_PTR);
+ TREE_VALUE (parms) = expr;
+ }
+ function = build_vfn_ref (&TREE_VALUE (parms), ref, DECL_VINDEX (dtor));
+ if (function == error_mark_node)
+ return error_mark_node;
+ TREE_TYPE (function) = build_pointer_type (TREE_TYPE (dtor));
+ TREE_CHAIN (parms) = build_tree_list (NULL_TREE, passed_auto_delete);
+ expr = build_function_call (function, parms);
+ if (do_delete)
+ expr = build (COMPOUND_EXPR, void_type_node, expr, do_delete);
+ if (ptr && (flags & LOOKUP_DESTRUCTOR) == 0)
+ {
+ /* Handle the case where a virtual destructor is
+ being called on an item that is 0.
+
+ @@ Does this really need to be done? */
+ tree ifexp = build_binary_op(NE_EXPR, addr, integer_zero_node,1);
+#if 0
+ if (TREE_CODE (ref) == VAR_DECL
+ || TREE_CODE (ref) == COMPONENT_REF)
+ warning ("losing in build_delete");
+#endif
+ expr = build (COND_EXPR, void_type_node,
+ ifexp, expr, void_zero_node);
+ }
+ }
+ else
+ {
+ tree ifexp;
+
+ if ((flags & LOOKUP_DESTRUCTOR)
+ || TREE_CODE (ref) == VAR_DECL
+ || TREE_CODE (ref) == PARM_DECL
+ || TREE_CODE (ref) == COMPONENT_REF
+ || TREE_CODE (ref) == ARRAY_REF)
+ /* These can't be 0. */
+ ifexp = integer_one_node;
+ else
+ /* Handle the case where a non-virtual destructor is
+ being called on an item that is 0. */
+ ifexp = build_binary_op (NE_EXPR, addr, integer_zero_node, 1);
+
+ /* Used to mean that this destructor was known to be empty,
+ but that's now obsolete. */
+ my_friendly_assert (DECL_INITIAL (dtor) != void_type_node, 221);
+
+ TREE_CHAIN (parms) = build_tree_list (NULL_TREE, passed_auto_delete);
+ expr = build_function_call (dtor, parms);
+ if (do_delete)
+ expr = build (COMPOUND_EXPR, void_type_node, expr, do_delete);
+
+ if (ifexp != integer_one_node)
+ expr = build (COND_EXPR, void_type_node,
+ ifexp, expr, void_zero_node);
+ }
+ return expr;
+ }
+ else
+ {
+ /* This can get visibilities wrong. */
+ tree binfos = BINFO_BASETYPES (TYPE_BINFO (type));
+ int i, n_baseclasses = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+ tree base_binfo = n_baseclasses > 0 ? TREE_VEC_ELT (binfos, 0) : NULL_TREE;
+ tree exprstmt = NULL_TREE;
+ tree parent_auto_delete = auto_delete;
+ tree cond;
+
+ /* If this type does not have a destructor, but does have
+ operator delete, call the parent parent destructor (if any),
+ but let this node do the deleting. Otherwise, it is ok
+ to let the parent destructor do the deleting. */
+ if (TYPE_GETS_REG_DELETE (type) && !use_global_delete)
+ {
+ parent_auto_delete = integer_zero_node;
+ if (auto_delete == integer_zero_node)
+ cond = NULL_TREE;
+ else
+ {
+ tree virtual_size;
+
+ /* This is probably wrong. It should be the size of the
+ virtual object being deleted. */
+ virtual_size = c_sizeof_nowarn (type);
+
+ expr = build_opfncall (DELETE_EXPR, LOOKUP_NORMAL, addr,
+ virtual_size, NULL_TREE);
+ if (expr == error_mark_node)
+ return error_mark_node;
+ if (auto_delete != integer_one_node)
+ cond = build (COND_EXPR, void_type_node,
+ build (BIT_AND_EXPR, integer_type_node,
+ auto_delete, integer_one_node),
+ expr, void_zero_node);
+ else
+ cond = expr;
+ }
+ }
+ else if (base_binfo == NULL_TREE
+ || (TREE_VIA_VIRTUAL (base_binfo) == 0
+ && ! TYPE_NEEDS_DESTRUCTOR (BINFO_TYPE (base_binfo))))
+ {
+ tree virtual_size;
+
+ /* This is probably wrong. It should be the size of the virtual
+ object being deleted. */
+ virtual_size = c_sizeof_nowarn (type);
+
+ cond = build (COND_EXPR, void_type_node,
+ build (BIT_AND_EXPR, integer_type_node, auto_delete, integer_one_node),
+ build_builtin_call (void_type_node, BID,
+ build_tree_list (NULL_TREE, addr)),
+ void_zero_node);
+ }
+ else
+ cond = NULL_TREE;
+
+ if (cond)
+ exprstmt = build_tree_list (NULL_TREE, cond);
+
+ if (base_binfo
+ && ! TREE_VIA_VIRTUAL (base_binfo)
+ && TYPE_NEEDS_DESTRUCTOR (BINFO_TYPE (base_binfo)))
+ {
+ tree this_auto_delete;
+
+ if (BINFO_OFFSET_ZEROP (base_binfo))
+ this_auto_delete = parent_auto_delete;
+ else
+ this_auto_delete = integer_zero_node;
+
+ expr = build_delete (build_pointer_type (BINFO_TYPE (base_binfo)), addr,
+ this_auto_delete, flags, 0);
+ exprstmt = tree_cons (NULL_TREE, expr, exprstmt);
+ }
+
+ /* Take care of the remaining baseclasses. */
+ for (i = 1; i < n_baseclasses; i++)
+ {
+ base_binfo = TREE_VEC_ELT (binfos, i);
+ if (! TYPE_NEEDS_DESTRUCTOR (BINFO_TYPE (base_binfo))
+ || TREE_VIA_VIRTUAL (base_binfo))
+ continue;
+
+ /* May be zero offset if other baseclasses are virtual. */
+ expr = fold (build (PLUS_EXPR, build_pointer_type (BINFO_TYPE (base_binfo)),
+ addr, BINFO_OFFSET (base_binfo)));
+
+ expr = build_delete (build_pointer_type (BINFO_TYPE (base_binfo)), expr,
+ integer_zero_node,
+ flags, 0);
+
+ exprstmt = tree_cons (NULL_TREE, expr, exprstmt);
+ }
+
+ for (member = TYPE_FIELDS (type); member; member = TREE_CHAIN (member))
+ {
+ if (TREE_CODE (member) != FIELD_DECL)
+ continue;
+ if (TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (member)))
+ {
+ tree this_member = build_component_ref (ref, DECL_NAME (member), 0, 0);
+ tree this_type = TREE_TYPE (member);
+ expr = build_delete (this_type, this_member, integer_two_node, flags, 0);
+ exprstmt = tree_cons (NULL_TREE, expr, exprstmt);
+ }
+ }
+
+ if (exprstmt)
+ return build_compound_expr (exprstmt);
+ /* Virtual base classes make this function do nothing. */
+ return void_zero_node;
+ }
+}
+
+/* For type TYPE, delete the virtual baseclass objects of DECL. */
+
+tree
+build_vbase_delete (type, decl)
+ tree type, decl;
+{
+ tree vbases = CLASSTYPE_VBASECLASSES (type);
+ tree result = NULL_TREE;
+ tree addr = build_unary_op (ADDR_EXPR, decl, 0);
+
+ my_friendly_assert (addr != error_mark_node, 222);
+
+ while (vbases)
+ {
+ tree this_addr = convert_force (build_pointer_type (BINFO_TYPE (vbases)),
+ addr, 0);
+ result = tree_cons (NULL_TREE,
+ build_delete (TREE_TYPE (this_addr), this_addr,
+ integer_zero_node,
+ LOOKUP_NORMAL|LOOKUP_DESTRUCTOR, 0),
+ result);
+ vbases = TREE_CHAIN (vbases);
+ }
+ return build_compound_expr (nreverse (result));
+}
+
+/* Build a C++ vector delete expression.
+ MAXINDEX is the number of elements to be deleted.
+ ELT_SIZE is the nominal size of each element in the vector.
+ BASE is the expression that should yield the store to be deleted.
+ This function expands (or synthesizes) these calls itself.
+ AUTO_DELETE_VEC says whether the container (vector) should be deallocated.
+ AUTO_DELETE say whether each item in the container should be deallocated.
+
+ This also calls delete for virtual baseclasses of elements of the vector.
+
+ Update: MAXINDEX is no longer needed. The size can be extracted from the
+ start of the vector for pointers, and from the type for arrays. We still
+ use MAXINDEX for arrays because it happens to already have one of the
+ values we'd have to extract. (We could use MAXINDEX with pointers to
+ confirm the size, and trap if the numbers differ; not clear that it'd
+ be worth bothering.) */
+tree
+build_vec_delete (base, maxindex, elt_size, auto_delete_vec, auto_delete,
+ use_global_delete)
+ tree base, maxindex, elt_size;
+ tree auto_delete_vec, auto_delete;
+ int use_global_delete;
+{
+ tree type;
+
+ if (TREE_CODE (base) == OFFSET_REF)
+ base = resolve_offset_ref (base);
+
+ type = TREE_TYPE (base);
+
+ base = stabilize_reference (base);
+
+ /* Since we can use base many times, save_expr it. */
+ if (TREE_SIDE_EFFECTS (base))
+ base = save_expr (base);
+
+ if (TREE_CODE (type) == POINTER_TYPE)
+ {
+ /* Step back one from start of vector, and read dimension. */
+ tree cookie_addr = build (MINUS_EXPR, build_pointer_type (BI_header_type),
+ base, BI_header_size);
+ tree cookie = build_indirect_ref (cookie_addr, NULL_PTR);
+ maxindex = build_component_ref (cookie, nc_nelts_field_id, 0, 0);
+ do
+ type = TREE_TYPE (type);
+ while (TREE_CODE (type) == ARRAY_TYPE);
+ }
+ else if (TREE_CODE (type) == ARRAY_TYPE)
+ {
+ /* get the total number of things in the array, maxindex is a bad name */
+ maxindex = array_type_nelts_total (type);
+ while (TREE_CODE (type) == ARRAY_TYPE)
+ type = TREE_TYPE (type);
+ base = build_unary_op (ADDR_EXPR, base, 1);
+ }
+ else
+ {
+ error ("type to vector delete is neither pointer or array type");
+ return error_mark_node;
+ }
+
+ return build_vec_delete_1 (base, maxindex, type, auto_delete_vec, auto_delete,
+ use_global_delete);
+}
diff --git a/contrib/gcc/cp/input.c b/contrib/gcc/cp/input.c
new file mode 100644
index 0000000..77a6468
--- /dev/null
+++ b/contrib/gcc/cp/input.c
@@ -0,0 +1,202 @@
+/* Input handling for G++.
+ Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+ Written by Ken Raeburn (raeburn@cygnus.com) while at Watchmaker Computing.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+/* G++ needs to do enough saving and re-parsing of text that it is
+ necessary to abandon the simple FILE* model and use a mechanism where
+ we can pre-empt one input stream with another derived from saved text;
+ we may need to do this arbitrarily often, and cannot depend on having
+ the GNU library available, so FILE objects just don't cut it.
+
+ This file is written as a separate module, but can be included by
+ lex.c for very minor efficiency gains (primarily in function
+ inlining). */
+
+#include <stdio.h>
+#include "obstack.h"
+
+extern FILE *finput;
+
+struct pending_input *save_pending_input ();
+void restore_pending_input ();
+
+struct input_source {
+ /* saved string */
+ char *str;
+ int length;
+ /* current position, when reading as input */
+ int offset;
+ /* obstack to free this input string from when finished, if any */
+ struct obstack *obstack;
+ /* linked list maintenance */
+ struct input_source *next;
+ /* values to restore after reading all of current string */
+ char *filename;
+ int lineno;
+ struct pending_input *input;
+ int putback_char;
+};
+
+static struct input_source *input, *free_inputs;
+
+extern char *input_filename;
+extern int lineno;
+
+#ifdef __GNUC__
+#define inline __inline__
+#else
+#define inline
+#endif
+
+static inline struct input_source *
+allocate_input ()
+{
+ struct input_source *inp;
+ if (free_inputs)
+ {
+ inp = free_inputs;
+ free_inputs = inp->next;
+ inp->next = 0;
+ return inp;
+ }
+ inp = (struct input_source *) xmalloc (sizeof (struct input_source));
+ inp->next = 0;
+ inp->obstack = 0;
+ return inp;
+}
+
+static inline void
+free_input (inp)
+ struct input_source *inp;
+{
+ if (inp->obstack)
+ obstack_free (inp->obstack, inp->str);
+ inp->obstack = 0;
+ inp->str = 0;
+ inp->length = 0;
+ inp->next = free_inputs;
+ free_inputs = inp;
+}
+
+static int putback_char = -1;
+
+/* Some of these external functions are declared inline in case this file
+ is included in lex.c. */
+
+inline
+void
+feed_input (str, len, delete)
+ char *str;
+ int len;
+ struct obstack *delete;
+{
+ struct input_source *inp = allocate_input ();
+
+ /* This shouldn't be necessary. */
+ while (len && !str[len-1])
+ len--;
+
+ inp->str = str;
+ inp->length = len;
+ inp->obstack = delete;
+ inp->offset = 0;
+ inp->next = input;
+ inp->filename = input_filename;
+ inp->lineno = lineno;
+ inp->input = save_pending_input ();
+ inp->putback_char = putback_char;
+ putback_char = -1;
+ input = inp;
+}
+
+struct pending_input *to_be_restored; /* XXX */
+extern int end_of_file;
+
+static inline int
+sub_getch ()
+{
+ if (putback_char != -1)
+ {
+ int ch = putback_char;
+ putback_char = -1;
+ return ch;
+ }
+ if (input)
+ {
+ if (input->offset == input->length)
+ {
+ struct input_source *inp = input;
+ my_friendly_assert (putback_char == -1, 223);
+ to_be_restored = inp->input;
+ input->offset++;
+ return EOF;
+ }
+ else if (input->offset > input->length)
+ {
+ struct input_source *inp = input;
+
+ end_of_file = 0;
+ input = inp->next;
+ input_filename = inp->filename;
+ lineno = inp->lineno;
+ /* Get interface/implementation back in sync. */
+ extract_interface_info ();
+ putback_char = inp->putback_char;
+ free_input (inp);
+ return getch ();
+ }
+ if (input)
+ return input->str[input->offset++];
+ }
+ return getc (finput);
+}
+
+inline
+void
+put_back (ch)
+ int ch;
+{
+ if (ch != EOF)
+ {
+ my_friendly_assert (putback_char == -1, 224);
+ putback_char = ch;
+ }
+}
+
+extern int linemode;
+
+int
+getch ()
+{
+ int ch = sub_getch ();
+ if (linemode && ch == '\n')
+ {
+ put_back (ch);
+ ch = EOF;
+ }
+ return ch;
+}
+
+inline
+int
+input_redirected ()
+{
+ return input != 0;
+}
diff --git a/contrib/gcc/cp/lang-options.h b/contrib/gcc/cp/lang-options.h
new file mode 100644
index 0000000..d551357
--- /dev/null
+++ b/contrib/gcc/cp/lang-options.h
@@ -0,0 +1,107 @@
+/* Definitions for switches for C++.
+ Copyright (C) 1995 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+/* This is the contribution to the `lang_options' array in gcc.c for
+ g++. */
+
+ "-+e0", /* gcc.c tacks the `-' on the front. */
+ "-+e1",
+ "-+e2",
+ "-faccess-control",
+ "-fno-access-control",
+ "-fall-virtual",
+ "-fno-all-virtual",
+ "-falt-external-templates",
+ "-fno-alt-external-templates",
+ "-fansi-overloading",
+ "-fno-ansi-overloading",
+ "-fcadillac",
+ "-fno-cadillac",
+ "-fcheck-new",
+ "-fno-check-new",
+ "-fconserve-space",
+ "-fno-conserve-space",
+ "-fdefault-inline",
+ "-fno-default-inline",
+ "-frtti",
+ "-fno-rtti",
+ "-felide-constructors",
+ "-fno-elide-constructors",
+ "-fenum-int-equiv",
+ "-fno-enum-int-equiv",
+ "-fexternal-templates",
+ "-fno-external-templates",
+ "-ffor-scope",
+ "-fno-for-scope",
+ "-fgc",
+ "-fno-gc",
+ "-fgnu-keywords",
+ "-fno-gnu-keywords",
+ "-fhandle-exceptions",
+ "-fno-handle-exceptions",
+ "-fhandle-signatures",
+ "-fno-handle-signatures",
+ "-fhuge-objects",
+ "-fno-huge-objects",
+ "-fimplement-inlines",
+ "-fno-implement-inlines",
+ "-fimplicit-templates",
+ "-fno-implicit-templates",
+ "-flabels-ok",
+ "-fno-labels-ok",
+ "-fmemoize-lookups",
+ "-fno-memoize-lookups",
+ "-fnonnull-objects",
+ "-fno-nonnull-objects",
+ "-foperator-names",
+ "-fno-operator-names",
+ "-frepo",
+ "-fno-repo",
+ "-fsave-memoized",
+ "-fno-save-memoized",
+ "-fshort-temps",
+ "-fno-short-temps",
+ "-fstats",
+ "-fno-stats",
+ "-fstrict-prototype",
+ "-fno-strict-prototype",
+ "-fthis-is-variable",
+ "-fno-this-is-variable",
+ "-fvtable-thunks",
+ "-fno-vtable-thunks",
+ "-fxref",
+ "-fno-xref",
+
+ "-Wreturn-type",
+ "-Wno-return-type",
+ "-Woverloaded-virtual",
+ "-Wno-overloaded-virtual",
+ "-Wtemplate-debugging",
+ "-Wno-template-debugging",
+ "-Wctor-dtor-privacy",
+ "-Wno-ctor-dtor-privacy",
+ "-Wnon-virtual-dtor",
+ "-Wno-non-virtual-dtor",
+ "-Wextern-inline",
+ "-Wno-extern-inline",
+ "-Wreorder",
+ "-Wno-reorder",
+ "-Wsynth",
+ "-Wno-synth",
diff --git a/contrib/gcc/cp/lang-specs.h b/contrib/gcc/cp/lang-specs.h
new file mode 100644
index 0000000..fbb72c9
--- /dev/null
+++ b/contrib/gcc/cp/lang-specs.h
@@ -0,0 +1,59 @@
+/* Definitions for specs for C++.
+ Copyright (C) 1995 Free Software Foundation, Inc.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+/* This is the contribution to the `default_compilers' array in gcc.c for
+ g++. */
+
+ {".cc", "@c++"},
+ {".cxx", "@c++"},
+ {".cpp", "@c++"},
+ {".c++", "@c++"},
+ {".C", "@c++"},
+ {"@c++",
+ "cpp -lang-c++ %{nostdinc*} %{C} %{v} %{A*} %{I*} %{P} %I\
+ %{C:%{!E:%eGNU C++ does not support -C without using -E}}\
+ %{M} %{MM} %{MD:-MD %b.d} %{MMD:-MMD %b.d} %{MG}\
+ -undef -D__GNUC__=%v1 -D__GNUG__=%v1 -D__cplusplus -D__GNUC_MINOR__=%v2\
+ %{ansi:-trigraphs -$ -D__STRICT_ANSI__} %{!undef:%{!ansi:%p} %P}\
+ %c %{O*:%{!O0:-D__OPTIMIZE__}} %{traditional} %{ftraditional:-traditional}\
+ %{traditional-cpp:-traditional} %{trigraphs}\
+ %{g*} %{W*} %{w} %{pedantic*} %{H} %{d*} %C %{D*} %{U*} %{i*} %Z\
+ %i %{!M:%{!MM:%{!E:%{!pipe:%g.ii}}}}%{E:%W{o*}}%{M:%W{o*}}%{MM:%W{o*}} |\n",
+ "%{!M:%{!MM:%{!E:cc1plus %{!pipe:%g.ii} %1 %2\
+ %{!Q:-quiet} -dumpbase %b.cc %{d*} %{m*} %{a}\
+ %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi}\
+ %{traditional} %{v:-version} %{pg:-p} %{p}\
+ %{f*} %{+e*} %{aux-info*}\
+ %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
+ %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}}|\n\
+ %{!S:as %a %Y\
+ %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}\
+ %{!pipe:%g.s} %A\n }}}}"},
+ {".ii", "@c++-cpp-output"},
+ {"@c++-cpp-output",
+ "%{!M:%{!MM:%{!E:cc1plus %i %1 %2 %{!Q:-quiet} %{d*} %{m*} %{a}\
+ %{g*} %{O*} %{W*} %{w} %{pedantic*} %{ansi}\
+ %{traditional} %{v:-version} %{pg:-p} %{p}\
+ %{f*} %{+e*} %{aux-info*}\
+ %{pg:%{fomit-frame-pointer:%e-pg and -fomit-frame-pointer are incompatible}}\
+ %{S:%W{o*}%{!o*:-o %b.s}}%{!S:-o %{|!pipe:%g.s}} |\n\
+ %{!S:as %a %Y\
+ %{c:%W{o*}%{!o*:-o %w%b%O}}%{!c:-o %d%w%u%O}\
+ %{!pipe:%g.s} %A\n }}}}"},
diff --git a/contrib/gcc/cp/lex.c b/contrib/gcc/cp/lex.c
new file mode 100644
index 0000000..1861f9e
--- /dev/null
+++ b/contrib/gcc/cp/lex.c
@@ -0,0 +1,4717 @@
+/* Separate lexical analyzer for GNU C++.
+ Copyright (C) 1987, 89, 92, 93, 94, 1995 Free Software Foundation, Inc.
+ Hacked by Michael Tiemann (tiemann@cygnus.com)
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+/* This file is the lexical analyzer for GNU C++. */
+
+/* Cause the `yydebug' variable to be defined. */
+#define YYDEBUG 1
+
+#include <sys/types.h>
+#include <stdio.h>
+#include <errno.h>
+#include <setjmp.h>
+#include "config.h"
+#include "input.h"
+#include "tree.h"
+#include "lex.h"
+#include "parse.h"
+#include "cp-tree.h"
+#include "flags.h"
+#include "obstack.h"
+#include "c-pragma.h"
+
+#ifdef MULTIBYTE_CHARS
+#include <stdlib.h>
+#include <locale.h>
+#endif
+
+#ifndef errno
+extern int errno; /* needed for VAX. */
+#endif
+extern jmp_buf toplevel;
+
+#define obstack_chunk_alloc xmalloc
+#define obstack_chunk_free free
+
+extern struct obstack *expression_obstack, permanent_obstack;
+extern struct obstack *current_obstack, *saveable_obstack;
+
+extern double atof ();
+
+extern char *get_directive_line (); /* In c-common.c */
+
+/* Given a file name X, return the nondirectory portion.
+ Keep in mind that X can be computed more than once. */
+#ifndef FILE_NAME_NONDIRECTORY
+#define FILE_NAME_NONDIRECTORY(X) \
+ (rindex (X, '/') != 0 ? rindex (X, '/') + 1 : X)
+#endif
+
+extern char *index ();
+extern char *rindex ();
+
+void extract_interface_info ();
+void yyerror ();
+
+/* This obstack is needed to hold text. It is not safe to use
+ TOKEN_BUFFER because `check_newline' calls `yylex'. */
+struct obstack inline_text_obstack;
+static char *inline_text_firstobj;
+
+/* This obstack is used to hold information about methods to be
+ synthesized. It should go away when synthesized methods are handled
+ properly (i.e. only when needed). */
+struct obstack synth_obstack;
+static char *synth_firstobj;
+
+int end_of_file;
+
+/* Pending language change.
+ Positive is push count, negative is pop count. */
+int pending_lang_change = 0;
+
+/* Wrap the current header file in extern "C". */
+static int c_header_level = 0;
+
+extern int first_token;
+extern struct obstack token_obstack;
+
+/* ??? Don't really know where this goes yet. */
+#if 1
+#include "input.c"
+#else
+extern void put_back (/* int */);
+extern int input_redirected ();
+extern void feed_input (/* char *, int, struct obstack * */);
+#endif
+
+/* Holds translations from TREE_CODEs to operator name strings,
+ i.e., opname_tab[PLUS_EXPR] == "+". */
+char **opname_tab;
+char **assignop_tab;
+
+extern int yychar; /* the lookahead symbol */
+extern YYSTYPE yylval; /* the semantic value of the */
+ /* lookahead symbol */
+
+#if 0
+YYLTYPE yylloc; /* location data for the lookahead */
+ /* symbol */
+#endif
+
+
+/* the declaration found for the last IDENTIFIER token read in.
+ yylex must look this up to detect typedefs, which get token type TYPENAME,
+ so it is left around in case the identifier is not a typedef but is
+ used in a context which makes it a reference to a variable. */
+tree lastiddecl;
+
+/* The elements of `ridpointers' are identifier nodes
+ for the reserved type names and storage classes.
+ It is indexed by a RID_... value. */
+tree ridpointers[(int) RID_MAX];
+
+/* We may keep statistics about how long which files took to compile. */
+static int header_time, body_time;
+static tree get_time_identifier ();
+static tree filename_times;
+static tree this_filename_time;
+
+/* For implementing #pragma unit. */
+tree current_unit_name;
+tree current_unit_language;
+
+/* Array for holding counts of the numbers of tokens seen. */
+extern int *token_count;
+
+/* Textual definition used for default functions. */
+static void default_copy_constructor_body ();
+static void default_assign_ref_body ();
+
+/* Return something to represent absolute declarators containing a *.
+ TARGET is the absolute declarator that the * contains.
+ TYPE_QUALS is a list of modifiers such as const or volatile
+ to apply to the pointer type, represented as identifiers.
+
+ We return an INDIRECT_REF whose "contents" are TARGET
+ and whose type is the modifier list. */
+
+tree
+make_pointer_declarator (type_quals, target)
+ tree type_quals, target;
+{
+ if (target && TREE_CODE (target) == IDENTIFIER_NODE
+ && ANON_AGGRNAME_P (target))
+ error ("type name expected before `*'");
+ target = build_parse_node (INDIRECT_REF, target);
+ TREE_TYPE (target) = type_quals;
+ return target;
+}
+
+/* Return something to represent absolute declarators containing a &.
+ TARGET is the absolute declarator that the & contains.
+ TYPE_QUALS is a list of modifiers such as const or volatile
+ to apply to the reference type, represented as identifiers.
+
+ We return an ADDR_EXPR whose "contents" are TARGET
+ and whose type is the modifier list. */
+
+tree
+make_reference_declarator (type_quals, target)
+ tree type_quals, target;
+{
+ if (target)
+ {
+ if (TREE_CODE (target) == ADDR_EXPR)
+ {
+ error ("cannot declare references to references");
+ return target;
+ }
+ if (TREE_CODE (target) == INDIRECT_REF)
+ {
+ error ("cannot declare pointers to references");
+ return target;
+ }
+ if (TREE_CODE (target) == IDENTIFIER_NODE && ANON_AGGRNAME_P (target))
+ error ("type name expected before `&'");
+ }
+ target = build_parse_node (ADDR_EXPR, target);
+ TREE_TYPE (target) = type_quals;
+ return target;
+}
+
+/* Build names and nodes for overloaded operators. */
+
+tree ansi_opname[LAST_CPLUS_TREE_CODE];
+tree ansi_assopname[LAST_CPLUS_TREE_CODE];
+
+char *
+operator_name_string (name)
+ tree name;
+{
+ char *opname = IDENTIFIER_POINTER (name) + 2;
+ tree *opname_table;
+ int i, assign;
+
+ /* Works for builtin and user defined types. */
+ if (IDENTIFIER_GLOBAL_VALUE (name)
+ && TREE_CODE (IDENTIFIER_GLOBAL_VALUE (name)) == TYPE_DECL)
+ return IDENTIFIER_POINTER (name);
+
+ if (opname[0] == 'a' && opname[2] != '\0' && opname[2] != '_')
+ {
+ opname += 1;
+ assign = 1;
+ opname_table = ansi_assopname;
+ }
+ else
+ {
+ assign = 0;
+ opname_table = ansi_opname;
+ }
+
+ for (i = 0; i < (int) LAST_CPLUS_TREE_CODE; i++)
+ {
+ if (opname[0] == IDENTIFIER_POINTER (opname_table[i])[2+assign]
+ && opname[1] == IDENTIFIER_POINTER (opname_table[i])[3+assign])
+ break;
+ }
+
+ if (i == LAST_CPLUS_TREE_CODE)
+ return "<invalid operator>";
+
+ if (assign)
+ return assignop_tab[i];
+ else
+ return opname_tab[i];
+}
+
+int interface_only; /* whether or not current file is only for
+ interface definitions. */
+int interface_unknown; /* whether or not we know this class
+ to behave according to #pragma interface. */
+
+/* lexical analyzer */
+
+/* File used for outputting assembler code. */
+extern FILE *asm_out_file;
+
+#ifndef WCHAR_TYPE_SIZE
+#ifdef INT_TYPE_SIZE
+#define WCHAR_TYPE_SIZE INT_TYPE_SIZE
+#else
+#define WCHAR_TYPE_SIZE BITS_PER_WORD
+#endif
+#endif
+
+/* Number of bytes in a wide character. */
+#define WCHAR_BYTES (WCHAR_TYPE_SIZE / BITS_PER_UNIT)
+
+static int maxtoken; /* Current nominal length of token buffer. */
+char *token_buffer; /* Pointer to token buffer.
+ Actual allocated length is maxtoken + 2. */
+
+#include "hash.h"
+
+int check_newline ();
+
+/* Nonzero tells yylex to ignore \ in string constants. */
+static int ignore_escape_flag = 0;
+
+static int skip_white_space ();
+
+static tree
+get_time_identifier (name)
+ char *name;
+{
+ tree time_identifier;
+ int len = strlen (name);
+ char *buf = (char *) alloca (len + 6);
+ strcpy (buf, "file ");
+ bcopy (name, buf+5, len);
+ buf[len+5] = '\0';
+ time_identifier = get_identifier (buf);
+ if (IDENTIFIER_LOCAL_VALUE (time_identifier) == NULL_TREE)
+ {
+ push_obstacks_nochange ();
+ end_temporary_allocation ();
+ IDENTIFIER_LOCAL_VALUE (time_identifier) = build_int_2 (0, 0);
+ IDENTIFIER_CLASS_VALUE (time_identifier) = build_int_2 (0, 1);
+ IDENTIFIER_GLOBAL_VALUE (time_identifier) = filename_times;
+ filename_times = time_identifier;
+ pop_obstacks ();
+ }
+ return time_identifier;
+}
+
+#ifdef __GNUC__
+__inline
+#endif
+static int
+my_get_run_time ()
+{
+ int old_quiet_flag = quiet_flag;
+ int this_time;
+ quiet_flag = 0;
+ this_time = get_run_time ();
+ quiet_flag = old_quiet_flag;
+ return this_time;
+}
+
+/* Table indexed by tree code giving a string containing a character
+ classifying the tree code. Possibilities are
+ t, d, s, c, r, <, 1 and 2. See cp/tree.def for details. */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE,
+
+char *cplus_tree_code_type[] = {
+ "x",
+#include "tree.def"
+};
+#undef DEFTREECODE
+
+/* Table indexed by tree code giving number of expression
+ operands beyond the fixed part of the node structure.
+ Not used for types or decls. */
+
+#define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH,
+
+int cplus_tree_code_length[] = {
+ 0,
+#include "tree.def"
+};
+#undef DEFTREECODE
+
+/* Names of tree components.
+ Used for printing out the tree and error messages. */
+#define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME,
+
+char *cplus_tree_code_name[] = {
+ "@@dummy",
+#include "tree.def"
+};
+#undef DEFTREECODE
+
+/* toplev.c needs to call these. */
+
+void
+lang_init ()
+{
+ /* the beginning of the file is a new line; check for # */
+ /* With luck, we discover the real source file's name from that
+ and put it in input_filename. */
+ put_back (check_newline ());
+
+ if (flag_cadillac)
+ cadillac_start ();
+ if (flag_gnu_xref) GNU_xref_begin (input_filename);
+ init_repo (input_filename);
+}
+
+void
+lang_finish ()
+{
+ extern int errorcount, sorrycount;
+ if (flag_gnu_xref) GNU_xref_end (errorcount+sorrycount);
+}
+
+char *
+lang_identify ()
+{
+ return "cplusplus";
+}
+
+void
+init_filename_times ()
+{
+ this_filename_time = get_time_identifier ("<top level>");
+ if (flag_detailed_statistics)
+ {
+ header_time = 0;
+ body_time = my_get_run_time ();
+ TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time)) = body_time;
+ }
+}
+
+/* Change by Bryan Boreham, Kewill, Thu Jul 27 09:46:05 1989.
+ Stuck this hack in to get the files open correctly; this is called
+ in place of init_lex if we are an unexec'd binary. */
+void
+reinit_lang_specific ()
+{
+ init_filename_times ();
+ reinit_search_statistics ();
+}
+
+void
+init_lex ()
+{
+ extern char *(*decl_printable_name) ();
+ extern int flag_no_gnu_keywords;
+ extern int flag_operator_names;
+
+ int i;
+
+ /* Initialize the lookahead machinery. */
+ init_spew ();
+
+ /* Make identifier nodes long enough for the language-specific slots. */
+ set_identifier_size (sizeof (struct lang_identifier));
+ decl_printable_name = lang_printable_name;
+
+ init_cplus_expand ();
+
+ tree_code_type
+ = (char **) realloc (tree_code_type,
+ sizeof (char *) * LAST_CPLUS_TREE_CODE);
+ tree_code_length
+ = (int *) realloc (tree_code_length,
+ sizeof (int) * LAST_CPLUS_TREE_CODE);
+ tree_code_name
+ = (char **) realloc (tree_code_name,
+ sizeof (char *) * LAST_CPLUS_TREE_CODE);
+ bcopy ((char *)cplus_tree_code_type,
+ (char *)(tree_code_type + (int) LAST_AND_UNUSED_TREE_CODE),
+ (LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
+ bcopy ((char *)cplus_tree_code_length,
+ (char *)(tree_code_length + (int) LAST_AND_UNUSED_TREE_CODE),
+ (LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (int));
+ bcopy ((char *)cplus_tree_code_name,
+ (char *)(tree_code_name + (int) LAST_AND_UNUSED_TREE_CODE),
+ (LAST_CPLUS_TREE_CODE - (int)LAST_AND_UNUSED_TREE_CODE) * sizeof (char *));
+
+ opname_tab = (char **)oballoc ((int)LAST_CPLUS_TREE_CODE * sizeof (char *));
+ bzero ((char *)opname_tab, (int)LAST_CPLUS_TREE_CODE * sizeof (char *));
+ assignop_tab = (char **)oballoc ((int)LAST_CPLUS_TREE_CODE * sizeof (char *));
+ bzero ((char *)assignop_tab, (int)LAST_CPLUS_TREE_CODE * sizeof (char *));
+
+ ansi_opname[0] = get_identifier ("<invalid operator>");
+ for (i = 0; i < (int) LAST_CPLUS_TREE_CODE; i++)
+ {
+ ansi_opname[i] = ansi_opname[0];
+ ansi_assopname[i] = ansi_opname[0];
+ }
+
+ ansi_opname[(int) MULT_EXPR] = get_identifier ("__ml");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) MULT_EXPR]) = 1;
+ ansi_opname[(int) INDIRECT_REF] = ansi_opname[(int) MULT_EXPR];
+ ansi_assopname[(int) MULT_EXPR] = get_identifier ("__aml");
+ IDENTIFIER_OPNAME_P (ansi_assopname[(int) MULT_EXPR]) = 1;
+ ansi_assopname[(int) INDIRECT_REF] = ansi_assopname[(int) MULT_EXPR];
+ ansi_opname[(int) TRUNC_MOD_EXPR] = get_identifier ("__md");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUNC_MOD_EXPR]) = 1;
+ ansi_assopname[(int) TRUNC_MOD_EXPR] = get_identifier ("__amd");
+ IDENTIFIER_OPNAME_P (ansi_assopname[(int) TRUNC_MOD_EXPR]) = 1;
+ ansi_opname[(int) CEIL_MOD_EXPR] = ansi_opname[(int) TRUNC_MOD_EXPR];
+ ansi_opname[(int) FLOOR_MOD_EXPR] = ansi_opname[(int) TRUNC_MOD_EXPR];
+ ansi_opname[(int) ROUND_MOD_EXPR] = ansi_opname[(int) TRUNC_MOD_EXPR];
+ ansi_opname[(int) MINUS_EXPR] = get_identifier ("__mi");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) MINUS_EXPR]) = 1;
+ ansi_opname[(int) NEGATE_EXPR] = ansi_opname[(int) MINUS_EXPR];
+ ansi_assopname[(int) MINUS_EXPR] = get_identifier ("__ami");
+ IDENTIFIER_OPNAME_P (ansi_assopname[(int) MINUS_EXPR]) = 1;
+ ansi_assopname[(int) NEGATE_EXPR] = ansi_assopname[(int) MINUS_EXPR];
+ ansi_opname[(int) RSHIFT_EXPR] = get_identifier ("__rs");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) RSHIFT_EXPR]) = 1;
+ ansi_assopname[(int) RSHIFT_EXPR] = get_identifier ("__ars");
+ IDENTIFIER_OPNAME_P (ansi_assopname[(int) RSHIFT_EXPR]) = 1;
+ ansi_opname[(int) NE_EXPR] = get_identifier ("__ne");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) NE_EXPR]) = 1;
+ ansi_opname[(int) GT_EXPR] = get_identifier ("__gt");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) GT_EXPR]) = 1;
+ ansi_opname[(int) GE_EXPR] = get_identifier ("__ge");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) GE_EXPR]) = 1;
+ ansi_opname[(int) BIT_IOR_EXPR] = get_identifier ("__or");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_IOR_EXPR]) = 1;
+ ansi_assopname[(int) BIT_IOR_EXPR] = get_identifier ("__aor");
+ IDENTIFIER_OPNAME_P (ansi_assopname[(int) BIT_IOR_EXPR]) = 1;
+ ansi_opname[(int) TRUTH_ANDIF_EXPR] = get_identifier ("__aa");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUTH_ANDIF_EXPR]) = 1;
+ ansi_opname[(int) TRUTH_NOT_EXPR] = get_identifier ("__nt");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUTH_NOT_EXPR]) = 1;
+ ansi_opname[(int) PREINCREMENT_EXPR] = get_identifier ("__pp");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) PREINCREMENT_EXPR]) = 1;
+ ansi_opname[(int) POSTINCREMENT_EXPR] = ansi_opname[(int) PREINCREMENT_EXPR];
+ ansi_opname[(int) MODIFY_EXPR] = get_identifier ("__as");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) MODIFY_EXPR]) = 1;
+ ansi_assopname[(int) NOP_EXPR] = ansi_opname[(int) MODIFY_EXPR];
+ ansi_opname[(int) COMPOUND_EXPR] = get_identifier ("__cm");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) COMPOUND_EXPR]) = 1;
+ ansi_opname[(int) EXACT_DIV_EXPR] = get_identifier ("__dv");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) EXACT_DIV_EXPR]) = 1;
+ ansi_assopname[(int) EXACT_DIV_EXPR] = get_identifier ("__adv");
+ IDENTIFIER_OPNAME_P (ansi_assopname[(int) EXACT_DIV_EXPR]) = 1;
+ ansi_opname[(int) TRUNC_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
+ ansi_opname[(int) CEIL_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
+ ansi_opname[(int) FLOOR_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
+ ansi_opname[(int) ROUND_DIV_EXPR] = ansi_opname[(int) EXACT_DIV_EXPR];
+ ansi_opname[(int) PLUS_EXPR] = get_identifier ("__pl");
+ ansi_assopname[(int) TRUNC_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
+ ansi_assopname[(int) CEIL_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
+ ansi_assopname[(int) FLOOR_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
+ ansi_assopname[(int) ROUND_DIV_EXPR] = ansi_assopname[(int) EXACT_DIV_EXPR];
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) PLUS_EXPR]) = 1;
+ ansi_assopname[(int) PLUS_EXPR] = get_identifier ("__apl");
+ IDENTIFIER_OPNAME_P (ansi_assopname[(int) PLUS_EXPR]) = 1;
+ ansi_opname[(int) CONVERT_EXPR] = ansi_opname[(int) PLUS_EXPR];
+ ansi_assopname[(int) CONVERT_EXPR] = ansi_assopname[(int) PLUS_EXPR];
+ ansi_opname[(int) LSHIFT_EXPR] = get_identifier ("__ls");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) LSHIFT_EXPR]) = 1;
+ ansi_assopname[(int) LSHIFT_EXPR] = get_identifier ("__als");
+ IDENTIFIER_OPNAME_P (ansi_assopname[(int) LSHIFT_EXPR]) = 1;
+ ansi_opname[(int) EQ_EXPR] = get_identifier ("__eq");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) EQ_EXPR]) = 1;
+ ansi_opname[(int) LT_EXPR] = get_identifier ("__lt");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) LT_EXPR]) = 1;
+ ansi_opname[(int) LE_EXPR] = get_identifier ("__le");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) LE_EXPR]) = 1;
+ ansi_opname[(int) BIT_AND_EXPR] = get_identifier ("__ad");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_AND_EXPR]) = 1;
+ ansi_assopname[(int) BIT_AND_EXPR] = get_identifier ("__aad");
+ IDENTIFIER_OPNAME_P (ansi_assopname[(int) BIT_AND_EXPR]) = 1;
+ ansi_opname[(int) ADDR_EXPR] = ansi_opname[(int) BIT_AND_EXPR];
+ ansi_assopname[(int) ADDR_EXPR] = ansi_assopname[(int) BIT_AND_EXPR];
+ ansi_opname[(int) BIT_XOR_EXPR] = get_identifier ("__er");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_XOR_EXPR]) = 1;
+ ansi_assopname[(int) BIT_XOR_EXPR] = get_identifier ("__aer");
+ IDENTIFIER_OPNAME_P (ansi_assopname[(int) BIT_XOR_EXPR]) = 1;
+ ansi_opname[(int) TRUTH_ORIF_EXPR] = get_identifier ("__oo");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) TRUTH_ORIF_EXPR]) = 1;
+ ansi_opname[(int) BIT_NOT_EXPR] = get_identifier ("__co");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) BIT_NOT_EXPR]) = 1;
+ ansi_opname[(int) PREDECREMENT_EXPR] = get_identifier ("__mm");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) PREDECREMENT_EXPR]) = 1;
+ ansi_opname[(int) POSTDECREMENT_EXPR] = ansi_opname[(int) PREDECREMENT_EXPR];
+ ansi_opname[(int) COMPONENT_REF] = get_identifier ("__rf");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) COMPONENT_REF]) = 1;
+ ansi_opname[(int) MEMBER_REF] = get_identifier ("__rm");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) MEMBER_REF]) = 1;
+ ansi_opname[(int) CALL_EXPR] = get_identifier ("__cl");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) CALL_EXPR]) = 1;
+ ansi_opname[(int) ARRAY_REF] = get_identifier ("__vc");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) ARRAY_REF]) = 1;
+ ansi_opname[(int) NEW_EXPR] = get_identifier ("__nw");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) NEW_EXPR]) = 1;
+ ansi_opname[(int) DELETE_EXPR] = get_identifier ("__dl");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) DELETE_EXPR]) = 1;
+ ansi_opname[(int) VEC_NEW_EXPR] = get_identifier ("__vn");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) VEC_NEW_EXPR]) = 1;
+ ansi_opname[(int) VEC_DELETE_EXPR] = get_identifier ("__vd");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) VEC_DELETE_EXPR]) = 1;
+ ansi_opname[(int) TYPE_EXPR] = get_identifier ("__op");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) TYPE_EXPR]) = 1;
+
+ /* This is not true: these operators are not defined in ANSI,
+ but we need them anyway. */
+ ansi_opname[(int) MIN_EXPR] = get_identifier ("__mn");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) MIN_EXPR]) = 1;
+ ansi_opname[(int) MAX_EXPR] = get_identifier ("__mx");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) MAX_EXPR]) = 1;
+ ansi_opname[(int) COND_EXPR] = get_identifier ("__cn");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) COND_EXPR]) = 1;
+ ansi_opname[(int) METHOD_CALL_EXPR] = get_identifier ("__wr");
+ IDENTIFIER_OPNAME_P (ansi_opname[(int) METHOD_CALL_EXPR]) = 1;
+
+ init_method ();
+ init_error ();
+ gcc_obstack_init (&inline_text_obstack);
+ inline_text_firstobj = (char *) obstack_alloc (&inline_text_obstack, 0);
+ gcc_obstack_init (&synth_obstack);
+ synth_firstobj = (char *) obstack_alloc (&synth_obstack, 0);
+
+ /* Start it at 0, because check_newline is called at the very beginning
+ and will increment it to 1. */
+ lineno = 0;
+ input_filename = "<internal>";
+ current_function_decl = NULL;
+
+ maxtoken = 40;
+ token_buffer = (char *) xmalloc (maxtoken + 2);
+
+ ridpointers[(int) RID_INT] = get_identifier ("int");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_INT],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_INT]));
+ ridpointers[(int) RID_BOOL] = get_identifier ("bool");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_BOOL],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_BOOL]));
+ ridpointers[(int) RID_CHAR] = get_identifier ("char");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_CHAR],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_CHAR]));
+ ridpointers[(int) RID_VOID] = get_identifier ("void");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VOID],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_VOID]));
+ ridpointers[(int) RID_FLOAT] = get_identifier ("float");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_FLOAT],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_FLOAT]));
+ ridpointers[(int) RID_DOUBLE] = get_identifier ("double");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_DOUBLE],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_DOUBLE]));
+ ridpointers[(int) RID_SHORT] = get_identifier ("short");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_SHORT],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_SHORT]));
+ ridpointers[(int) RID_LONG] = get_identifier ("long");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_LONG],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_LONG]));
+ ridpointers[(int) RID_UNSIGNED] = get_identifier ("unsigned");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_UNSIGNED],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_UNSIGNED]));
+ ridpointers[(int) RID_SIGNED] = get_identifier ("signed");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_SIGNED],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_SIGNED]));
+ ridpointers[(int) RID_INLINE] = get_identifier ("inline");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_INLINE],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_INLINE]));
+ ridpointers[(int) RID_CONST] = get_identifier ("const");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_CONST],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_CONST]));
+ ridpointers[(int) RID_VOLATILE] = get_identifier ("volatile");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VOLATILE],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_VOLATILE]));
+ ridpointers[(int) RID_AUTO] = get_identifier ("auto");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_AUTO],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_AUTO]));
+ ridpointers[(int) RID_STATIC] = get_identifier ("static");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_STATIC],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_STATIC]));
+ ridpointers[(int) RID_EXTERN] = get_identifier ("extern");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_EXTERN],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_EXTERN]));
+ ridpointers[(int) RID_TYPEDEF] = get_identifier ("typedef");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_TYPEDEF],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_TYPEDEF]));
+ ridpointers[(int) RID_REGISTER] = get_identifier ("register");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_REGISTER],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_REGISTER]));
+
+ /* C++ extensions. These are probably not correctly named. */
+ ridpointers[(int) RID_WCHAR] = get_identifier ("__wchar_t");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_WCHAR],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_WCHAR]));
+ class_type_node = build_int_2 (class_type, 0);
+ TREE_TYPE (class_type_node) = class_type_node;
+ ridpointers[(int) RID_CLASS] = class_type_node;
+
+ record_type_node = build_int_2 (record_type, 0);
+ TREE_TYPE (record_type_node) = record_type_node;
+ ridpointers[(int) RID_RECORD] = record_type_node;
+
+ union_type_node = build_int_2 (union_type, 0);
+ TREE_TYPE (union_type_node) = union_type_node;
+ ridpointers[(int) RID_UNION] = union_type_node;
+
+ enum_type_node = build_int_2 (enum_type, 0);
+ TREE_TYPE (enum_type_node) = enum_type_node;
+ ridpointers[(int) RID_ENUM] = enum_type_node;
+
+ ridpointers[(int) RID_VIRTUAL] = get_identifier ("virtual");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_VIRTUAL],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_VIRTUAL]));
+ ridpointers[(int) RID_EXPLICIT] = get_identifier ("explicit");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_EXPLICIT],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_EXPLICIT]));
+ ridpointers[(int) RID_FRIEND] = get_identifier ("friend");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_FRIEND],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_FRIEND]));
+
+ ridpointers[(int) RID_PUBLIC] = get_identifier ("public");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_PUBLIC],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_PUBLIC]));
+ ridpointers[(int) RID_PRIVATE] = get_identifier ("private");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_PRIVATE],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_PRIVATE]));
+ ridpointers[(int) RID_PROTECTED] = get_identifier ("protected");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_PROTECTED],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_PROTECTED]));
+ ridpointers[(int) RID_TEMPLATE] = get_identifier ("template");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_TEMPLATE],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_TEMPLATE]));
+ /* This is for ANSI C++. */
+ ridpointers[(int) RID_MUTABLE] = get_identifier ("mutable");
+ SET_IDENTIFIER_AS_LIST (ridpointers[(int) RID_MUTABLE],
+ build_tree_list (NULL_TREE, ridpointers[(int) RID_MUTABLE]));
+
+ /* Signature handling extensions. */
+ signature_type_node = build_int_2 (signature_type, 0);
+ TREE_TYPE (signature_type_node) = signature_type_node;
+ ridpointers[(int) RID_SIGNATURE] = signature_type_node;
+
+ opname_tab[(int) COMPONENT_REF] = "->";
+ opname_tab[(int) MEMBER_REF] = "->*";
+ opname_tab[(int) METHOD_CALL_EXPR] = "->()";
+ opname_tab[(int) INDIRECT_REF] = "(unary *)";
+ opname_tab[(int) ARRAY_REF] = "[]";
+ opname_tab[(int) MODIFY_EXPR] = "=";
+ opname_tab[(int) NEW_EXPR] = "new";
+ opname_tab[(int) DELETE_EXPR] = "delete";
+ opname_tab[(int) VEC_NEW_EXPR] = "new []";
+ opname_tab[(int) VEC_DELETE_EXPR] = "delete []";
+ opname_tab[(int) COND_EXPR] = "... ? ... : ...";
+ opname_tab[(int) CALL_EXPR] = "()";
+ opname_tab[(int) PLUS_EXPR] = "+";
+ opname_tab[(int) MINUS_EXPR] = "-";
+ opname_tab[(int) MULT_EXPR] = "*";
+ opname_tab[(int) TRUNC_DIV_EXPR] = "/";
+ opname_tab[(int) CEIL_DIV_EXPR] = "(ceiling /)";
+ opname_tab[(int) FLOOR_DIV_EXPR] = "(floor /)";
+ opname_tab[(int) ROUND_DIV_EXPR] = "(round /)";
+ opname_tab[(int) TRUNC_MOD_EXPR] = "%";
+ opname_tab[(int) CEIL_MOD_EXPR] = "(ceiling %)";
+ opname_tab[(int) FLOOR_MOD_EXPR] = "(floor %)";
+ opname_tab[(int) ROUND_MOD_EXPR] = "(round %)";
+ opname_tab[(int) NEGATE_EXPR] = "-";
+ opname_tab[(int) MIN_EXPR] = "<?";
+ opname_tab[(int) MAX_EXPR] = ">?";
+ opname_tab[(int) ABS_EXPR] = "abs";
+ opname_tab[(int) FFS_EXPR] = "ffs";
+ opname_tab[(int) LSHIFT_EXPR] = "<<";
+ opname_tab[(int) RSHIFT_EXPR] = ">>";
+ opname_tab[(int) BIT_IOR_EXPR] = "|";
+ opname_tab[(int) BIT_XOR_EXPR] = "^";
+ opname_tab[(int) BIT_AND_EXPR] = "&";
+ opname_tab[(int) BIT_ANDTC_EXPR] = "&~";
+ opname_tab[(int) BIT_NOT_EXPR] = "~";
+ opname_tab[(int) TRUTH_ANDIF_EXPR] = "&&";
+ opname_tab[(int) TRUTH_ORIF_EXPR] = "||";
+ opname_tab[(int) TRUTH_AND_EXPR] = "strict &&";
+ opname_tab[(int) TRUTH_OR_EXPR] = "strict ||";
+ opname_tab[(int) TRUTH_NOT_EXPR] = "!";
+ opname_tab[(int) LT_EXPR] = "<";
+ opname_tab[(int) LE_EXPR] = "<=";
+ opname_tab[(int) GT_EXPR] = ">";
+ opname_tab[(int) GE_EXPR] = ">=";
+ opname_tab[(int) EQ_EXPR] = "==";
+ opname_tab[(int) NE_EXPR] = "!=";
+ opname_tab[(int) IN_EXPR] = "in";
+ opname_tab[(int) RANGE_EXPR] = "..";
+ opname_tab[(int) CONVERT_EXPR] = "(unary +)";
+ opname_tab[(int) ADDR_EXPR] = "(unary &)";
+ opname_tab[(int) PREDECREMENT_EXPR] = "--";
+ opname_tab[(int) PREINCREMENT_EXPR] = "++";
+ opname_tab[(int) POSTDECREMENT_EXPR] = "--";
+ opname_tab[(int) POSTINCREMENT_EXPR] = "++";
+ opname_tab[(int) COMPOUND_EXPR] = ",";
+
+ assignop_tab[(int) NOP_EXPR] = "=";
+ assignop_tab[(int) PLUS_EXPR] = "+=";
+ assignop_tab[(int) CONVERT_EXPR] = "+=";
+ assignop_tab[(int) MINUS_EXPR] = "-=";
+ assignop_tab[(int) NEGATE_EXPR] = "-=";
+ assignop_tab[(int) MULT_EXPR] = "*=";
+ assignop_tab[(int) INDIRECT_REF] = "*=";
+ assignop_tab[(int) TRUNC_DIV_EXPR] = "/=";
+ assignop_tab[(int) EXACT_DIV_EXPR] = "(exact /=)";
+ assignop_tab[(int) CEIL_DIV_EXPR] = "(ceiling /=)";
+ assignop_tab[(int) FLOOR_DIV_EXPR] = "(floor /=)";
+ assignop_tab[(int) ROUND_DIV_EXPR] = "(round /=)";
+ assignop_tab[(int) TRUNC_MOD_EXPR] = "%=";
+ assignop_tab[(int) CEIL_MOD_EXPR] = "(ceiling %=)";
+ assignop_tab[(int) FLOOR_MOD_EXPR] = "(floor %=)";
+ assignop_tab[(int) ROUND_MOD_EXPR] = "(round %=)";
+ assignop_tab[(int) MIN_EXPR] = "<?=";
+ assignop_tab[(int) MAX_EXPR] = ">?=";
+ assignop_tab[(int) LSHIFT_EXPR] = "<<=";
+ assignop_tab[(int) RSHIFT_EXPR] = ">>=";
+ assignop_tab[(int) BIT_IOR_EXPR] = "|=";
+ assignop_tab[(int) BIT_XOR_EXPR] = "^=";
+ assignop_tab[(int) BIT_AND_EXPR] = "&=";
+ assignop_tab[(int) ADDR_EXPR] = "&=";
+
+ init_filename_times ();
+
+ /* Some options inhibit certain reserved words.
+ Clear those words out of the hash table so they won't be recognized. */
+#define UNSET_RESERVED_WORD(STRING) \
+ do { struct resword *s = is_reserved_word (STRING, sizeof (STRING) - 1); \
+ if (s) s->name = ""; } while (0)
+
+#if 0
+ /* let's parse things, and if they use it, then give them an error. */
+ if (!flag_handle_exceptions)
+ {
+ UNSET_RESERVED_WORD ("throw");
+ UNSET_RESERVED_WORD ("try");
+ UNSET_RESERVED_WORD ("catch");
+ }
+#endif
+
+ if (! (flag_gc || flag_rtti) || flag_no_gnu_keywords)
+ {
+ UNSET_RESERVED_WORD ("classof");
+ UNSET_RESERVED_WORD ("headof");
+ }
+ if (! flag_handle_signatures || flag_no_gnu_keywords)
+ {
+ /* Easiest way to not recognize signature
+ handling extensions... */
+ UNSET_RESERVED_WORD ("signature");
+ UNSET_RESERVED_WORD ("sigof");
+ }
+ if (flag_no_asm || flag_no_gnu_keywords)
+ UNSET_RESERVED_WORD ("typeof");
+ if (! flag_operator_names)
+ {
+ /* These are new ANSI keywords that may break code. */
+ UNSET_RESERVED_WORD ("and");
+ UNSET_RESERVED_WORD ("and_eq");
+ UNSET_RESERVED_WORD ("bitand");
+ UNSET_RESERVED_WORD ("bitor");
+ UNSET_RESERVED_WORD ("compl");
+ UNSET_RESERVED_WORD ("not");
+ UNSET_RESERVED_WORD ("not_eq");
+ UNSET_RESERVED_WORD ("or");
+ UNSET_RESERVED_WORD ("or_eq");
+ UNSET_RESERVED_WORD ("xor");
+ UNSET_RESERVED_WORD ("xor_eq");
+ }
+ if (! flag_traditional)
+ UNSET_RESERVED_WORD ("overload");
+
+ token_count = init_parse ();
+ interface_unknown = 1;
+}
+
+void
+reinit_parse_for_function ()
+{
+ current_base_init_list = NULL_TREE;
+ current_member_init_list = NULL_TREE;
+}
+
+#ifdef __GNUC__
+__inline
+#endif
+void
+yyprint (file, yychar, yylval)
+ FILE *file;
+ int yychar;
+ YYSTYPE yylval;
+{
+ tree t;
+ switch (yychar)
+ {
+ case IDENTIFIER:
+ case TYPENAME:
+ case TYPESPEC:
+ case PTYPENAME:
+ case IDENTIFIER_DEFN:
+ case TYPENAME_DEFN:
+ case PTYPENAME_DEFN:
+ case TYPENAME_ELLIPSIS:
+ case SCSPEC:
+ case PRE_PARSED_CLASS_DECL:
+ t = yylval.ttype;
+ my_friendly_assert (TREE_CODE (t) == IDENTIFIER_NODE, 224);
+ if (IDENTIFIER_POINTER (t))
+ fprintf (file, " `%s'", IDENTIFIER_POINTER (t));
+ break;
+ case AGGR:
+ if (yylval.ttype == class_type_node)
+ fprintf (file, " `class'");
+ else if (yylval.ttype == record_type_node)
+ fprintf (file, " `struct'");
+ else if (yylval.ttype == union_type_node)
+ fprintf (file, " `union'");
+ else if (yylval.ttype == enum_type_node)
+ fprintf (file, " `enum'");
+ else if (yylval.ttype == signature_type_node)
+ fprintf (file, " `signature'");
+ else
+ my_friendly_abort (80);
+ break;
+ }
+}
+
+static int *reduce_count;
+int *token_count;
+
+#define REDUCE_LENGTH (sizeof (yyr2) / sizeof (yyr2[0]))
+#define TOKEN_LENGTH (256 + sizeof (yytname) / sizeof (yytname[0]))
+
+int *
+init_parse ()
+{
+#ifdef GATHER_STATISTICS
+ reduce_count = (int *)malloc (sizeof (int) * (REDUCE_LENGTH + 1));
+ bzero (reduce_count, sizeof (int) * (REDUCE_LENGTH + 1));
+ reduce_count += 1;
+ token_count = (int *)malloc (sizeof (int) * (TOKEN_LENGTH + 1));
+ bzero (token_count, sizeof (int) * (TOKEN_LENGTH + 1));
+ token_count += 1;
+#endif
+ return token_count;
+}
+
+#ifdef GATHER_STATISTICS
+void
+yyhook (yyn)
+ int yyn;
+{
+ reduce_count[yyn] += 1;
+}
+
+static int
+reduce_cmp (p, q)
+ int *p, *q;
+{
+ return reduce_count[*q] - reduce_count[*p];
+}
+
+static int
+token_cmp (p, q)
+ int *p, *q;
+{
+ return token_count[*q] - token_count[*p];
+}
+#endif
+
+void
+print_parse_statistics ()
+{
+#ifdef GATHER_STATISTICS
+#if YYDEBUG != 0
+ int i;
+ int maxlen = REDUCE_LENGTH;
+ unsigned *sorted;
+
+ if (reduce_count[-1] == 0)
+ return;
+
+ if (TOKEN_LENGTH > REDUCE_LENGTH)
+ maxlen = TOKEN_LENGTH;
+ sorted = (unsigned *) alloca (sizeof (int) * maxlen);
+
+ for (i = 0; i < TOKEN_LENGTH; i++)
+ sorted[i] = i;
+ qsort (sorted, TOKEN_LENGTH, sizeof (int), token_cmp);
+ for (i = 0; i < TOKEN_LENGTH; i++)
+ {
+ int index = sorted[i];
+ if (token_count[index] == 0)
+ break;
+ if (token_count[index] < token_count[-1])
+ break;
+ fprintf (stderr, "token %d, `%s', count = %d\n",
+ index, yytname[YYTRANSLATE (index)], token_count[index]);
+ }
+ fprintf (stderr, "\n");
+ for (i = 0; i < REDUCE_LENGTH; i++)
+ sorted[i] = i;
+ qsort (sorted, REDUCE_LENGTH, sizeof (int), reduce_cmp);
+ for (i = 0; i < REDUCE_LENGTH; i++)
+ {
+ int index = sorted[i];
+ if (reduce_count[index] == 0)
+ break;
+ if (reduce_count[index] < reduce_count[-1])
+ break;
+ fprintf (stderr, "rule %d, line %d, count = %d\n",
+ index, yyrline[index], reduce_count[index]);
+ }
+ fprintf (stderr, "\n");
+#endif
+#endif
+}
+
+/* Sets the value of the 'yydebug' variable to VALUE.
+ This is a function so we don't have to have YYDEBUG defined
+ in order to build the compiler. */
+void
+set_yydebug (value)
+ int value;
+{
+#if YYDEBUG != 0
+ extern int yydebug;
+ yydebug = value;
+#else
+ warning ("YYDEBUG not defined.");
+#endif
+}
+
+
+/* Functions and data structures for #pragma interface.
+
+ `#pragma implementation' means that the main file being compiled
+ is considered to implement (provide) the classes that appear in
+ its main body. I.e., if this is file "foo.cc", and class `bar'
+ is defined in "foo.cc", then we say that "foo.cc implements bar".
+
+ All main input files "implement" themselves automagically.
+
+ `#pragma interface' means that unless this file (of the form "foo.h"
+ is not presently being included by file "foo.cc", the
+ CLASSTYPE_INTERFACE_ONLY bit gets set. The effect is that none
+ of the vtables nor any of the inline functions defined in foo.h
+ will ever be output.
+
+ There are cases when we want to link files such as "defs.h" and
+ "main.cc". In this case, we give "defs.h" a `#pragma interface',
+ and "main.cc" has `#pragma implementation "defs.h"'. */
+
+struct impl_files
+{
+ char *filename;
+ struct impl_files *next;
+};
+
+static struct impl_files *impl_file_chain;
+
+/* Helper function to load global variables with interface
+ information. */
+void
+extract_interface_info ()
+{
+ tree fileinfo = 0;
+
+ if (flag_alt_external_templates)
+ {
+ struct tinst_level *til = tinst_for_decl ();
+
+ if (til)
+ fileinfo = get_time_identifier (til->file);
+ }
+ if (!fileinfo)
+ fileinfo = get_time_identifier (input_filename);
+ fileinfo = IDENTIFIER_CLASS_VALUE (fileinfo);
+ interface_only = TREE_INT_CST_LOW (fileinfo);
+ if (!processing_template_defn || flag_external_templates)
+ interface_unknown = TREE_INT_CST_HIGH (fileinfo);
+}
+
+/* Return nonzero if S is not considered part of an
+ INTERFACE/IMPLEMENTATION pair. Otherwise, return 0. */
+static int
+interface_strcmp (s)
+ char *s;
+{
+ /* Set the interface/implementation bits for this scope. */
+ struct impl_files *ifiles;
+ char *s1;
+
+ for (ifiles = impl_file_chain; ifiles; ifiles = ifiles->next)
+ {
+ char *t1 = ifiles->filename;
+ s1 = s;
+
+ if (*s1 != *t1 || *s1 == 0)
+ continue;
+
+ while (*s1 == *t1 && *s1 != 0)
+ s1++, t1++;
+
+ /* A match. */
+ if (*s1 == *t1)
+ return 0;
+
+ /* Don't get faked out by xxx.yyy.cc vs xxx.zzz.cc. */
+ if (index (s1, '.') || index (t1, '.'))
+ continue;
+
+ if (*s1 == '\0' || s1[-1] != '.' || t1[-1] != '.')
+ continue;
+
+ /* A match. */
+ return 0;
+ }
+
+ /* No matches. */
+ return 1;
+}
+
+void
+set_typedecl_interface_info (prev, vars)
+ tree prev, vars;
+{
+ tree id = get_time_identifier (DECL_SOURCE_FILE (vars));
+ tree fileinfo = IDENTIFIER_CLASS_VALUE (id);
+ tree type = TREE_TYPE (vars);
+
+ CLASSTYPE_INTERFACE_ONLY (type) = TREE_INT_CST_LOW (fileinfo)
+ = interface_strcmp (FILE_NAME_NONDIRECTORY (DECL_SOURCE_FILE (vars)));
+}
+
+void
+set_vardecl_interface_info (prev, vars)
+ tree prev, vars;
+{
+ tree type = DECL_CONTEXT (vars);
+
+ if (CLASSTYPE_INTERFACE_KNOWN (type))
+ {
+ if (CLASSTYPE_INTERFACE_ONLY (type))
+ set_typedecl_interface_info (prev, TYPE_NAME (type));
+ else
+ CLASSTYPE_VTABLE_NEEDS_WRITING (type) = 1;
+ DECL_EXTERNAL (vars) = CLASSTYPE_INTERFACE_ONLY (type);
+ TREE_PUBLIC (vars) = 1;
+ }
+}
+
+/* Called from the top level: if there are any pending inlines to
+ do, set up to process them now. This function sets up the first function
+ to be parsed; after it has been, the rule for fndef in parse.y will
+ call process_next_inline to start working on the next one. */
+void
+do_pending_inlines ()
+{
+ struct pending_inline *t;
+
+ /* Oops, we're still dealing with the last batch. */
+ if (yychar == PRE_PARSED_FUNCTION_DECL)
+ return;
+
+ /* Reverse the pending inline functions, since
+ they were cons'd instead of appended. */
+ {
+ struct pending_inline *prev = 0, *tail, *bottom = 0;
+ t = pending_inlines;
+ pending_inlines = 0;
+
+ for (; t; t = tail)
+ {
+ tail = t->next;
+ t->next = prev;
+ t->deja_vu = 1;
+ prev = t;
+ }
+
+ /* This kludge should go away when synthesized methods are handled
+ properly, i.e. only when needed. */
+ for (t = prev; t; t = t->next)
+ {
+ if (t->lineno <= 0)
+ {
+ tree f = t->fndecl;
+ DECL_PENDING_INLINE_INFO (f) = 0;
+ interface_unknown = t->interface == 1;
+ interface_only = t->interface == 0;
+ synthesize_method (f);
+ if (tail)
+ tail->next = t->next;
+ else
+ prev = t->next;
+ if (! bottom)
+ bottom = t;
+ }
+ else
+ tail = t;
+ }
+ if (bottom)
+ {
+ obstack_free (&synth_obstack, bottom);
+ extract_interface_info ();
+ }
+ t = prev;
+ }
+
+ if (t == 0)
+ return;
+
+ /* Now start processing the first inline function. */
+ my_friendly_assert ((t->parm_vec == NULL_TREE) == (t->bindings == NULL_TREE),
+ 226);
+ if (t->parm_vec)
+ push_template_decls (t->parm_vec, t->bindings, 0);
+ if (t->len > 0)
+ {
+ feed_input (t->buf, t->len, t->can_free ? &inline_text_obstack : 0);
+ lineno = t->lineno;
+#if 0
+ if (input_filename != t->filename)
+ {
+ input_filename = t->filename;
+ /* Get interface/implementation back in sync. */
+ extract_interface_info ();
+ }
+#else
+ input_filename = t->filename;
+ interface_unknown = t->interface == 1;
+ interface_only = t->interface == 0;
+#endif
+ yychar = PRE_PARSED_FUNCTION_DECL;
+ }
+ /* Pass back a handle on the rest of the inline functions, so that they
+ can be processed later. */
+ yylval.ttype = build_tree_list ((tree) t, t->fndecl);
+#if 0
+ if (flag_default_inline && t->fndecl
+ /* If we're working from a template, don't change
+ the `inline' state. */
+ && t->parm_vec == NULL_TREE)
+ DECL_INLINE (t->fndecl) = 1;
+#endif
+ DECL_PENDING_INLINE_INFO (t->fndecl) = 0;
+}
+
+extern struct pending_input *to_be_restored;
+static int nextchar = -1;
+
+/* Called from the fndecl rule in the parser when the function just parsed
+ was declared using a PRE_PARSED_FUNCTION_DECL (i.e. came from
+ do_pending_inlines). */
+void
+process_next_inline (t)
+ tree t;
+{
+ struct pending_inline *i = (struct pending_inline *) TREE_PURPOSE (t);
+ my_friendly_assert ((i->parm_vec == NULL_TREE) == (i->bindings == NULL_TREE),
+ 227);
+ if (i->parm_vec)
+ pop_template_decls (i->parm_vec, i->bindings, 0);
+ i = i->next;
+ if (yychar == YYEMPTY)
+ yychar = yylex ();
+ if (yychar != END_OF_SAVED_INPUT)
+ {
+ error ("parse error at end of saved function text");
+ /* restore_pending_input will abort unless yychar is either
+ * END_OF_SAVED_INPUT or YYEMPTY; since we already know we're
+ * hosed, feed back YYEMPTY.
+ * We also need to discard nextchar, since that may have gotten
+ * set as well.
+ */
+ nextchar = -1;
+ }
+ yychar = YYEMPTY;
+ if (to_be_restored == 0)
+ my_friendly_abort (123);
+ restore_pending_input (to_be_restored);
+ to_be_restored = 0;
+ if (i && i->fndecl != NULL_TREE)
+ {
+ my_friendly_assert ((i->parm_vec == NULL_TREE) == (i->bindings == NULL_TREE),
+ 228);
+ if (i->parm_vec)
+ push_template_decls (i->parm_vec, i->bindings, 0);
+ feed_input (i->buf, i->len, i->can_free ? &inline_text_obstack : 0);
+ lineno = i->lineno;
+ input_filename = i->filename;
+ yychar = PRE_PARSED_FUNCTION_DECL;
+ yylval.ttype = build_tree_list ((tree) i, i->fndecl);
+#if 0
+ if (flag_default_inline
+ /* If we're working from a template, don't change
+ the `inline' state. */
+ && i->parm_vec == NULL_TREE)
+ DECL_INLINE (i->fndecl) = 1;
+#endif
+ DECL_PENDING_INLINE_INFO (i->fndecl) = 0;
+ }
+ if (i)
+ {
+ interface_unknown = i->interface == 1;
+ interface_only = i->interface == 0;
+ }
+ else
+ extract_interface_info ();
+}
+
+/* Since inline methods can refer to text which has not yet been seen,
+ we store the text of the method in a structure which is placed in the
+ DECL_PENDING_INLINE_INFO field of the FUNCTION_DECL.
+ After parsing the body of the class definition, the FUNCTION_DECL's are
+ scanned to see which ones have this field set. Those are then digested
+ one at a time.
+
+ This function's FUNCTION_DECL will have a bit set in its common so
+ that we know to watch out for it. */
+
+static void
+consume_string (this_obstack, matching_char)
+ register struct obstack *this_obstack;
+ int matching_char;
+{
+ register int c;
+ int starting_lineno = lineno;
+ do
+ {
+ c = getch ();
+ if (c == EOF)
+ {
+ int save_lineno = lineno;
+ lineno = starting_lineno;
+ if (matching_char == '"')
+ error ("end of file encountered inside string constant");
+ else
+ error ("end of file encountered inside character constant");
+ lineno = save_lineno;
+ return;
+ }
+ if (c == '\\')
+ {
+ obstack_1grow (this_obstack, c);
+ c = getch ();
+ obstack_1grow (this_obstack, c);
+
+ /* Make sure we continue the loop */
+ c = 0;
+ continue;
+ }
+ if (c == '\n')
+ {
+ if (pedantic)
+ pedwarn ("ANSI C++ forbids newline in string constant");
+ lineno++;
+ }
+ obstack_1grow (this_obstack, c);
+ }
+ while (c != matching_char);
+}
+
+static int nextyychar = YYEMPTY;
+static YYSTYPE nextyylval;
+
+struct pending_input {
+ int nextchar, yychar, nextyychar, eof;
+ YYSTYPE yylval, nextyylval;
+ struct obstack token_obstack;
+ int first_token;
+};
+
+struct pending_input *
+save_pending_input ()
+{
+ struct pending_input *p;
+ p = (struct pending_input *) xmalloc (sizeof (struct pending_input));
+ p->nextchar = nextchar;
+ p->yychar = yychar;
+ p->nextyychar = nextyychar;
+ p->yylval = yylval;
+ p->nextyylval = nextyylval;
+ p->eof = end_of_file;
+ yychar = nextyychar = YYEMPTY;
+ nextchar = -1;
+ p->first_token = first_token;
+ p->token_obstack = token_obstack;
+
+ first_token = 0;
+ gcc_obstack_init (&token_obstack);
+ end_of_file = 0;
+ return p;
+}
+
+void
+restore_pending_input (p)
+ struct pending_input *p;
+{
+ my_friendly_assert (nextchar == -1, 229);
+ nextchar = p->nextchar;
+ my_friendly_assert (yychar == YYEMPTY || yychar == END_OF_SAVED_INPUT, 230);
+ yychar = p->yychar;
+ my_friendly_assert (nextyychar == YYEMPTY, 231);
+ nextyychar = p->nextyychar;
+ yylval = p->yylval;
+ nextyylval = p->nextyylval;
+ first_token = p->first_token;
+ obstack_free (&token_obstack, (char *) 0);
+ token_obstack = p->token_obstack;
+ end_of_file = p->eof;
+ free (p);
+}
+
+/* Return next non-whitespace input character, which may come
+ from `finput', or from `nextchar'. */
+static int
+yynextch ()
+{
+ int c;
+
+ if (nextchar >= 0)
+ {
+ c = nextchar;
+ nextchar = -1;
+ }
+ else c = getch ();
+ return skip_white_space (c);
+}
+
+/* Unget character CH from the input stream.
+ If RESCAN is non-zero, then we want to `see' this
+ character as the next input token. */
+void
+yyungetc (ch, rescan)
+ int ch;
+ int rescan;
+{
+ /* Unget a character from the input stream. */
+ if (yychar == YYEMPTY || rescan == 0)
+ {
+ if (nextchar >= 0)
+ put_back (nextchar);
+ nextchar = ch;
+ }
+ else
+ {
+ my_friendly_assert (nextyychar == YYEMPTY, 232);
+ nextyychar = yychar;
+ nextyylval = yylval;
+ yychar = ch;
+ }
+}
+
+/* This function stores away the text for an inline function that should
+ be processed later. It decides how much later, and may need to move
+ the info between obstacks; therefore, the caller should not refer to
+ the T parameter after calling this function.
+
+ This function also stores the list of template-parameter bindings that
+ will be needed for expanding the template, if any. */
+
+static void
+store_pending_inline (decl, t)
+ tree decl;
+ struct pending_inline *t;
+{
+ extern int processing_template_defn;
+ int delay_to_eof = 0;
+ struct pending_inline **inlines;
+
+ t->fndecl = decl;
+ /* Default: compile right away, and no extra bindings are needed. */
+ t->parm_vec = t->bindings = 0;
+ if (processing_template_defn)
+ {
+ tree type = current_class_type;
+ /* Assumption: In this (possibly) nested class sequence, only
+ one name will have template parms. */
+ while (type && TREE_CODE_CLASS (TREE_CODE (type)) == 't')
+ {
+ tree decl = TYPE_NAME (type);
+ tree tmpl = IDENTIFIER_TEMPLATE (DECL_NAME (decl));
+ if (tmpl)
+ {
+ t->parm_vec = DECL_TEMPLATE_INFO (TREE_PURPOSE (tmpl))->parm_vec;
+ t->bindings = TREE_VALUE (tmpl);
+ }
+ type = DECL_CONTEXT (decl);
+ }
+ if (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE
+ || TREE_CODE (TREE_TYPE (decl)) == FUNCTION_TYPE)
+ {
+ if (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)
+ my_friendly_assert (TYPE_MAX_VALUE (TREE_TYPE (decl)) == current_class_type,
+ 233);
+
+ /* Inline functions can be compiled immediately. Other functions
+ will be output separately, so if we're in interface-only mode,
+ punt them now, or output them now if we're doing implementations
+ and we know no overrides will exist. Otherwise, we delay until
+ end-of-file, to see if the definition is really required. */
+ if (DECL_THIS_INLINE (decl))
+ /* delay_to_eof == 0 */;
+ else if (current_class_type && !interface_unknown)
+ {
+ if (interface_only)
+ {
+#if 0
+ print_node_brief (stderr, "\ndiscarding text for ", decl, 0);
+#endif
+ if (t->can_free)
+ obstack_free (&inline_text_obstack, t->buf);
+ DECL_PENDING_INLINE_INFO (decl) = 0;
+ return;
+ }
+ }
+ /* Don't delay the processing of virtual functions. */
+ else if (DECL_VINDEX (decl) == NULL_TREE)
+ delay_to_eof = 1;
+ }
+ else
+ my_friendly_abort (58);
+ }
+
+ if (delay_to_eof)
+ {
+ extern struct pending_inline *pending_template_expansions;
+
+ if (t->can_free)
+ {
+ char *free_to = t->buf;
+ t->buf = (char *) obstack_copy (&permanent_obstack, t->buf,
+ t->len + 1);
+ t = (struct pending_inline *) obstack_copy (&permanent_obstack,
+ (char *)t, sizeof (*t));
+ obstack_free (&inline_text_obstack, free_to);
+ }
+ inlines = &pending_template_expansions;
+ t->can_free = 0;
+ }
+ else
+ {
+ inlines = &pending_inlines;
+ DECL_PENDING_INLINE_INFO (decl) = t;
+ }
+
+ /* Because we use obstacks, we must process these in precise order. */
+ t->next = *inlines;
+ *inlines = t;
+}
+
+void reinit_parse_for_block ();
+
+void
+reinit_parse_for_method (yychar, decl)
+ int yychar;
+ tree decl;
+{
+ int len;
+ int starting_lineno = lineno;
+ char *starting_filename = input_filename;
+
+ reinit_parse_for_block (yychar, &inline_text_obstack, 0);
+
+ len = obstack_object_size (&inline_text_obstack);
+ current_base_init_list = NULL_TREE;
+ current_member_init_list = NULL_TREE;
+ if (decl == void_type_node
+ || (current_class_type && TYPE_REDEFINED (current_class_type)))
+ {
+ /* Happens when we get two declarations of the same
+ function in the same scope. */
+ char *buf = obstack_finish (&inline_text_obstack);
+ obstack_free (&inline_text_obstack, buf);
+ return;
+ }
+ else
+ {
+ struct pending_inline *t;
+ char *buf = obstack_finish (&inline_text_obstack);
+
+ t = (struct pending_inline *) obstack_alloc (&inline_text_obstack,
+ sizeof (struct pending_inline));
+ t->lineno = starting_lineno;
+ t->filename = starting_filename;
+ t->token = YYEMPTY;
+ t->token_value = 0;
+ t->buf = buf;
+ t->len = len;
+ t->can_free = 1;
+ t->deja_vu = 0;
+ if (interface_unknown && processing_template_defn && flag_external_templates && ! DECL_IN_SYSTEM_HEADER (decl))
+ warn_if_unknown_interface (decl);
+ t->interface = (interface_unknown ? 1 : (interface_only ? 0 : 2));
+ store_pending_inline (decl, t);
+ }
+}
+
+/* Consume a block -- actually, a method or template definition beginning
+ with `:' or `{' -- and save it away on the specified obstack.
+
+ Argument IS_TEMPLATE indicates which set of error messages should be
+ output if something goes wrong. This should really be cleaned up somehow,
+ without loss of clarity. */
+void
+reinit_parse_for_block (pyychar, obstackp, is_template)
+ int pyychar;
+ struct obstack *obstackp;
+ int is_template;
+{
+ register int c = 0;
+ int blev = 1;
+ int starting_lineno = lineno;
+ char *starting_filename = input_filename;
+ int len;
+ int look_for_semicolon = 0;
+ int look_for_lbrac = 0;
+
+ if (pyychar == '{')
+ obstack_1grow (obstackp, '{');
+ else if (pyychar == '=')
+ look_for_semicolon = 1;
+ else if (pyychar == ':')
+ {
+ obstack_1grow (obstackp, pyychar);
+ look_for_lbrac = 1;
+ blev = 0;
+ }
+ else if (pyychar == RETURN && !is_template)
+ {
+ obstack_grow (obstackp, "return", 6);
+ look_for_lbrac = 1;
+ blev = 0;
+ }
+ else if (pyychar == TRY && !is_template)
+ {
+ obstack_grow (obstackp, "try", 3);
+ look_for_lbrac = 1;
+ blev = 0;
+ }
+ else
+ {
+ yyerror (is_template
+ ? "parse error in template specification"
+ : "parse error in method specification");
+ obstack_1grow (obstackp, '{');
+ }
+
+ if (nextchar != EOF)
+ {
+ c = nextchar;
+ nextchar = EOF;
+ }
+ else
+ c = getch ();
+
+ while (c != EOF)
+ {
+ int this_lineno = lineno;
+
+ c = skip_white_space (c);
+
+ /* Don't lose our cool if there are lots of comments. */
+ if (lineno == this_lineno + 1)
+ obstack_1grow (obstackp, '\n');
+ else if (lineno == this_lineno)
+ ;
+ else if (lineno - this_lineno < 10)
+ {
+ int i;
+ for (i = lineno - this_lineno; i > 0; i--)
+ obstack_1grow (obstackp, '\n');
+ }
+ else
+ {
+ char buf[16];
+ sprintf (buf, "\n# %d \"", lineno);
+ len = strlen (buf);
+ obstack_grow (obstackp, buf, len);
+
+ len = strlen (input_filename);
+ obstack_grow (obstackp, input_filename, len);
+ obstack_1grow (obstackp, '\"');
+ obstack_1grow (obstackp, '\n');
+ }
+
+ while (c > ' ') /* ASCII dependent... */
+ {
+ obstack_1grow (obstackp, c);
+ if (c == '{')
+ {
+ look_for_lbrac = 0;
+ blev++;
+ }
+ else if (c == '}')
+ {
+ blev--;
+ if (blev == 0 && !look_for_semicolon)
+ {
+ if (pyychar == TRY)
+ {
+ if (peekyylex () == CATCH)
+ {
+ yylex ();
+ obstack_grow (obstackp, " catch ", 7);
+ look_for_lbrac = 1;
+ }
+ else
+ {
+ yychar = '{';
+ goto done;
+ }
+ }
+ else
+ {
+ goto done;
+ }
+ }
+ }
+ else if (c == '\\')
+ {
+ /* Don't act on the next character...e.g, doing an escaped
+ double-quote. */
+ c = getch ();
+ if (c == EOF)
+ {
+ error_with_file_and_line (starting_filename,
+ starting_lineno,
+ "end of file read inside definition");
+ goto done;
+ }
+ obstack_1grow (obstackp, c);
+ }
+ else if (c == '\"')
+ consume_string (obstackp, c);
+ else if (c == '\'')
+ consume_string (obstackp, c);
+ else if (c == ';')
+ {
+ if (look_for_lbrac)
+ {
+ error (is_template
+ ? "template body missing"
+ : "function body for constructor missing");
+ obstack_1grow (obstackp, '{');
+ obstack_1grow (obstackp, '}');
+ len += 2;
+ goto done;
+ }
+ else if (look_for_semicolon && blev == 0)
+ goto done;
+ }
+ c = getch ();
+ }
+
+ if (c == EOF)
+ {
+ error_with_file_and_line (starting_filename,
+ starting_lineno,
+ "end of file read inside definition");
+ goto done;
+ }
+ else if (c != '\n')
+ {
+ obstack_1grow (obstackp, c);
+ c = getch ();
+ }
+ }
+ done:
+ obstack_1grow (obstackp, '\0');
+}
+
+/* Build a default function named NAME for type TYPE.
+ KIND says what to build.
+
+ When KIND == 0, build default destructor.
+ When KIND == 1, build virtual destructor.
+ When KIND == 2, build default constructor.
+ When KIND == 3, build default X(const X&) constructor.
+ When KIND == 4, build default X(X&) constructor.
+ When KIND == 5, build default operator = (const X&).
+ When KIND == 6, build default operator = (X&). */
+
+tree
+cons_up_default_function (type, full_name, kind)
+ tree type, full_name;
+ int kind;
+{
+ extern tree void_list_node;
+ char *func_buf = NULL;
+ int func_len = 0;
+ tree declspecs = NULL_TREE;
+ tree fn, args;
+ tree argtype;
+ int retref = 0;
+ int complex = 0;
+ tree name = constructor_name (full_name);
+
+ switch (kind)
+ {
+ /* Destructors. */
+ case 1:
+ declspecs = build_decl_list (NULL_TREE, ridpointers [(int) RID_VIRTUAL]);
+ /* Fall through... */
+ case 0:
+ name = build_parse_node (BIT_NOT_EXPR, name);
+ args = void_list_node;
+ break;
+
+ case 2:
+ /* Default constructor. */
+ args = void_list_node;
+ complex = TYPE_NEEDS_CONSTRUCTING (type);
+ break;
+
+ case 3:
+ type = build_type_variant (type, 1, 0);
+ /* Fall through... */
+ case 4:
+ /* According to ARM $12.8, the default copy ctor will be declared, but
+ not defined, unless it's needed. */
+ argtype = build_reference_type (type);
+ args = tree_cons (NULL_TREE,
+ build_tree_list (hash_tree_chain (argtype, NULL_TREE),
+ get_identifier ("_ctor_arg")),
+ void_list_node);
+ complex = TYPE_HAS_COMPLEX_INIT_REF (type);
+ break;
+
+ case 5:
+ type = build_type_variant (type, 1, 0);
+ /* Fall through... */
+ case 6:
+ retref = 1;
+ declspecs = build_decl_list (NULL_TREE, full_name);
+
+ name = ansi_opname [(int) MODIFY_EXPR];
+
+ argtype = build_reference_type (type);
+ args = tree_cons (NULL_TREE,
+ build_tree_list (hash_tree_chain (argtype, NULL_TREE),
+ get_identifier ("_ctor_arg")),
+ void_list_node);
+ complex = TYPE_HAS_COMPLEX_ASSIGN_REF (type);
+ break;
+
+ default:
+ my_friendly_abort (59);
+ }
+
+ declspecs = decl_tree_cons (NULL_TREE, ridpointers [(int) RID_INLINE],
+ declspecs);
+
+ TREE_PARMLIST (args) = 1;
+
+ {
+ tree declarator = build_parse_node (CALL_EXPR, name, args, NULL_TREE);
+ if (retref)
+ declarator = build_parse_node (ADDR_EXPR, declarator);
+
+ fn = grokfield (declarator, declspecs, NULL_TREE, NULL_TREE,
+ NULL_TREE, NULL_TREE);
+ }
+
+ if (fn == void_type_node)
+ return fn;
+
+ if (processing_template_defn)
+ {
+ SET_DECL_IMPLICIT_INSTANTIATION (fn);
+ repo_template_used (fn);
+ }
+
+ if (CLASSTYPE_INTERFACE_KNOWN (type))
+ {
+ DECL_INTERFACE_KNOWN (fn) = 1;
+ DECL_NOT_REALLY_EXTERN (fn) = (!CLASSTYPE_INTERFACE_ONLY (type)
+ && flag_implement_inlines);
+ }
+ else
+ DECL_NOT_REALLY_EXTERN (fn) = 1;
+
+#if 0
+ /* When on-the-fly synthesis works properly, remove the second and third
+ conditions here. */
+ if (flag_keep_inline_functions
+#if 0
+ || ! flag_no_inline
+ || complex
+#endif
+ || ! DECL_EXTERNAL (fn))
+ {
+ struct pending_inline *t;
+ t = (struct pending_inline *)
+ obstack_alloc (&synth_obstack, sizeof (struct pending_inline));
+ t->lineno = -kind;
+ t->can_free = 0;
+ t->interface = (interface_unknown ? 1 : (interface_only ? 0 : 2));
+ store_pending_inline (fn, t);
+ }
+ else
+#endif
+ mark_inline_for_output (fn);
+
+#ifdef DEBUG_DEFAULT_FUNCTIONS
+ { char *fn_type = NULL;
+ tree t = name;
+ switch (kind)
+ {
+ case 0: fn_type = "default destructor"; break;
+ case 1: fn_type = "virtual destructor"; break;
+ case 2: fn_type = "default constructor"; break;
+ case 3: fn_type = "default X(const X&)"; break;
+ case 4: fn_type = "default X(X&)"; break;
+ }
+ if (fn_type)
+ {
+ if (TREE_CODE (name) == BIT_NOT_EXPR)
+ t = TREE_OPERAND (name, 0);
+ fprintf (stderr, "[[[[ %s for %s:\n%s]]]]\n", fn_type,
+ IDENTIFIER_POINTER (t), func_buf);
+ }
+ }
+#endif /* DEBUG_DEFAULT_FUNCTIONS */
+
+ /* Show that this function was generated by the compiler. */
+ SET_DECL_ARTIFICIAL (fn);
+
+ return fn;
+}
+
+/* Heuristic to tell whether the user is missing a semicolon
+ after a struct or enum declaration. Emit an error message
+ if we know the user has blown it. */
+void
+check_for_missing_semicolon (type)
+ tree type;
+{
+ if (yychar < 0)
+ yychar = yylex ();
+
+ if ((yychar > 255
+ && yychar != SCSPEC
+ && yychar != IDENTIFIER
+ && yychar != TYPENAME)
+ || end_of_file)
+ {
+ if (ANON_AGGRNAME_P (TYPE_IDENTIFIER (type)))
+ error ("semicolon missing after %s declaration",
+ TREE_CODE (type) == ENUMERAL_TYPE ? "enum" : "struct");
+ else
+ cp_error ("semicolon missing after declaration of `%T'", type);
+ shadow_tag (build_tree_list (0, type));
+ }
+ /* Could probably also hack cases where class { ... } f (); appears. */
+ clear_anon_tags ();
+}
+
+void
+note_got_semicolon (type)
+ tree type;
+{
+ if (TREE_CODE_CLASS (TREE_CODE (type)) != 't')
+ my_friendly_abort (60);
+ if (IS_AGGR_TYPE (type))
+ CLASSTYPE_GOT_SEMICOLON (type) = 1;
+}
+
+void
+note_list_got_semicolon (declspecs)
+ tree declspecs;
+{
+ tree link;
+
+ for (link = declspecs; link; link = TREE_CHAIN (link))
+ {
+ tree type = TREE_VALUE (link);
+ if (TREE_CODE_CLASS (TREE_CODE (type)) == 't')
+ note_got_semicolon (type);
+ }
+ clear_anon_tags ();
+}
+
+/* If C is not whitespace, return C.
+ Otherwise skip whitespace and return first nonwhite char read. */
+
+static int
+skip_white_space (c)
+ register int c;
+{
+ for (;;)
+ {
+ switch (c)
+ {
+ case '\n':
+ c = check_newline ();
+ break;
+
+ case ' ':
+ case '\t':
+ case '\f':
+ case '\r':
+ case '\v':
+ case '\b':
+ do
+ c = getch ();
+ while (c == ' ' || c == '\t');
+ break;
+
+ case '\\':
+ c = getch ();
+ if (c == '\n')
+ lineno++;
+ else
+ error ("stray '\\' in program");
+ c = getch ();
+ break;
+
+ default:
+ return (c);
+ }
+ }
+}
+
+
+
+/* Make the token buffer longer, preserving the data in it.
+ P should point to just beyond the last valid character in the old buffer.
+ The value we return is a pointer to the new buffer
+ at a place corresponding to P. */
+
+static char *
+extend_token_buffer (p)
+ char *p;
+{
+ int offset = p - token_buffer;
+
+ maxtoken = maxtoken * 2 + 10;
+ token_buffer = (char *) xrealloc (token_buffer, maxtoken + 2);
+
+ return token_buffer + offset;
+}
+
+static int
+get_last_nonwhite_on_line ()
+{
+ register int c;
+
+ /* Is this the last nonwhite stuff on the line? */
+ if (nextchar >= 0)
+ c = nextchar, nextchar = -1;
+ else
+ c = getch ();
+
+ while (c == ' ' || c == '\t')
+ c = getch ();
+ return c;
+}
+
+/* At the beginning of a line, increment the line number
+ and process any #-directive on this line.
+ If the line is a #-directive, read the entire line and return a newline.
+ Otherwise, return the line's first non-whitespace character. */
+
+int linemode;
+
+int
+check_newline ()
+{
+ register int c;
+ register int token;
+
+ /* Read first nonwhite char on the line. Do this before incrementing the
+ line number, in case we're at the end of saved text. */
+
+ do
+ c = getch ();
+ while (c == ' ' || c == '\t');
+
+ lineno++;
+
+ if (c != '#')
+ {
+ /* If not #, return it so caller will use it. */
+ return c;
+ }
+
+ /* Don't read beyond this line. */
+ linemode = 1;
+
+ /* Read first nonwhite char after the `#'. */
+
+ do
+ c = getch ();
+ while (c == ' ' || c == '\t');
+
+ /* If a letter follows, then if the word here is `line', skip
+ it and ignore it; otherwise, ignore the line, with an error
+ if the word isn't `pragma'. */
+
+ if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z'))
+ {
+ if (c == 'p')
+ {
+ if (getch () == 'r'
+ && getch () == 'a'
+ && getch () == 'g'
+ && getch () == 'm'
+ && getch () == 'a')
+ {
+ /* Read first nonwhite char after the `#pragma'. */
+
+ do
+ c = getch ();
+ while (c == ' ' || c == '\t');
+
+ if (c == 'v'
+ && getch () == 't'
+ && getch () == 'a'
+ && getch () == 'b'
+ && getch () == 'l'
+ && getch () == 'e'
+ && ((c = getch ()) == ' ' || c == '\t'))
+ {
+ extern tree pending_vtables;
+
+ /* More follows: it must be a string constant (class name). */
+ token = real_yylex ();
+ if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
+ {
+ error ("invalid #pragma vtable");
+ goto skipline;
+ }
+ if (write_virtuals != 2)
+ {
+ warning ("use `+e2' option to enable #pragma vtable");
+ goto skipline;
+ }
+ pending_vtables = perm_tree_cons (NULL_TREE, get_identifier (TREE_STRING_POINTER (yylval.ttype)), pending_vtables);
+ if (nextchar < 0)
+ nextchar = getch ();
+ c = nextchar;
+ if (c != EOF)
+ warning ("trailing characters ignored");
+ }
+ else if (c == 'u'
+ && getch () == 'n'
+ && getch () == 'i'
+ && getch () == 't'
+ && ((c = getch ()) == ' ' || c == '\t'))
+ {
+ /* More follows: it must be a string constant (unit name). */
+ token = real_yylex ();
+ if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
+ {
+ error ("invalid #pragma unit");
+ goto skipline;
+ }
+ current_unit_name = get_identifier (TREE_STRING_POINTER (yylval.ttype));
+ current_unit_language = current_lang_name;
+ if (nextchar < 0)
+ nextchar = getch ();
+ c = nextchar;
+ if (c != EOF)
+ warning ("trailing characters ignored");
+ }
+ else if (c == 'i')
+ {
+ tree fileinfo = IDENTIFIER_CLASS_VALUE (get_time_identifier (input_filename));
+ c = getch ();
+
+ if (c == 'n'
+ && getch () == 't'
+ && getch () == 'e'
+ && getch () == 'r'
+ && getch () == 'f'
+ && getch () == 'a'
+ && getch () == 'c'
+ && getch () == 'e'
+ && ((c = getch ()) == ' ' || c == '\t' || c == EOF))
+ {
+ int warned_already = 0;
+ char *main_filename = input_filename;
+
+ main_filename = FILE_NAME_NONDIRECTORY (main_filename);
+ while (c == ' ' || c == '\t')
+ c = getch ();
+ if (c != EOF)
+ {
+ put_back (c);
+ token = real_yylex ();
+ if (token != STRING
+ || TREE_CODE (yylval.ttype) != STRING_CST)
+ {
+ error ("invalid `#pragma interface'");
+ goto skipline;
+ }
+ main_filename = TREE_STRING_POINTER (yylval.ttype);
+ c = getch();
+ put_back (c);
+ }
+
+ while (c == ' ' || c == '\t')
+ c = getch ();
+
+ while (c != EOF)
+ {
+ if (!warned_already && extra_warnings
+ && c != ' ' && c != '\t')
+ {
+ warning ("garbage after `#pragma interface' ignored");
+ warned_already = 1;
+ }
+ c = getch ();
+ }
+
+ write_virtuals = 3;
+
+ if (impl_file_chain == 0)
+ {
+ /* If this is zero at this point, then we are
+ auto-implementing. */
+ if (main_input_filename == 0)
+ main_input_filename = input_filename;
+
+#ifdef AUTO_IMPLEMENT
+ filename = FILE_NAME_NONDIRECTORY (main_input_filename);
+ fi = get_time_identifier (filename);
+ fi = IDENTIFIER_CLASS_VALUE (fi);
+ TREE_INT_CST_LOW (fi) = 0;
+ TREE_INT_CST_HIGH (fi) = 1;
+ /* Get default. */
+ impl_file_chain = (struct impl_files *)permalloc (sizeof (struct impl_files));
+ impl_file_chain->filename = filename;
+ impl_file_chain->next = 0;
+#endif
+ }
+
+ interface_only = interface_strcmp (main_filename);
+ interface_unknown = 0;
+ TREE_INT_CST_LOW (fileinfo) = interface_only;
+ TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
+ }
+ else if (c == 'm'
+ && getch () == 'p'
+ && getch () == 'l'
+ && getch () == 'e'
+ && getch () == 'm'
+ && getch () == 'e'
+ && getch () == 'n'
+ && getch () == 't'
+ && getch () == 'a'
+ && getch () == 't'
+ && getch () == 'i'
+ && getch () == 'o'
+ && getch () == 'n'
+ && ((c = getch ()) == ' ' || c == '\t' || c == EOF))
+ {
+ int warned_already = 0;
+ char *main_filename = main_input_filename ? main_input_filename : input_filename;
+
+ main_filename = FILE_NAME_NONDIRECTORY (main_filename);
+ while (c == ' ' || c == '\t')
+ c = getch ();
+ if (c != EOF)
+ {
+ put_back (c);
+ token = real_yylex ();
+ if (token != STRING
+ || TREE_CODE (yylval.ttype) != STRING_CST)
+ {
+ error ("invalid `#pragma implementation'");
+ goto skipline;
+ }
+ main_filename = TREE_STRING_POINTER (yylval.ttype);
+ c = getch();
+ put_back (c);
+ }
+
+ while (c == ' ' || c == '\t')
+ c = getch ();
+
+ while (c != EOF)
+ {
+ if (!warned_already && extra_warnings
+ && c != ' ' && c != '\t')
+ {
+ warning ("garbage after `#pragma implementation' ignored");
+ warned_already = 1;
+ }
+ c = getch ();
+ }
+
+ if (write_virtuals == 3)
+ {
+ struct impl_files *ifiles = impl_file_chain;
+ while (ifiles)
+ {
+ if (! strcmp (ifiles->filename, main_filename))
+ break;
+ ifiles = ifiles->next;
+ }
+ if (ifiles == 0)
+ {
+ ifiles = (struct impl_files*) permalloc (sizeof (struct impl_files));
+ ifiles->filename = main_filename;
+ ifiles->next = impl_file_chain;
+ impl_file_chain = ifiles;
+ }
+ }
+ else if ((main_input_filename != 0
+ && ! strcmp (main_input_filename, input_filename))
+ || ! strcmp (input_filename, main_filename))
+ {
+ write_virtuals = 3;
+ if (impl_file_chain == 0)
+ {
+ impl_file_chain = (struct impl_files*) permalloc (sizeof (struct impl_files));
+ impl_file_chain->filename = main_filename;
+ impl_file_chain->next = 0;
+ }
+ }
+ else
+ error ("`#pragma implementation' can only appear at top-level");
+ interface_only = 0;
+#if 1
+ /* We make this non-zero so that we infer decl linkage
+ in the impl file only for variables first declared
+ in the interface file. */
+ interface_unknown = 1;
+#else
+ /* We make this zero so that templates in the impl
+ file will be emitted properly. */
+ interface_unknown = 0;
+#endif
+ TREE_INT_CST_LOW (fileinfo) = interface_only;
+ TREE_INT_CST_HIGH (fileinfo) = interface_unknown;
+ }
+ }
+#ifdef HANDLE_SYSV_PRAGMA
+ else
+ {
+ put_back (c);
+ handle_sysv_pragma ();
+ }
+#else
+#ifdef HANDLE_PRAGMA
+ /* FIXME: This will break if we're doing any of the C++ input
+ tricks. */
+ else
+ {
+ ungetc (c, finput);
+ HANDLE_PRAGMA (finput);
+ }
+#endif
+#endif
+ goto skipline;
+ }
+ }
+ else if (c == 'd')
+ {
+ if (getch () == 'e'
+ && getch () == 'f'
+ && getch () == 'i'
+ && getch () == 'n'
+ && getch () == 'e'
+ && ((c = getch ()) == ' ' || c == '\t'))
+ {
+#ifdef DWARF_DEBUGGING_INFO
+ if ((debug_info_level == DINFO_LEVEL_VERBOSE)
+ && (write_symbols == DWARF_DEBUG))
+ dwarfout_define (lineno, get_directive_line (finput));
+#endif /* DWARF_DEBUGGING_INFO */
+ goto skipline;
+ }
+ }
+ else if (c == 'u')
+ {
+ if (getch () == 'n'
+ && getch () == 'd'
+ && getch () == 'e'
+ && getch () == 'f'
+ && ((c = getch ()) == ' ' || c == '\t'))
+ {
+#ifdef DWARF_DEBUGGING_INFO
+ if ((debug_info_level == DINFO_LEVEL_VERBOSE)
+ && (write_symbols == DWARF_DEBUG))
+ dwarfout_undef (lineno, get_directive_line (finput));
+#endif /* DWARF_DEBUGGING_INFO */
+ goto skipline;
+ }
+ }
+ else if (c == 'l')
+ {
+ if (getch () == 'i'
+ && getch () == 'n'
+ && getch () == 'e'
+ && ((c = getch ()) == ' ' || c == '\t'))
+ goto linenum;
+ }
+ else if (c == 'i')
+ {
+ if (getch () == 'd'
+ && getch () == 'e'
+ && getch () == 'n'
+ && getch () == 't'
+ && ((c = getch ()) == ' ' || c == '\t'))
+ {
+#ifdef ASM_OUTPUT_IDENT
+ extern FILE *asm_out_file;
+#endif
+ /* #ident. The pedantic warning is now in cccp.c. */
+
+ /* Here we have just seen `#ident '.
+ A string constant should follow. */
+
+ while (c == ' ' || c == '\t')
+ c = getch ();
+
+ /* If no argument, ignore the line. */
+ if (c == EOF)
+ goto skipline;
+
+ put_back (c);
+ token = real_yylex ();
+ if (token != STRING
+ || TREE_CODE (yylval.ttype) != STRING_CST)
+ {
+ error ("invalid #ident");
+ goto skipline;
+ }
+
+ if (! flag_no_ident)
+ {
+#ifdef ASM_OUTPUT_IDENT
+ ASM_OUTPUT_IDENT (asm_out_file,
+ TREE_STRING_POINTER (yylval.ttype));
+#endif
+ }
+
+ /* Skip the rest of this line. */
+ goto skipline;
+ }
+ }
+ else if (c == 'n')
+ {
+ if (getch () == 'e'
+ && getch () == 'w'
+ && getch () == 'w'
+ && getch () == 'o'
+ && getch () == 'r'
+ && getch () == 'l'
+ && getch () == 'd'
+ && ((c = getch ()) == ' ' || c == '\t'))
+ {
+ /* Used to test incremental compilation. */
+ sorry ("#pragma newworld");
+ goto skipline;
+ }
+ }
+ error ("undefined or invalid # directive");
+ goto skipline;
+ }
+
+linenum:
+ /* Here we have either `#line' or `# <nonletter>'.
+ In either case, it should be a line number; a digit should follow. */
+
+ while (c == ' ' || c == '\t')
+ c = getch ();
+
+ /* If the # is the only nonwhite char on the line,
+ just ignore it. Check the new newline. */
+ if (c == EOF)
+ goto skipline;
+
+ /* Something follows the #; read a token. */
+
+ put_back (c);
+ token = real_yylex ();
+
+ if (token == CONSTANT
+ && TREE_CODE (yylval.ttype) == INTEGER_CST)
+ {
+ int old_lineno = lineno;
+ enum { act_none, act_push, act_pop } action = act_none;
+ int entering_system_header = 0;
+ int entering_c_header = 0;
+
+ /* subtract one, because it is the following line that
+ gets the specified number */
+
+ int l = TREE_INT_CST_LOW (yylval.ttype) - 1;
+ c = get_last_nonwhite_on_line ();
+ if (c == EOF)
+ {
+ /* No more: store the line number and check following line. */
+ lineno = l;
+ goto skipline;
+ }
+ put_back (c);
+
+ /* More follows: it must be a string constant (filename). */
+
+ /* Read the string constant, but don't treat \ as special. */
+ ignore_escape_flag = 1;
+ token = real_yylex ();
+ ignore_escape_flag = 0;
+
+ if (token != STRING || TREE_CODE (yylval.ttype) != STRING_CST)
+ {
+ error ("invalid #line");
+ goto skipline;
+ }
+
+ /* Changing files again. This means currently collected time
+ is charged against header time, and body time starts back
+ at 0. */
+ if (flag_detailed_statistics)
+ {
+ int this_time = my_get_run_time ();
+ tree time_identifier = get_time_identifier (TREE_STRING_POINTER (yylval.ttype));
+ header_time += this_time - body_time;
+ TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time))
+ += this_time - body_time;
+ this_filename_time = time_identifier;
+ body_time = this_time;
+ }
+
+ if (flag_cadillac)
+ cadillac_note_source ();
+
+ input_filename
+ = (char *) permalloc (TREE_STRING_LENGTH (yylval.ttype) + 1);
+ strcpy (input_filename, TREE_STRING_POINTER (yylval.ttype));
+ lineno = l;
+ GNU_xref_file (input_filename);
+
+ if (main_input_filename == 0)
+ {
+ struct impl_files *ifiles = impl_file_chain;
+
+ if (ifiles)
+ {
+ while (ifiles->next)
+ ifiles = ifiles->next;
+ ifiles->filename = FILE_NAME_NONDIRECTORY (input_filename);
+ }
+
+ main_input_filename = input_filename;
+ if (write_virtuals == 3)
+ walk_vtables (set_typedecl_interface_info, set_vardecl_interface_info);
+ }
+
+ extract_interface_info ();
+
+ c = get_last_nonwhite_on_line ();
+ if (c == EOF)
+ {
+ /* Update the name in the top element of input_file_stack. */
+ if (input_file_stack)
+ input_file_stack->name = input_filename;
+ }
+ else
+ {
+ put_back (c);
+
+ token = real_yylex ();
+
+ /* `1' after file name means entering new file.
+ `2' after file name means just left a file. */
+
+ if (token == CONSTANT
+ && TREE_CODE (yylval.ttype) == INTEGER_CST)
+ {
+ if (TREE_INT_CST_LOW (yylval.ttype) == 1)
+ action = act_push;
+ else if (TREE_INT_CST_LOW (yylval.ttype) == 2)
+ action = act_pop;
+
+ if (action)
+ {
+ c = get_last_nonwhite_on_line ();
+ if (c != EOF)
+ {
+ put_back (c);
+ token = real_yylex ();
+ }
+ }
+ }
+
+ /* `3' after file name means this is a system header file. */
+
+ if (token == CONSTANT
+ && TREE_CODE (yylval.ttype) == INTEGER_CST
+ && TREE_INT_CST_LOW (yylval.ttype) == 3)
+ {
+ entering_system_header = 1;
+
+ c = get_last_nonwhite_on_line ();
+ if (c != EOF)
+ {
+ put_back (c);
+ token = real_yylex ();
+ }
+ }
+
+ /* `4' after file name means this is a C header file. */
+
+ if (token == CONSTANT
+ && TREE_CODE (yylval.ttype) == INTEGER_CST
+ && TREE_INT_CST_LOW (yylval.ttype) == 4)
+ {
+ entering_c_header = 1;
+
+ c = get_last_nonwhite_on_line ();
+ if (c != EOF)
+ {
+ put_back (c);
+ token = real_yylex ();
+ }
+ }
+
+ /* Do the actions implied by the preceding numbers. */
+
+ if (action == act_push)
+ {
+ /* Pushing to a new file. */
+ struct file_stack *p;
+
+ p = (struct file_stack *) xmalloc (sizeof (struct file_stack));
+ input_file_stack->line = old_lineno;
+ p->next = input_file_stack;
+ p->name = input_filename;
+ input_file_stack = p;
+ input_file_stack_tick++;
+#ifdef DWARF_DEBUGGING_INFO
+ if (debug_info_level == DINFO_LEVEL_VERBOSE
+ && write_symbols == DWARF_DEBUG)
+ dwarfout_start_new_source_file (input_filename);
+#endif /* DWARF_DEBUGGING_INFO */
+ if (flag_cadillac)
+ cadillac_push_source ();
+ in_system_header = entering_system_header;
+ if (c_header_level)
+ ++c_header_level;
+ else if (entering_c_header)
+ {
+ c_header_level = 1;
+ ++pending_lang_change;
+ }
+ }
+ else if (action == act_pop)
+ {
+ /* Popping out of a file. */
+ if (input_file_stack->next)
+ {
+ struct file_stack *p;
+
+ if (c_header_level && --c_header_level == 0)
+ {
+ if (entering_c_header)
+ warning ("badly nested C headers from preprocessor");
+ --pending_lang_change;
+ }
+ if (flag_cadillac)
+ cadillac_pop_source ();
+ in_system_header = entering_system_header;
+
+ p = input_file_stack;
+ input_file_stack = p->next;
+ free (p);
+ input_file_stack_tick++;
+#ifdef DWARF_DEBUGGING_INFO
+ if (debug_info_level == DINFO_LEVEL_VERBOSE
+ && write_symbols == DWARF_DEBUG)
+ dwarfout_resume_previous_source_file (input_file_stack->line);
+#endif /* DWARF_DEBUGGING_INFO */
+ }
+ else
+ error ("#-lines for entering and leaving files don't match");
+ }
+ else
+ {
+ in_system_header = entering_system_header;
+ if (flag_cadillac)
+ cadillac_switch_source (-1);
+ }
+ }
+
+ /* If NEXTCHAR is not end of line, we don't care what it is. */
+ if (nextchar == EOF)
+ c = EOF;
+ }
+ else
+ error ("invalid #-line");
+
+ /* skip the rest of this line. */
+ skipline:
+ linemode = 0;
+ end_of_file = 0;
+ while ((c = getch ()) != EOF && c != '\n');
+ return c;
+}
+
+void
+do_pending_lang_change ()
+{
+ for (; pending_lang_change > 0; --pending_lang_change)
+ push_lang_context (lang_name_c);
+ for (; pending_lang_change < 0; ++pending_lang_change)
+ pop_lang_context ();
+}
+
+#if 0
+#define isalnum(char) (char >= 'a' ? char <= 'z' : char >= '0' ? char <= '9' || (char >= 'A' && char <= 'Z') : 0)
+#define isdigit(char) (char >= '0' && char <= '9')
+#else
+#include <ctype.h>
+#endif
+
+#define ENDFILE -1 /* token that represents end-of-file */
+
+/* Read an escape sequence, returning its equivalent as a character,
+ or store 1 in *ignore_ptr if it is backslash-newline. */
+
+static int
+readescape (ignore_ptr)
+ int *ignore_ptr;
+{
+ register int c = getch ();
+ register int code;
+ register unsigned count;
+ unsigned firstdig;
+ int nonnull;
+
+ switch (c)
+ {
+ case 'x':
+ if (warn_traditional)
+ warning ("the meaning of `\\x' varies with -traditional");
+
+ if (flag_traditional)
+ return c;
+
+ code = 0;
+ count = 0;
+ nonnull = 0;
+ while (1)
+ {
+ c = getch ();
+ if (! isxdigit (c))
+ {
+ put_back (c);
+ break;
+ }
+ code *= 16;
+ if (c >= 'a' && c <= 'f')
+ code += c - 'a' + 10;
+ if (c >= 'A' && c <= 'F')
+ code += c - 'A' + 10;
+ if (c >= '0' && c <= '9')
+ code += c - '0';
+ if (code != 0 || count != 0)
+ {
+ if (count == 0)
+ firstdig = code;
+ count++;
+ }
+ nonnull = 1;
+ }
+ if (! nonnull)
+ error ("\\x used with no following hex digits");
+ else if (count == 0)
+ /* Digits are all 0's. Ok. */
+ ;
+ else if ((count - 1) * 4 >= TYPE_PRECISION (integer_type_node)
+ || (count > 1
+ && ((1 << (TYPE_PRECISION (integer_type_node) - (count - 1) * 4))
+ <= firstdig)))
+ pedwarn ("hex escape out of range");
+ return code;
+
+ case '0': case '1': case '2': case '3': case '4':
+ case '5': case '6': case '7':
+ code = 0;
+ count = 0;
+ while ((c <= '7') && (c >= '0') && (count++ < 3))
+ {
+ code = (code * 8) + (c - '0');
+ c = getch ();
+ }
+ put_back (c);
+ return code;
+
+ case '\\': case '\'': case '"':
+ return c;
+
+ case '\n':
+ lineno++;
+ *ignore_ptr = 1;
+ return 0;
+
+ case 'n':
+ return TARGET_NEWLINE;
+
+ case 't':
+ return TARGET_TAB;
+
+ case 'r':
+ return TARGET_CR;
+
+ case 'f':
+ return TARGET_FF;
+
+ case 'b':
+ return TARGET_BS;
+
+ case 'a':
+ if (warn_traditional)
+ warning ("the meaning of `\\a' varies with -traditional");
+
+ if (flag_traditional)
+ return c;
+ return TARGET_BELL;
+
+ case 'v':
+ return TARGET_VT;
+
+ case 'e':
+ case 'E':
+ if (pedantic)
+ pedwarn ("non-ANSI-standard escape sequence, `\\%c'", c);
+ return 033;
+
+ case '?':
+ return c;
+
+ /* `\(', etc, are used at beginning of line to avoid confusing Emacs. */
+ case '(':
+ case '{':
+ case '[':
+ /* `\%' is used to prevent SCCS from getting confused. */
+ case '%':
+ if (pedantic)
+ pedwarn ("unknown escape sequence `\\%c'", c);
+ return c;
+ }
+ if (c >= 040 && c < 0177)
+ pedwarn ("unknown escape sequence `\\%c'", c);
+ else
+ pedwarn ("unknown escape sequence: `\\' followed by char code 0x%x", c);
+ return c;
+}
+
+/* Value is 1 (or 2) if we should try to make the next identifier look like
+ a typename (when it may be a local variable or a class variable).
+ Value is 0 if we treat this name in a default fashion. */
+int looking_for_typename = 0;
+
+#if 0
+/* NO LONGER USED: Value is -1 if we must not see a type name. */
+void
+dont_see_typename ()
+{
+ looking_for_typename = -1;
+ if (yychar == TYPENAME || yychar == PTYPENAME)
+ {
+ yychar = IDENTIFIER;
+ lastiddecl = 0;
+ }
+}
+#endif
+
+#ifdef __GNUC__
+extern __inline int identifier_type ();
+__inline
+#endif
+int
+identifier_type (decl)
+ tree decl;
+{
+ if (TREE_CODE (decl) == TEMPLATE_DECL
+ && DECL_TEMPLATE_IS_CLASS (decl))
+ return PTYPENAME;
+ if (TREE_CODE (decl) == NAMESPACE_DECL)
+ return NSNAME;
+ if (TREE_CODE (decl) != TYPE_DECL)
+ return IDENTIFIER;
+ return TYPENAME;
+}
+
+void
+see_typename ()
+{
+ looking_for_typename = 1;
+ if (yychar < 0)
+ if ((yychar = yylex()) < 0) yychar = 0;
+ looking_for_typename = 0;
+ if (yychar == IDENTIFIER)
+ {
+ lastiddecl = lookup_name (yylval.ttype, -2);
+ if (lastiddecl == 0)
+ {
+ if (flag_labels_ok)
+ lastiddecl = IDENTIFIER_LABEL_VALUE (yylval.ttype);
+ }
+ else
+ yychar = identifier_type (lastiddecl);
+ }
+}
+
+tree
+do_identifier (token)
+ register tree token;
+{
+ register tree id = lastiddecl;
+
+ if (yychar == YYEMPTY)
+ yychar = yylex ();
+ /* Scope class declarations before global
+ declarations. */
+ if (id == IDENTIFIER_GLOBAL_VALUE (token)
+ && current_class_type != 0
+ && TYPE_SIZE (current_class_type) == 0
+ && TREE_CODE (current_class_type) != UNINSTANTIATED_P_TYPE)
+ {
+ /* Could be from one of the base classes. */
+ tree field = lookup_field (current_class_type, token, 1, 0);
+ if (field == 0)
+ ;
+ else if (field == error_mark_node)
+ /* We have already generated the error message.
+ But we still want to return this value. */
+ id = lookup_field (current_class_type, token, 0, 0);
+ else if (TREE_CODE (field) == VAR_DECL
+ || TREE_CODE (field) == CONST_DECL)
+ id = field;
+ else if (TREE_CODE (field) != FIELD_DECL)
+ my_friendly_abort (61);
+ else
+ {
+ cp_error ("invalid use of member `%D' from base class `%T'", field,
+ DECL_FIELD_CONTEXT (field));
+ id = error_mark_node;
+ return id;
+ }
+ }
+
+ /* Remember that this name has been used in the class definition, as per
+ [class.scope0] */
+ if (id && current_class_type
+ && TYPE_BEING_DEFINED (current_class_type)
+ && ! IDENTIFIER_CLASS_VALUE (token))
+ pushdecl_class_level (id);
+
+ if (!id || id == error_mark_node)
+ {
+ if (id == error_mark_node && current_class_type != NULL_TREE)
+ {
+ id = lookup_nested_field (token, 1);
+ /* In lookup_nested_field(), we marked this so we can gracefully
+ leave this whole mess. */
+ if (id && id != error_mark_node && TREE_TYPE (id) == error_mark_node)
+ return id;
+ }
+ if (yychar == '(' || yychar == LEFT_RIGHT)
+ {
+ id = implicitly_declare (token);
+ }
+ else if (current_function_decl == 0)
+ {
+ cp_error ("`%D' was not declared in this scope", token);
+ id = error_mark_node;
+ }
+ else
+ {
+ if (IDENTIFIER_GLOBAL_VALUE (token) != error_mark_node
+ || IDENTIFIER_ERROR_LOCUS (token) != current_function_decl)
+ {
+ static int undeclared_variable_notice;
+
+ cp_error ("`%D' undeclared (first use this function)", token);
+
+ if (! undeclared_variable_notice)
+ {
+ error ("(Each undeclared identifier is reported only once");
+ error ("for each function it appears in.)");
+ undeclared_variable_notice = 1;
+ }
+ }
+ id = error_mark_node;
+ /* Prevent repeated error messages. */
+ IDENTIFIER_GLOBAL_VALUE (token) = error_mark_node;
+ SET_IDENTIFIER_ERROR_LOCUS (token, current_function_decl);
+ }
+ }
+
+ if (TREE_CODE (id) == VAR_DECL && DECL_DEAD_FOR_LOCAL (id))
+ {
+ tree shadowed = DECL_SHADOWED_FOR_VAR (id);
+ if (shadowed)
+ {
+ if (!DECL_ERROR_REPORTED (id))
+ {
+ warning ("name lookup of `%s' changed",
+ IDENTIFIER_POINTER (token));
+ cp_warning_at (" matches this `%D' under current ANSI rules",
+ shadowed);
+ cp_warning_at (" matches this `%D' under old rules", id);
+ DECL_ERROR_REPORTED (id) = 1;
+ }
+ id = shadowed;
+ }
+ else if (!DECL_ERROR_REPORTED (id))
+ {
+ static char msg[]
+ = "name lookup of `%s' changed for new ANSI `for' scoping";
+ DECL_ERROR_REPORTED (id) = 1;
+ if (TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (id)))
+ {
+ error (msg, IDENTIFIER_POINTER (token));
+ cp_error_at (" cannot use obsolete binding at `%D' because it has a destructor", id);
+ id = error_mark_node;
+ }
+ else
+ {
+ pedwarn (msg, IDENTIFIER_POINTER (token));
+ cp_pedwarn_at (" using obsolete binding at `%D'", id);
+ }
+ }
+ }
+ /* TREE_USED is set in `hack_identifier'. */
+ if (TREE_CODE (id) == CONST_DECL)
+ {
+ if (IDENTIFIER_CLASS_VALUE (token) == id)
+ {
+ /* Check access. */
+ enum access_type access
+ = compute_access (TYPE_BINFO (current_class_type), id);
+ if (access == access_private)
+ cp_error ("enum `%D' is private", id);
+ /* protected is OK, since it's an enum of `this'. */
+ }
+ id = DECL_INITIAL (id);
+ }
+ else
+ id = hack_identifier (id, token, yychar);
+ return id;
+}
+
+tree
+identifier_typedecl_value (node)
+ tree node;
+{
+ tree t, type;
+ type = IDENTIFIER_TYPE_VALUE (node);
+ if (type == NULL_TREE)
+ return NULL_TREE;
+#define do(X) \
+ { \
+ t = (X); \
+ if (t && TREE_CODE (t) == TYPE_DECL && TREE_TYPE (t) == type) \
+ return t; \
+ }
+ do (IDENTIFIER_LOCAL_VALUE (node));
+ do (IDENTIFIER_CLASS_VALUE (node));
+ do (IDENTIFIER_GLOBAL_VALUE (node));
+#undef do
+ /* Will this one ever happen? */
+ if (TYPE_NAME (type))
+ return TYPE_NAME (type);
+
+ /* We used to do an internal error of 62 here, but instead we will
+ handle the return of a null appropriately in the callers. */
+ return NULL_TREE;
+}
+
+struct try_type
+{
+ tree *node_var;
+ char unsigned_flag;
+ char long_flag;
+ char long_long_flag;
+};
+
+struct try_type type_sequence[] =
+{
+ { &integer_type_node, 0, 0, 0},
+ { &unsigned_type_node, 1, 0, 0},
+ { &long_integer_type_node, 0, 1, 0},
+ { &long_unsigned_type_node, 1, 1, 0},
+ { &long_long_integer_type_node, 0, 1, 1},
+ { &long_long_unsigned_type_node, 1, 1, 1}
+};
+
+int
+real_yylex ()
+{
+ register int c;
+ register int value;
+ int wide_flag = 0;
+ int dollar_seen = 0;
+ int i;
+
+ if (nextchar >= 0)
+ c = nextchar, nextchar = -1;
+ else
+ c = getch ();
+
+ /* Effectively do c = skip_white_space (c)
+ but do it faster in the usual cases. */
+ while (1)
+ switch (c)
+ {
+ case ' ':
+ case '\t':
+ case '\f':
+ case '\v':
+ case '\b':
+ c = getch ();
+ break;
+
+ case '\r':
+ /* Call skip_white_space so we can warn if appropriate. */
+
+ case '\n':
+ case '/':
+ case '\\':
+ c = skip_white_space (c);
+ default:
+ goto found_nonwhite;
+ }
+ found_nonwhite:
+
+ token_buffer[0] = c;
+ token_buffer[1] = 0;
+
+/* yylloc.first_line = lineno; */
+
+ switch (c)
+ {
+ case EOF:
+ token_buffer[0] = '\0';
+ end_of_file = 1;
+ if (input_redirected ())
+ value = END_OF_SAVED_INPUT;
+ else if (linemode)
+ value = END_OF_LINE;
+ else if (do_pending_expansions ())
+ /* this will set yychar for us */
+ return yychar;
+ else
+ value = ENDFILE;
+ break;
+
+ case '$':
+ if (dollars_in_ident)
+ {
+ dollar_seen = 1;
+ goto letter;
+ }
+ value = '$';
+ goto done;
+
+ case 'L':
+ /* Capital L may start a wide-string or wide-character constant. */
+ {
+ register int c = getch ();
+ if (c == '\'')
+ {
+ wide_flag = 1;
+ goto char_constant;
+ }
+ if (c == '"')
+ {
+ wide_flag = 1;
+ goto string_constant;
+ }
+ put_back (c);
+ }
+
+ case 'A': case 'B': case 'C': case 'D': case 'E':
+ case 'F': case 'G': case 'H': case 'I': case 'J':
+ case 'K': case 'M': case 'N': case 'O':
+ case 'P': case 'Q': case 'R': case 'S': case 'T':
+ case 'U': case 'V': case 'W': case 'X': case 'Y':
+ case 'Z':
+ case 'a': case 'b': case 'c': case 'd': case 'e':
+ case 'f': case 'g': case 'h': case 'i': case 'j':
+ case 'k': case 'l': case 'm': case 'n': case 'o':
+ case 'p': case 'q': case 'r': case 's': case 't':
+ case 'u': case 'v': case 'w': case 'x': case 'y':
+ case 'z':
+ case '_':
+ letter:
+ {
+ register char *p;
+
+ p = token_buffer;
+ if (input == 0)
+ {
+ /* We know that `token_buffer' can hold at least on char,
+ so we install C immediately.
+ We may have to read the value in `putback_char', so call
+ `getch' once. */
+ *p++ = c;
+ c = getch ();
+
+ /* Make this run fast. We know that we are reading straight
+ from FINPUT in this case (since identifiers cannot straddle
+ input sources. */
+ while (isalnum (c) || (c == '_') || c == '$')
+ {
+ if (c == '$' && ! dollars_in_ident)
+ break;
+ if (p >= token_buffer + maxtoken)
+ p = extend_token_buffer (p);
+
+ *p++ = c;
+ c = getc (finput);
+ }
+
+ if (linemode && c == '\n')
+ {
+ put_back (c);
+ c = EOF;
+ }
+ }
+ else
+ {
+ /* We know that `token_buffer' can hold at least on char,
+ so we install C immediately. */
+ *p++ = c;
+ c = getch ();
+
+ while (isalnum (c) || (c == '_') || c == '$')
+ {
+ if (c == '$' && ! dollars_in_ident)
+ break;
+ if (p >= token_buffer + maxtoken)
+ p = extend_token_buffer (p);
+
+ *p++ = c;
+ c = getch ();
+ }
+ }
+
+ *p = 0;
+ nextchar = c;
+
+ value = IDENTIFIER;
+ yylval.itype = 0;
+
+ /* Try to recognize a keyword. Uses minimum-perfect hash function */
+
+ {
+ register struct resword *ptr;
+
+ if (ptr = is_reserved_word (token_buffer, p - token_buffer))
+ {
+ if (ptr->rid)
+ {
+ tree old_ttype = ridpointers[(int) ptr->rid];
+
+ /* If this provides a type for us, then revert lexical
+ state to standard state. */
+ if (TREE_CODE (old_ttype) == IDENTIFIER_NODE
+ && IDENTIFIER_GLOBAL_VALUE (old_ttype) != 0
+ && TREE_CODE (IDENTIFIER_GLOBAL_VALUE (old_ttype)) == TYPE_DECL)
+ looking_for_typename = 0;
+ else if (ptr->token == AGGR || ptr->token == ENUM)
+ looking_for_typename = 1;
+
+ /* Check if this is a language-type declaration.
+ Just glimpse the next non-white character. */
+ nextchar = skip_white_space (nextchar);
+ if (nextchar == '"')
+ {
+ /* We are looking at a string. Complain
+ if the token before the string is no `extern'.
+
+ Could cheat some memory by placing this string
+ on the temporary_, instead of the saveable_
+ obstack. */
+
+ if (ptr->rid != RID_EXTERN)
+ error ("invalid modifier `%s' for language string",
+ ptr->name);
+ real_yylex ();
+ value = EXTERN_LANG_STRING;
+ yylval.ttype = get_identifier (TREE_STRING_POINTER (yylval.ttype));
+ break;
+ }
+ if (ptr->token == VISSPEC)
+ {
+ switch (ptr->rid)
+ {
+ case RID_PUBLIC:
+ yylval.itype = access_public;
+ break;
+ case RID_PRIVATE:
+ yylval.itype = access_private;
+ break;
+ case RID_PROTECTED:
+ yylval.itype = access_protected;
+ break;
+ default:
+ my_friendly_abort (63);
+ }
+ }
+ else
+ yylval.ttype = old_ttype;
+ }
+ else if (ptr->token == EQCOMPARE)
+ {
+ yylval.code = NE_EXPR;
+ token_buffer[0] = '!';
+ token_buffer[1] = '=';
+ token_buffer[2] = 0;
+ }
+ else if (ptr->token == ASSIGN)
+ {
+ if (strcmp ("and_eq", token_buffer) == 0)
+ {
+ yylval.code = BIT_AND_EXPR;
+ token_buffer[0] = '&';
+ }
+ else if (strcmp ("or_eq", token_buffer) == 0)
+ {
+ yylval.code = BIT_IOR_EXPR;
+ token_buffer[0] = '|';
+ }
+ else if (strcmp ("xor_eq", token_buffer) == 0)
+ {
+ yylval.code = BIT_XOR_EXPR;
+ token_buffer[0] = '^';
+ }
+ token_buffer[1] = '=';
+ token_buffer[2] = 0;
+ }
+ else if (ptr->token == '&')
+ {
+ yylval.code = BIT_AND_EXPR;
+ token_buffer[0] = '&';
+ token_buffer[1] = 0;
+ }
+ else if (ptr->token == '|')
+ {
+ yylval.code = BIT_IOR_EXPR;
+ token_buffer[0] = '|';
+ token_buffer[1] = 0;
+ }
+ else if (ptr->token == '^')
+ {
+ yylval.code = BIT_XOR_EXPR;
+ token_buffer[0] = '^';
+ token_buffer[1] = 0;
+ }
+
+ value = (int) ptr->token;
+ }
+ }
+
+ /* If we did not find a keyword, look for an identifier
+ (or a typename). */
+
+ if (strcmp ("catch", token_buffer) == 0
+ || strcmp ("throw", token_buffer) == 0
+ || strcmp ("try", token_buffer) == 0)
+ {
+ static int did_warn = 0;
+ if (! did_warn && ! flag_handle_exceptions)
+ {
+ pedwarn ("`catch', `throw', and `try' are all C++ reserved words");
+ did_warn = 1;
+ }
+ }
+
+ if (value == IDENTIFIER || value == TYPESPEC)
+ GNU_xref_ref (current_function_decl, token_buffer);
+
+ if (value == IDENTIFIER)
+ {
+ register tree tmp = get_identifier (token_buffer);
+
+#if !defined(VMS) && defined(JOINER)
+ /* Make sure that user does not collide with our internal
+ naming scheme. */
+ if (JOINER == '$'
+ && dollar_seen
+ && (THIS_NAME_P (tmp)
+ || VPTR_NAME_P (tmp)
+ || DESTRUCTOR_NAME_P (tmp)
+ || VTABLE_NAME_P (tmp)
+ || TEMP_NAME_P (tmp)
+ || ANON_AGGRNAME_P (tmp)
+ || ANON_PARMNAME_P (tmp)))
+ warning ("identifier name `%s' conflicts with GNU C++ internal naming strategy",
+ token_buffer);
+#endif
+
+ yylval.ttype = tmp;
+
+ /* A user-invisible read-only initialized variable
+ should be replaced by its value. We only handle strings
+ since that's the only case used in C (and C++). */
+ /* Note we go right after the local value for the identifier
+ (e.g., __FUNCTION__ or __PRETTY_FUNCTION__). We used to
+ call lookup_name, but that could result in an error about
+ ambiguities. */
+ tmp = IDENTIFIER_LOCAL_VALUE (yylval.ttype);
+ if (tmp != NULL_TREE
+ && TREE_CODE (tmp) == VAR_DECL
+ && DECL_IGNORED_P (tmp)
+ && TREE_READONLY (tmp)
+ && DECL_INITIAL (tmp) != NULL_TREE
+ && TREE_CODE (DECL_INITIAL (tmp)) == STRING_CST)
+ {
+ yylval.ttype = DECL_INITIAL (tmp);
+ value = STRING;
+ }
+ }
+ if (value == NEW && ! global_bindings_p ())
+ {
+ value = NEW;
+ goto done;
+ }
+ }
+ break;
+
+ case '.':
+ {
+ register int c1 = getch ();
+ token_buffer[0] = c;
+ token_buffer[1] = c1;
+ if (c1 == '*')
+ {
+ value = DOT_STAR;
+ token_buffer[2] = 0;
+ goto done;
+ }
+ if (c1 == '.')
+ {
+ c1 = getch ();
+ if (c1 == '.')
+ {
+ token_buffer[2] = c1;
+ token_buffer[3] = 0;
+ value = ELLIPSIS;
+ goto done;
+ }
+ error ("parse error at `..'");
+ }
+ if (isdigit (c1))
+ {
+ put_back (c1);
+ goto resume_numerical_scan;
+ }
+ nextchar = c1;
+ value = '.';
+ token_buffer[1] = 0;
+ goto done;
+ }
+ case '0': case '1':
+ /* Optimize for most frequent case. */
+ {
+ register int c1 = getch ();
+ if (! isalnum (c1) && c1 != '.')
+ {
+ /* Terminate string. */
+ token_buffer[0] = c;
+ token_buffer[1] = 0;
+ if (c == '0')
+ yylval.ttype = integer_zero_node;
+ else
+ yylval.ttype = integer_one_node;
+ nextchar = c1;
+ value = CONSTANT;
+ goto done;
+ }
+ put_back (c1);
+ }
+ /* fall through... */
+ case '2': case '3': case '4':
+ case '5': case '6': case '7': case '8': case '9':
+ resume_numerical_scan:
+ {
+ register char *p;
+ int base = 10;
+ int count = 0;
+ int largest_digit = 0;
+ int numdigits = 0;
+ /* for multi-precision arithmetic,
+ we actually store only HOST_BITS_PER_CHAR bits in each part.
+ The number of parts is chosen so as to be sufficient to hold
+ the enough bits to fit into the two HOST_WIDE_INTs that contain
+ the integer value (this is always at least as many bits as are
+ in a target `long long' value, but may be wider). */
+#define TOTAL_PARTS ((HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR) * 2 + 2)
+ int parts[TOTAL_PARTS];
+ int overflow = 0;
+
+ enum anon1 { NOT_FLOAT, AFTER_POINT, TOO_MANY_POINTS} floatflag
+ = NOT_FLOAT;
+
+ p = token_buffer;
+ *p++ = c;
+
+ for (count = 0; count < TOTAL_PARTS; count++)
+ parts[count] = 0;
+
+ if (c == '0')
+ {
+ *p++ = (c = getch ());
+ if ((c == 'x') || (c == 'X'))
+ {
+ base = 16;
+ *p++ = (c = getch ());
+ }
+ /* Leading 0 forces octal unless the 0 is the only digit. */
+ else if (c >= '0' && c <= '9')
+ {
+ base = 8;
+ numdigits++;
+ }
+ else
+ numdigits++;
+ }
+
+ /* Read all the digits-and-decimal-points. */
+
+ while (c == '.'
+ || (isalnum (c) && (c != 'l') && (c != 'L')
+ && (c != 'u') && (c != 'U')
+ && (floatflag == NOT_FLOAT || ((c != 'f') && (c != 'F')))))
+ {
+ if (c == '.')
+ {
+ if (base == 16)
+ error ("floating constant may not be in radix 16");
+ if (floatflag == AFTER_POINT)
+ {
+ error ("malformed floating constant");
+ floatflag = TOO_MANY_POINTS;
+ }
+ else
+ floatflag = AFTER_POINT;
+
+ base = 10;
+ *p++ = c = getch ();
+ /* Accept '.' as the start of a floating-point number
+ only when it is followed by a digit.
+ Otherwise, unread the following non-digit
+ and use the '.' as a structural token. */
+ if (p == token_buffer + 2 && !isdigit (c))
+ {
+ if (c == '.')
+ {
+ c = getch ();
+ if (c == '.')
+ {
+ *p++ = '.';
+ *p = '\0';
+ value = ELLIPSIS;
+ goto done;
+ }
+ error ("parse error at `..'");
+ }
+ nextchar = c;
+ token_buffer[1] = '\0';
+ value = '.';
+ goto done;
+ }
+ }
+ else
+ {
+ /* It is not a decimal point.
+ It should be a digit (perhaps a hex digit). */
+
+ if (isdigit (c))
+ {
+ c = c - '0';
+ }
+ else if (base <= 10)
+ {
+ if (c == 'e' || c == 'E')
+ {
+ base = 10;
+ floatflag = AFTER_POINT;
+ break; /* start of exponent */
+ }
+ error ("nondigits in number and not hexadecimal");
+ c = 0;
+ }
+ else if (c >= 'a')
+ {
+ c = c - 'a' + 10;
+ }
+ else
+ {
+ c = c - 'A' + 10;
+ }
+ if (c >= largest_digit)
+ largest_digit = c;
+ numdigits++;
+
+ for (count = 0; count < TOTAL_PARTS; count++)
+ {
+ parts[count] *= base;
+ if (count)
+ {
+ parts[count]
+ += (parts[count-1] >> HOST_BITS_PER_CHAR);
+ parts[count-1]
+ &= (1 << HOST_BITS_PER_CHAR) - 1;
+ }
+ else
+ parts[0] += c;
+ }
+
+ /* If the extra highest-order part ever gets anything in it,
+ the number is certainly too big. */
+ if (parts[TOTAL_PARTS - 1] != 0)
+ overflow = 1;
+
+ if (p >= token_buffer + maxtoken - 3)
+ p = extend_token_buffer (p);
+ *p++ = (c = getch ());
+ }
+ }
+
+ if (numdigits == 0)
+ error ("numeric constant with no digits");
+
+ if (largest_digit >= base)
+ error ("numeric constant contains digits beyond the radix");
+
+ /* Remove terminating char from the token buffer and delimit the string */
+ *--p = 0;
+
+ if (floatflag != NOT_FLOAT)
+ {
+ tree type = double_type_node;
+ char f_seen = 0;
+ char l_seen = 0;
+ int garbage_chars = 0;
+ REAL_VALUE_TYPE value;
+ jmp_buf handler;
+
+ /* Read explicit exponent if any, and put it in tokenbuf. */
+
+ if ((c == 'e') || (c == 'E'))
+ {
+ if (p >= token_buffer + maxtoken - 3)
+ p = extend_token_buffer (p);
+ *p++ = c;
+ c = getch ();
+ if ((c == '+') || (c == '-'))
+ {
+ *p++ = c;
+ c = getch ();
+ }
+ if (! isdigit (c))
+ error ("floating constant exponent has no digits");
+ while (isdigit (c))
+ {
+ if (p >= token_buffer + maxtoken - 3)
+ p = extend_token_buffer (p);
+ *p++ = c;
+ c = getch ();
+ }
+ }
+
+ *p = 0;
+ errno = 0;
+
+ /* Convert string to a double, checking for overflow. */
+ if (setjmp (handler))
+ {
+ error ("floating constant out of range");
+ value = dconst0;
+ }
+ else
+ {
+ set_float_handler (handler);
+ /* The second argument, machine_mode, of REAL_VALUE_ATOF
+ tells the desired precision of the binary result of
+ decimal-to-binary conversion. */
+
+ /* Read the suffixes to choose a data type. */
+ switch (c)
+ {
+ case 'f': case 'F':
+ type = float_type_node;
+ value = REAL_VALUE_ATOF (token_buffer, TYPE_MODE (type));
+ garbage_chars = -1;
+ break;
+
+ case 'l': case 'L':
+ type = long_double_type_node;
+ value = REAL_VALUE_ATOF (token_buffer, TYPE_MODE (type));
+ garbage_chars = -1;
+ break;
+
+ default:
+ value = REAL_VALUE_ATOF (token_buffer, TYPE_MODE (type));
+ }
+ set_float_handler (NULL_PTR);
+ }
+ if (pedantic
+ && (REAL_VALUE_ISINF (value)
+#ifdef ERANGE
+ || (TARGET_FLOAT_FORMAT != IEEE_FLOAT_FORMAT
+ && errno == ERANGE
+ /* ERANGE is also reported for underflow, so test the
+ value to distinguish overflow from that. */
+ && (REAL_VALUES_LESS (dconst1, value)
+ || REAL_VALUES_LESS (value, dconstm1)))
+#endif
+ ))
+ {
+ pedwarn ("floating point number exceeds range of `%s'",
+ IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))));
+ }
+ /* Note: garbage_chars is -1 if first char is *not* garbage. */
+ while (isalnum (c))
+ {
+ if (c == 'f' || c == 'F')
+ {
+ if (f_seen)
+ error ("two `f's in floating constant");
+ f_seen = 1;
+ }
+ if (c == 'l' || c == 'L')
+ {
+ if (l_seen)
+ error ("two `l's in floating constant");
+ l_seen = 1;
+ }
+ if (p >= token_buffer + maxtoken - 3)
+ p = extend_token_buffer (p);
+ *p++ = c;
+ c = getch ();
+ garbage_chars++;
+ }
+
+ if (garbage_chars > 0)
+ error ("garbage at end of number");
+
+ /* Create a node with determined type and value. */
+ yylval.ttype = build_real (type, value);
+
+ put_back (c);
+ *p = 0;
+ }
+ else
+ {
+ tree type;
+ HOST_WIDE_INT high, low;
+ int spec_unsigned = 0;
+ int spec_long = 0;
+ int spec_long_long = 0;
+ int bytes, warn;
+
+ while (1)
+ {
+ if (c == 'u' || c == 'U')
+ {
+ if (spec_unsigned)
+ error ("two `u's in integer constant");
+ spec_unsigned = 1;
+ }
+ else if (c == 'l' || c == 'L')
+ {
+ if (spec_long)
+ {
+ if (spec_long_long)
+ error ("three `l's in integer constant");
+ else if (pedantic)
+ pedwarn ("ANSI C++ forbids long long integer constants");
+ spec_long_long = 1;
+ }
+ spec_long = 1;
+ }
+ else
+ {
+ if (isalnum (c))
+ {
+ error ("garbage at end of number");
+ while (isalnum (c))
+ {
+ if (p >= token_buffer + maxtoken - 3)
+ p = extend_token_buffer (p);
+ *p++ = c;
+ c = getch ();
+ }
+ }
+ break;
+ }
+ if (p >= token_buffer + maxtoken - 3)
+ p = extend_token_buffer (p);
+ *p++ = c;
+ c = getch ();
+ }
+
+ put_back (c);
+
+ /* If the constant is not long long and it won't fit in an
+ unsigned long, or if the constant is long long and won't fit
+ in an unsigned long long, then warn that the constant is out
+ of range. */
+
+ /* ??? This assumes that long long and long integer types are
+ a multiple of 8 bits. This better than the original code
+ though which assumed that long was exactly 32 bits and long
+ long was exactly 64 bits. */
+
+ if (spec_long_long)
+ bytes = TYPE_PRECISION (long_long_integer_type_node) / 8;
+ else
+ bytes = TYPE_PRECISION (long_integer_type_node) / 8;
+
+ warn = overflow;
+ for (i = bytes; i < TOTAL_PARTS; i++)
+ if (parts[i])
+ warn = 1;
+ if (warn)
+ pedwarn ("integer constant out of range");
+
+ /* This is simplified by the fact that our constant
+ is always positive. */
+ high = low = 0;
+
+ for (i = 0; i < HOST_BITS_PER_WIDE_INT / HOST_BITS_PER_CHAR; i++)
+ {
+ high |= ((HOST_WIDE_INT) parts[i + (HOST_BITS_PER_WIDE_INT
+ / HOST_BITS_PER_CHAR)]
+ << (i * HOST_BITS_PER_CHAR));
+ low |= (HOST_WIDE_INT) parts[i] << (i * HOST_BITS_PER_CHAR);
+ }
+
+
+ yylval.ttype = build_int_2 (low, high);
+ TREE_TYPE (yylval.ttype) = long_long_unsigned_type_node;
+
+#if 0
+ /* Find the first allowable type that the value fits in. */
+ type = 0;
+ for (i = 0; i < sizeof (type_sequence) / sizeof (type_sequence[0]);
+ i++)
+ if (!(spec_long && !type_sequence[i].long_flag)
+ && !(spec_long_long && !type_sequence[i].long_long_flag)
+ && !(spec_unsigned && !type_sequence[i].unsigned_flag)
+ /* A hex or octal constant traditionally is unsigned. */
+ && !(base != 10 && flag_traditional
+ && !type_sequence[i].unsigned_flag)
+ /* A decimal constant can't be unsigned int
+ unless explicitly specified. */
+ && !(base == 10 && !spec_unsigned
+ && *type_sequence[i].node_var == unsigned_type_node))
+ if (int_fits_type_p (yylval.ttype, *type_sequence[i].node_var))
+ {
+ type = *type_sequence[i].node_var;
+ break;
+ }
+ if (flag_traditional && type == long_unsigned_type_node
+ && !spec_unsigned)
+ type = long_integer_type_node;
+
+ if (type == 0)
+ {
+ type = long_long_integer_type_node;
+ warning ("integer constant out of range");
+ }
+
+ /* Warn about some cases where the type of a given constant
+ changes from traditional C to ANSI C. */
+ if (warn_traditional)
+ {
+ tree other_type = 0;
+
+ /* This computation is the same as the previous one
+ except that flag_traditional is used backwards. */
+ for (i = 0; i < sizeof (type_sequence) / sizeof (type_sequence[0]);
+ i++)
+ if (!(spec_long && !type_sequence[i].long_flag)
+ && !(spec_long_long && !type_sequence[i].long_long_flag)
+ && !(spec_unsigned && !type_sequence[i].unsigned_flag)
+ /* A hex or octal constant traditionally is unsigned. */
+ && !(base != 10 && !flag_traditional
+ && !type_sequence[i].unsigned_flag)
+ /* A decimal constant can't be unsigned int
+ unless explicitly specified. */
+ && !(base == 10 && !spec_unsigned
+ && *type_sequence[i].node_var == unsigned_type_node))
+ if (int_fits_type_p (yylval.ttype, *type_sequence[i].node_var))
+ {
+ other_type = *type_sequence[i].node_var;
+ break;
+ }
+ if (!flag_traditional && type == long_unsigned_type_node
+ && !spec_unsigned)
+ type = long_integer_type_node;
+
+ if (other_type != 0 && other_type != type)
+ {
+ if (flag_traditional)
+ warning ("type of integer constant would be different without -traditional");
+ else
+ warning ("type of integer constant would be different with -traditional");
+ }
+ }
+
+#else /* 1 */
+ if (!spec_long && !spec_unsigned
+ && !(flag_traditional && base != 10)
+ && int_fits_type_p (yylval.ttype, integer_type_node))
+ {
+#if 0
+ if (warn_traditional && base != 10)
+ warning ("small nondecimal constant becomes signed in ANSI C++");
+#endif
+ type = integer_type_node;
+ }
+ else if (!spec_long && (base != 10 || spec_unsigned)
+ && int_fits_type_p (yylval.ttype, unsigned_type_node))
+ {
+ /* Nondecimal constants try unsigned even in traditional C. */
+ type = unsigned_type_node;
+ }
+
+ else if (!spec_unsigned && !spec_long_long
+ && int_fits_type_p (yylval.ttype, long_integer_type_node))
+ type = long_integer_type_node;
+
+ else if (! spec_long_long
+ && int_fits_type_p (yylval.ttype,
+ long_unsigned_type_node))
+ {
+#if 0
+ if (warn_traditional && !spec_unsigned)
+ warning ("large integer constant becomes unsigned in ANSI C++");
+#endif
+ if (flag_traditional && !spec_unsigned)
+ type = long_integer_type_node;
+ else
+ type = long_unsigned_type_node;
+ }
+
+ else if (! spec_unsigned
+ /* Verify value does not overflow into sign bit. */
+ && TREE_INT_CST_HIGH (yylval.ttype) >= 0
+ && int_fits_type_p (yylval.ttype,
+ long_long_integer_type_node))
+ type = long_long_integer_type_node;
+
+ else if (int_fits_type_p (yylval.ttype,
+ long_long_unsigned_type_node))
+ {
+#if 0
+ if (warn_traditional && !spec_unsigned)
+ warning ("large nondecimal constant is unsigned in ANSI C++");
+#endif
+
+ if (flag_traditional && !spec_unsigned)
+ type = long_long_integer_type_node;
+ else
+ type = long_long_unsigned_type_node;
+ }
+
+ else
+ {
+ type = long_long_integer_type_node;
+ warning ("integer constant out of range");
+
+ if (base == 10 && ! spec_unsigned && TREE_UNSIGNED (type))
+ warning ("decimal integer constant is so large that it is unsigned");
+ }
+#endif
+
+ TREE_TYPE (yylval.ttype) = type;
+ *p = 0;
+ }
+
+ value = CONSTANT; break;
+ }
+
+ case '\'':
+ char_constant:
+ {
+ register int result = 0;
+ register int num_chars = 0;
+ unsigned width = TYPE_PRECISION (char_type_node);
+ int max_chars;
+
+ if (wide_flag)
+ {
+ width = WCHAR_TYPE_SIZE;
+#ifdef MULTIBYTE_CHARS
+ max_chars = MB_CUR_MAX;
+#else
+ max_chars = 1;
+#endif
+ }
+ else
+ max_chars = TYPE_PRECISION (integer_type_node) / width;
+
+ while (1)
+ {
+ tryagain:
+
+ c = getch ();
+
+ if (c == '\'' || c == EOF)
+ break;
+
+ if (c == '\\')
+ {
+ int ignore = 0;
+ c = readescape (&ignore);
+ if (ignore)
+ goto tryagain;
+ if (width < HOST_BITS_PER_INT
+ && (unsigned) c >= (1 << width))
+ warning ("escape sequence out of range for character");
+#ifdef MAP_CHARACTER
+ if (isprint (c))
+ c = MAP_CHARACTER (c);
+#endif
+ }
+ else if (c == '\n')
+ {
+ if (pedantic)
+ pedwarn ("ANSI C++ forbids newline in character constant");
+ lineno++;
+ }
+#ifdef MAP_CHARACTER
+ else
+ c = MAP_CHARACTER (c);
+#endif
+
+ num_chars++;
+ if (num_chars > maxtoken - 4)
+ extend_token_buffer (token_buffer);
+
+ token_buffer[num_chars] = c;
+
+ /* Merge character into result; ignore excess chars. */
+ if (num_chars < max_chars + 1)
+ {
+ if (width < HOST_BITS_PER_INT)
+ result = (result << width) | (c & ((1 << width) - 1));
+ else
+ result = c;
+ }
+ }
+
+ token_buffer[num_chars + 1] = '\'';
+ token_buffer[num_chars + 2] = 0;
+
+ if (c != '\'')
+ error ("malformatted character constant");
+ else if (num_chars == 0)
+ error ("empty character constant");
+ else if (num_chars > max_chars)
+ {
+ num_chars = max_chars;
+ error ("character constant too long");
+ }
+ else if (num_chars != 1 && ! flag_traditional)
+ warning ("multi-character character constant");
+
+ /* If char type is signed, sign-extend the constant. */
+ if (! wide_flag)
+ {
+ int num_bits = num_chars * width;
+ if (num_bits == 0)
+ /* We already got an error; avoid invalid shift. */
+ yylval.ttype = build_int_2 (0, 0);
+ else if (TREE_UNSIGNED (char_type_node)
+ || ((result >> (num_bits - 1)) & 1) == 0)
+ yylval.ttype
+ = build_int_2 (result & ((unsigned HOST_WIDE_INT) ~0
+ >> (HOST_BITS_PER_WIDE_INT - num_bits)),
+ 0);
+ else
+ yylval.ttype
+ = build_int_2 (result | ~((unsigned HOST_WIDE_INT) ~0
+ >> (HOST_BITS_PER_WIDE_INT - num_bits)),
+ -1);
+ if (num_chars<=1)
+ TREE_TYPE (yylval.ttype) = char_type_node;
+ else
+ TREE_TYPE (yylval.ttype) = integer_type_node;
+ }
+ else
+ {
+#ifdef MULTIBYTE_CHARS
+ /* Set the initial shift state and convert the next sequence. */
+ result = 0;
+ /* In all locales L'\0' is zero and mbtowc will return zero,
+ so don't use it. */
+ if (num_chars > 1
+ || (num_chars == 1 && token_buffer[1] != '\0'))
+ {
+ wchar_t wc;
+ (void) mbtowc (NULL, NULL, 0);
+ if (mbtowc (& wc, token_buffer + 1, num_chars) == num_chars)
+ result = wc;
+ else
+ warning ("Ignoring invalid multibyte character");
+ }
+#endif
+ yylval.ttype = build_int_2 (result, 0);
+ TREE_TYPE (yylval.ttype) = wchar_type_node;
+ }
+
+ value = CONSTANT;
+ break;
+ }
+
+ case '"':
+ string_constant:
+ {
+ register char *p;
+
+ c = getch ();
+ p = token_buffer + 1;
+
+ while (c != '"' && c >= 0)
+ {
+ /* ignore_escape_flag is set for reading the filename in #line. */
+ if (!ignore_escape_flag && c == '\\')
+ {
+ int ignore = 0;
+ c = readescape (&ignore);
+ if (ignore)
+ goto skipnewline;
+ if (!wide_flag
+ && TYPE_PRECISION (char_type_node) < HOST_BITS_PER_INT
+ && c >= ((unsigned) 1 << TYPE_PRECISION (char_type_node)))
+ warning ("escape sequence out of range for character");
+ }
+ else if (c == '\n')
+ {
+ if (pedantic)
+ pedwarn ("ANSI C++ forbids newline in string constant");
+ lineno++;
+ }
+
+ if (p == token_buffer + maxtoken)
+ p = extend_token_buffer (p);
+ *p++ = c;
+
+ skipnewline:
+ c = getch ();
+ if (c == EOF) {
+ error("Unterminated string");
+ break;
+ }
+ }
+ *p = 0;
+
+ /* We have read the entire constant.
+ Construct a STRING_CST for the result. */
+
+ if (wide_flag)
+ {
+ /* If this is a L"..." wide-string, convert the multibyte string
+ to a wide character string. */
+ char *widep = (char *) alloca ((p - token_buffer) * WCHAR_BYTES);
+ int len;
+
+#ifdef MULTIBYTE_CHARS
+ len = mbstowcs ((wchar_t *) widep, token_buffer + 1, p - token_buffer);
+ if (len < 0 || len >= (p - token_buffer))
+ {
+ warning ("Ignoring invalid multibyte string");
+ len = 0;
+ }
+ bzero (widep + (len * WCHAR_BYTES), WCHAR_BYTES);
+#else
+ {
+ union { long l; char c[sizeof (long)]; } u;
+ int big_endian;
+ char *wp, *cp;
+
+ /* Determine whether host is little or big endian. */
+ u.l = 1;
+ big_endian = u.c[sizeof (long) - 1];
+ wp = widep + (big_endian ? WCHAR_BYTES - 1 : 0);
+
+ bzero (widep, (p - token_buffer) * WCHAR_BYTES);
+ for (cp = token_buffer + 1; cp < p; cp++)
+ *wp = *cp, wp += WCHAR_BYTES;
+ len = p - token_buffer - 1;
+ }
+#endif
+ yylval.ttype = build_string ((len + 1) * WCHAR_BYTES, widep);
+ TREE_TYPE (yylval.ttype) = wchar_array_type_node;
+ }
+ else
+ {
+ yylval.ttype = build_string (p - token_buffer, token_buffer + 1);
+ TREE_TYPE (yylval.ttype) = char_array_type_node;
+ }
+
+ *p++ = '"';
+ *p = 0;
+
+ value = STRING; break;
+ }
+
+ case '+':
+ case '-':
+ case '&':
+ case '|':
+ case '<':
+ case '>':
+ case '*':
+ case '/':
+ case '%':
+ case '^':
+ case '!':
+ case '=':
+ {
+ register int c1;
+
+ combine:
+
+ switch (c)
+ {
+ case '+':
+ yylval.code = PLUS_EXPR; break;
+ case '-':
+ yylval.code = MINUS_EXPR; break;
+ case '&':
+ yylval.code = BIT_AND_EXPR; break;
+ case '|':
+ yylval.code = BIT_IOR_EXPR; break;
+ case '*':
+ yylval.code = MULT_EXPR; break;
+ case '/':
+ yylval.code = TRUNC_DIV_EXPR; break;
+ case '%':
+ yylval.code = TRUNC_MOD_EXPR; break;
+ case '^':
+ yylval.code = BIT_XOR_EXPR; break;
+ case LSHIFT:
+ yylval.code = LSHIFT_EXPR; break;
+ case RSHIFT:
+ yylval.code = RSHIFT_EXPR; break;
+ case '<':
+ yylval.code = LT_EXPR; break;
+ case '>':
+ yylval.code = GT_EXPR; break;
+ }
+
+ token_buffer[1] = c1 = getch ();
+ token_buffer[2] = 0;
+
+ if (c1 == '=')
+ {
+ switch (c)
+ {
+ case '<':
+ value = ARITHCOMPARE; yylval.code = LE_EXPR; goto done;
+ case '>':
+ value = ARITHCOMPARE; yylval.code = GE_EXPR; goto done;
+ case '!':
+ value = EQCOMPARE; yylval.code = NE_EXPR; goto done;
+ case '=':
+ value = EQCOMPARE; yylval.code = EQ_EXPR; goto done;
+ }
+ value = ASSIGN; goto done;
+ }
+ else if (c == c1)
+ switch (c)
+ {
+ case '+':
+ value = PLUSPLUS; goto done;
+ case '-':
+ value = MINUSMINUS; goto done;
+ case '&':
+ value = ANDAND; goto done;
+ case '|':
+ value = OROR; goto done;
+ case '<':
+ c = LSHIFT;
+ goto combine;
+ case '>':
+ c = RSHIFT;
+ goto combine;
+ }
+ else if ((c == '-') && (c1 == '>'))
+ {
+ nextchar = getch ();
+ if (nextchar == '*')
+ {
+ nextchar = -1;
+ value = POINTSAT_STAR;
+ }
+ else
+ value = POINTSAT;
+ goto done;
+ }
+ else if (c1 == '?' && (c == '<' || c == '>'))
+ {
+ token_buffer[3] = 0;
+
+ c1 = getch ();
+ yylval.code = (c == '<' ? MIN_EXPR : MAX_EXPR);
+ if (c1 == '=')
+ {
+ /* <?= or >?= expression. */
+ token_buffer[2] = c1;
+ value = ASSIGN;
+ }
+ else
+ {
+ value = MIN_MAX;
+ nextchar = c1;
+ }
+ if (pedantic)
+ pedwarn ("use of `operator %s' is not standard C++",
+ token_buffer);
+ goto done;
+ }
+ /* digraphs */
+ else if (c == '<' && c1 == '%')
+ { value = '{'; goto done; }
+ else if (c == '<' && c1 == ':')
+ { value = '['; goto done; }
+ else if (c == '%' && c1 == '>')
+ { value = '}'; goto done; }
+ else if (c == '%' && c1 == ':')
+ { value = '#'; goto done; }
+
+ nextchar = c1;
+ token_buffer[1] = 0;
+
+ value = c;
+ goto done;
+ }
+
+ case ':':
+ c = getch ();
+ if (c == ':')
+ {
+ token_buffer[1] = ':';
+ token_buffer[2] = '\0';
+ value = SCOPE;
+ yylval.itype = 1;
+ }
+ else if (c == '>')
+ {
+ value = ']';
+ goto done;
+ }
+ else
+ {
+ nextchar = c;
+ value = ':';
+ }
+ break;
+
+ case 0:
+ /* Don't make yyparse think this is eof. */
+ value = 1;
+ break;
+
+ case '(':
+ /* try, weakly, to handle casts to pointers to functions. */
+ nextchar = skip_white_space (getch ());
+ if (nextchar == '*')
+ {
+ int next_c = skip_white_space (getch ());
+ if (next_c == ')')
+ {
+ nextchar = -1;
+ yylval.ttype = build1 (INDIRECT_REF, 0, 0);
+ value = PAREN_STAR_PAREN;
+ }
+ else
+ {
+ put_back (next_c);
+ value = c;
+ }
+ }
+ else if (nextchar == ')')
+ {
+ nextchar = -1;
+ yylval.ttype = NULL_TREE;
+ value = LEFT_RIGHT;
+ }
+ else value = c;
+ break;
+
+ default:
+ value = c;
+ }
+
+done:
+/* yylloc.last_line = lineno; */
+#ifdef GATHER_STATISTICS
+ token_count[value] += 1;
+#endif
+
+ return value;
+}
+
+typedef enum
+{
+ d_kind, t_kind, s_kind, r_kind, e_kind, c_kind,
+ id_kind, op_id_kind, perm_list_kind, temp_list_kind,
+ vec_kind, x_kind, lang_decl, lang_type, all_kinds
+} tree_node_kind;
+extern int tree_node_counts[];
+extern int tree_node_sizes[];
+extern char *tree_node_kind_names[];
+
+/* Place to save freed lang_decls which were allocated on the
+ permanent_obstack. @@ Not currently used. */
+tree free_lang_decl_chain;
+
+tree
+build_lang_decl (code, name, type)
+ enum tree_code code;
+ tree name;
+ tree type;
+{
+ register tree t = build_decl (code, name, type);
+ struct obstack *obstack = current_obstack;
+ register int i = sizeof (struct lang_decl) / sizeof (int);
+ register int *pi;
+
+ if (! TREE_PERMANENT (t))
+ obstack = saveable_obstack;
+ else
+ /* Could be that saveable is permanent and current is not. */
+ obstack = &permanent_obstack;
+
+ if (free_lang_decl_chain && obstack == &permanent_obstack)
+ {
+ pi = (int *)free_lang_decl_chain;
+ free_lang_decl_chain = TREE_CHAIN (free_lang_decl_chain);
+ }
+ else
+ pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl));
+
+ while (i > 0)
+ pi[--i] = 0;
+
+ DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi;
+ LANG_DECL_PERMANENT ((struct lang_decl *) pi)
+ = obstack == &permanent_obstack;
+ my_friendly_assert (LANG_DECL_PERMANENT ((struct lang_decl *) pi)
+ == TREE_PERMANENT (t), 234);
+ DECL_MAIN_VARIANT (t) = t;
+ if (current_lang_name == lang_name_cplusplus)
+ {
+ DECL_LANGUAGE (t) = lang_cplusplus;
+#if 0
+#ifndef NO_AUTO_OVERLOAD
+ if (code == FUNCTION_DECL && name != 0
+ && ! (IDENTIFIER_LENGTH (name) == 4
+ && IDENTIFIER_POINTER (name)[0] == 'm'
+ && strcmp (IDENTIFIER_POINTER (name), "main") == 0)
+ && ! (IDENTIFIER_LENGTH (name) > 10
+ && IDENTIFIER_POINTER (name)[0] == '_'
+ && IDENTIFIER_POINTER (name)[1] == '_'
+ && strncmp (IDENTIFIER_POINTER (name)+2, "builtin_", 8) == 0))
+ TREE_OVERLOADED (name) = 1;
+#endif
+#endif
+ }
+ else if (current_lang_name == lang_name_c)
+ DECL_LANGUAGE (t) = lang_c;
+ else my_friendly_abort (64);
+
+#if 0 /* not yet, should get fixed properly later */
+ if (code == TYPE_DECL)
+ {
+ tree id;
+ id = get_identifier (build_overload_name (type, 1, 1));
+ DECL_ASSEMBLER_NAME (t) = id;
+ }
+
+#endif
+#ifdef GATHER_STATISTICS
+ tree_node_counts[(int)lang_decl] += 1;
+ tree_node_sizes[(int)lang_decl] += sizeof(struct lang_decl);
+#endif
+
+ return t;
+}
+
+tree
+build_lang_field_decl (code, name, type)
+ enum tree_code code;
+ tree name;
+ tree type;
+{
+ extern struct obstack *current_obstack, *saveable_obstack;
+ register tree t = build_decl (code, name, type);
+ struct obstack *obstack = current_obstack;
+ register int i = sizeof (struct lang_decl_flags) / sizeof (int);
+ register int *pi;
+#if 0 /* not yet, should get fixed properly later */
+
+ if (code == TYPE_DECL)
+ {
+ tree id;
+ id = get_identifier (build_overload_name (type, 1, 1));
+ DECL_ASSEMBLER_NAME (t) = id;
+ }
+#endif
+
+ if (! TREE_PERMANENT (t))
+ obstack = saveable_obstack;
+ else
+ my_friendly_assert (obstack == &permanent_obstack, 235);
+
+ pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl_flags));
+ while (i > 0)
+ pi[--i] = 0;
+
+ DECL_LANG_SPECIFIC (t) = (struct lang_decl *) pi;
+ return t;
+}
+
+void
+copy_lang_decl (node)
+ tree node;
+{
+ int size;
+ int *pi;
+
+ if (TREE_CODE (node) == FIELD_DECL)
+ size = sizeof (struct lang_decl_flags);
+ else
+ size = sizeof (struct lang_decl);
+ pi = (int *)obstack_alloc (&permanent_obstack, size);
+ bcopy ((char *)DECL_LANG_SPECIFIC (node), (char *)pi, size);
+ DECL_LANG_SPECIFIC (node) = (struct lang_decl *)pi;
+}
+
+tree
+make_lang_type (code)
+ enum tree_code code;
+{
+ extern struct obstack *current_obstack, *saveable_obstack;
+ register tree t = make_node (code);
+ struct obstack *obstack = current_obstack;
+ register int i = sizeof (struct lang_type) / sizeof (int);
+ register int *pi;
+
+ /* Set up some flags that give proper default behavior. */
+ IS_AGGR_TYPE (t) = 1;
+
+ if (! TREE_PERMANENT (t))
+ obstack = saveable_obstack;
+ else
+ my_friendly_assert (obstack == &permanent_obstack, 236);
+
+ pi = (int *) obstack_alloc (obstack, sizeof (struct lang_type));
+ while (i > 0)
+ pi[--i] = 0;
+
+ TYPE_LANG_SPECIFIC (t) = (struct lang_type *) pi;
+ CLASSTYPE_AS_LIST (t) = build_tree_list (NULL_TREE, t);
+ SET_CLASSTYPE_INTERFACE_UNKNOWN_X (t, interface_unknown);
+ CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
+ CLASSTYPE_VBASE_SIZE (t) = integer_zero_node;
+ TYPE_BINFO (t) = make_binfo (integer_zero_node, t, NULL_TREE, NULL_TREE,
+ NULL_TREE);
+ CLASSTYPE_BINFO_AS_LIST (t) = build_tree_list (NULL_TREE, TYPE_BINFO (t));
+
+ /* Make sure this is laid out, for ease of use later.
+ In the presence of parse errors, the normal was of assuring
+ this might not ever get executed, so we lay it out *immediately*. */
+ build_pointer_type (t);
+
+#ifdef GATHER_STATISTICS
+ tree_node_counts[(int)lang_type] += 1;
+ tree_node_sizes[(int)lang_type] += sizeof(struct lang_type);
+#endif
+
+ return t;
+}
+
+void
+copy_decl_lang_specific (decl)
+ tree decl;
+{
+ extern struct obstack *current_obstack, *saveable_obstack;
+ register int *old = (int *)DECL_LANG_SPECIFIC (decl);
+ struct obstack *obstack = current_obstack;
+ register int i = sizeof (struct lang_decl) / sizeof (int);
+ register int *pi;
+
+ if (! TREE_PERMANENT (decl))
+ obstack = saveable_obstack;
+ else
+ my_friendly_assert (obstack == &permanent_obstack, 237);
+
+ pi = (int *) obstack_alloc (obstack, sizeof (struct lang_decl));
+ while (i-- > 0)
+ pi[i] = old[i];
+
+ DECL_LANG_SPECIFIC (decl) = (struct lang_decl *) pi;
+
+#ifdef GATHER_STATISTICS
+ tree_node_counts[(int)lang_decl] += 1;
+ tree_node_sizes[(int)lang_decl] += sizeof(struct lang_decl);
+#endif
+}
+
+void
+dump_time_statistics ()
+{
+ register tree prev = 0, decl, next;
+ int this_time = my_get_run_time ();
+ TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (this_filename_time))
+ += this_time - body_time;
+
+ fprintf (stderr, "\n******\n");
+ print_time ("header files (total)", header_time);
+ print_time ("main file (total)", this_time - body_time);
+ fprintf (stderr, "ratio = %g : 1\n",
+ (double)header_time / (double)(this_time - body_time));
+ fprintf (stderr, "\n******\n");
+
+ for (decl = filename_times; decl; decl = next)
+ {
+ next = IDENTIFIER_GLOBAL_VALUE (decl);
+ IDENTIFIER_GLOBAL_VALUE (decl) = prev;
+ prev = decl;
+ }
+
+ for (decl = prev; decl; decl = IDENTIFIER_GLOBAL_VALUE (decl))
+ print_time (IDENTIFIER_POINTER (decl),
+ TREE_INT_CST_LOW (IDENTIFIER_LOCAL_VALUE (decl)));
+}
+
+void
+compiler_error (s, v, v2)
+ char *s;
+ HOST_WIDE_INT v, v2; /* @@also used as pointer */
+{
+ char buf[1024];
+ sprintf (buf, s, v, v2);
+ error_with_file_and_line (input_filename, lineno, "%s (compiler error)", buf);
+}
+
+void
+compiler_error_with_decl (decl, s)
+ tree decl;
+ char *s;
+{
+ char *name;
+ count_error (0);
+
+ report_error_function (0);
+
+ if (TREE_CODE (decl) == PARM_DECL)
+ fprintf (stderr, "%s:%d: ",
+ DECL_SOURCE_FILE (DECL_CONTEXT (decl)),
+ DECL_SOURCE_LINE (DECL_CONTEXT (decl)));
+ else
+ fprintf (stderr, "%s:%d: ",
+ DECL_SOURCE_FILE (decl), DECL_SOURCE_LINE (decl));
+
+ name = lang_printable_name (decl);
+ if (name)
+ fprintf (stderr, s, name);
+ else
+ fprintf (stderr, s, "((anonymous))");
+ fprintf (stderr, " (compiler error)\n");
+}
+
+void
+yyerror (string)
+ char *string;
+{
+ extern int end_of_file;
+ char buf[200];
+
+ strcpy (buf, string);
+
+ /* We can't print string and character constants well
+ because the token_buffer contains the result of processing escapes. */
+ if (end_of_file)
+ strcat (buf, input_redirected ()
+ ? " at end of saved text"
+ : " at end of input");
+ else if (token_buffer[0] == 0)
+ strcat (buf, " at null character");
+ else if (token_buffer[0] == '"')
+ strcat (buf, " before string constant");
+ else if (token_buffer[0] == '\'')
+ strcat (buf, " before character constant");
+ else if (token_buffer[0] < 040 || (unsigned char) token_buffer[0] >= 0177)
+ sprintf (buf + strlen (buf), " before character 0%o",
+ (unsigned char) token_buffer[0]);
+ else
+ strcat (buf, " before `%s'");
+
+ error (buf, token_buffer);
+}
+
+#ifdef HANDLE_SYSV_PRAGMA
+
+/* Handle a #pragma directive. INPUT is the current input stream,
+ and C is a character to reread. Processes the entire input line
+ and returns a character for the caller to reread: either \n or EOF. */
+
+/* This function has to be in this file, in order to get at
+ the token types. */
+
+handle_sysv_pragma ()
+{
+ for (;;)
+ {
+ switch (yylex ())
+ {
+ case IDENTIFIER:
+ case TYPENAME:
+ case STRING:
+ case CONSTANT:
+ handle_pragma_token ("ignored", yylval.ttype);
+ break;
+ case '(':
+ handle_pragma_token ("(", NULL_TREE);
+ break;
+ case ')':
+ handle_pragma_token (")", NULL_TREE);
+ break;
+ case ',':
+ handle_pragma_token (",", NULL_TREE);
+ break;
+ case '=':
+ handle_pragma_token ("=", NULL_TREE);
+ break;
+ case LEFT_RIGHT:
+ handle_pragma_token ("(", NULL_TREE);
+ handle_pragma_token (")", NULL_TREE);
+ break;
+ case END_OF_LINE:
+ handle_pragma_token (NULL_PTR, NULL_TREE);
+ return;
+ default:
+ handle_pragma_token (NULL_PTR, NULL_TREE);
+ while (yylex () != END_OF_LINE)
+ /* continue */;
+ return;
+ }
+ }
+}
+#endif /* HANDLE_SYSV_PRAGMA */
diff --git a/contrib/gcc/cp/lex.h b/contrib/gcc/cp/lex.h
new file mode 100644
index 0000000..1cf5687
--- /dev/null
+++ b/contrib/gcc/cp/lex.h
@@ -0,0 +1,135 @@
+/* Define constants and variables for communication with parse.y.
+ Copyright (C) 1987, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+ Hacked by Michael Tiemann (tiemann@cygnus.com)
+ and by Brendan Kehoe (brendan@cygnus.com).
+
+This file is part of GNU CC.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY. No author or distributor
+accepts responsibility to anyone for the consequences of using it
+or for whether it serves any particular purpose or works at all,
+unless he says so in writing. Refer to the GNU CC General Public
+License for full details.
+
+Everyone is granted permission to copy, modify and redistribute
+GNU CC, but only under the conditions described in the
+GNU CC General Public License. A copy of this license is
+supposed to have been given to you along with GNU CC so you
+can know your rights and responsibilities. It should be in a
+file named COPYING. Among other things, the copyright notice
+and this notice must be preserved on all copies. */
+
+
+
+enum rid
+{
+ RID_UNUSED,
+ RID_INT,
+ RID_BOOL,
+ RID_CHAR,
+ RID_WCHAR,
+ RID_FLOAT,
+ RID_DOUBLE,
+ RID_VOID,
+
+ /* C++ extension */
+ RID_CLASS,
+ RID_RECORD,
+ RID_UNION,
+ RID_ENUM,
+ RID_LONGLONG,
+
+ /* This is where grokdeclarator starts its search when setting the specbits.
+ The first seven are in the order of most frequently used, as found
+ building libg++. */
+
+ RID_EXTERN,
+ RID_CONST,
+ RID_LONG,
+ RID_TYPEDEF,
+ RID_UNSIGNED,
+ RID_SHORT,
+ RID_INLINE,
+
+ RID_STATIC,
+
+ RID_REGISTER,
+ RID_VOLATILE,
+ RID_FRIEND,
+ RID_VIRTUAL,
+ RID_EXPLICIT,
+ RID_SIGNED,
+ RID_AUTO,
+ RID_MUTABLE,
+
+ /* This is where grokdeclarator ends its search when setting the specbits. */
+
+ RID_PUBLIC,
+ RID_PRIVATE,
+ RID_PROTECTED,
+ RID_EXCEPTION,
+ RID_TEMPLATE,
+ RID_SIGNATURE,
+ /* Before adding enough to get up to 64, the RIDBIT_* macros
+ will have to be changed a little. */
+ RID_MAX
+};
+
+#define NORID RID_UNUSED
+
+#define RID_FIRST_MODIFIER RID_EXTERN
+#define RID_LAST_MODIFIER RID_MUTABLE
+
+/* The type that can represent all values of RIDBIT. */
+/* We assume that we can stick in at least 32 bits into this. */
+typedef struct { unsigned long idata[2]; }
+ RID_BIT_TYPE;
+
+/* Be careful, all these modify N twice. */
+#define RIDBIT_SETP(N, V) (((unsigned long)1 << (int) ((N)%32)) \
+ & (V).idata[(N)/32])
+#define RIDBIT_NOTSETP(NN, VV) (! RIDBIT_SETP (NN, VV))
+#define RIDBIT_SET(N, V) do { \
+ (V).idata[(N)/32] \
+ |= ((unsigned long)1 << (int) ((N)%32)); \
+ } while (0)
+#define RIDBIT_RESET(N, V) do { \
+ (V).idata[(N)/32] \
+ &= ~((unsigned long)1 << (int) ((N)%32)); \
+ } while (0)
+#define RIDBIT_RESET_ALL(V) do { \
+ (V).idata[0] = 0; \
+ (V).idata[1] = 0; \
+ } while (0)
+#define RIDBIT_ANY_SET(V) ((V).idata[0] || (V).idata[1])
+
+/* The elements of `ridpointers' are identifier nodes
+ for the reserved type names and storage classes.
+ It is indexed by a RID_... value. */
+extern tree ridpointers[(int) RID_MAX];
+
+/* the declaration found for the last IDENTIFIER token read in.
+ yylex must look this up to detect typedefs, which get token type TYPENAME,
+ so it is left around in case the identifier is not a typedef but is
+ used in a context which makes it a reference to a variable. */
+extern tree lastiddecl;
+
+extern char *token_buffer; /* Pointer to token buffer. */
+
+/* Back-door communication channel to the lexer. */
+extern int looking_for_typename;
+extern int looking_for_template;
+
+/* Tell the lexer where to look for names. */
+extern tree got_scope;
+extern tree got_object;
+
+/* Pending language change.
+ Positive is push count, negative is pop count. */
+extern int pending_lang_change;
+
+extern tree make_pointer_declarator (), make_reference_declarator ();
+extern void reinit_parse_for_function ();
+extern void reinit_parse_for_method ();
+extern int yylex ();
diff --git a/contrib/gcc/cp/method.c b/contrib/gcc/cp/method.c
new file mode 100644
index 0000000..a0e1527
--- /dev/null
+++ b/contrib/gcc/cp/method.c
@@ -0,0 +1,2287 @@
+/* Handle the hair of processing (but not expanding) inline functions.
+ Also manage function and variable name overloading.
+ Copyright (C) 1987, 89, 92, 93, 94, 1995 Free Software Foundation, Inc.
+ Contributed by Michael Tiemann (tiemann@cygnus.com)
+
+ This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+#ifndef PARM_CAN_BE_ARRAY_TYPE
+#define PARM_CAN_BE_ARRAY_TYPE 1
+#endif
+
+/* Handle method declarations. */
+#include <stdio.h>
+#include "config.h"
+#include "tree.h"
+#include "cp-tree.h"
+#include "class.h"
+#include "obstack.h"
+#include <ctype.h>
+#include "rtl.h"
+#include "expr.h"
+#include "output.h"
+#include "hard-reg-set.h"
+#include "flags.h"
+
+/* TREE_LIST of the current inline functions that need to be
+ processed. */
+struct pending_inline *pending_inlines;
+
+#define obstack_chunk_alloc xmalloc
+#define obstack_chunk_free free
+
+/* Obstack where we build text strings for overloading, etc. */
+static struct obstack scratch_obstack;
+static char *scratch_firstobj;
+
+# define OB_INIT() (scratch_firstobj ? (obstack_free (&scratch_obstack, scratch_firstobj), 0) : 0)
+# define OB_PUTC(C) (obstack_1grow (&scratch_obstack, (C)))
+# define OB_PUTC2(C1,C2) \
+ (obstack_1grow (&scratch_obstack, (C1)), obstack_1grow (&scratch_obstack, (C2)))
+# define OB_PUTS(S) (obstack_grow (&scratch_obstack, (S), sizeof (S) - 1))
+# define OB_PUTID(ID) \
+ (obstack_grow (&scratch_obstack, IDENTIFIER_POINTER (ID), \
+ IDENTIFIER_LENGTH (ID)))
+# define OB_PUTCP(S) (obstack_grow (&scratch_obstack, (S), strlen (S)))
+# define OB_FINISH() (obstack_1grow (&scratch_obstack, '\0'))
+# define OB_LAST() (obstack_next_free (&scratch_obstack)[-1])
+
+#ifdef NO_AUTO_OVERLOAD
+int is_overloaded ();
+#endif
+
+void
+init_method ()
+{
+ gcc_obstack_init (&scratch_obstack);
+ scratch_firstobj = (char *)obstack_alloc (&scratch_obstack, 0);
+}
+
+/* This must be large enough to hold any printed integer or floating-point
+ value. */
+static char digit_buffer[128];
+
+/* Move inline function definitions out of structure so that they
+ can be processed normally. CNAME is the name of the class
+ we are working from, METHOD_LIST is the list of method lists
+ of the structure. We delete friend methods here, after
+ saving away their inline function definitions (if any). */
+
+void
+do_inline_function_hair (type, friend_list)
+ tree type, friend_list;
+{
+ tree method = TYPE_METHODS (type);
+
+ if (method && TREE_CODE (method) == TREE_VEC)
+ {
+ if (TREE_VEC_ELT (method, 0))
+ method = TREE_VEC_ELT (method, 0);
+ else
+ method = TREE_VEC_ELT (method, 1);
+ }
+
+ while (method)
+ {
+ /* Do inline member functions. */
+ struct pending_inline *info = DECL_PENDING_INLINE_INFO (method);
+ if (info)
+ {
+ tree args;
+
+ my_friendly_assert (info->fndecl == method, 238);
+ args = DECL_ARGUMENTS (method);
+ while (args)
+ {
+ DECL_CONTEXT (args) = method;
+ args = TREE_CHAIN (args);
+ }
+
+ /* Allow this decl to be seen in global scope. Don't do this for
+ local class methods, though. */
+ if (! current_function_decl)
+ IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (method)) = method;
+ }
+ method = TREE_CHAIN (method);
+ }
+ while (friend_list)
+ {
+ tree fndecl = TREE_VALUE (friend_list);
+ struct pending_inline *info = DECL_PENDING_INLINE_INFO (fndecl);
+ if (info)
+ {
+ tree args;
+
+ my_friendly_assert (info->fndecl == fndecl, 239);
+ args = DECL_ARGUMENTS (fndecl);
+ while (args)
+ {
+ DECL_CONTEXT (args) = fndecl;
+ args = TREE_CHAIN (args);
+ }
+
+ /* Allow this decl to be seen in global scope */
+ if (! current_function_decl)
+ IDENTIFIER_GLOBAL_VALUE (DECL_ASSEMBLER_NAME (fndecl)) = fndecl;
+ }
+
+ friend_list = TREE_CHAIN (friend_list);
+ }
+}
+
+/* Report an argument type mismatch between the best declared function
+ we could find and the current argument list that we have. */
+void
+report_type_mismatch (cp, parmtypes, name_kind)
+ struct candidate *cp;
+ tree parmtypes;
+ char *name_kind;
+{
+ int i = cp->u.bad_arg;
+ tree ttf, tta;
+ char *tmp_firstobj;
+
+ switch (i)
+ {
+ case -4:
+ my_friendly_assert (TREE_CODE (cp->function) == TEMPLATE_DECL, 240);
+ cp_error ("type unification failed for function template `%#D'",
+ cp->function);
+ return;
+
+ case -2:
+ cp_error ("too few arguments for %s `%#D'", name_kind, cp->function);
+ return;
+ case -1:
+ cp_error ("too many arguments for %s `%#D'", name_kind, cp->function);
+ return;
+ case 0:
+ if (TREE_CODE (TREE_TYPE (cp->function)) != METHOD_TYPE)
+ break;
+ case -3:
+ /* Happens when the implicit object parameter is rejected. */
+ my_friendly_assert (! TYPE_READONLY (TREE_TYPE (TREE_VALUE (parmtypes))),
+ 241);
+ cp_error ("call to non-const %s `%#D' with const object",
+ name_kind, cp->function);
+ return;
+ }
+
+ ttf = TYPE_ARG_TYPES (TREE_TYPE (cp->function));
+ tta = parmtypes;
+
+ while (i-- > 0)
+ {
+ ttf = TREE_CHAIN (ttf);
+ tta = TREE_CHAIN (tta);
+ }
+
+ OB_INIT ();
+ OB_PUTS ("bad argument ");
+ sprintf (digit_buffer, "%d", cp->u.bad_arg
+ - (TREE_CODE (TREE_TYPE (cp->function)) == METHOD_TYPE)
+ + 1);
+ OB_PUTCP (digit_buffer);
+
+ OB_PUTS (" for function `");
+ OB_PUTCP (decl_as_string (cp->function, 1));
+ OB_PUTS ("' (type was ");
+
+ /* Reset `i' so that type printing routines do the right thing. */
+ if (tta)
+ {
+ enum tree_code code = TREE_CODE (TREE_TYPE (TREE_VALUE (tta)));
+ if (code == ERROR_MARK)
+ OB_PUTS ("(failed type instantiation)");
+ else
+ {
+ i = (code == FUNCTION_TYPE || code == METHOD_TYPE);
+ OB_PUTCP (type_as_string (TREE_TYPE (TREE_VALUE (tta)), 1));
+ }
+ }
+ else OB_PUTS ("void");
+ OB_PUTC (')');
+ OB_FINISH ();
+
+ tmp_firstobj = (char *)alloca (obstack_object_size (&scratch_obstack));
+ bcopy (obstack_base (&scratch_obstack), tmp_firstobj,
+ obstack_object_size (&scratch_obstack));
+ error (tmp_firstobj);
+}
+
+/* Here is where overload code starts. */
+
+/* Array of types seen so far in top-level call to `build_overload_name'.
+ Allocated and deallocated by caller. */
+static tree *typevec;
+
+/* Number of types interned by `build_overload_name' so far. */
+static int maxtype;
+
+/* Number of occurrences of last type seen. */
+static int nrepeats;
+
+/* Nonzero if we should not try folding parameter types. */
+static int nofold;
+
+#define ALLOCATE_TYPEVEC(PARMTYPES) \
+ do { maxtype = 0, nrepeats = 0; \
+ typevec = (tree *)alloca (list_length (PARMTYPES) * sizeof (tree)); } while (0)
+
+#define DEALLOCATE_TYPEVEC(PARMTYPES) \
+ do { tree t = (PARMTYPES); \
+ while (t) { TREE_USED (TREE_VALUE (t)) = 0; t = TREE_CHAIN (t); } \
+ } while (0)
+
+/* Code to concatenate an asciified integer to a string. */
+static
+#ifdef __GNUC__
+__inline
+#endif
+void
+icat (i)
+ int i;
+{
+ /* Handle this case first, to go really quickly. For many common values,
+ the result of i/10 below is 1. */
+ if (i == 1)
+ {
+ OB_PUTC ('1');
+ return;
+ }
+
+ if (i < 0)
+ {
+ OB_PUTC ('m');
+ i = -i;
+ }
+ if (i < 10)
+ OB_PUTC ('0' + i);
+ else
+ {
+ icat (i / 10);
+ OB_PUTC ('0' + (i % 10));
+ }
+}
+
+static
+#ifdef __GNUC__
+__inline
+#endif
+void
+flush_repeats (type)
+ tree type;
+{
+ int tindex = 0;
+
+ while (typevec[tindex] != type)
+ tindex++;
+
+ if (nrepeats > 1)
+ {
+ OB_PUTC ('N');
+ icat (nrepeats);
+ if (nrepeats > 9)
+ OB_PUTC ('_');
+ }
+ else
+ OB_PUTC ('T');
+ nrepeats = 0;
+ icat (tindex);
+ if (tindex > 9)
+ OB_PUTC ('_');
+}
+
+static int numeric_output_need_bar;
+static void build_overload_identifier ();
+
+static void
+build_overload_nested_name (decl)
+ tree decl;
+{
+ if (DECL_CONTEXT (decl))
+ {
+ tree context = DECL_CONTEXT (decl);
+ if (TREE_CODE_CLASS (TREE_CODE (context)) == 't')
+ context = TYPE_MAIN_DECL (context);
+ build_overload_nested_name (context);
+ }
+
+ if (TREE_CODE (decl) == FUNCTION_DECL)
+ {
+ tree name = DECL_ASSEMBLER_NAME (decl);
+ char *label;
+ extern int var_labelno;
+
+ ASM_FORMAT_PRIVATE_NAME (label, IDENTIFIER_POINTER (name), var_labelno);
+ var_labelno++;
+
+ if (numeric_output_need_bar)
+ {
+ OB_PUTC ('_');
+ numeric_output_need_bar = 0;
+ }
+ icat (strlen (label));
+ OB_PUTCP (label);
+ }
+ else /* TYPE_DECL */
+ {
+ tree name = DECL_NAME (decl);
+ build_overload_identifier (name);
+ }
+}
+
+/* Encoding for an INTEGER_CST value. */
+static void
+build_overload_int (value)
+ tree value;
+{
+ my_friendly_assert (TREE_CODE (value) == INTEGER_CST, 243);
+ if (TYPE_PRECISION (value) == 2 * HOST_BITS_PER_WIDE_INT)
+ {
+ if (tree_int_cst_lt (value, integer_zero_node))
+ {
+ OB_PUTC ('m');
+ value = build_int_2 (~ TREE_INT_CST_LOW (value),
+ - TREE_INT_CST_HIGH (value));
+ }
+ if (TREE_INT_CST_HIGH (value)
+ != (TREE_INT_CST_LOW (value) >> (HOST_BITS_PER_WIDE_INT - 1)))
+ {
+ /* need to print a DImode value in decimal */
+ sorry ("conversion of long long as PT parameter");
+ }
+ /* else fall through to print in smaller mode */
+ }
+ /* Wordsize or smaller */
+ icat (TREE_INT_CST_LOW (value));
+}
+
+static void
+build_overload_value (type, value)
+ tree type, value;
+{
+ while (TREE_CODE (value) == NON_LVALUE_EXPR
+ || TREE_CODE (value) == NOP_EXPR)
+ value = TREE_OPERAND (value, 0);
+ my_friendly_assert (TREE_CODE (type) == PARM_DECL, 242);
+ type = TREE_TYPE (type);
+
+ if (numeric_output_need_bar)
+ {
+ OB_PUTC ('_');
+ numeric_output_need_bar = 0;
+ }
+
+ if (TREE_CODE (type) == POINTER_TYPE
+ && TREE_CODE (TREE_TYPE (type)) == OFFSET_TYPE)
+ {
+ /* Handle a pointer to data member as a template instantiation
+ parameter, boy, what fun! */
+ type = integer_type_node;
+ if (TREE_CODE (value) != INTEGER_CST)
+ {
+ sorry ("unknown pointer to member constant");
+ return;
+ }
+ }
+
+ if (TYPE_PTRMEMFUNC_P (type))
+ type = TYPE_PTRMEMFUNC_FN_TYPE (type);
+
+ switch (TREE_CODE (type))
+ {
+ case INTEGER_TYPE:
+ case ENUMERAL_TYPE:
+ case BOOLEAN_TYPE:
+ {
+ build_overload_int (value);
+ numeric_output_need_bar = 1;
+ return;
+ }
+#ifndef REAL_IS_NOT_DOUBLE
+ case REAL_TYPE:
+ {
+ REAL_VALUE_TYPE val;
+ char *bufp = digit_buffer;
+ extern char *index ();
+
+ my_friendly_assert (TREE_CODE (value) == REAL_CST, 244);
+ val = TREE_REAL_CST (value);
+ if (val < 0)
+ {
+ val = -val;
+ *bufp++ = 'm';
+ }
+ sprintf (bufp, "%e", val);
+ bufp = (char *) index (bufp, 'e');
+ if (!bufp)
+ strcat (digit_buffer, "e0");
+ else
+ {
+ char *p;
+ bufp++;
+ if (*bufp == '-')
+ {
+ *bufp++ = 'm';
+ }
+ p = bufp;
+ if (*p == '+')
+ p++;
+ while (*p == '0')
+ p++;
+ if (*p == 0)
+ {
+ *bufp++ = '0';
+ *bufp = 0;
+ }
+ else if (p != bufp)
+ {
+ while (*p)
+ *bufp++ = *p++;
+ *bufp = 0;
+ }
+ }
+ OB_PUTCP (digit_buffer);
+ numeric_output_need_bar = 1;
+ return;
+ }
+#endif
+ case POINTER_TYPE:
+ if (TREE_CODE (TREE_TYPE (type)) == METHOD_TYPE
+ && TREE_CODE (value) != ADDR_EXPR)
+ {
+ if (TREE_CODE (value) == CONSTRUCTOR)
+ {
+ /* This is dangerous code, crack built up pointer to members. */
+ tree args = CONSTRUCTOR_ELTS (value);
+ tree a1 = TREE_VALUE (args);
+ tree a2 = TREE_VALUE (TREE_CHAIN (args));
+ tree a3 = CONSTRUCTOR_ELTS (TREE_VALUE (TREE_CHAIN (TREE_CHAIN (args))));
+ a3 = TREE_VALUE (a3);
+ STRIP_NOPS (a3);
+ if (TREE_CODE (a1) == INTEGER_CST
+ && TREE_CODE (a2) == INTEGER_CST)
+ {
+ build_overload_int (a1);
+ OB_PUTC ('_');
+ build_overload_int (a2);
+ OB_PUTC ('_');
+ if (TREE_CODE (a3) == ADDR_EXPR)
+ {
+ a3 = TREE_OPERAND (a3, 0);
+ if (TREE_CODE (a3) == FUNCTION_DECL)
+ {
+ numeric_output_need_bar = 0;
+ build_overload_identifier (DECL_ASSEMBLER_NAME (a3));
+ return;
+ }
+ }
+ else if (TREE_CODE (a3) == INTEGER_CST)
+ {
+ OB_PUTC ('i');
+ build_overload_int (a3);
+ numeric_output_need_bar = 1;
+ return;
+ }
+ }
+ }
+ sorry ("template instantiation with pointer to method that is too complex");
+ return;
+ }
+ if (TREE_CODE (value) == INTEGER_CST)
+ {
+ build_overload_int (value);
+ numeric_output_need_bar = 1;
+ return;
+ }
+ value = TREE_OPERAND (value, 0);
+ if (TREE_CODE (value) == VAR_DECL)
+ {
+ my_friendly_assert (DECL_NAME (value) != 0, 245);
+ build_overload_identifier (DECL_NAME (value));
+ return;
+ }
+ else if (TREE_CODE (value) == FUNCTION_DECL)
+ {
+ my_friendly_assert (DECL_NAME (value) != 0, 246);
+ build_overload_identifier (DECL_NAME (value));
+ return;
+ }
+ else
+ my_friendly_abort (71);
+ break; /* not really needed */
+
+ default:
+ sorry ("conversion of %s as template parameter",
+ tree_code_name [(int) TREE_CODE (type)]);
+ my_friendly_abort (72);
+ }
+}
+
+static void
+build_overload_identifier (name)
+ tree name;
+{
+ if (IDENTIFIER_TEMPLATE (name))
+ {
+ tree template, parmlist, arglist, tname;
+ int i, nparms;
+ template = IDENTIFIER_TEMPLATE (name);
+ arglist = TREE_VALUE (template);
+ template = TREE_PURPOSE (template);
+ tname = DECL_NAME (template);
+ parmlist = DECL_ARGUMENTS (template);
+ nparms = TREE_VEC_LENGTH (parmlist);
+ OB_PUTC ('t');
+ icat (IDENTIFIER_LENGTH (tname));
+ OB_PUTID (tname);
+ icat (nparms);
+ for (i = 0; i < nparms; i++)
+ {
+ tree parm = TREE_VALUE (TREE_VEC_ELT (parmlist, i));
+ tree arg = TREE_VEC_ELT (arglist, i);
+ if (TREE_CODE (parm) == TYPE_DECL)
+ {
+ /* This parameter is a type. */
+ OB_PUTC ('Z');
+ build_overload_name (arg, 0, 0);
+ }
+ else
+ {
+ parm = tsubst (parm, &TREE_VEC_ELT (arglist, 0),
+ TREE_VEC_LENGTH (arglist), NULL_TREE);
+ /* It's a PARM_DECL. */
+ build_overload_name (TREE_TYPE (parm), 0, 0);
+ build_overload_value (parm, arg);
+ }
+ }
+ }
+ else
+ {
+ if (numeric_output_need_bar)
+ {
+ OB_PUTC ('_');
+ numeric_output_need_bar = 0;
+ }
+ icat (IDENTIFIER_LENGTH (name));
+ OB_PUTID (name);
+ }
+}
+
+/* Given a list of parameters in PARMTYPES, create an unambiguous
+ overload string. Should distinguish any type that C (or C++) can
+ distinguish. I.e., pointers to functions are treated correctly.
+
+ Caller must deal with whether a final `e' goes on the end or not.
+
+ Any default conversions must take place before this function
+ is called.
+
+ BEGIN and END control initialization and finalization of the
+ obstack where we build the string. */
+
+char *
+build_overload_name (parmtypes, begin, end)
+ tree parmtypes;
+ int begin, end;
+{
+ int just_one;
+ tree parmtype;
+
+ if (begin) OB_INIT ();
+ numeric_output_need_bar = 0;
+
+ if ((just_one = (TREE_CODE (parmtypes) != TREE_LIST)))
+ {
+ parmtype = parmtypes;
+ goto only_one;
+ }
+
+ while (parmtypes)
+ {
+ parmtype = TREE_VALUE (parmtypes);
+
+ only_one:
+
+ if (! nofold && ! just_one)
+ {
+ /* Every argument gets counted. */
+ typevec[maxtype++] = parmtype;
+
+ if (TREE_USED (parmtype) && parmtype == typevec[maxtype-2])
+ {
+ nrepeats++;
+ goto next;
+ }
+
+ if (nrepeats)
+ flush_repeats (typevec[maxtype-2]);
+
+ if (TREE_USED (parmtype))
+ {
+ flush_repeats (parmtype);
+ goto next;
+ }
+
+ /* Only cache types which take more than one character. */
+ if (parmtype != TYPE_MAIN_VARIANT (parmtype)
+ || (TREE_CODE (parmtype) != INTEGER_TYPE
+ && TREE_CODE (parmtype) != REAL_TYPE))
+ TREE_USED (parmtype) = 1;
+ }
+
+ if (TYPE_PTRMEMFUNC_P (parmtype))
+ parmtype = TYPE_PTRMEMFUNC_FN_TYPE (parmtype);
+
+ if (TREE_READONLY (parmtype))
+ OB_PUTC ('C');
+ if (TREE_CODE (parmtype) == INTEGER_TYPE
+ && TYPE_MAIN_VARIANT (parmtype) == unsigned_type (TYPE_MAIN_VARIANT (parmtype)))
+ OB_PUTC ('U');
+ if (TYPE_VOLATILE (parmtype))
+ OB_PUTC ('V');
+
+ switch (TREE_CODE (parmtype))
+ {
+ case OFFSET_TYPE:
+ OB_PUTC ('O');
+ build_overload_name (TYPE_OFFSET_BASETYPE (parmtype), 0, 0);
+ OB_PUTC ('_');
+ build_overload_name (TREE_TYPE (parmtype), 0, 0);
+ break;
+
+ case REFERENCE_TYPE:
+ OB_PUTC ('R');
+ goto more;
+
+ case ARRAY_TYPE:
+#if PARM_CAN_BE_ARRAY_TYPE
+ {
+ tree length;
+
+ OB_PUTC ('A');
+ if (TYPE_DOMAIN (parmtype) == NULL_TREE)
+ error ("pointer or reference to array of unknown bound in parm type");
+ else
+ {
+ length = array_type_nelts (parmtype);
+ if (TREE_CODE (length) == INTEGER_CST)
+ icat (TREE_INT_CST_LOW (length) + 1);
+ }
+ OB_PUTC ('_');
+ goto more;
+ }
+#else
+ OB_PUTC ('P');
+ goto more;
+#endif
+
+ case POINTER_TYPE:
+ OB_PUTC ('P');
+ more:
+ build_overload_name (TREE_TYPE (parmtype), 0, 0);
+ break;
+
+ case FUNCTION_TYPE:
+ case METHOD_TYPE:
+ {
+ tree firstarg = TYPE_ARG_TYPES (parmtype);
+ /* Otherwise have to implement reentrant typevecs,
+ unmark and remark types, etc. */
+ int old_nofold = nofold;
+ nofold = 1;
+
+ if (nrepeats)
+ flush_repeats (typevec[maxtype-1]);
+
+ /* @@ It may be possible to pass a function type in
+ which is not preceded by a 'P'. */
+ if (TREE_CODE (parmtype) == FUNCTION_TYPE)
+ {
+ OB_PUTC ('F');
+ if (firstarg == NULL_TREE)
+ OB_PUTC ('e');
+ else if (firstarg == void_list_node)
+ OB_PUTC ('v');
+ else
+ build_overload_name (firstarg, 0, 0);
+ }
+ else
+ {
+ int constp = TYPE_READONLY (TREE_TYPE (TREE_VALUE (firstarg)));
+ int volatilep = TYPE_VOLATILE (TREE_TYPE (TREE_VALUE (firstarg)));
+ OB_PUTC ('M');
+ firstarg = TREE_CHAIN (firstarg);
+
+ build_overload_name (TYPE_METHOD_BASETYPE (parmtype), 0, 0);
+ if (constp)
+ OB_PUTC ('C');
+ if (volatilep)
+ OB_PUTC ('V');
+
+ /* For cfront 2.0 compatibility. */
+ OB_PUTC ('F');
+
+ if (firstarg == NULL_TREE)
+ OB_PUTC ('e');
+ else if (firstarg == void_list_node)
+ OB_PUTC ('v');
+ else
+ build_overload_name (firstarg, 0, 0);
+ }
+
+ /* Separate args from return type. */
+ OB_PUTC ('_');
+ build_overload_name (TREE_TYPE (parmtype), 0, 0);
+ nofold = old_nofold;
+ break;
+ }
+
+ case INTEGER_TYPE:
+ parmtype = TYPE_MAIN_VARIANT (parmtype);
+ if (parmtype == integer_type_node
+ || parmtype == unsigned_type_node)
+ OB_PUTC ('i');
+ else if (parmtype == long_integer_type_node
+ || parmtype == long_unsigned_type_node)
+ OB_PUTC ('l');
+ else if (parmtype == short_integer_type_node
+ || parmtype == short_unsigned_type_node)
+ OB_PUTC ('s');
+ else if (parmtype == signed_char_type_node)
+ {
+ OB_PUTC ('S');
+ OB_PUTC ('c');
+ }
+ else if (parmtype == char_type_node
+ || parmtype == unsigned_char_type_node)
+ OB_PUTC ('c');
+ else if (parmtype == wchar_type_node)
+ OB_PUTC ('w');
+ else if (parmtype == long_long_integer_type_node
+ || parmtype == long_long_unsigned_type_node)
+ OB_PUTC ('x');
+#if 0
+ /* it would seem there is no way to enter these in source code,
+ yet. (mrs) */
+ else if (parmtype == long_long_long_integer_type_node
+ || parmtype == long_long_long_unsigned_type_node)
+ OB_PUTC ('q');
+#endif
+ else
+ my_friendly_abort (73);
+ break;
+
+ case BOOLEAN_TYPE:
+ OB_PUTC ('b');
+ break;
+
+ case REAL_TYPE:
+ parmtype = TYPE_MAIN_VARIANT (parmtype);
+ if (parmtype == long_double_type_node)
+ OB_PUTC ('r');
+ else if (parmtype == double_type_node)
+ OB_PUTC ('d');
+ else if (parmtype == float_type_node)
+ OB_PUTC ('f');
+ else my_friendly_abort (74);
+ break;
+
+ case VOID_TYPE:
+ if (! just_one)
+ {
+#if 0
+ extern tree void_list_node;
+
+ /* See if anybody is wasting memory. */
+ my_friendly_assert (parmtypes == void_list_node, 247);
+#endif
+ /* This is the end of a parameter list. */
+ if (end) OB_FINISH ();
+ return (char *)obstack_base (&scratch_obstack);
+ }
+ OB_PUTC ('v');
+ break;
+
+ case ERROR_MARK: /* not right, but nothing is anyway */
+ break;
+
+ /* have to do these */
+ case UNION_TYPE:
+ case RECORD_TYPE:
+ if (! just_one)
+ /* Make this type signature look incompatible
+ with AT&T. */
+ OB_PUTC ('G');
+ goto common;
+ case ENUMERAL_TYPE:
+ common:
+ {
+ tree name = TYPE_NAME (parmtype);
+ int i = 1;
+
+ if (TREE_CODE (name) == TYPE_DECL)
+ {
+ tree context = name;
+
+ /* If DECL_ASSEMBLER_NAME has been set properly, use it. */
+ if (DECL_ASSEMBLER_NAME (context) != DECL_NAME (context))
+ {
+ OB_PUTID (DECL_ASSEMBLER_NAME (context));
+ break;
+ }
+ while (DECL_CONTEXT (context))
+ {
+ i += 1;
+ context = DECL_CONTEXT (context);
+ if (TREE_CODE_CLASS (TREE_CODE (context)) == 't')
+ context = TYPE_NAME (context);
+ }
+ name = DECL_NAME (name);
+ }
+ my_friendly_assert (TREE_CODE (name) == IDENTIFIER_NODE, 248);
+ if (i > 1)
+ {
+ OB_PUTC ('Q');
+ if (i > 9)
+ OB_PUTC ('_');
+ icat (i);
+ if (i > 9)
+ OB_PUTC ('_');
+ numeric_output_need_bar = 0;
+ build_overload_nested_name (TYPE_MAIN_DECL (parmtype));
+ }
+ else
+ build_overload_identifier (name);
+ break;
+ }
+
+ case UNKNOWN_TYPE:
+ /* This will take some work. */
+ OB_PUTC ('?');
+ break;
+
+ case TEMPLATE_TYPE_PARM:
+ case TEMPLATE_CONST_PARM:
+ case UNINSTANTIATED_P_TYPE:
+ /* We don't ever want this output, but it's inconvenient not to
+ be able to build the string. This should cause assembler
+ errors we'll notice. */
+ {
+ static int n;
+ sprintf (digit_buffer, " *%d", n++);
+ OB_PUTCP (digit_buffer);
+ }
+ break;
+
+ default:
+ my_friendly_abort (75);
+ }
+
+ next:
+ if (just_one) break;
+ parmtypes = TREE_CHAIN (parmtypes);
+ }
+ if (! just_one)
+ {
+ if (nrepeats)
+ flush_repeats (typevec[maxtype-1]);
+
+ /* To get here, parms must end with `...'. */
+ OB_PUTC ('e');
+ }
+
+ if (end) OB_FINISH ();
+ return (char *)obstack_base (&scratch_obstack);
+}
+
+tree
+build_static_name (basetype, name)
+ tree basetype, name;
+{
+ char *basename = build_overload_name (basetype, 1, 1);
+ char *buf = (char *) alloca (IDENTIFIER_LENGTH (name)
+ + sizeof (STATIC_NAME_FORMAT)
+ + strlen (basename));
+ sprintf (buf, STATIC_NAME_FORMAT, basename, IDENTIFIER_POINTER (name));
+ return get_identifier (buf);
+}
+
+/* Generate an identifier that encodes the (ANSI) exception TYPE. */
+
+/* This should be part of `ansi_opname', or at least be defined by the std. */
+#define EXCEPTION_NAME_PREFIX "__ex"
+#define EXCEPTION_NAME_LENGTH 4
+
+tree
+cplus_exception_name (type)
+ tree type;
+{
+ OB_INIT ();
+ OB_PUTS (EXCEPTION_NAME_PREFIX);
+ return get_identifier (build_overload_name (type, 0, 1));
+}
+
+/* Change the name of a function definition so that it may be
+ overloaded. NAME is the name of the function to overload,
+ PARMS is the parameter list (which determines what name the
+ final function obtains).
+
+ FOR_METHOD is 1 if this overload is being performed
+ for a method, rather than a function type. It is 2 if
+ this overload is being performed for a constructor. */
+tree
+build_decl_overload (dname, parms, for_method)
+ tree dname;
+ tree parms;
+ int for_method;
+{
+ char *name = IDENTIFIER_POINTER (dname);
+
+ /* member operators new and delete look like methods at this point. */
+ if (! for_method && parms != NULL_TREE && TREE_CODE (parms) == TREE_LIST)
+ {
+ if (dname == ansi_opname[(int) DELETE_EXPR])
+ return get_identifier ("__builtin_delete");
+ else if (dname == ansi_opname[(int) VEC_DELETE_EXPR])
+ return get_identifier ("__builtin_vec_delete");
+ else if (TREE_CHAIN (parms) == void_list_node)
+ {
+ if (dname == ansi_opname[(int) NEW_EXPR])
+ return get_identifier ("__builtin_new");
+ else if (dname == ansi_opname[(int) VEC_NEW_EXPR])
+ return get_identifier ("__builtin_vec_new");
+ }
+ }
+
+ OB_INIT ();
+ if (for_method != 2)
+ OB_PUTCP (name);
+ /* Otherwise, we can divine that this is a constructor,
+ and figure out its name without any extra encoding. */
+
+ OB_PUTC2 ('_', '_');
+ if (for_method)
+ {
+#if 0
+ /* We can get away without doing this. */
+ OB_PUTC ('M');
+#endif
+ {
+ tree this_type = TREE_VALUE (parms);
+
+ if (TREE_CODE (this_type) == RECORD_TYPE) /* a signature pointer */
+ parms = temp_tree_cons (NULL_TREE, SIGNATURE_TYPE (this_type),
+ TREE_CHAIN (parms));
+ else
+ parms = temp_tree_cons (NULL_TREE, TREE_TYPE (this_type),
+ TREE_CHAIN (parms));
+ }
+ }
+ else
+ OB_PUTC ('F');
+
+ if (parms == NULL_TREE)
+ OB_PUTC2 ('e', '\0');
+ else if (parms == void_list_node)
+ OB_PUTC2 ('v', '\0');
+ else
+ {
+ ALLOCATE_TYPEVEC (parms);
+ nofold = 0;
+ if (for_method)
+ {
+ build_overload_name (TREE_VALUE (parms), 0, 0);
+
+ typevec[maxtype++] = TREE_VALUE (parms);
+ TREE_USED (TREE_VALUE (parms)) = 1;
+
+ if (TREE_CHAIN (parms))
+ build_overload_name (TREE_CHAIN (parms), 0, 1);
+ else
+ OB_PUTC2 ('e', '\0');
+ }
+ else
+ build_overload_name (parms, 0, 1);
+ DEALLOCATE_TYPEVEC (parms);
+ }
+ {
+ tree n = get_identifier (obstack_base (&scratch_obstack));
+ if (IDENTIFIER_OPNAME_P (dname))
+ IDENTIFIER_OPNAME_P (n) = 1;
+ return n;
+ }
+}
+
+/* Build an overload name for the type expression TYPE. */
+tree
+build_typename_overload (type)
+ tree type;
+{
+ tree id;
+
+ OB_INIT ();
+ OB_PUTID (ansi_opname[(int) TYPE_EXPR]);
+ nofold = 1;
+ build_overload_name (type, 0, 1);
+ id = get_identifier (obstack_base (&scratch_obstack));
+ IDENTIFIER_OPNAME_P (id) = 1;
+#if 0
+ IDENTIFIER_GLOBAL_VALUE (id) = TYPE_NAME (type);
+#endif
+ TREE_TYPE (id) = type;
+ return id;
+}
+
+#ifndef NO_DOLLAR_IN_LABEL
+#define T_DESC_FORMAT "TD$"
+#define I_DESC_FORMAT "ID$"
+#define M_DESC_FORMAT "MD$"
+#else
+#if !defined(NO_DOT_IN_LABEL)
+#define T_DESC_FORMAT "TD."
+#define I_DESC_FORMAT "ID."
+#define M_DESC_FORMAT "MD."
+#else
+#define T_DESC_FORMAT "__t_desc_"
+#define I_DESC_FORMAT "__i_desc_"
+#define M_DESC_FORMAT "__m_desc_"
+#endif
+#endif
+
+/* Build an overload name for the type expression TYPE. */
+tree
+build_t_desc_overload (type)
+ tree type;
+{
+ OB_INIT ();
+ OB_PUTS (T_DESC_FORMAT);
+ nofold = 1;
+
+#if 0
+ /* Use a different format if the type isn't defined yet. */
+ if (TYPE_SIZE (type) == NULL_TREE)
+ {
+ char *p;
+ int changed;
+
+ for (p = tname; *p; p++)
+ if (isupper (*p))
+ {
+ changed = 1;
+ *p = tolower (*p);
+ }
+ /* If there's no change, we have an inappropriate T_DESC_FORMAT. */
+ my_friendly_assert (changed != 0, 249);
+ }
+#endif
+
+ build_overload_name (type, 0, 1);
+ return get_identifier (obstack_base (&scratch_obstack));
+}
+
+/* Top-level interface to explicit overload requests. Allow NAME
+ to be overloaded. Error if NAME is already declared for the current
+ scope. Warning if function is redundantly overloaded. */
+
+void
+declare_overloaded (name)
+ tree name;
+{
+#ifdef NO_AUTO_OVERLOAD
+ if (is_overloaded (name))
+ warning ("function `%s' already declared overloaded",
+ IDENTIFIER_POINTER (name));
+ else if (IDENTIFIER_GLOBAL_VALUE (name))
+ error ("overloading function `%s' that is already defined",
+ IDENTIFIER_POINTER (name));
+ else
+ {
+ TREE_OVERLOADED (name) = 1;
+ IDENTIFIER_GLOBAL_VALUE (name) = build_tree_list (name, NULL_TREE);
+ TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (name)) = unknown_type_node;
+ }
+#else
+ if (current_lang_name == lang_name_cplusplus)
+ {
+ if (0)
+ warning ("functions are implicitly overloaded in C++");
+ }
+ else if (current_lang_name == lang_name_c)
+ error ("overloading function `%s' cannot be done in C language context");
+ else
+ my_friendly_abort (76);
+#endif
+}
+
+#ifdef NO_AUTO_OVERLOAD
+/* Check to see if NAME is overloaded. For first approximation,
+ check to see if its TREE_OVERLOADED is set. This is used on
+ IDENTIFIER nodes. */
+int
+is_overloaded (name)
+ tree name;
+{
+ /* @@ */
+ return (TREE_OVERLOADED (name)
+ && (! IDENTIFIER_CLASS_VALUE (name) || current_class_type == 0)
+ && ! IDENTIFIER_LOCAL_VALUE (name));
+}
+#endif
+
+/* Given a tree_code CODE, and some arguments (at least one),
+ attempt to use an overloaded operator on the arguments.
+
+ For unary operators, only the first argument need be checked.
+ For binary operators, both arguments may need to be checked.
+
+ Member functions can convert class references to class pointers,
+ for one-level deep indirection. More than that is not supported.
+ Operators [](), ()(), and ->() must be member functions.
+
+ We call function call building calls with LOOKUP_COMPLAIN if they
+ are our only hope. This is true when we see a vanilla operator
+ applied to something of aggregate type. If this fails, we are free
+ to return `error_mark_node', because we will have reported the
+ error.
+
+ Operators NEW and DELETE overload in funny ways: operator new takes
+ a single `size' parameter, and operator delete takes a pointer to the
+ storage being deleted. When overloading these operators, success is
+ assumed. If there is a failure, report an error message and return
+ `error_mark_node'. */
+
+/* NOSTRICT */
+tree
+build_opfncall (code, flags, xarg1, xarg2, arg3)
+ enum tree_code code;
+ int flags;
+ tree xarg1, xarg2, arg3;
+{
+ tree rval = 0;
+ tree arg1, arg2;
+ tree type1, type2, fnname;
+ tree fields1 = 0, parms = 0;
+ tree global_fn;
+ int try_second;
+ int binary_is_unary;
+
+ if (xarg1 == error_mark_node)
+ return error_mark_node;
+
+ if (code == COND_EXPR)
+ {
+ if (TREE_CODE (xarg2) == ERROR_MARK
+ || TREE_CODE (arg3) == ERROR_MARK)
+ return error_mark_node;
+ }
+ if (code == COMPONENT_REF)
+ if (TREE_CODE (TREE_TYPE (xarg1)) == POINTER_TYPE)
+ return rval;
+
+ /* First, see if we can work with the first argument */
+ type1 = TREE_TYPE (xarg1);
+
+ /* Some tree codes have length > 1, but we really only want to
+ overload them if their first argument has a user defined type. */
+ switch (code)
+ {
+ case PREINCREMENT_EXPR:
+ case PREDECREMENT_EXPR:
+ case POSTINCREMENT_EXPR:
+ case POSTDECREMENT_EXPR:
+ case COMPONENT_REF:
+ binary_is_unary = 1;
+ try_second = 0;
+ break;
+
+ /* ARRAY_REFs and CALL_EXPRs must overload successfully.
+ If they do not, return error_mark_node instead of NULL_TREE. */
+ case ARRAY_REF:
+ if (xarg2 == error_mark_node)
+ return error_mark_node;
+ case CALL_EXPR:
+ rval = error_mark_node;
+ binary_is_unary = 0;
+ try_second = 0;
+ break;
+
+ case VEC_NEW_EXPR:
+ case NEW_EXPR:
+ {
+ tree args = tree_cons (NULL_TREE, xarg2, arg3);
+ fnname = ansi_opname[(int) code];
+ if (flags & LOOKUP_GLOBAL)
+ return build_overload_call (fnname, args, flags & LOOKUP_COMPLAIN,
+ (struct candidate *)0);
+
+ rval = build_method_call
+ (build_indirect_ref (build1 (NOP_EXPR, xarg1, error_mark_node),
+ "new"),
+ fnname, args, NULL_TREE, flags);
+ if (rval == error_mark_node)
+ /* User might declare fancy operator new, but invoke it
+ like standard one. */
+ return rval;
+
+ TREE_TYPE (rval) = xarg1;
+ TREE_CALLS_NEW (rval) = 1;
+ return rval;
+ }
+ break;
+
+ case VEC_DELETE_EXPR:
+ case DELETE_EXPR:
+ {
+ fnname = ansi_opname[(int) code];
+ if (flags & LOOKUP_GLOBAL)
+ return build_overload_call (fnname,
+ build_tree_list (NULL_TREE, xarg1),
+ flags & LOOKUP_COMPLAIN,
+ (struct candidate *)0);
+
+ rval = build_method_call
+ (build_indirect_ref (build1 (NOP_EXPR, TREE_TYPE (xarg1),
+ error_mark_node),
+ NULL_PTR),
+ fnname, tree_cons (NULL_TREE, xarg1,
+ build_tree_list (NULL_TREE, xarg2)),
+ NULL_TREE, flags);
+#if 0
+ /* This can happen when operator delete is protected. */
+ my_friendly_assert (rval != error_mark_node, 250);
+ TREE_TYPE (rval) = void_type_node;
+#endif
+ return rval;
+ }
+ break;
+
+ default:
+ binary_is_unary = 0;
+ try_second = tree_code_length [(int) code] == 2;
+ if (try_second && xarg2 == error_mark_node)
+ return error_mark_node;
+ break;
+ }
+
+ if (try_second && xarg2 == error_mark_node)
+ return error_mark_node;
+
+ /* What ever it was, we do not know how to deal with it. */
+ if (type1 == NULL_TREE)
+ return rval;
+
+ if (TREE_CODE (type1) == OFFSET_TYPE)
+ type1 = TREE_TYPE (type1);
+
+ if (TREE_CODE (type1) == REFERENCE_TYPE)
+ {
+ arg1 = convert_from_reference (xarg1);
+ type1 = TREE_TYPE (arg1);
+ }
+ else
+ {
+ arg1 = xarg1;
+ }
+
+ if (!IS_AGGR_TYPE (type1) || TYPE_PTRMEMFUNC_P (type1))
+ {
+ /* Try to fail. First, fail if unary */
+ if (! try_second)
+ return rval;
+ /* Second, see if second argument is non-aggregate. */
+ type2 = TREE_TYPE (xarg2);
+ if (TREE_CODE (type2) == OFFSET_TYPE)
+ type2 = TREE_TYPE (type2);
+ if (TREE_CODE (type2) == REFERENCE_TYPE)
+ {
+ arg2 = convert_from_reference (xarg2);
+ type2 = TREE_TYPE (arg2);
+ }
+ else
+ {
+ arg2 = xarg2;
+ }
+
+ if (!IS_AGGR_TYPE (type2))
+ return rval;
+ try_second = 0;
+ }
+
+ if (try_second)
+ {
+ /* First arg may succeed; see whether second should. */
+ type2 = TREE_TYPE (xarg2);
+ if (TREE_CODE (type2) == OFFSET_TYPE)
+ type2 = TREE_TYPE (type2);
+ if (TREE_CODE (type2) == REFERENCE_TYPE)
+ {
+ arg2 = convert_from_reference (xarg2);
+ type2 = TREE_TYPE (arg2);
+ }
+ else
+ {
+ arg2 = xarg2;
+ }
+
+ if (! IS_AGGR_TYPE (type2))
+ try_second = 0;
+ }
+
+ if (type1 == unknown_type_node
+ || (try_second && TREE_TYPE (xarg2) == unknown_type_node))
+ {
+ /* This will not be implemented in the foreseeable future. */
+ return rval;
+ }
+
+ if (code == MODIFY_EXPR)
+ fnname = ansi_assopname[(int) TREE_CODE (arg3)];
+ else
+ fnname = ansi_opname[(int) code];
+
+ global_fn = lookup_name_nonclass (fnname);
+
+ /* This is the last point where we will accept failure. This
+ may be too eager if we wish an overloaded operator not to match,
+ but would rather a normal operator be called on a type-converted
+ argument. */
+
+ if (IS_AGGR_TYPE (type1))
+ {
+ fields1 = lookup_fnfields (TYPE_BINFO (type1), fnname, 0);
+ /* ARM $13.4.7, prefix/postfix ++/--. */
+ if (code == POSTINCREMENT_EXPR || code == POSTDECREMENT_EXPR)
+ {
+ xarg2 = integer_zero_node;
+ binary_is_unary = 0;
+
+ if (fields1)
+ {
+ tree t, t2;
+ int have_postfix = 0;
+
+ /* Look for an `operator++ (int)'. If they didn't have
+ one, then we fall back to the old way of doing things. */
+ for (t = TREE_VALUE (fields1); t ; t = DECL_CHAIN (t))
+ {
+ t2 = TYPE_ARG_TYPES (TREE_TYPE (t));
+ if (TREE_CHAIN (t2) != NULL_TREE
+ && TREE_VALUE (TREE_CHAIN (t2)) == integer_type_node)
+ {
+ have_postfix = 1;
+ break;
+ }
+ }
+
+ if (! have_postfix)
+ {
+ char *op = POSTINCREMENT_EXPR ? "++" : "--";
+
+ /* There's probably a LOT of code in the world that
+ relies upon this old behavior. */
+ if (! flag_traditional)
+ pedwarn ("no `operator%s (int)' declared for postfix `%s', using prefix operator instead",
+ op, op);
+ xarg2 = NULL_TREE;
+ binary_is_unary = 1;
+ }
+ }
+ }
+ }
+
+ if (fields1 == NULL_TREE && global_fn == NULL_TREE)
+ return rval;
+
+ /* If RVAL winds up being `error_mark_node', we will return
+ that... There is no way that normal semantics of these
+ operators will succeed. */
+
+ /* This argument may be an uncommitted OFFSET_REF. This is
+ the case for example when dealing with static class members
+ which are referenced from their class name rather than
+ from a class instance. */
+ if (TREE_CODE (xarg1) == OFFSET_REF
+ && TREE_CODE (TREE_OPERAND (xarg1, 1)) == VAR_DECL)
+ xarg1 = TREE_OPERAND (xarg1, 1);
+ if (try_second && xarg2 && TREE_CODE (xarg2) == OFFSET_REF
+ && TREE_CODE (TREE_OPERAND (xarg2, 1)) == VAR_DECL)
+ xarg2 = TREE_OPERAND (xarg2, 1);
+
+ if (global_fn)
+ flags |= LOOKUP_GLOBAL;
+
+ if (code == CALL_EXPR)
+ {
+ /* This can only be a member function. */
+ return build_method_call (xarg1, fnname, xarg2,
+ NULL_TREE, LOOKUP_NORMAL);
+ }
+ else if (tree_code_length[(int) code] == 1 || binary_is_unary)
+ {
+ parms = NULL_TREE;
+ rval = build_method_call (xarg1, fnname, NULL_TREE, NULL_TREE, flags);
+ }
+ else if (code == COND_EXPR)
+ {
+ parms = tree_cons (0, xarg2, build_tree_list (NULL_TREE, arg3));
+ rval = build_method_call (xarg1, fnname, parms, NULL_TREE, flags);
+ }
+ else if (code == METHOD_CALL_EXPR)
+ {
+ /* must be a member function. */
+ parms = tree_cons (NULL_TREE, xarg2, arg3);
+ return build_method_call (xarg1, fnname, parms, NULL_TREE,
+ LOOKUP_NORMAL);
+ }
+ else if (fields1)
+ {
+ parms = build_tree_list (NULL_TREE, xarg2);
+ rval = build_method_call (xarg1, fnname, parms, NULL_TREE, flags);
+ }
+ else
+ {
+ parms = tree_cons (NULL_TREE, xarg1,
+ build_tree_list (NULL_TREE, xarg2));
+ rval = build_overload_call (fnname, parms, flags,
+ (struct candidate *)0);
+ }
+
+ return rval;
+}
+
+/* This function takes an identifier, ID, and attempts to figure out what
+ it means. There are a number of possible scenarios, presented in increasing
+ order of hair:
+
+ 1) not in a class's scope
+ 2) in class's scope, member name of the class's method
+ 3) in class's scope, but not a member name of the class
+ 4) in class's scope, member name of a class's variable
+
+ NAME is $1 from the bison rule. It is an IDENTIFIER_NODE.
+ VALUE is $$ from the bison rule. It is the value returned by lookup_name ($1)
+ yychar is the pending input character (suitably encoded :-).
+
+ As a last ditch, try to look up the name as a label and return that
+ address.
+
+ Values which are declared as being of REFERENCE_TYPE are
+ automatically dereferenced here (as a hack to make the
+ compiler faster). */
+
+tree
+hack_identifier (value, name, yychar)
+ tree value, name;
+ int yychar;
+{
+ tree type;
+
+ if (TREE_CODE (value) == ERROR_MARK)
+ {
+ if (current_class_name)
+ {
+ tree fields = lookup_fnfields (TYPE_BINFO (current_class_type), name, 1);
+ if (fields == error_mark_node)
+ return error_mark_node;
+ if (fields)
+ {
+ tree fndecl;
+
+ fndecl = TREE_VALUE (fields);
+ my_friendly_assert (TREE_CODE (fndecl) == FUNCTION_DECL, 251);
+ if (DECL_CHAIN (fndecl) == NULL_TREE)
+ {
+ warning ("methods cannot be converted to function pointers");
+ return fndecl;
+ }
+ else
+ {
+ error ("ambiguous request for method pointer `%s'",
+ IDENTIFIER_POINTER (name));
+ return error_mark_node;
+ }
+ }
+ }
+ if (flag_labels_ok && IDENTIFIER_LABEL_VALUE (name))
+ {
+ return IDENTIFIER_LABEL_VALUE (name);
+ }
+ return error_mark_node;
+ }
+
+ type = TREE_TYPE (value);
+ if (TREE_CODE (value) == FIELD_DECL)
+ {
+ if (current_class_decl == NULL_TREE)
+ {
+ error ("request for member `%s' in static member function",
+ IDENTIFIER_POINTER (DECL_NAME (value)));
+ return error_mark_node;
+ }
+ TREE_USED (current_class_decl) = 1;
+
+ /* Mark so that if we are in a constructor, and then find that
+ this field was initialized by a base initializer,
+ we can emit an error message. */
+ TREE_USED (value) = 1;
+ return build_component_ref (C_C_D, name, 0, 1);
+ }
+
+ if (really_overloaded_fn (value))
+ {
+ tree t = get_first_fn (value);
+ for (; t; t = DECL_CHAIN (t))
+ {
+ if (TREE_CODE (t) == TEMPLATE_DECL)
+ continue;
+
+ assemble_external (t);
+ TREE_USED (t) = 1;
+ }
+ }
+ else if (TREE_CODE (value) == TREE_LIST)
+ {
+ tree t = value;
+ while (t && TREE_CODE (t) == TREE_LIST)
+ {
+ assemble_external (TREE_VALUE (t));
+ TREE_USED (t) = 1;
+ t = TREE_CHAIN (t);
+ }
+ }
+ else
+ {
+ assemble_external (value);
+ TREE_USED (value) = 1;
+ }
+
+ if (TREE_CODE_CLASS (TREE_CODE (value)) == 'd' && DECL_NONLOCAL (value))
+ {
+ if (DECL_LANG_SPECIFIC (value)
+ && DECL_CLASS_CONTEXT (value) != current_class_type)
+ {
+ tree path;
+ enum access_type access;
+ register tree context
+ = (TREE_CODE (value) == FUNCTION_DECL && DECL_VIRTUAL_P (value))
+ ? DECL_CLASS_CONTEXT (value)
+ : DECL_CONTEXT (value);
+
+ get_base_distance (context, current_class_type, 0, &path);
+ if (path)
+ {
+ access = compute_access (path, value);
+ if (access != access_public)
+ {
+ if (TREE_CODE (value) == VAR_DECL)
+ error ("static member `%s' is %s",
+ IDENTIFIER_POINTER (name),
+ TREE_PRIVATE (value) ? "private" :
+ "from a private base class");
+ else
+ error ("enum `%s' is from private base class",
+ IDENTIFIER_POINTER (name));
+ return error_mark_node;
+ }
+ }
+ }
+ return value;
+ }
+ if (TREE_CODE (value) == TREE_LIST && TREE_NONLOCAL_FLAG (value))
+ {
+ if (type == 0)
+ {
+ error ("request for member `%s' is ambiguous in multiple inheritance lattice",
+ IDENTIFIER_POINTER (name));
+ return error_mark_node;
+ }
+
+ return value;
+ }
+
+ if (TREE_CODE (type) == REFERENCE_TYPE)
+ {
+ my_friendly_assert (TREE_CODE (value) == VAR_DECL
+ || TREE_CODE (value) == PARM_DECL
+ || TREE_CODE (value) == RESULT_DECL, 252);
+ return convert_from_reference (value);
+ }
+ return value;
+}
+
+
+#if 0
+/* Given an object OF, and a type conversion operator COMPONENT
+ build a call to the conversion operator, if a call is requested,
+ or return the address (as a pointer to member function) if one is not.
+
+ OF can be a TYPE_DECL or any kind of datum that would normally
+ be passed to `build_component_ref'. It may also be NULL_TREE,
+ in which case `current_class_type' and `current_class_decl'
+ provide default values.
+
+ BASETYPE_PATH, if non-null, is the path of basetypes
+ to go through before we get the the instance of interest.
+
+ PROTECT says whether we apply C++ scoping rules or not. */
+tree
+build_component_type_expr (of, component, basetype_path, protect)
+ tree of, component, basetype_path;
+ int protect;
+{
+ tree cname = NULL_TREE;
+ tree tmp, last;
+ tree name;
+ int flags = protect ? LOOKUP_NORMAL : LOOKUP_COMPLAIN;
+
+ if (of)
+ my_friendly_assert (IS_AGGR_TYPE (TREE_TYPE (of)), 253);
+ my_friendly_assert (TREE_CODE (component) == TYPE_EXPR, 254);
+
+ tmp = TREE_OPERAND (component, 0);
+ last = NULL_TREE;
+
+ while (tmp)
+ {
+ switch (TREE_CODE (tmp))
+ {
+ case CALL_EXPR:
+ if (last)
+ TREE_OPERAND (last, 0) = TREE_OPERAND (tmp, 0);
+ else
+ TREE_OPERAND (component, 0) = TREE_OPERAND (tmp, 0);
+
+ last = groktypename (build_tree_list (TREE_TYPE (component),
+ TREE_OPERAND (component, 0)));
+ name = build_typename_overload (last);
+ TREE_TYPE (name) = last;
+
+ if (TREE_OPERAND (tmp, 0)
+ && TREE_OPERAND (tmp, 0) != void_list_node)
+ {
+ cp_error ("`operator %T' requires empty parameter list", last);
+ TREE_OPERAND (tmp, 0) = NULL_TREE;
+ }
+
+ if (of && TREE_CODE (of) != TYPE_DECL)
+ return build_method_call (of, name, NULL_TREE, NULL_TREE, flags);
+ else if (of)
+ {
+ tree this_this;
+
+ if (current_class_decl == NULL_TREE)
+ {
+ cp_error ("object required for `operator %T' call",
+ TREE_TYPE (name));
+ return error_mark_node;
+ }
+
+ this_this = convert_pointer_to (TREE_TYPE (of),
+ current_class_decl);
+ this_this = build_indirect_ref (this_this, NULL_PTR);
+ return build_method_call (this_this, name, NULL_TREE,
+ NULL_TREE, flags | LOOKUP_NONVIRTUAL);
+ }
+ else if (current_class_decl)
+ return build_method_call (tmp, name, NULL_TREE, NULL_TREE, flags);
+
+ cp_error ("object required for `operator %T' call",
+ TREE_TYPE (name));
+ return error_mark_node;
+
+ case INDIRECT_REF:
+ case ADDR_EXPR:
+ case ARRAY_REF:
+ break;
+
+ case SCOPE_REF:
+ my_friendly_assert (cname == 0, 255);
+ cname = TREE_OPERAND (tmp, 0);
+ tmp = TREE_OPERAND (tmp, 1);
+ break;
+
+ default:
+ my_friendly_abort (77);
+ }
+ last = tmp;
+ tmp = TREE_OPERAND (tmp, 0);
+ }
+
+ last = groktypename (build_tree_list (TREE_TYPE (component), TREE_OPERAND (component, 0)));
+ name = build_typename_overload (last);
+ TREE_TYPE (name) = last;
+ if (of && TREE_CODE (of) == TYPE_DECL)
+ {
+ if (cname == NULL_TREE)
+ {
+ cname = DECL_NAME (of);
+ of = NULL_TREE;
+ }
+ else my_friendly_assert (cname == DECL_NAME (of), 256);
+ }
+
+ if (of)
+ {
+ tree this_this;
+
+ if (current_class_decl == NULL_TREE)
+ {
+ cp_error ("object required for `operator %T' call",
+ TREE_TYPE (name));
+ return error_mark_node;
+ }
+
+ this_this = convert_pointer_to (TREE_TYPE (of), current_class_decl);
+ return build_component_ref (this_this, name, 0, protect);
+ }
+ else if (cname)
+ return build_offset_ref (cname, name);
+ else if (current_class_name)
+ return build_offset_ref (current_class_name, name);
+
+ cp_error ("object required for `operator %T' member reference",
+ TREE_TYPE (name));
+ return error_mark_node;
+}
+#endif
+
+static char *
+thunk_printable_name (decl)
+ tree decl;
+{
+ return "<thunk function>";
+}
+
+tree
+make_thunk (function, delta)
+ tree function;
+ int delta;
+{
+ char buffer[250];
+ tree thunk_fndecl, thunk_id;
+ tree thunk;
+ char *func_name;
+ static int thunk_number = 0;
+ tree func_decl;
+ if (TREE_CODE (function) != ADDR_EXPR)
+ abort ();
+ func_decl = TREE_OPERAND (function, 0);
+ if (TREE_CODE (func_decl) != FUNCTION_DECL)
+ abort ();
+ func_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (func_decl));
+ if (delta<=0)
+ sprintf (buffer, "__thunk_%d_%s", -delta, func_name);
+ else
+ sprintf (buffer, "__thunk_n%d_%s", delta, func_name);
+ thunk_id = get_identifier (buffer);
+ thunk = IDENTIFIER_GLOBAL_VALUE (thunk_id);
+ if (thunk && TREE_CODE (thunk) != THUNK_DECL)
+ {
+ error_with_decl ("implementation-reserved name `%s' used");
+ IDENTIFIER_GLOBAL_VALUE (thunk_id) = thunk = NULL_TREE;
+ }
+ if (thunk == NULL_TREE)
+ {
+ thunk = build_decl (THUNK_DECL, thunk_id, TREE_TYPE (func_decl));
+ DECL_RESULT (thunk)
+ = build_decl (RESULT_DECL, 0, TYPE_MAIN_VARIANT (TREE_TYPE (vtable_entry_type)));
+ TREE_READONLY (thunk) = TYPE_READONLY (TREE_TYPE (vtable_entry_type));
+ TREE_THIS_VOLATILE (thunk) = TYPE_VOLATILE (TREE_TYPE (vtable_entry_type));
+ make_function_rtl (thunk);
+ DECL_INITIAL (thunk) = function;
+ THUNK_DELTA (thunk) = delta;
+ /* So that finish_file can write out any thunks that need to be: */
+ pushdecl_top_level (thunk);
+ }
+ return thunk;
+}
+
+void
+emit_thunk (thunk_fndecl)
+ tree thunk_fndecl;
+{
+ rtx insns;
+ char *fnname;
+ char buffer[250];
+ tree argp;
+ struct args_size stack_args_size;
+ tree function = TREE_OPERAND (DECL_INITIAL (thunk_fndecl), 0);
+ int delta = THUNK_DELTA (thunk_fndecl);
+ int tem;
+ int failure = 0;
+ int current_call_is_indirect = 0; /* needed for HPPA FUNCTION_ARG */
+
+ /* Used to remember which regs we need to emit a USE rtx for. */
+ rtx need_use[FIRST_PSEUDO_REGISTER];
+ int need_use_count = 0;
+
+ /* rtx for the 'this' parameter. */
+ rtx this_rtx = 0, this_reg_rtx = 0, fixed_this_rtx;
+
+ char *(*save_decl_printable_name) () = decl_printable_name;
+ /* Data on reg parms scanned so far. */
+ CUMULATIVE_ARGS args_so_far;
+
+ if (TREE_ASM_WRITTEN (thunk_fndecl))
+ return;
+
+ TREE_ASM_WRITTEN (thunk_fndecl) = 1;
+
+ if (TREE_PUBLIC (function))
+ {
+ TREE_PUBLIC (thunk_fndecl) = 1;
+ if (DECL_EXTERNAL (function))
+ {
+ DECL_EXTERNAL (thunk_fndecl) = 1;
+ assemble_external (thunk_fndecl);
+ return;
+ }
+ }
+
+ decl_printable_name = thunk_printable_name;
+ if (current_function_decl)
+ abort ();
+ current_function_decl = thunk_fndecl;
+ init_function_start (thunk_fndecl, input_filename, lineno);
+ pushlevel (0);
+ expand_start_bindings (1);
+
+ /* Start updating where the next arg would go. */
+ INIT_CUMULATIVE_ARGS (args_so_far, TREE_TYPE (function), NULL_RTX);
+ stack_args_size.constant = 0;
+ stack_args_size.var = 0;
+ /* SETUP for possible structure return address FIXME */
+
+ /* Now look through all the parameters, make sure that we
+ don't clobber any registers used for parameters.
+ Also, pick up an rtx for the first "this" parameter. */
+ for (argp = TYPE_ARG_TYPES (TREE_TYPE (function));
+ argp != NULL_TREE;
+ argp = TREE_CHAIN (argp))
+
+ {
+ tree passed_type = TREE_VALUE (argp);
+ register rtx entry_parm;
+ int named = 1; /* FIXME */
+ struct args_size stack_offset;
+ struct args_size arg_size;
+
+ if (passed_type == void_type_node)
+ break;
+
+ if ((TREE_CODE (TYPE_SIZE (passed_type)) != INTEGER_CST
+ && contains_placeholder_p (TYPE_SIZE (passed_type)))
+#ifdef FUNCTION_ARG_PASS_BY_REFERENCE
+ || FUNCTION_ARG_PASS_BY_REFERENCE (args_so_far,
+ TYPE_MODE (passed_type),
+ passed_type, named)
+#endif
+ )
+ passed_type = build_pointer_type (passed_type);
+
+ entry_parm = FUNCTION_ARG (args_so_far,
+ TYPE_MODE (passed_type),
+ passed_type,
+ named);
+ if (entry_parm != 0)
+ need_use[need_use_count++] = entry_parm;
+
+ locate_and_pad_parm (TYPE_MODE (passed_type), passed_type,
+#ifdef STACK_PARMS_IN_REG_PARM_AREA
+ 1,
+#else
+ entry_parm != 0,
+#endif
+ thunk_fndecl,
+ &stack_args_size, &stack_offset, &arg_size);
+
+/* REGNO (entry_parm);*/
+ if (this_rtx == 0)
+ {
+ this_reg_rtx = entry_parm;
+ if (!entry_parm)
+ {
+ rtx offset_rtx = ARGS_SIZE_RTX (stack_offset);
+
+ rtx internal_arg_pointer, stack_parm;
+
+ if ((ARG_POINTER_REGNUM == STACK_POINTER_REGNUM
+ || ! (fixed_regs[ARG_POINTER_REGNUM]
+ || ARG_POINTER_REGNUM == FRAME_POINTER_REGNUM)))
+ internal_arg_pointer = copy_to_reg (virtual_incoming_args_rtx);
+ else
+ internal_arg_pointer = virtual_incoming_args_rtx;
+
+ if (offset_rtx == const0_rtx)
+ entry_parm = gen_rtx (MEM, TYPE_MODE (passed_type),
+ internal_arg_pointer);
+ else
+ entry_parm = gen_rtx (MEM, TYPE_MODE (passed_type),
+ gen_rtx (PLUS, Pmode,
+ internal_arg_pointer,
+ offset_rtx));
+ }
+
+ this_rtx = entry_parm;
+ }
+
+ FUNCTION_ARG_ADVANCE (args_so_far,
+ TYPE_MODE (passed_type),
+ passed_type,
+ named);
+ }
+
+ fixed_this_rtx = plus_constant (this_rtx, delta);
+ if (this_rtx != fixed_this_rtx)
+ emit_move_insn (this_rtx, fixed_this_rtx);
+
+ if (this_reg_rtx)
+ emit_insn (gen_rtx (USE, VOIDmode, this_reg_rtx));
+
+ emit_indirect_jump (XEXP (DECL_RTL (function), 0));
+
+ while (need_use_count > 0)
+ emit_insn (gen_rtx (USE, VOIDmode, need_use[--need_use_count]));
+
+ expand_end_bindings (NULL, 1, 0);
+ poplevel (0, 0, 1);
+
+ /* From now on, allocate rtl in current_obstack, not in saveable_obstack.
+ Note that that may have been done above, in save_for_inline_copying.
+ The call to resume_temporary_allocation near the end of this function
+ goes back to the usual state of affairs. */
+
+ rtl_in_current_obstack ();
+
+ insns = get_insns ();
+
+ /* Copy any shared structure that should not be shared. */
+
+ unshare_all_rtl (insns);
+
+ /* Instantiate all virtual registers. */
+
+ instantiate_virtual_regs (current_function_decl, get_insns ());
+
+ /* We are no longer anticipating cse in this function, at least. */
+
+ cse_not_expected = 1;
+
+ /* Now we choose between stupid (pcc-like) register allocation
+ (if we got the -noreg switch and not -opt)
+ and smart register allocation. */
+
+ if (optimize > 0) /* Stupid allocation probably won't work */
+ obey_regdecls = 0; /* if optimizations being done. */
+
+ regclass_init ();
+
+ regclass (insns, max_reg_num ());
+ if (obey_regdecls)
+ {
+ stupid_life_analysis (insns, max_reg_num (), NULL);
+ failure = reload (insns, 0, NULL);
+ }
+ else
+ {
+ /* Do control and data flow analysis,
+ and write some of the results to dump file. */
+
+ flow_analysis (insns, max_reg_num (), NULL);
+ local_alloc ();
+ failure = global_alloc (NULL);
+ }
+
+ reload_completed = 1;
+
+#ifdef LEAF_REGISTERS
+ leaf_function = 0;
+ if (optimize > 0 && only_leaf_regs_used () && leaf_function_p ())
+ leaf_function = 1;
+#endif
+
+ /* If a machine dependent reorganization is needed, call it. */
+#ifdef MACHINE_DEPENDENT_REORG
+ MACHINE_DEPENDENT_REORG (insns);
+#endif
+
+ /* Now turn the rtl into assembler code. */
+
+ {
+ char *fnname = XSTR (XEXP (DECL_RTL (thunk_fndecl), 0), 0);
+ assemble_start_function (thunk_fndecl, fnname);
+ final (insns, asm_out_file, optimize, 0);
+ assemble_end_function (thunk_fndecl, fnname);
+ };
+
+ exit_rest_of_compilation:
+
+ reload_completed = 0;
+
+ /* Cancel the effect of rtl_in_current_obstack. */
+
+ resume_temporary_allocation ();
+
+ decl_printable_name = save_decl_printable_name;
+ current_function_decl = 0;
+}
+
+/* Code for synthesizing methods which have default semantics defined. */
+
+/* For the anonymous union in TYPE, return the member that is at least as
+ large as the rest of the members, so we can copy it. */
+static tree
+largest_union_member (type)
+ tree type;
+{
+ tree f, type_size = TYPE_SIZE (type);
+
+ for (f = TYPE_FIELDS (type); f; f = TREE_CHAIN (f))
+ if (simple_cst_equal (DECL_SIZE (f), type_size) == 1)
+ return f;
+
+ /* We should always find one. */
+ my_friendly_abort (323);
+ return NULL_TREE;
+}
+
+/* Generate code for default X(X&) constructor. */
+void
+do_build_copy_constructor (fndecl)
+ tree fndecl;
+{
+ tree parm = TREE_CHAIN (DECL_ARGUMENTS (fndecl));
+ tree t;
+
+ clear_last_expr ();
+ push_momentary ();
+
+ if (TYPE_USES_VIRTUAL_BASECLASSES (current_class_type))
+ parm = TREE_CHAIN (parm);
+ parm = convert_from_reference (parm);
+
+ if (TYPE_HAS_TRIVIAL_INIT_REF (current_class_type))
+ {
+ t = build (INIT_EXPR, void_type_node, C_C_D, parm);
+ TREE_SIDE_EFFECTS (t) = 1;
+ cplus_expand_expr_stmt (t);
+ }
+ else
+ {
+ tree fields = TYPE_FIELDS (current_class_type);
+ int n_bases = CLASSTYPE_N_BASECLASSES (current_class_type);
+ tree binfos = TYPE_BINFO_BASETYPES (current_class_type);
+ int i;
+
+ for (t = CLASSTYPE_VBASECLASSES (current_class_type); t;
+ t = TREE_CHAIN (t))
+ {
+ tree basetype = BINFO_TYPE (t);
+ tree p = convert_to_reference
+ (build_reference_type (basetype), parm,
+ CONV_IMPLICIT|CONV_CONST, LOOKUP_COMPLAIN, NULL_TREE);
+ p = convert_from_reference (p);
+ current_base_init_list = tree_cons (TYPE_NESTED_NAME (basetype),
+ p, current_base_init_list);
+ }
+
+ for (i = 0; i < n_bases; ++i)
+ {
+ tree p, basetype = TREE_VEC_ELT (binfos, i);
+ if (TREE_VIA_VIRTUAL (basetype))
+ continue;
+
+ basetype = BINFO_TYPE (basetype);
+ p = convert_to_reference
+ (build_reference_type (basetype), parm,
+ CONV_IMPLICIT|CONV_CONST, LOOKUP_COMPLAIN, NULL_TREE);
+ p = convert_from_reference (p);
+ current_base_init_list = tree_cons (TYPE_NESTED_NAME (basetype),
+ p, current_base_init_list);
+ }
+ for (; fields; fields = TREE_CHAIN (fields))
+ {
+ tree name, init, t;
+ tree field = fields;
+
+ if (TREE_CODE (field) != FIELD_DECL)
+ continue;
+ if (DECL_NAME (field))
+ {
+ if (VFIELD_NAME_P (DECL_NAME (field)))
+ continue;
+ if (VBASE_NAME_P (DECL_NAME (field)))
+ continue;
+
+ /* True for duplicate members. */
+ if (IDENTIFIER_CLASS_VALUE (DECL_NAME (field)) != field)
+ continue;
+ }
+ else if ((t = TREE_TYPE (field)) != NULL_TREE
+ && TREE_CODE (t) == UNION_TYPE
+ && ANON_AGGRNAME_P (TYPE_IDENTIFIER (t))
+ && TYPE_FIELDS (t) != NULL_TREE)
+ field = largest_union_member (t);
+ else
+ continue;
+
+ init = build (COMPONENT_REF, TREE_TYPE (field), parm, field);
+ init = build_tree_list (NULL_TREE, init);
+
+ current_member_init_list
+ = tree_cons (DECL_NAME (field), init, current_member_init_list);
+ }
+ current_member_init_list = nreverse (current_member_init_list);
+ current_base_init_list = nreverse (current_base_init_list);
+ setup_vtbl_ptr ();
+ }
+
+ pop_momentary ();
+}
+
+void
+do_build_assign_ref (fndecl)
+ tree fndecl;
+{
+ tree parm = TREE_CHAIN (DECL_ARGUMENTS (fndecl));
+
+ clear_last_expr ();
+ push_momentary ();
+
+ parm = convert_from_reference (parm);
+
+ if (TYPE_HAS_TRIVIAL_ASSIGN_REF (current_class_type))
+ {
+ tree t = build (MODIFY_EXPR, void_type_node, C_C_D, parm);
+ TREE_SIDE_EFFECTS (t) = 1;
+ cplus_expand_expr_stmt (t);
+ }
+ else
+ {
+ tree fields = TYPE_FIELDS (current_class_type);
+ int n_bases = CLASSTYPE_N_BASECLASSES (current_class_type);
+ tree binfos = TYPE_BINFO_BASETYPES (current_class_type);
+ int i;
+
+ for (i = 0; i < n_bases; ++i)
+ {
+ tree basetype = BINFO_TYPE (TREE_VEC_ELT (binfos, i));
+ if (TYPE_HAS_ASSIGN_REF (basetype))
+ {
+ tree p = convert_to_reference
+ (build_reference_type (basetype), parm,
+ CONV_IMPLICIT|CONV_CONST, LOOKUP_COMPLAIN, NULL_TREE);
+ p = convert_from_reference (p);
+ p = build_member_call (TYPE_NESTED_NAME (basetype),
+ ansi_opname [MODIFY_EXPR],
+ build_tree_list (NULL_TREE, p));
+ expand_expr_stmt (p);
+ }
+ }
+ for (; fields; fields = TREE_CHAIN (fields))
+ {
+ tree comp, init, t;
+ tree field = fields;
+
+ if (TREE_CODE (field) != FIELD_DECL)
+ continue;
+ if (DECL_NAME (field))
+ {
+ if (VFIELD_NAME_P (DECL_NAME (field)))
+ continue;
+ if (VBASE_NAME_P (DECL_NAME (field)))
+ continue;
+
+ /* True for duplicate members. */
+ if (IDENTIFIER_CLASS_VALUE (DECL_NAME (field)) != field)
+ continue;
+ }
+ else if ((t = TREE_TYPE (field)) != NULL_TREE
+ && TREE_CODE (t) == UNION_TYPE
+ && ANON_AGGRNAME_P (TYPE_IDENTIFIER (t))
+ && TYPE_FIELDS (t) != NULL_TREE)
+ field = largest_union_member (t);
+ else
+ continue;
+
+ comp = build (COMPONENT_REF, TREE_TYPE (field), C_C_D, field);
+ init = build (COMPONENT_REF, TREE_TYPE (field), parm, field);
+
+ expand_expr_stmt (build_modify_expr (comp, NOP_EXPR, init));
+ }
+ }
+ c_expand_return (C_C_D);
+ pop_momentary ();
+}
+
+void push_cp_function_context ();
+void pop_cp_function_context ();
+
+void
+synthesize_method (fndecl)
+ tree fndecl;
+{
+ int nested = (current_function_decl != NULL_TREE);
+ tree context = decl_function_context (fndecl);
+ char *f = input_filename;
+ tree base = DECL_CLASS_CONTEXT (fndecl);
+
+ if (nested)
+ push_cp_function_context (context);
+
+ input_filename = DECL_SOURCE_FILE (fndecl);
+ interface_unknown = CLASSTYPE_INTERFACE_UNKNOWN (base);
+ interface_only = CLASSTYPE_INTERFACE_ONLY (base);
+ start_function (NULL_TREE, fndecl, NULL_TREE, NULL_TREE, 1);
+ store_parm_decls ();
+
+ if (DECL_NAME (fndecl) == ansi_opname[MODIFY_EXPR])
+ do_build_assign_ref (fndecl);
+ else if (DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (fndecl)))
+ ;
+ else
+ {
+ tree arg_chain = FUNCTION_ARG_CHAIN (fndecl);
+ if (DECL_CONSTRUCTOR_FOR_VBASE_P (fndecl))
+ arg_chain = TREE_CHAIN (arg_chain);
+ if (arg_chain != void_list_node)
+ do_build_copy_constructor (fndecl);
+ else if (TYPE_NEEDS_CONSTRUCTING (current_class_type))
+ setup_vtbl_ptr ();
+ }
+
+ finish_function (lineno, 0, nested);
+
+ /* Do we really *want* to inline this function? */
+ if (DECL_INLINE (fndecl))
+ {
+ /* Turn off DECL_INLINE for the moment so function_cannot_inline_p
+ will check our size. */
+ DECL_INLINE (fndecl) = 0;
+ if (function_cannot_inline_p (fndecl) == 0)
+ DECL_INLINE (fndecl) = 1;
+ }
+
+ input_filename = f;
+ extract_interface_info ();
+ if (nested)
+ pop_cp_function_context (context);
+}
diff --git a/contrib/gcc/cp/parse.y b/contrib/gcc/cp/parse.y
new file mode 100644
index 0000000..fd034af
--- /dev/null
+++ b/contrib/gcc/cp/parse.y
@@ -0,0 +1,3906 @@
+/* YACC parser for C++ syntax.
+ Copyright (C) 1988, 1989, 1993, 1994, 1995 Free Software Foundation, Inc.
+ Hacked by Michael Tiemann (tiemann@cygnus.com)
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+/* This grammar is based on the GNU CC grammar. */
+
+/* Note: Bison automatically applies a default action of "$$ = $1" for
+ all derivations; this is applied before the explicit action, if one
+ is given. Keep this in mind when reading the actions. */
+
+%{
+/* Cause the `yydebug' variable to be defined. */
+#define YYDEBUG 1
+
+#include "config.h"
+
+#include <stdio.h>
+#include <errno.h>
+
+#include "tree.h"
+#include "input.h"
+#include "flags.h"
+#include "lex.h"
+#include "cp-tree.h"
+#include "output.h"
+
+/* Since parsers are distinct for each language, put the language string
+ definition here. (fnf) */
+char *language_string = "GNU C++";
+
+extern tree void_list_node;
+extern struct obstack permanent_obstack;
+
+#ifndef errno
+extern int errno;
+#endif
+
+extern int end_of_file;
+extern int current_class_depth;
+
+/* FSF LOCAL dje prefix attributes */
+extern tree strip_attrs PROTO((tree));
+/* END FSF LOCAL */
+
+void yyerror ();
+
+/* Like YYERROR but do call yyerror. */
+#define YYERROR1 { yyerror ("syntax error"); YYERROR; }
+
+#define OP0(NODE) (TREE_OPERAND (NODE, 0))
+#define OP1(NODE) (TREE_OPERAND (NODE, 1))
+
+/* Contains the statement keyword (if/while/do) to include in an
+ error message if the user supplies an empty conditional expression. */
+static char *cond_stmt_keyword;
+
+/* Nonzero if we have an `extern "C"' acting as an extern specifier. */
+int have_extern_spec;
+int used_extern_spec;
+
+void yyhook ();
+
+/* Cons up an empty parameter list. */
+#ifdef __GNUC__
+__inline
+#endif
+static tree
+empty_parms ()
+{
+ tree parms;
+
+ if (strict_prototype)
+ parms = void_list_node;
+ else
+ parms = NULL_TREE;
+ return parms;
+}
+%}
+
+%start program
+
+%union {long itype; tree ttype; char *strtype; enum tree_code code; }
+
+/* All identifiers that are not reserved words
+ and are not declared typedefs in the current block */
+%token IDENTIFIER
+
+/* All identifiers that are declared typedefs in the current block.
+ In some contexts, they are treated just like IDENTIFIER,
+ but they can also serve as typespecs in declarations. */
+%token TYPENAME
+
+/* Reserved words that specify storage class.
+ yylval contains an IDENTIFIER_NODE which indicates which one. */
+%token SCSPEC
+
+/* Reserved words that specify type.
+ yylval contains an IDENTIFIER_NODE which indicates which one. */
+%token TYPESPEC
+
+/* Reserved words that qualify type: "const" or "volatile".
+ yylval contains an IDENTIFIER_NODE which indicates which one. */
+%token TYPE_QUAL
+
+/* Character or numeric constants.
+ yylval is the node for the constant. */
+%token CONSTANT
+
+/* String constants in raw form.
+ yylval is a STRING_CST node. */
+%token STRING
+
+/* "...", used for functions with variable arglists. */
+%token ELLIPSIS
+
+/* the reserved words */
+/* SCO include files test "ASM", so use something else. */
+%token SIZEOF ENUM /* STRUCT UNION */ IF ELSE WHILE DO FOR SWITCH CASE DEFAULT
+%token BREAK CONTINUE RETURN GOTO ASM_KEYWORD GCC_ASM_KEYWORD TYPEOF ALIGNOF
+%token SIGOF
+%token ATTRIBUTE EXTENSION LABEL
+
+/* the reserved words... C++ extensions */
+%token <ttype> AGGR
+%token <itype> VISSPEC
+%token DELETE NEW OVERLOAD THIS OPERATOR CXX_TRUE CXX_FALSE
+%token NAMESPACE TYPENAME_KEYWORD USING
+%token LEFT_RIGHT TEMPLATE
+%token TYPEID DYNAMIC_CAST STATIC_CAST REINTERPRET_CAST CONST_CAST
+%token <itype> SCOPE
+
+/* Define the operator tokens and their precedences.
+ The value is an integer because, if used, it is the tree code
+ to use in the expression made from the operator. */
+
+%left EMPTY /* used to resolve s/r with epsilon */
+
+%left error
+
+/* Add precedence rules to solve dangling else s/r conflict */
+%nonassoc IF
+%nonassoc ELSE
+
+%left IDENTIFIER TYPENAME PTYPENAME SCSPEC TYPESPEC TYPE_QUAL ENUM AGGR ELLIPSIS TYPEOF SIGOF OPERATOR NSNAME TYPENAME_KEYWORD
+
+%left '{' ',' ';'
+
+%nonassoc THROW
+%right <code> ':'
+%right <code> ASSIGN '='
+%right <code> '?'
+%left <code> OROR
+%left <code> ANDAND
+%left <code> '|'
+%left <code> '^'
+%left <code> '&'
+%left <code> MIN_MAX
+%left <code> EQCOMPARE
+%left <code> ARITHCOMPARE '<' '>'
+%left <code> LSHIFT RSHIFT
+%left <code> '+' '-'
+%left <code> '*' '/' '%'
+%left <code> POINTSAT_STAR DOT_STAR
+%right <code> UNARY PLUSPLUS MINUSMINUS '~'
+%left HYPERUNARY
+%left <ttype> PAREN_STAR_PAREN LEFT_RIGHT
+%left <code> POINTSAT '.' '(' '['
+
+%right SCOPE /* C++ extension */
+%nonassoc NEW DELETE TRY CATCH
+
+%type <code> unop
+
+%type <ttype> identifier IDENTIFIER TYPENAME CONSTANT expr nonnull_exprlist
+%type <ttype> paren_expr_or_null nontrivial_exprlist
+%type <ttype> expr_no_commas cast_expr unary_expr primary string STRING
+%type <ttype> typed_declspecs reserved_declspecs boolean.literal
+%type <ttype> typed_typespecs reserved_typespecquals
+%type <ttype> declmods typespec typespecqual_reserved
+%type <ttype> SCSPEC TYPESPEC TYPE_QUAL nonempty_type_quals maybe_type_qual
+%type <itype> initdecls notype_initdecls initdcl /* C++ modification */
+%type <ttype> init initlist maybeasm maybe_init
+%type <ttype> asm_operands nonnull_asm_operands asm_operand asm_clobbers
+%type <ttype> maybe_attribute attributes attribute attribute_list attrib
+%type <ttype> any_word
+
+%type <ttype> compstmt implicitly_scoped_stmt
+
+%type <ttype> declarator notype_declarator after_type_declarator
+%type <ttype> direct_notype_declarator direct_after_type_declarator
+
+%type <ttype> structsp opt.component_decl_list component_decl_list
+%type <ttype> component_decl component_decl_1 components notype_components
+%type <ttype> component_declarator component_declarator0
+%type <ttype> notype_component_declarator notype_component_declarator0
+%type <ttype> after_type_component_declarator after_type_component_declarator0
+%type <ttype> enumlist enumerator
+%type <ttype> type_id absdcl type_quals
+%type <ttype> direct_abstract_declarator conversion_declarator
+%type <ttype> new_type_id new_declarator direct_new_declarator
+%type <ttype> xexpr parmlist parms parm bad_parm full_parm
+%type <ttype> identifiers_or_typenames
+%type <ttype> fcast_or_absdcl regcast_or_absdcl
+%type <ttype> expr_or_declarator complex_notype_declarator
+%type <ttype> notype_unqualified_id unqualified_id qualified_id
+%type <ttype> overqualified_id notype_qualified_id any_id
+%type <ttype> complex_direct_notype_declarator functional_cast
+%type <ttype> named_parm complex_parmlist typed_declspecs1 parms_comma
+
+/* C++ extensions */
+%token <ttype> TYPENAME_ELLIPSIS PTYPENAME
+%token <ttype> PRE_PARSED_FUNCTION_DECL EXTERN_LANG_STRING ALL
+%token <ttype> PRE_PARSED_CLASS_DECL
+%type <ttype> fn.def1 /* Not really! */
+%type <ttype> fn.def2 return_id
+%type <itype> ctor_initializer_opt
+%type <ttype> named_class_head named_class_head_sans_basetype
+%type <ttype> named_complex_class_head_sans_basetype
+%type <ttype> unnamed_class_head
+%type <ttype> class_head base_class_list
+%type <itype> base_class_access_list
+%type <ttype> base_class maybe_base_class_list base_class.1
+%type <ttype> exception_specification_opt ansi_raise_identifier ansi_raise_identifiers
+%type <ttype> operator_name
+%type <ttype> object aggr
+%type <itype> new delete
+/* %type <ttype> primary_no_id */
+%type <ttype> nonmomentary_expr maybe_parmlist
+%type <itype> initdcl0 notype_initdcl0 member_init_list
+%type <ttype> template_header template_parm_list template_parm
+%type <ttype> template_type_parm
+%type <ttype> template_type template_arg_list template_arg
+%type <ttype> template_instantiation template_type_name tmpl.2
+%type <ttype> template_instantiate_once template_instantiate_some
+%type <itype> fn_tmpl_end
+/* %type <itype> try_for_typename */
+%type <ttype> condition xcond paren_cond_or_null
+%type <ttype> type_name nested_name_specifier nested_type ptr_to_mem
+%type <ttype> qualified_type_name complete_type_name notype_identifier
+%type <ttype> complex_type_name nested_name_specifier_1
+%type <itype> nomods_initdecls nomods_initdcl0
+%type <ttype> new_initializer new_placement specialization type_specifier_seq
+%type <ttype> using_decl .poplevel
+
+/* in order to recognize aggr tags as defining and thus shadowing. */
+%token TYPENAME_DEFN IDENTIFIER_DEFN PTYPENAME_DEFN
+%type <ttype> named_class_head_sans_basetype_defn
+%type <ttype> identifier_defn IDENTIFIER_DEFN TYPENAME_DEFN PTYPENAME_DEFN
+
+%token NSNAME
+%type <ttype> NSNAME
+
+/* Used in lex.c for parsing pragmas. */
+%token END_OF_LINE
+
+/* lex.c and pt.c depends on this being the last token. Define
+ any new tokens before this one! */
+%token END_OF_SAVED_INPUT
+
+%{
+/* List of types and structure classes of the current declaration. */
+static tree current_declspecs;
+/* List of prefix attributes in effect.
+ Prefix attributes are parsed by the reserved_declspecs and declmods
+ rules. They create a list that contains *both* declspecs and attrs. */
+/* ??? It is not clear yet that all cases where an attribute can now appear in
+ a declspec list have been updated. */
+static tree prefix_attributes;
+
+/* When defining an aggregate, this is the most recent one being defined. */
+static tree current_aggr;
+
+/* Tell yyparse how to print a token's value, if yydebug is set. */
+
+#define YYPRINT(FILE,YYCHAR,YYLVAL) yyprint(FILE,YYCHAR,YYLVAL)
+extern void yyprint ();
+extern tree combine_strings PROTO((tree));
+%}
+
+%%
+program: /* empty */
+ | extdefs
+ {
+ /* In case there were missing closebraces,
+ get us back to the global binding level. */
+ while (! global_bindings_p ())
+ poplevel (0, 0, 0);
+ finish_file ();
+ }
+ ;
+
+/* the reason for the strange actions in this rule
+ is so that notype_initdecls when reached via datadef
+ can find a valid list of type and sc specs in $0. */
+
+extdefs:
+ { $<ttype>$ = NULL_TREE; } lang_extdef
+ { $<ttype>$ = NULL_TREE; }
+ | extdefs lang_extdef
+ { $<ttype>$ = NULL_TREE; }
+ ;
+
+extdefs_opt:
+ extdefs
+ | /* empty */
+ ;
+
+.hush_warning:
+ { have_extern_spec = 1;
+ used_extern_spec = 0;
+ $<ttype>$ = NULL_TREE; }
+ ;
+.warning_ok:
+ { have_extern_spec = 0; }
+ ;
+
+asm_keyword:
+ ASM_KEYWORD
+ | GCC_ASM_KEYWORD
+ ;
+
+lang_extdef:
+ { if (pending_lang_change) do_pending_lang_change(); }
+ extdef
+ { if (! toplevel_bindings_p () && ! pseudo_global_level_p())
+ pop_everything (); }
+ ;
+
+extdef:
+ fndef
+ { if (pending_inlines) do_pending_inlines (); }
+ | datadef
+ { if (pending_inlines) do_pending_inlines (); }
+ | template_def
+ { if (pending_inlines) do_pending_inlines (); }
+ | overloaddef
+ | asm_keyword '(' string ')' ';'
+ { if (TREE_CHAIN ($3)) $3 = combine_strings ($3);
+ assemble_asm ($3); }
+ | extern_lang_string '{' extdefs_opt '}'
+ { pop_lang_context (); }
+ | extern_lang_string .hush_warning fndef .warning_ok
+ { if (pending_inlines) do_pending_inlines ();
+ pop_lang_context (); }
+ | extern_lang_string .hush_warning datadef .warning_ok
+ { if (pending_inlines) do_pending_inlines ();
+ pop_lang_context (); }
+ | NAMESPACE identifier '{'
+ { push_namespace ($2); }
+ extdefs_opt '}'
+ { pop_namespace (); }
+ | NAMESPACE '{'
+ { push_namespace (NULL_TREE); }
+ extdefs_opt '}'
+ { pop_namespace (); }
+ | NAMESPACE identifier '=' any_id ';'
+ { do_namespace_alias ($2, $4); }
+ | using_decl ';'
+ { do_toplevel_using_decl ($1); }
+ | USING NAMESPACE any_id ';'
+ { do_using_directive ($3); }
+ ;
+
+using_decl:
+ USING qualified_id
+ { $$ = $2; }
+ | USING global_scope qualified_id
+ { $$ = $3; }
+ | USING global_scope unqualified_id
+ { $$ = $3; }
+ ;
+
+any_id:
+ unqualified_id
+ | qualified_id
+ | global_scope qualified_id
+ { $$ = $2; }
+ | global_scope unqualified_id
+ { $$ = $2; }
+ ;
+
+extern_lang_string:
+ EXTERN_LANG_STRING
+ { push_lang_context ($1); }
+ | extern_lang_string EXTERN_LANG_STRING
+ { if (current_lang_name != $2)
+ cp_error ("use of linkage spec `%D' is different from previous spec `%D'", $2, current_lang_name);
+ pop_lang_context (); push_lang_context ($2); }
+ ;
+
+template_header:
+ TEMPLATE '<'
+ { begin_template_parm_list (); }
+ template_parm_list '>'
+ { $$ = end_template_parm_list ($4); }
+ ;
+
+template_parm_list:
+ template_parm
+ { $$ = process_template_parm (NULL_TREE, $1); }
+ | template_parm_list ',' template_parm
+ { $$ = process_template_parm ($1, $3); }
+ ;
+
+template_type_parm:
+ aggr
+ {
+ $$ = build_tree_list ($1, NULL_TREE);
+ ttpa:
+ if (TREE_PURPOSE ($$) == signature_type_node)
+ sorry ("signature as template type parameter");
+ else if (TREE_PURPOSE ($$) != class_type_node)
+ pedwarn ("template type parameters must use the keyword `class'");
+ }
+ | aggr identifier
+ { $$ = build_tree_list ($1, $2); goto ttpa; }
+ | TYPENAME_KEYWORD
+ { $$ = build_tree_list (class_type_node, NULL_TREE); }
+ | TYPENAME_KEYWORD identifier
+ { $$ = build_tree_list (class_type_node, $2); }
+ ;
+
+template_parm:
+ /* The following rules introduce a new reduce/reduce
+ conflict on the ',' and '>' input tokens: they are valid
+ prefixes for a `structsp', which means they could match a
+ nameless parameter. See 14.6, paragraph 3.
+ By putting them before the `parm' rule, we get
+ their match before considering them nameless parameter
+ declarations. */
+ template_type_parm
+ { $$ = build_tree_list (NULL_TREE, $$); }
+ | template_type_parm '=' typespec
+ { $$ = build_tree_list ($3, $$); }
+ | full_parm
+ ;
+
+overloaddef:
+ OVERLOAD ov_identifiers ';'
+ { warning ("use of `overload' is an anachronism"); }
+ ;
+
+ov_identifiers: IDENTIFIER
+ { declare_overloaded ($1); }
+ | ov_identifiers ',' IDENTIFIER
+ { declare_overloaded ($3); }
+ ;
+
+template_def:
+ /* Class template declarations go here; they aren't normal class
+ declarations, because we can't process the bodies yet. */
+ template_header named_class_head_sans_basetype '{'
+ { yychar = '{'; goto template1; }
+ ';'
+ | template_header named_class_head_sans_basetype_defn '{'
+ { yychar = '{'; goto template1; }
+ ';'
+ | template_header named_class_head_sans_basetype ':'
+ { yychar = ':'; goto template1; }
+ ';'
+ | template_header named_class_head_sans_basetype_defn ':'
+ {
+ yychar = ':';
+ template1:
+ if (current_aggr == signature_type_node)
+ sorry ("template type defining a signature");
+ /* Maybe pedantic warning for union?
+ How about an enum? :-) */
+ end_template_decl ($1, $2, current_aggr, 1);
+ reinit_parse_for_template (yychar, $1, $2);
+ yychar = YYEMPTY;
+ }
+ ';'
+ | template_header named_class_head_sans_basetype ';'
+ {
+ end_template_decl ($1, $2, current_aggr, 0);
+ /* declare $2 as template name with $1 parm list */
+ }
+ | template_header named_class_head_sans_basetype_defn ';'
+ {
+ end_template_decl ($1, $2, current_aggr, 0);
+ /* declare $2 as template name with $1 parm list */
+ }
+ | template_header /* notype_initdcl0 ';' */
+ notype_declarator exception_specification_opt maybeasm maybe_attribute
+ fn_tmpl_end
+ {
+ tree d;
+ int momentary;
+ int def = ($6 != ';');
+ momentary = suspend_momentary ();
+ d = start_decl ($<ttype>2, /*current_declspecs*/NULL_TREE, 0,
+ $3);
+ cplus_decl_attributes (d, $5, /*prefix_attributes*/NULL_TREE);
+ cp_finish_decl (d, NULL_TREE, $4, 0, 0);
+ end_template_decl ($1, d, 0, def);
+ if (def)
+ reinit_parse_for_template ((int) $6, $1, d);
+ resume_momentary (momentary);
+ }
+ | template_header typed_declspecs /*initdcl0*/
+ declarator exception_specification_opt maybeasm maybe_attribute
+ fn_tmpl_end
+ {
+ tree d, specs, attrs;
+ int momentary;
+ int def = ($7 != ';');
+ split_specs_attrs ($2, &specs, &attrs);
+ momentary = suspend_momentary ();
+ d = start_decl ($<ttype>3, specs, 0, $<ttype>4);
+ cplus_decl_attributes (d, $6, attrs);
+ cp_finish_decl (d, NULL_TREE, $5, 0, 0);
+ end_template_decl ($1, d, 0, def);
+ if (def)
+ {
+ reinit_parse_for_template ((int) $7, $1, d);
+ yychar = YYEMPTY;
+ }
+ note_list_got_semicolon ($<ttype>2);
+ resume_momentary (momentary);
+ }
+ | template_header declmods notype_declarator fn_tmpl_end
+ {
+ tree d, specs, attrs;
+ int def = ($4 != ';');
+ split_specs_attrs ($2, &specs, &attrs);
+ d = start_decl ($<ttype>3, specs, 0, NULL_TREE);
+ cplus_decl_attributes (d, NULL_TREE, attrs);
+ cp_finish_decl (d, NULL_TREE, NULL_TREE, 0, 0);
+ end_template_decl ($1, d, 0, def);
+ if (def)
+ reinit_parse_for_template ((int) $4, $1, d);
+ }
+ /* Try to recover from syntax errors in templates. */
+ | template_header error '}' { end_template_decl ($1, 0, 0, 0); }
+ | template_header error ';' { end_template_decl ($1, 0, 0, 0); }
+ ;
+
+fn_tmpl_end: '{' { $$ = '{'; }
+ | ':' { $$ = ':'; }
+ | ';' { $$ = ';'; }
+ | '=' { $$ = '='; }
+ | RETURN { $$ = RETURN; }
+ ;
+
+datadef:
+ nomods_initdecls ';'
+ {}
+ | declmods notype_initdecls ';'
+ {}
+ /* Normal case to make fast: "const i;". */
+ | declmods notype_declarator ';'
+ { tree d, specs, attrs;
+ split_specs_attrs ($1, &specs, &attrs);
+ d = start_decl ($<ttype>2, specs, 0, NULL_TREE);
+ cplus_decl_attributes (d, NULL_TREE, attrs);
+ cp_finish_decl (d, NULL_TREE, NULL_TREE, 0, 0);
+ }
+ | typed_declspecs initdecls ';'
+ {
+ note_list_got_semicolon ($<ttype>$);
+ }
+ /* Normal case: make this fast. */
+ | typed_declspecs declarator ';'
+ { tree d, specs, attrs;
+ split_specs_attrs ($1, &specs, &attrs);
+ d = start_decl ($<ttype>2, specs, 0, NULL_TREE);
+ cplus_decl_attributes (d, NULL_TREE, attrs);
+ cp_finish_decl (d, NULL_TREE, NULL_TREE, 0, 0);
+ note_list_got_semicolon ($<ttype>$);
+ }
+ | declmods ';'
+ { pedwarn ("empty declaration"); }
+ | explicit_instantiation ';'
+ | typed_declspecs ';'
+ {
+ tree t, attrs;
+ split_specs_attrs ($1, &t, &attrs);
+ shadow_tag (t);
+ if (TREE_CODE (t) == TREE_LIST
+ && TREE_PURPOSE (t) == NULL_TREE)
+ {
+ t = TREE_VALUE (t);
+ if (IS_AGGR_TYPE (t)
+ && IDENTIFIER_TEMPLATE (TYPE_IDENTIFIER (t)))
+ {
+ if (CLASSTYPE_USE_TEMPLATE (t) == 0)
+ SET_CLASSTYPE_TEMPLATE_SPECIALIZATION (t);
+ else if (CLASSTYPE_TEMPLATE_INSTANTIATION (t))
+ error ("override declaration for already-expanded template");
+ }
+ }
+ note_list_got_semicolon ($<ttype>$);
+ }
+ | error ';'
+ | error '}'
+ | ';'
+ ;
+
+ctor_initializer_opt:
+ nodecls
+ { $$ = 0; }
+ | base_init
+ { $$ = 1; }
+ ;
+
+maybe_return_init:
+ /* empty */
+ | return_init
+ | return_init ';'
+ ;
+
+eat_saved_input:
+ /* empty */
+ | END_OF_SAVED_INPUT
+ ;
+
+fndef:
+ fn.def1 maybe_return_init ctor_initializer_opt compstmt_or_error
+ {
+ finish_function (lineno, (int)$3, 0);
+ if ($<ttype>$) process_next_inline ($<ttype>$);
+ }
+ | fn.def1 maybe_return_init function_try_block
+ {
+ if ($<ttype>$) process_next_inline ($<ttype>$);
+ }
+ eat_saved_input
+ | typed_declspecs declarator error
+ {}
+ | declmods notype_declarator error
+ {}
+ | notype_declarator error
+ {}
+ ;
+
+fn.def1:
+ typed_declspecs declarator exception_specification_opt
+ { tree specs, attrs;
+ split_specs_attrs ($1, &specs, &attrs);
+ if (! start_function (specs, $2, $3, attrs, 0))
+ YYERROR1;
+ reinit_parse_for_function ();
+ $$ = NULL_TREE; }
+ | declmods notype_declarator exception_specification_opt
+ { tree specs = strip_attrs ($1);
+ if (! start_function (specs, $2, $3, NULL_TREE, 0))
+ YYERROR1;
+ reinit_parse_for_function ();
+ $$ = NULL_TREE; }
+ | notype_declarator exception_specification_opt
+ { if (! start_function (NULL_TREE, $$, $2, NULL_TREE, 0))
+ YYERROR1;
+ reinit_parse_for_function ();
+ $$ = NULL_TREE; }
+ | PRE_PARSED_FUNCTION_DECL
+ { start_function (NULL_TREE, TREE_VALUE ($$),
+ NULL_TREE, NULL_TREE, 1);
+ reinit_parse_for_function (); }
+ ;
+
+/* more C++ complexity. See component_decl for a comment on the
+ reduce/reduce conflict introduced by these rules. */
+fn.def2:
+ typed_declspecs '(' parmlist ')' type_quals exception_specification_opt
+ { tree specs = strip_attrs ($1);
+ $$ = build_parse_node (CALL_EXPR, TREE_VALUE (specs), $3, $5);
+ $$ = start_method (TREE_CHAIN (specs), $$, $6);
+ rest_of_mdef:
+ if (! $$)
+ YYERROR1;
+ if (yychar == YYEMPTY)
+ yychar = YYLEX;
+ reinit_parse_for_method (yychar, $$); }
+ | typed_declspecs LEFT_RIGHT type_quals exception_specification_opt
+ { tree specs = strip_attrs ($1);
+ $$ = build_parse_node (CALL_EXPR, TREE_VALUE (specs),
+ empty_parms (), $3);
+ $$ = start_method (TREE_CHAIN (specs), $$, $4);
+ goto rest_of_mdef;
+ }
+ | typed_declspecs declarator exception_specification_opt
+ { tree specs = strip_attrs ($1);
+ $$ = start_method (specs, $2, $3); goto rest_of_mdef; }
+ | declmods notype_declarator exception_specification_opt
+ { tree specs = strip_attrs ($1);
+ $$ = start_method (specs, $2, $3); goto rest_of_mdef; }
+ | notype_declarator exception_specification_opt
+ { $$ = start_method (NULL_TREE, $$, $2); goto rest_of_mdef; }
+ ;
+
+return_id: RETURN IDENTIFIER
+ {
+ if (! current_function_parms_stored)
+ store_parm_decls ();
+ $$ = $2;
+ }
+ ;
+
+return_init: return_id maybe_init
+ { store_return_init ($<ttype>$, $2); }
+ | return_id '(' nonnull_exprlist ')'
+ { store_return_init ($<ttype>$, $3); }
+ | return_id LEFT_RIGHT
+ { store_return_init ($<ttype>$, NULL_TREE); }
+ ;
+
+base_init:
+ ':' .set_base_init member_init_list
+ {
+ if ($3 == 0)
+ error ("no base initializers given following ':'");
+ setup_vtbl_ptr ();
+ /* Always keep the BLOCK node associated with the outermost
+ pair of curley braces of a function. These are needed
+ for correct operation of dwarfout.c. */
+ keep_next_level ();
+ }
+ ;
+
+.set_base_init:
+ /* empty */
+ {
+ if (! current_function_parms_stored)
+ store_parm_decls ();
+
+ if (DECL_CONSTRUCTOR_P (current_function_decl))
+ {
+ /* Make a contour for the initializer list. */
+ pushlevel (0);
+ clear_last_expr ();
+ expand_start_bindings (0);
+ }
+ else if (current_class_type == NULL_TREE)
+ error ("base initializers not allowed for non-member functions");
+ else if (! DECL_CONSTRUCTOR_P (current_function_decl))
+ error ("only constructors take base initializers");
+ }
+ ;
+
+member_init_list:
+ /* empty */
+ { $$ = 0; }
+ | member_init
+ { $$ = 1; }
+ | member_init_list ',' member_init
+ | member_init_list error
+ ;
+
+member_init: '(' nonnull_exprlist ')'
+ {
+ if (current_class_name && !flag_traditional)
+ pedwarn ("anachronistic old style base class initializer");
+ expand_member_init (C_C_D, NULL_TREE, $2);
+ }
+ | LEFT_RIGHT
+ {
+ if (current_class_name && !flag_traditional)
+ pedwarn ("anachronistic old style base class initializer");
+ expand_member_init (C_C_D, NULL_TREE, void_type_node);
+ }
+ | notype_identifier '(' nonnull_exprlist ')'
+ { expand_member_init (C_C_D, $<ttype>$, $3); }
+ | notype_identifier LEFT_RIGHT
+ { expand_member_init (C_C_D, $<ttype>$, void_type_node); }
+ | complete_type_name '(' nonnull_exprlist ')'
+ { expand_member_init (C_C_D, $<ttype>$, $3); }
+ | complete_type_name LEFT_RIGHT
+ { expand_member_init (C_C_D, $<ttype>$, void_type_node); }
+ /* GNU extension */
+ | notype_qualified_id '(' nonnull_exprlist ')'
+ {
+ do_member_init (OP0 ($1), OP1 ($1), $3);
+ }
+ | notype_qualified_id LEFT_RIGHT
+ {
+ do_member_init (OP0 ($1), OP1 ($1), void_type_node);
+ }
+ ;
+
+identifier:
+ IDENTIFIER
+ | TYPENAME
+ | PTYPENAME
+ | NSNAME
+ ;
+
+notype_identifier:
+ IDENTIFIER
+ | PTYPENAME
+ | NSNAME %prec EMPTY
+ ;
+
+identifier_defn:
+ IDENTIFIER_DEFN
+ | TYPENAME_DEFN
+ | PTYPENAME_DEFN
+ ;
+
+explicit_instantiation:
+ TEMPLATE specialization template_instantiation
+ { do_type_instantiation ($3 ? $3 : $2, NULL_TREE); }
+ | TEMPLATE typed_declspecs declarator
+ { tree specs = strip_attrs ($2);
+ do_function_instantiation (specs, $3, NULL_TREE); }
+ | TEMPLATE notype_declarator
+ { do_function_instantiation (NULL_TREE, $2, NULL_TREE); }
+ | SCSPEC TEMPLATE specialization template_instantiation
+ { do_type_instantiation ($4 ? $4 : $3, $1); }
+ | SCSPEC TEMPLATE typed_declspecs declarator
+ { tree specs = strip_attrs ($3);
+ do_function_instantiation (specs, $4, $1); }
+ | SCSPEC TEMPLATE notype_declarator
+ { do_function_instantiation (NULL_TREE, $3, $1); }
+ ;
+
+template_type:
+ template_type_name tmpl.2 template_instantiation
+ { if ($3) $$ = $3; }
+ ;
+
+template_type_name:
+ PTYPENAME '<' template_arg_list '>'
+ { $$ = lookup_template_class ($$, $3, NULL_TREE); }
+ | PTYPENAME '<' '>'
+ { $$ = lookup_template_class ($$, NULL_TREE, NULL_TREE); }
+ | TYPENAME '<' template_arg_list '>'
+ { $$ = lookup_template_class ($$, $3, NULL_TREE); }
+ ;
+
+tmpl.2:
+ /* empty */ %prec EMPTY
+ { $$ = instantiate_class_template ($<ttype>0, 1); }
+ ;
+
+template_arg_list:
+ template_arg
+ { $$ = build_tree_list (NULL_TREE, $$); }
+ | template_arg_list ',' template_arg
+ { $$ = chainon ($$, build_tree_list (NULL_TREE, $3)); }
+ ;
+
+template_arg:
+ type_id
+ { $$ = groktypename ($$); }
+ | expr_no_commas %prec UNARY
+ ;
+
+template_instantiate_once:
+ PRE_PARSED_CLASS_DECL maybe_base_class_list
+ {
+ tree t, decl, tmpl;
+
+ tmpl = TREE_PURPOSE (IDENTIFIER_TEMPLATE ($1));
+ t = xref_tag (DECL_TEMPLATE_INFO (tmpl)->aggr, $1, $2, 0);
+ set_current_level_tags_transparency (1);
+ my_friendly_assert (TREE_CODE (t) == RECORD_TYPE
+ || TREE_CODE (t) == UNION_TYPE, 257);
+ $<ttype>$ = t;
+
+ /* Now, put a copy of the decl in global scope, to avoid
+ recursive expansion. */
+ decl = IDENTIFIER_LOCAL_VALUE ($1);
+ if (!decl)
+ decl = IDENTIFIER_CLASS_VALUE ($1);
+ /* Now, put a copy of the decl in global scope, to avoid
+ recursive expansion. */
+ if (decl)
+ {
+ /* Need to copy it to clear the chain pointer,
+ and need to get it into permanent storage. */
+ my_friendly_assert (TREE_CODE (decl) == TYPE_DECL, 258);
+ push_obstacks (&permanent_obstack, &permanent_obstack);
+ decl = copy_node (decl);
+ if (DECL_LANG_SPECIFIC (decl))
+ copy_lang_decl (decl);
+ pop_obstacks ();
+ pushdecl_top_level (decl);
+ }
+ /* Kludge; see instantiate_class_template. */
+ TYPE_BEING_DEFINED (t) = 0;
+ }
+ left_curly opt.component_decl_list '}'
+ {
+ tree t = finish_struct ($<ttype>3, $5, 0);
+
+ pop_obstacks ();
+ end_template_instantiation ($1);
+
+ repo_template_used (t);
+
+ /* Now go after the methods & class data. */
+ instantiate_member_templates ($1);
+
+ pop_tinst_level();
+
+ CLASSTYPE_GOT_SEMICOLON (t) = 1;
+ }
+ ;
+
+template_instantiation:
+ /* empty */
+ { $$ = NULL_TREE; }
+ | template_instantiate_once
+ { $$ = $1; }
+ ;
+
+template_instantiate_some:
+ /* empty */
+ { $$ = NULL_TREE; /* never used from here... */}
+ | template_instantiate_once template_instantiate_some
+ { $$ = $1; /*???*/ }
+ ;
+
+unop: '-'
+ { $$ = NEGATE_EXPR; }
+ | '+'
+ { $$ = CONVERT_EXPR; }
+ | PLUSPLUS
+ { $$ = PREINCREMENT_EXPR; }
+ | MINUSMINUS
+ { $$ = PREDECREMENT_EXPR; }
+ | '!'
+ { $$ = TRUTH_NOT_EXPR; }
+ ;
+
+expr: nontrivial_exprlist
+ { $$ = build_x_compound_expr ($$); }
+ | expr_no_commas
+ ;
+
+paren_expr_or_null:
+ LEFT_RIGHT
+ { error ("ANSI C++ forbids an empty condition for `%s'",
+ cond_stmt_keyword);
+ $$ = integer_zero_node; }
+ | '(' expr ')'
+ { $$ = condition_conversion ($2); }
+ ;
+
+paren_cond_or_null:
+ LEFT_RIGHT
+ { error ("ANSI C++ forbids an empty condition for `%s'",
+ cond_stmt_keyword);
+ $$ = integer_zero_node; }
+ | '(' condition ')'
+ { $$ = condition_conversion ($2); }
+ ;
+
+xcond:
+ /* empty */
+ { $$ = NULL_TREE; }
+ | condition
+ { $$ = condition_conversion ($$); }
+ | error
+ { $$ = NULL_TREE; }
+ ;
+
+condition:
+ type_specifier_seq declarator exception_specification_opt maybeasm maybe_attribute '='
+ { {
+ tree d;
+ for (d = getdecls (); d; d = TREE_CHAIN (d))
+ if (TREE_CODE (d) == TYPE_DECL) {
+ tree s = TREE_TYPE (d);
+ if (TREE_CODE (s) == RECORD_TYPE)
+ cp_error ("definition of class `%T' in condition", s);
+ else if (TREE_CODE (s) == ENUMERAL_TYPE)
+ cp_error ("definition of enum `%T' in condition", s);
+ }
+ }
+ current_declspecs = $1;
+ $<itype>6 = suspend_momentary ();
+ $<ttype>$ = start_decl ($<ttype>2, current_declspecs, 1, $3);
+ cplus_decl_attributes ($<ttype>$, $5,
+ /*prefix_attributes*/ NULL_TREE);
+ }
+ init
+ {
+ cp_finish_decl ($<ttype>7, $8, $5, 0, LOOKUP_ONLYCONVERTING);
+ resume_momentary ($<itype>6);
+ $$ = $<ttype>7;
+ if (TREE_CODE (TREE_TYPE ($$)) == ARRAY_TYPE)
+ cp_error ("definition of array `%#D' in condition", $$);
+ }
+ | expr
+ ;
+
+compstmtend:
+ '}'
+ | maybe_label_decls stmts '}'
+ | maybe_label_decls stmts error '}'
+ | maybe_label_decls error '}'
+ ;
+
+already_scoped_stmt:
+ '{' compstmtend
+ { finish_stmt (); }
+ | simple_stmt
+ ;
+
+
+nontrivial_exprlist:
+ expr_no_commas ',' expr_no_commas
+ { $$ = tree_cons (NULL_TREE, $$,
+ build_tree_list (NULL_TREE, $3)); }
+ | expr_no_commas ',' error
+ { $$ = tree_cons (NULL_TREE, $$,
+ build_tree_list (NULL_TREE, error_mark_node)); }
+ | nontrivial_exprlist ',' expr_no_commas
+ { chainon ($$, build_tree_list (NULL_TREE, $3)); }
+ | nontrivial_exprlist ',' error
+ { chainon ($$, build_tree_list (NULL_TREE, error_mark_node)); }
+ ;
+
+nonnull_exprlist:
+ expr_no_commas
+ { $$ = build_tree_list (NULL_TREE, $$); }
+ | nontrivial_exprlist
+ ;
+
+unary_expr:
+ primary %prec UNARY
+ {
+#if 0
+ if (TREE_CODE ($$) == TYPE_EXPR)
+ $$ = build_component_type_expr (C_C_D, $$, NULL_TREE, 1);
+#endif
+ }
+ /* __extension__ turns off -pedantic for following primary. */
+ | EXTENSION
+ { $<itype>1 = pedantic;
+ pedantic = 0; }
+ cast_expr %prec UNARY
+ { $$ = $3;
+ pedantic = $<itype>1; }
+ | '*' cast_expr %prec UNARY
+ { $$ = build_x_indirect_ref ($2, "unary *"); }
+ | '&' cast_expr %prec UNARY
+ { $$ = build_x_unary_op (ADDR_EXPR, $2); }
+ | '~' cast_expr
+ { $$ = build_x_unary_op (BIT_NOT_EXPR, $2); }
+ | unop cast_expr %prec UNARY
+ { $$ = build_x_unary_op ($1, $2);
+ if ($1 == NEGATE_EXPR && TREE_CODE ($2) == INTEGER_CST)
+ TREE_NEGATED_INT ($$) = 1;
+ overflow_warning ($$);
+ }
+ /* Refer to the address of a label as a pointer. */
+ | ANDAND identifier
+ { tree label = lookup_label ($2);
+ if (label == NULL_TREE)
+ $$ = null_pointer_node;
+ else
+ {
+ TREE_USED (label) = 1;
+ $$ = build1 (ADDR_EXPR, ptr_type_node, label);
+ TREE_CONSTANT ($$) = 1;
+ }
+ }
+ | SIZEOF unary_expr %prec UNARY
+ { if (TREE_CODE ($2) == COMPONENT_REF
+ && DECL_BIT_FIELD (TREE_OPERAND ($2, 1)))
+ error ("sizeof applied to a bit-field");
+ /* ANSI says arrays and functions are converted inside comma.
+ But we can't really convert them in build_compound_expr
+ because that would break commas in lvalues.
+ So do the conversion here if operand was a comma. */
+ if (TREE_CODE ($2) == COMPOUND_EXPR
+ && (TREE_CODE (TREE_TYPE ($2)) == ARRAY_TYPE
+ || TREE_CODE (TREE_TYPE ($2)) == FUNCTION_TYPE))
+ $2 = default_conversion ($2);
+ else if (TREE_CODE ($2) == TREE_LIST)
+ {
+ tree t = TREE_VALUE ($2);
+ if (t != NULL_TREE
+ && ((TREE_TYPE (t)
+ && TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE)
+ || is_overloaded_fn (t)))
+ pedwarn ("ANSI C++ forbids taking the sizeof a function type");
+ }
+ $$ = c_sizeof (TREE_TYPE ($2)); }
+ | SIZEOF '(' type_id ')' %prec HYPERUNARY
+ { $$ = c_sizeof (groktypename ($3)); }
+ | ALIGNOF unary_expr %prec UNARY
+ { $$ = grok_alignof ($2); }
+ | ALIGNOF '(' type_id ')' %prec HYPERUNARY
+ { $$ = c_alignof (groktypename ($3)); }
+
+ /* The %prec EMPTY's here are required by the = init initializer
+ syntax extension; see below. */
+ | new new_type_id %prec EMPTY
+ { $$ = build_new (NULL_TREE, $2, NULL_TREE, $1); }
+ | new new_type_id new_initializer
+ { $$ = build_new (NULL_TREE, $2, $3, $1); }
+ | new new_placement new_type_id %prec EMPTY
+ { $$ = build_new ($2, $3, NULL_TREE, $1); }
+ | new new_placement new_type_id new_initializer
+ { $$ = build_new ($2, $3, $4, $1); }
+ | new '(' type_id ')' %prec EMPTY
+ { $$ = build_new (NULL_TREE, groktypename($3),
+ NULL_TREE, $1); }
+ | new '(' type_id ')' new_initializer
+ { $$ = build_new (NULL_TREE, groktypename($3), $5, $1); }
+ | new new_placement '(' type_id ')' %prec EMPTY
+ { $$ = build_new ($2, groktypename($4), NULL_TREE, $1); }
+ | new new_placement '(' type_id ')' new_initializer
+ { $$ = build_new ($2, groktypename($4), $6, $1); }
+
+ | delete cast_expr %prec UNARY
+ { $$ = delete_sanity ($2, NULL_TREE, 0, $1); }
+ | delete '[' ']' cast_expr %prec UNARY
+ { $$ = delete_sanity ($4, NULL_TREE, 1, $1);
+ if (yychar == YYEMPTY)
+ yychar = YYLEX; }
+ | delete '[' expr ']' cast_expr %prec UNARY
+ { $$ = delete_sanity ($5, $3, 2, $1);
+ if (yychar == YYEMPTY)
+ yychar = YYLEX; }
+ ;
+
+new_placement:
+ '(' nonnull_exprlist ')'
+ { $$ = $2; }
+ | '{' nonnull_exprlist '}'
+ {
+ $$ = $2;
+ pedwarn ("old style placement syntax, use () instead");
+ }
+ ;
+
+new_initializer:
+ '(' nonnull_exprlist ')'
+ { $$ = $2; }
+ | LEFT_RIGHT
+ { $$ = NULL_TREE; }
+ | '(' typespec ')'
+ {
+ cp_error ("`%T' is not a valid expression", $2);
+ $$ = error_mark_node;
+ }
+ /* GNU extension so people can use initializer lists. Note that
+ this alters the meaning of `new int = 1', which was previously
+ syntactically valid but semantically invalid. */
+ | '=' init
+ {
+ if (pedantic)
+ pedwarn ("ANSI C++ forbids initialization of new expression with `='");
+ $$ = $2;
+ }
+ ;
+
+/* This is necessary to postpone reduction of `int ((int)(int)(int))'. */
+regcast_or_absdcl:
+ '(' type_id ')' %prec EMPTY
+ { $2 = tree_cons (NULL_TREE, $2, void_list_node);
+ TREE_PARMLIST ($2) = 1;
+ $$ = build_parse_node (CALL_EXPR, NULL_TREE, $2,
+ NULL_TREE); }
+ | regcast_or_absdcl '(' type_id ')' %prec EMPTY
+ { $3 = tree_cons (NULL_TREE, $3, void_list_node);
+ TREE_PARMLIST ($3) = 1;
+ $$ = build_parse_node (CALL_EXPR, $$, $3, NULL_TREE); }
+ ;
+
+cast_expr:
+ unary_expr
+ | regcast_or_absdcl unary_expr %prec UNARY
+ { $$ = reparse_absdcl_as_casts ($$, $2); }
+ | regcast_or_absdcl '{' initlist maybecomma '}' %prec UNARY
+ {
+ tree init = build_nt (CONSTRUCTOR, NULL_TREE,
+ nreverse ($3));
+ if (pedantic)
+ pedwarn ("ANSI C++ forbids constructor-expressions");
+ /* Indicate that this was a GNU C constructor expression. */
+ TREE_HAS_CONSTRUCTOR (init) = 1;
+
+ $$ = reparse_absdcl_as_casts ($$, init);
+ }
+ ;
+
+expr_no_commas:
+ cast_expr
+ /* Handle general members. */
+ | expr_no_commas POINTSAT_STAR expr_no_commas
+ { $$ = build_x_binary_op (MEMBER_REF, $$, $3); }
+ | expr_no_commas DOT_STAR expr_no_commas
+ { $$ = build_m_component_ref ($$, $3); }
+ | expr_no_commas '+' expr_no_commas
+ { $$ = build_x_binary_op ($2, $$, $3); }
+ | expr_no_commas '-' expr_no_commas
+ { $$ = build_x_binary_op ($2, $$, $3); }
+ | expr_no_commas '*' expr_no_commas
+ { $$ = build_x_binary_op ($2, $$, $3); }
+ | expr_no_commas '/' expr_no_commas
+ { $$ = build_x_binary_op ($2, $$, $3); }
+ | expr_no_commas '%' expr_no_commas
+ { $$ = build_x_binary_op ($2, $$, $3); }
+ | expr_no_commas LSHIFT expr_no_commas
+ { $$ = build_x_binary_op ($2, $$, $3); }
+ | expr_no_commas RSHIFT expr_no_commas
+ { $$ = build_x_binary_op ($2, $$, $3); }
+ | expr_no_commas ARITHCOMPARE expr_no_commas
+ { $$ = build_x_binary_op ($2, $$, $3); }
+ | expr_no_commas '<' expr_no_commas
+ { $$ = build_x_binary_op (LT_EXPR, $$, $3); }
+ | expr_no_commas '>' expr_no_commas
+ { $$ = build_x_binary_op (GT_EXPR, $$, $3); }
+ | expr_no_commas EQCOMPARE expr_no_commas
+ { $$ = build_x_binary_op ($2, $$, $3); }
+ | expr_no_commas MIN_MAX expr_no_commas
+ { $$ = build_x_binary_op ($2, $$, $3); }
+ | expr_no_commas '&' expr_no_commas
+ { $$ = build_x_binary_op ($2, $$, $3); }
+ | expr_no_commas '|' expr_no_commas
+ { $$ = build_x_binary_op ($2, $$, $3); }
+ | expr_no_commas '^' expr_no_commas
+ { $$ = build_x_binary_op ($2, $$, $3); }
+ | expr_no_commas ANDAND expr_no_commas
+ { $$ = build_x_binary_op (TRUTH_ANDIF_EXPR, $$, $3); }
+ | expr_no_commas OROR expr_no_commas
+ { $$ = build_x_binary_op (TRUTH_ORIF_EXPR, $$, $3); }
+ | expr_no_commas '?' xexpr ':' expr_no_commas
+ { $$ = build_x_conditional_expr ($$, $3, $5); }
+ | expr_no_commas '=' expr_no_commas
+ { $$ = build_modify_expr ($$, NOP_EXPR, $3);
+ C_SET_EXP_ORIGINAL_CODE ($$, MODIFY_EXPR); }
+ | expr_no_commas ASSIGN expr_no_commas
+ { register tree rval;
+ if ((rval = build_opfncall (MODIFY_EXPR, LOOKUP_NORMAL, $$, $3,
+ make_node ($2))))
+ $$ = rval;
+ else
+ $$ = build_modify_expr ($$, $2, $3); }
+ | THROW
+ { $$ = build_throw (NULL_TREE); }
+ | THROW expr_no_commas
+ { $$ = build_throw ($2); }
+/* These extensions are not defined. The second arg to build_m_component_ref
+ is old, build_m_component_ref now does an implicit
+ build_indirect_ref (x, NULL_PTR) on the second argument.
+ | object '&' expr_no_commas %prec UNARY
+ { $$ = build_m_component_ref ($$, build_x_unary_op (ADDR_EXPR, $3)); }
+ | object unop expr_no_commas %prec UNARY
+ { $$ = build_m_component_ref ($$, build_x_unary_op ($2, $3)); }
+ | object '(' type_id ')' expr_no_commas %prec UNARY
+ { tree type = groktypename ($3);
+ $$ = build_m_component_ref ($$, build_c_cast (type, $5, 0)); }
+ | object primary_no_id %prec UNARY
+ { $$ = build_m_component_ref ($$, $2); }
+*/
+ ;
+
+notype_unqualified_id:
+ '~' see_typename identifier
+ { $$ = build_parse_node (BIT_NOT_EXPR, $3); }
+ | operator_name
+ | IDENTIFIER
+ | PTYPENAME
+ | NSNAME %prec EMPTY
+ ;
+
+unqualified_id:
+ notype_unqualified_id
+ | TYPENAME
+ ;
+
+expr_or_declarator:
+ notype_unqualified_id
+ | '*' expr_or_declarator %prec UNARY
+ { $$ = build_parse_node (INDIRECT_REF, $2); }
+ | '&' expr_or_declarator %prec UNARY
+ { $$ = build_parse_node (ADDR_EXPR, $2); }
+ | '(' expr_or_declarator ')'
+ { $$ = $2; }
+ ;
+
+direct_notype_declarator:
+ complex_direct_notype_declarator
+ | notype_unqualified_id
+ | '(' expr_or_declarator ')'
+ { $$ = finish_decl_parsing ($2); }
+ ;
+
+primary:
+ notype_unqualified_id
+ {
+ if (TREE_CODE ($$) == BIT_NOT_EXPR)
+ $$ = build_x_unary_op (BIT_NOT_EXPR, TREE_OPERAND ($$, 0));
+ else if (IDENTIFIER_OPNAME_P ($$))
+ {
+ tree op = $$;
+ $$ = lookup_name (op, 0);
+ if ($$ == NULL_TREE)
+ {
+ if (op != ansi_opname[ERROR_MARK])
+ error ("operator %s not defined",
+ operator_name_string (op));
+ $$ = error_mark_node;
+ }
+ }
+ else
+ $$ = do_identifier ($$);
+ }
+ | CONSTANT
+ | boolean.literal
+ | string
+ { $$ = combine_strings ($$); }
+ | '(' expr ')'
+ { char class;
+ $$ = $2;
+ class = TREE_CODE_CLASS (TREE_CODE ($$));
+ if (class == 'e' || class == '1'
+ || class == '2' || class == '<')
+ /* This inhibits warnings in truthvalue_conversion. */
+ C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
+ | '(' expr_or_declarator ')'
+ { char class;
+ $$ = reparse_decl_as_expr (NULL_TREE, $2);
+ class = TREE_CODE_CLASS (TREE_CODE ($$));
+ if (class == 'e' || class == '1'
+ || class == '2' || class == '<')
+ /* This inhibits warnings in truthvalue_conversion. */
+ C_SET_EXP_ORIGINAL_CODE ($$, ERROR_MARK); }
+ | '(' error ')'
+ { $$ = error_mark_node; }
+ | '('
+ { if (current_function_decl == 0)
+ {
+ error ("braced-group within expression allowed only inside a function");
+ YYERROR;
+ }
+ keep_next_level ();
+ $<ttype>$ = expand_start_stmt_expr (); }
+ compstmt ')'
+ { tree rtl_exp;
+ if (pedantic)
+ pedwarn ("ANSI C++ forbids braced-groups within expressions");
+ rtl_exp = expand_end_stmt_expr ($<ttype>2);
+ /* The statements have side effects, so the group does. */
+ TREE_SIDE_EFFECTS (rtl_exp) = 1;
+
+ if (TREE_CODE ($3) == BLOCK)
+ {
+ /* Make a BIND_EXPR for the BLOCK already made. */
+ $$ = build (BIND_EXPR, TREE_TYPE (rtl_exp),
+ NULL_TREE, rtl_exp, $3);
+ /* Remove the block from the tree at this point.
+ It gets put back at the proper place
+ when the BIND_EXPR is expanded. */
+ delete_block ($3);
+ }
+ else
+ $$ = $3;
+ }
+ | primary '(' nonnull_exprlist ')'
+ { /* [eichin:19911016.1902EST] */
+ $<ttype>$ = build_x_function_call ($1, $3, current_class_decl);
+ /* here we instantiate_class_template as needed... */
+ do_pending_templates ();
+ } template_instantiate_some {
+ if (TREE_CODE ($<ttype>5) == CALL_EXPR
+ && TREE_TYPE ($<ttype>5) != void_type_node)
+ $$ = require_complete_type ($<ttype>5);
+ else
+ $$ = $<ttype>5;
+ }
+ | primary LEFT_RIGHT
+ {
+ $$ = build_x_function_call ($$, NULL_TREE, current_class_decl);
+ if (TREE_CODE ($$) == CALL_EXPR
+ && TREE_TYPE ($$) != void_type_node)
+ $$ = require_complete_type ($$);
+ }
+ | primary '[' expr ']'
+ { $$ = grok_array_decl ($$, $3); }
+ | primary PLUSPLUS
+ { /* If we get an OFFSET_REF, turn it into what it really
+ means (e.g., a COMPONENT_REF). This way if we've got,
+ say, a reference to a static member that's being operated
+ on, we don't end up trying to find a member operator for
+ the class it's in. */
+ if (TREE_CODE ($$) == OFFSET_REF)
+ $$ = resolve_offset_ref ($$);
+ $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
+ | primary MINUSMINUS
+ { if (TREE_CODE ($$) == OFFSET_REF)
+ $$ = resolve_offset_ref ($$);
+ $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
+ /* C++ extensions */
+ | THIS
+ { if (current_class_decl)
+ {
+#ifdef WARNING_ABOUT_CCD
+ TREE_USED (current_class_decl) = 1;
+#endif
+ $$ = current_class_decl;
+ }
+ else if (current_function_decl
+ && DECL_STATIC_FUNCTION_P (current_function_decl))
+ {
+ error ("`this' is unavailable for static member functions");
+ $$ = error_mark_node;
+ }
+ else
+ {
+ if (current_function_decl)
+ error ("invalid use of `this' in non-member function");
+ else
+ error ("invalid use of `this' at top level");
+ $$ = error_mark_node;
+ }
+ }
+ | TYPE_QUAL '(' nonnull_exprlist ')'
+ {
+ tree type;
+ tree id = $$;
+
+ /* This is a C cast in C++'s `functional' notation. */
+ if ($3 == error_mark_node)
+ {
+ $$ = error_mark_node;
+ break;
+ }
+#if 0
+ if ($3 == NULL_TREE)
+ {
+ error ("cannot cast null list to type `%s'",
+ IDENTIFIER_POINTER (TYPE_NAME (id)));
+ $$ = error_mark_node;
+ break;
+ }
+#endif
+#if 0
+ /* type is not set! (mrs) */
+ if (type == error_mark_node)
+ $$ = error_mark_node;
+ else
+#endif
+ {
+ if (id == ridpointers[(int) RID_CONST])
+ type = build_type_variant (integer_type_node, 1, 0);
+ else if (id == ridpointers[(int) RID_VOLATILE])
+ type = build_type_variant (integer_type_node, 0, 1);
+#if 0
+ /* should not be able to get here (mrs) */
+ else if (id == ridpointers[(int) RID_FRIEND])
+ {
+ error ("cannot cast expression to `friend' type");
+ $$ = error_mark_node;
+ break;
+ }
+#endif
+ else my_friendly_abort (79);
+ $$ = build_c_cast (type, build_compound_expr ($3), 1);
+ }
+ }
+ | functional_cast
+ | DYNAMIC_CAST '<'
+ { dont_allow_type_definitions = "inside dynamic_cast"; }
+ type_id '>'
+ { dont_allow_type_definitions = 0; }
+ '(' expr ')'
+ { tree type = groktypename ($4);
+ $$ = build_dynamic_cast (type, $8); }
+ | STATIC_CAST '<'
+ { dont_allow_type_definitions = "inside static_cast"; }
+ type_id '>'
+ { dont_allow_type_definitions = 0; }
+ '(' expr ')'
+ { tree type = groktypename ($4);
+ $$ = build_static_cast (type, $8); }
+ | REINTERPRET_CAST '<'
+ { dont_allow_type_definitions = "inside reinterpret_cast"; }
+ type_id '>'
+ { dont_allow_type_definitions = 0; }
+ '(' expr ')'
+ { tree type = groktypename ($4);
+ $$ = build_reinterpret_cast (type, $8); }
+ | CONST_CAST '<'
+ { dont_allow_type_definitions = "inside const_cast"; }
+ type_id '>'
+ { dont_allow_type_definitions = 0; }
+ '(' expr ')'
+ { tree type = groktypename ($4);
+ $$ = build_const_cast (type, $8); }
+ | TYPEID '(' expr ')'
+ { $$ = build_typeid ($3); }
+ | TYPEID '(' type_id ')'
+ { tree type = groktypename ($3);
+ $$ = get_typeid (TYPE_MAIN_VARIANT (type)); }
+ | global_scope IDENTIFIER
+ {
+ do_scoped_id:
+ $$ = IDENTIFIER_GLOBAL_VALUE ($2);
+ if (yychar == YYEMPTY)
+ yychar = YYLEX;
+ if (! $$)
+ {
+ if (yychar == '(' || yychar == LEFT_RIGHT)
+ $$ = implicitly_declare ($2);
+ else
+ {
+ if (IDENTIFIER_GLOBAL_VALUE ($2) != error_mark_node)
+ error ("undeclared variable `%s' (first use here)",
+ IDENTIFIER_POINTER ($2));
+ $$ = error_mark_node;
+ /* Prevent repeated error messages. */
+ IDENTIFIER_GLOBAL_VALUE ($2) = error_mark_node;
+ }
+ }
+ else
+ {
+ if (TREE_CODE ($$) == ADDR_EXPR)
+ assemble_external (TREE_OPERAND ($$, 0));
+ else
+ assemble_external ($$);
+ TREE_USED ($$) = 1;
+ }
+ if (TREE_CODE ($$) == CONST_DECL)
+ {
+ /* XXX CHS - should we set TREE_USED of the constant? */
+ $$ = DECL_INITIAL ($$);
+ /* This is to prevent an enum whose value is 0
+ from being considered a null pointer constant. */
+ $$ = build1 (NOP_EXPR, TREE_TYPE ($$), $$);
+ TREE_CONSTANT ($$) = 1;
+ }
+
+ }
+ | global_scope operator_name
+ {
+ got_scope = NULL_TREE;
+ if (TREE_CODE ($2) == IDENTIFIER_NODE)
+ goto do_scoped_id;
+ $$ = $2;
+ }
+ | overqualified_id %prec HYPERUNARY
+ { $$ = build_offset_ref (OP0 ($$), OP1 ($$)); }
+ | overqualified_id '(' nonnull_exprlist ')'
+ { $$ = build_member_call (OP0 ($$), OP1 ($$), $3); }
+ | overqualified_id LEFT_RIGHT
+ { $$ = build_member_call (OP0 ($$), OP1 ($$), NULL_TREE); }
+ | object unqualified_id %prec UNARY
+ { got_object = NULL_TREE;
+ $$ = build_component_ref ($$, $2, NULL_TREE, 1); }
+ | object overqualified_id %prec UNARY
+ { got_object = NULL_TREE;
+ $$ = build_object_ref ($$, OP0 ($2), OP1 ($2)); }
+ | object unqualified_id '(' nonnull_exprlist ')'
+ {
+ got_object = NULL_TREE;
+#if 0
+ /* This is a future direction of this code, but because
+ build_x_function_call cannot always undo what is done
+ in build_component_ref entirely yet, we cannot do this. */
+ $$ = build_x_function_call (build_component_ref ($$, $2, NULL_TREE, 1), $4, $$);
+ if (TREE_CODE ($$) == CALL_EXPR
+ && TREE_TYPE ($$) != void_type_node)
+ $$ = require_complete_type ($$);
+#else
+ $$ = build_method_call ($$, $2, $4, NULL_TREE,
+ (LOOKUP_NORMAL|LOOKUP_AGGR));
+#endif
+ }
+ | object unqualified_id LEFT_RIGHT
+ {
+ got_object = NULL_TREE;
+#if 0
+ /* This is a future direction of this code, but because
+ build_x_function_call cannot always undo what is done
+ in build_component_ref entirely yet, we cannot do this. */
+ $$ = build_x_function_call (build_component_ref ($$, $2, NULL_TREE, 1), NULL_TREE, $$);
+ if (TREE_CODE ($$) == CALL_EXPR
+ && TREE_TYPE ($$) != void_type_node)
+ $$ = require_complete_type ($$);
+#else
+ $$ = build_method_call ($$, $2, NULL_TREE, NULL_TREE,
+ (LOOKUP_NORMAL|LOOKUP_AGGR));
+#endif
+ }
+ | object overqualified_id '(' nonnull_exprlist ')'
+ {
+ got_object = NULL_TREE;
+ if (IS_SIGNATURE (IDENTIFIER_TYPE_VALUE (OP0 ($2))))
+ {
+ warning ("signature name in scope resolution ignored");
+ $$ = build_method_call ($$, OP1 ($2), $4, NULL_TREE,
+ (LOOKUP_NORMAL|LOOKUP_AGGR));
+ }
+ else
+ $$ = build_scoped_method_call ($$, OP0 ($2), OP1 ($2), $4);
+ }
+ | object overqualified_id LEFT_RIGHT
+ {
+ got_object = NULL_TREE;
+ if (IS_SIGNATURE (IDENTIFIER_TYPE_VALUE (OP0 ($2))))
+ {
+ warning ("signature name in scope resolution ignored");
+ $$ = build_method_call ($$, OP1 ($2), NULL_TREE, NULL_TREE,
+ (LOOKUP_NORMAL|LOOKUP_AGGR));
+ }
+ else
+ $$ = build_scoped_method_call ($$, OP0 ($2), OP1 ($2), NULL_TREE);
+ }
+ /* p->int::~int() is valid -- 12.4 */
+ | object '~' TYPESPEC LEFT_RIGHT
+ {
+ got_object = NULL_TREE;
+ if (IDENTIFIER_GLOBAL_VALUE ($3)
+ && (TREE_CODE (TREE_TYPE ($1))
+ != TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE ($3)))))
+ cp_error ("`%E' is not of type `%T'", $1, $3);
+ $$ = convert (void_type_node, $1);
+ }
+ | object TYPESPEC SCOPE '~' TYPESPEC LEFT_RIGHT
+ {
+ got_object = NULL_TREE;
+ if ($2 != $5)
+ cp_error ("destructor specifier `%T::~%T()' must have matching names", $2, $5);
+ if (TREE_CODE (TREE_TYPE ($1))
+ != TREE_CODE (TREE_TYPE (IDENTIFIER_GLOBAL_VALUE ($2))))
+ cp_error ("`%E' is not of type `%T'", $1, $2);
+ $$ = convert (void_type_node, $1);
+ }
+ | object error
+ {
+ got_object = NULL_TREE;
+ $$ = error_mark_node;
+ }
+ ;
+
+/* Not needed for now.
+
+primary_no_id:
+ '(' expr ')'
+ { $$ = $2; }
+ | '(' error ')'
+ { $$ = error_mark_node; }
+ | '('
+ { if (current_function_decl == 0)
+ {
+ error ("braced-group within expression allowed only inside a function");
+ YYERROR;
+ }
+ $<ttype>$ = expand_start_stmt_expr (); }
+ compstmt ')'
+ { if (pedantic)
+ pedwarn ("ANSI C++ forbids braced-groups within expressions");
+ $$ = expand_end_stmt_expr ($<ttype>2); }
+ | primary_no_id '(' nonnull_exprlist ')'
+ { $$ = build_x_function_call ($$, $3, current_class_decl); }
+ | primary_no_id LEFT_RIGHT
+ { $$ = build_x_function_call ($$, NULL_TREE, current_class_decl); }
+ | primary_no_id '[' expr ']'
+ { goto do_array; }
+ | primary_no_id PLUSPLUS
+ { $$ = build_x_unary_op (POSTINCREMENT_EXPR, $$); }
+ | primary_no_id MINUSMINUS
+ { $$ = build_x_unary_op (POSTDECREMENT_EXPR, $$); }
+ | SCOPE IDENTIFIER
+ { goto do_scoped_id; }
+ | SCOPE operator_name
+ { if (TREE_CODE ($2) == IDENTIFIER_NODE)
+ goto do_scoped_id;
+ goto do_scoped_operator;
+ }
+ ;
+*/
+
+new: NEW
+ { $$ = 0; }
+ | global_scope NEW
+ { got_scope = NULL_TREE; $$ = 1; }
+ ;
+
+delete: DELETE
+ { $$ = 0; }
+ | global_scope delete
+ { got_scope = NULL_TREE; $$ = 1; }
+ ;
+
+boolean.literal:
+ CXX_TRUE
+ { $$ = boolean_true_node; }
+ | CXX_FALSE
+ { $$ = boolean_false_node; }
+ ;
+
+/* Produces a STRING_CST with perhaps more STRING_CSTs chained onto it. */
+string:
+ STRING
+ | string STRING
+ { $$ = chainon ($$, $2); }
+ ;
+
+nodecls:
+ /* empty */
+ {
+ if (! current_function_parms_stored)
+ store_parm_decls ();
+ setup_vtbl_ptr ();
+ /* Always keep the BLOCK node associated with the outermost
+ pair of curley braces of a function. These are needed
+ for correct operation of dwarfout.c. */
+ keep_next_level ();
+ }
+ ;
+
+object: primary '.'
+ { got_object = TREE_TYPE ($$); }
+ | primary POINTSAT
+ {
+ $$ = build_x_arrow ($$);
+ got_object = TREE_TYPE ($$);
+ }
+ ;
+
+decl:
+ /* Normal case: make this fast. */
+ typespec declarator ';'
+ { tree d = get_decl_list ($1);
+ int yes = suspend_momentary ();
+ d = start_decl ($2, d, 0, NULL_TREE);
+ cp_finish_decl (d, NULL_TREE, NULL_TREE, 0, 0);
+ resume_momentary (yes);
+ if (IS_AGGR_TYPE_CODE (TREE_CODE ($1)))
+ note_got_semicolon ($1);
+ }
+ | typed_declspecs declarator ';'
+ { tree d, specs, attrs;
+ int yes;
+ split_specs_attrs ($1, &specs, &attrs);
+ yes = suspend_momentary ();
+ d = start_decl ($2, specs, 0, NULL_TREE);
+ cplus_decl_attributes (d, NULL_TREE, attrs);
+ cp_finish_decl (d, NULL_TREE, NULL_TREE, 0, 0);
+ resume_momentary (yes);
+ note_list_got_semicolon ($1);
+ }
+ | typespec initdecls ';'
+ {
+ resume_momentary ($2);
+ if (IS_AGGR_TYPE_CODE (TREE_CODE ($1)))
+ note_got_semicolon ($1);
+ }
+ | typed_declspecs initdecls ';'
+ {
+ resume_momentary ($2);
+ note_list_got_semicolon ($1);
+ }
+ | declmods notype_initdecls ';'
+ { resume_momentary ($2); }
+ | typed_declspecs ';'
+ {
+ shadow_tag ($1);
+ note_list_got_semicolon ($1);
+ }
+ | declmods ';'
+ { warning ("empty declaration"); }
+ ;
+
+/* Any kind of declarator (thus, all declarators allowed
+ after an explicit typespec). */
+
+declarator:
+ after_type_declarator %prec EMPTY
+ | notype_declarator %prec EMPTY
+ ;
+
+/* This is necessary to postpone reduction of `int()()()()'. */
+fcast_or_absdcl:
+ LEFT_RIGHT %prec EMPTY
+ { $$ = build_parse_node (CALL_EXPR, NULL_TREE, empty_parms (),
+ NULL_TREE); }
+ | fcast_or_absdcl LEFT_RIGHT %prec EMPTY
+ { $$ = build_parse_node (CALL_EXPR, $$, empty_parms (),
+ NULL_TREE); }
+ ;
+
+/* ANSI type-id (8.1) */
+type_id:
+ typed_typespecs absdcl
+ { $$ = build_decl_list ($$, $2); }
+ | nonempty_type_quals absdcl
+ { $$ = build_decl_list ($$, $2); }
+ | typespec absdcl
+ { $$ = build_decl_list (get_decl_list ($$), $2); }
+ | typed_typespecs %prec EMPTY
+ { $$ = build_decl_list ($$, NULL_TREE); }
+ | nonempty_type_quals %prec EMPTY
+ { $$ = build_decl_list ($$, NULL_TREE); }
+ ;
+
+/* Declspecs which contain at least one type specifier or typedef name.
+ (Just `const' or `volatile' is not enough.)
+ A typedef'd name following these is taken as a name to be declared.
+ In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
+
+typed_declspecs:
+ typed_typespecs %prec EMPTY
+ | typed_declspecs1
+ ;
+
+typed_declspecs1:
+ declmods typespec
+ { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
+ | typespec reserved_declspecs %prec HYPERUNARY
+ { $$ = decl_tree_cons (NULL_TREE, $$, $2); }
+ | typespec reserved_typespecquals reserved_declspecs
+ { $$ = decl_tree_cons (NULL_TREE, $$, chainon ($2, $3)); }
+ | declmods typespec reserved_declspecs
+ { $$ = decl_tree_cons (NULL_TREE, $2, chainon ($3, $$)); }
+ | declmods typespec reserved_typespecquals
+ { $$ = decl_tree_cons (NULL_TREE, $2, chainon ($3, $$)); }
+ | declmods typespec reserved_typespecquals reserved_declspecs
+ { $$ = decl_tree_cons (NULL_TREE, $2,
+ chainon ($3, chainon ($4, $$))); }
+ ;
+
+reserved_declspecs:
+ SCSPEC
+ { if (extra_warnings)
+ warning ("`%s' is not at beginning of declaration",
+ IDENTIFIER_POINTER ($$));
+ $$ = build_decl_list (NULL_TREE, $$); }
+ | reserved_declspecs typespecqual_reserved
+ { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
+ | reserved_declspecs SCSPEC
+ { if (extra_warnings)
+ warning ("`%s' is not at beginning of declaration",
+ IDENTIFIER_POINTER ($2));
+ $$ = decl_tree_cons (NULL_TREE, $2, $$); }
+ | reserved_declspecs attributes
+ { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
+ | attributes
+ { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
+ ;
+
+/* List of just storage classes and type modifiers.
+ A declaration can start with just this, but then it cannot be used
+ to redeclare a typedef-name.
+ In the result, declspecs have a non-NULL TREE_VALUE, attributes do not. */
+
+declmods:
+ nonempty_type_quals %prec EMPTY
+ { TREE_STATIC ($$) = 1; }
+ | SCSPEC
+ { $$ = IDENTIFIER_AS_LIST ($$); }
+ | declmods TYPE_QUAL
+ { $$ = decl_tree_cons (NULL_TREE, $2, $$);
+ TREE_STATIC ($$) = 1; }
+ | declmods SCSPEC
+ { if (extra_warnings && TREE_STATIC ($$))
+ warning ("`%s' is not at beginning of declaration",
+ IDENTIFIER_POINTER ($2));
+ $$ = decl_tree_cons (NULL_TREE, $2, $$);
+ TREE_STATIC ($$) = TREE_STATIC ($1); }
+ | declmods attributes
+ { $$ = decl_tree_cons ($2, NULL_TREE, $1); }
+ | attributes
+ { $$ = decl_tree_cons ($1, NULL_TREE, NULL_TREE); }
+ ;
+
+/* Used instead of declspecs where storage classes are not allowed
+ (that is, for typenames and structure components).
+
+ C++ can takes storage classes for structure components.
+ Don't accept a typedef-name if anything but a modifier precedes it. */
+
+typed_typespecs:
+ typespec %prec EMPTY
+ { $$ = get_decl_list ($$); }
+ | nonempty_type_quals typespec
+ { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
+ | typespec reserved_typespecquals
+ { $$ = decl_tree_cons (NULL_TREE, $$, $2); }
+ | nonempty_type_quals typespec reserved_typespecquals
+ { $$ = decl_tree_cons (NULL_TREE, $2, chainon ($3, $$)); }
+ ;
+
+reserved_typespecquals:
+ typespecqual_reserved
+ { $$ = build_decl_list (NULL_TREE, $$); }
+ | reserved_typespecquals typespecqual_reserved
+ { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
+ ;
+
+/* A typespec (but not a type qualifier).
+ Once we have seen one of these in a declaration,
+ if a typedef name appears then it is being redeclared. */
+
+typespec: structsp
+ | TYPESPEC %prec EMPTY
+ | complete_type_name
+ | TYPEOF '(' expr ')'
+ { $$ = TREE_TYPE ($3);
+ if (pedantic && !in_system_header)
+ pedwarn ("ANSI C++ forbids `typeof'"); }
+ | TYPEOF '(' type_id ')'
+ { $$ = groktypename ($3);
+ if (pedantic && !in_system_header)
+ pedwarn ("ANSI C++ forbids `typeof'"); }
+ | SIGOF '(' expr ')'
+ { tree type = TREE_TYPE ($3);
+
+ if (IS_AGGR_TYPE (type))
+ {
+ sorry ("sigof type specifier");
+ $$ = type;
+ }
+ else
+ {
+ error ("`sigof' applied to non-aggregate expression");
+ $$ = error_mark_node;
+ }
+ }
+ | SIGOF '(' type_id ')'
+ { tree type = groktypename ($3);
+
+ if (IS_AGGR_TYPE (type))
+ {
+ sorry ("sigof type specifier");
+ $$ = type;
+ }
+ else
+ {
+ error("`sigof' applied to non-aggregate type");
+ $$ = error_mark_node;
+ }
+ }
+ ;
+
+/* A typespec that is a reserved word, or a type qualifier. */
+
+typespecqual_reserved: TYPESPEC
+ | TYPE_QUAL
+ | structsp
+ ;
+
+initdecls:
+ initdcl0
+ | initdecls ',' initdcl
+ ;
+
+notype_initdecls:
+ notype_initdcl0
+ | notype_initdecls ',' initdcl
+ ;
+
+nomods_initdecls:
+ nomods_initdcl0
+ | nomods_initdecls ',' initdcl
+ ;
+
+maybeasm:
+ /* empty */
+ { $$ = NULL_TREE; }
+ | asm_keyword '(' string ')'
+ { if (TREE_CHAIN ($3)) $3 = combine_strings ($3); $$ = $3; }
+ ;
+
+initdcl0:
+ declarator exception_specification_opt maybeasm maybe_attribute '='
+ { split_specs_attrs ($<ttype>0, &current_declspecs,
+ &prefix_attributes);
+ if (TREE_CODE (current_declspecs) != TREE_LIST)
+ current_declspecs = get_decl_list (current_declspecs);
+ if (have_extern_spec && !used_extern_spec)
+ {
+ current_declspecs = decl_tree_cons
+ (NULL_TREE, get_identifier ("extern"),
+ current_declspecs);
+ used_extern_spec = 1;
+ }
+ $<itype>5 = suspend_momentary ();
+ $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1, $2);
+ cplus_decl_attributes ($<ttype>$, $4, prefix_attributes); }
+ init
+/* Note how the declaration of the variable is in effect while its init is parsed! */
+ { cp_finish_decl ($<ttype>6, $7, $3, 0, LOOKUP_ONLYCONVERTING);
+ $$ = $<itype>5; }
+ | declarator exception_specification_opt maybeasm maybe_attribute
+ { tree d;
+ split_specs_attrs ($<ttype>0, &current_declspecs,
+ &prefix_attributes);
+ if (TREE_CODE (current_declspecs) != TREE_LIST)
+ current_declspecs = get_decl_list (current_declspecs);
+ if (have_extern_spec && !used_extern_spec)
+ {
+ current_declspecs = decl_tree_cons
+ (NULL_TREE, get_identifier ("extern"),
+ current_declspecs);
+ used_extern_spec = 1;
+ }
+ $$ = suspend_momentary ();
+ d = start_decl ($<ttype>1, current_declspecs, 0, $2);
+ cplus_decl_attributes (d, $4, prefix_attributes);
+ cp_finish_decl (d, NULL_TREE, $3, 0, 0); }
+ ;
+
+initdcl:
+ declarator exception_specification_opt maybeasm maybe_attribute '='
+ { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1, $2);
+ cplus_decl_attributes ($<ttype>$, $4, prefix_attributes); }
+ init
+/* Note how the declaration of the variable is in effect while its init is parsed! */
+ { cp_finish_decl ($<ttype>6, $7, $3, 0, LOOKUP_ONLYCONVERTING); }
+ | declarator exception_specification_opt maybeasm maybe_attribute
+ { $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 0, $2);
+ cplus_decl_attributes ($<ttype>$, $4, prefix_attributes);
+ cp_finish_decl ($<ttype>$, NULL_TREE, $3, 0, 0); }
+ ;
+
+notype_initdcl0:
+ notype_declarator exception_specification_opt maybeasm maybe_attribute '='
+ { split_specs_attrs ($<ttype>0, &current_declspecs,
+ &prefix_attributes);
+ $<itype>5 = suspend_momentary ();
+ $<ttype>$ = start_decl ($<ttype>1, current_declspecs, 1, $2);
+ cplus_decl_attributes ($<ttype>$, $4, prefix_attributes); }
+ init
+/* Note how the declaration of the variable is in effect while its init is parsed! */
+ { cp_finish_decl ($<ttype>6, $7, $3, 0, LOOKUP_ONLYCONVERTING);
+ $$ = $<itype>5; }
+ | notype_declarator exception_specification_opt maybeasm maybe_attribute
+ { tree d;
+ split_specs_attrs ($<ttype>0, &current_declspecs,
+ &prefix_attributes);
+ $$ = suspend_momentary ();
+ d = start_decl ($<ttype>1, current_declspecs, 0, $2);
+ cplus_decl_attributes (d, $4, prefix_attributes);
+ cp_finish_decl (d, NULL_TREE, $3, 0, 0); }
+ ;
+
+nomods_initdcl0:
+ notype_declarator exception_specification_opt maybeasm maybe_attribute '='
+ { current_declspecs = NULL_TREE;
+ prefix_attributes = NULL_TREE;
+ $<itype>5 = suspend_momentary ();
+ $<ttype>$ = start_decl ($1, current_declspecs, 1, $2);
+ cplus_decl_attributes ($<ttype>$, $4, prefix_attributes); }
+ init
+/* Note how the declaration of the variable is in effect while its init is parsed! */
+ { cp_finish_decl ($<ttype>6, $7, $3, 0, LOOKUP_ONLYCONVERTING);
+ $$ = $<itype>5; }
+ | notype_declarator exception_specification_opt maybeasm maybe_attribute
+ { tree d;
+ current_declspecs = NULL_TREE;
+ prefix_attributes = NULL_TREE;
+ $$ = suspend_momentary ();
+ d = start_decl ($1, current_declspecs, 0, $2);
+ cplus_decl_attributes (d, $4, prefix_attributes);
+ cp_finish_decl (d, NULL_TREE, $3, 0, 0); }
+ ;
+
+/* the * rules are dummies to accept the Apollo extended syntax
+ so that the header files compile. */
+maybe_attribute:
+ /* empty */
+ { $$ = NULL_TREE; }
+ | attributes
+ { $$ = $1; }
+ ;
+
+attributes:
+ attribute
+ { $$ = $1; }
+ | attributes attribute
+ { $$ = chainon ($1, $2); }
+ ;
+
+attribute:
+ ATTRIBUTE '(' '(' attribute_list ')' ')'
+ { $$ = $4; }
+ ;
+
+attribute_list:
+ attrib
+ { $$ = $1; }
+ | attribute_list ',' attrib
+ { $$ = chainon ($1, $3); }
+ ;
+
+attrib:
+ /* empty */
+ { $$ = NULL_TREE; }
+ | any_word
+ { $$ = build_tree_list ($1, NULL_TREE); }
+ | any_word '(' IDENTIFIER ')'
+ { $$ = build_tree_list ($1, build_tree_list (NULL_TREE, $3)); }
+ | any_word '(' IDENTIFIER ',' nonnull_exprlist ')'
+ { $$ = build_tree_list ($1, tree_cons (NULL_TREE, $3, $5)); }
+ | any_word '(' nonnull_exprlist ')'
+ { $$ = build_tree_list ($1, $3); }
+ ;
+
+/* This still leaves out most reserved keywords,
+ shouldn't we include them? */
+
+any_word:
+ identifier
+ | SCSPEC
+ | TYPESPEC
+ | TYPE_QUAL
+ ;
+
+/* A nonempty list of identifiers, including typenames. */
+identifiers_or_typenames:
+ identifier
+ { $$ = build_tree_list (NULL_TREE, $1); }
+ | identifiers_or_typenames ',' identifier
+ { $$ = chainon ($1, build_tree_list (NULL_TREE, $3)); }
+ ;
+
+maybe_init:
+ %prec EMPTY /* empty */
+ { $$ = NULL_TREE; }
+ | '=' init
+ { $$ = $2; }
+
+init:
+ expr_no_commas %prec '='
+ | '{' '}'
+ { $$ = build_nt (CONSTRUCTOR, NULL_TREE, NULL_TREE);
+ TREE_HAS_CONSTRUCTOR ($$) = 1; }
+ | '{' initlist '}'
+ { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
+ TREE_HAS_CONSTRUCTOR ($$) = 1; }
+ | '{' initlist ',' '}'
+ { $$ = build_nt (CONSTRUCTOR, NULL_TREE, nreverse ($2));
+ TREE_HAS_CONSTRUCTOR ($$) = 1; }
+ | error
+ { $$ = NULL_TREE; }
+ ;
+
+/* This chain is built in reverse order,
+ and put in forward order where initlist is used. */
+initlist:
+ init
+ { $$ = build_tree_list (NULL_TREE, $$); }
+ | initlist ',' init
+ { $$ = tree_cons (NULL_TREE, $3, $$); }
+ /* These are for labeled elements. */
+ | '[' expr_no_commas ']' init
+ { $$ = build_tree_list ($2, $4); }
+ | initlist ',' CASE expr_no_commas ':' init
+ { $$ = tree_cons ($4, $6, $$); }
+ | identifier ':' init
+ { $$ = build_tree_list ($$, $3); }
+ | initlist ',' identifier ':' init
+ { $$ = tree_cons ($3, $5, $$); }
+ ;
+
+structsp:
+ ENUM identifier '{'
+ { $<itype>3 = suspend_momentary ();
+ $$ = start_enum ($2); }
+ enumlist maybecomma_warn '}'
+ { $$ = finish_enum ($<ttype>4, $5);
+ resume_momentary ((int) $<itype>3);
+ check_for_missing_semicolon ($<ttype>4); }
+ | ENUM identifier '{' '}'
+ { $$ = finish_enum (start_enum ($2), NULL_TREE);
+ check_for_missing_semicolon ($$); }
+ | ENUM '{'
+ { $<itype>2 = suspend_momentary ();
+ $$ = start_enum (make_anon_name ()); }
+ enumlist maybecomma_warn '}'
+ { $$ = finish_enum ($<ttype>3, $4);
+ resume_momentary ((int) $<itype>1);
+ check_for_missing_semicolon ($<ttype>3); }
+ | ENUM '{' '}'
+ { $$ = finish_enum (start_enum (make_anon_name()), NULL_TREE);
+ check_for_missing_semicolon ($$); }
+ | ENUM identifier
+ { $$ = xref_tag (enum_type_node, $2, NULL_TREE, 1); }
+ | ENUM complex_type_name
+ { $$ = xref_tag (enum_type_node, $2, NULL_TREE, 1); }
+ | TYPENAME_KEYWORD complex_type_name
+ { $$ = $2; }
+ /* C++ extensions, merged with C to avoid shift/reduce conflicts */
+ | class_head left_curly opt.component_decl_list '}'
+ {
+ int semi;
+ tree id;
+
+#if 0
+ /* Need to rework class nesting in the
+ presence of nested classes, etc. */
+ shadow_tag (CLASSTYPE_AS_LIST ($$)); */
+#endif
+ if (yychar == YYEMPTY)
+ yychar = YYLEX;
+ semi = yychar == ';';
+ /* finish_struct nukes this anyway; if
+ finish_exception does too, then it can go. */
+ if (semi)
+ note_got_semicolon ($$);
+
+ if (TREE_CODE ($$) == ENUMERAL_TYPE)
+ /* $$ = $1 from default rule. */;
+ else
+ {
+ $$ = finish_struct ($$, $3, semi);
+ if (semi) note_got_semicolon ($$);
+ }
+
+ pop_obstacks ();
+
+ id = TYPE_IDENTIFIER ($$);
+ if (id && IDENTIFIER_TEMPLATE (id))
+ {
+ tree decl;
+
+ /* I don't know if the copying of this TYPE_DECL is
+ * really needed. However, it's such a small per-
+ * formance penalty that the extra safety is a bargain.
+ * - niklas@appli.se
+ */
+ push_obstacks (&permanent_obstack, &permanent_obstack);
+ decl = copy_node (lookup_name (id, 0));
+ if (DECL_LANG_SPECIFIC (decl))
+ copy_lang_decl (decl);
+ pop_obstacks ();
+ undo_template_name_overload (id, 0);
+ pushdecl_top_level (decl);
+ }
+ if (! semi)
+ check_for_missing_semicolon ($$); }
+ | class_head %prec EMPTY
+ {
+ /* struct B: public A; is not accepted by the WP grammar. */
+ if (TYPE_BINFO_BASETYPES ($$) && !TYPE_SIZE ($$)
+ && ! TYPE_BEING_DEFINED ($$))
+ cp_error ("base clause without member specification for `%#T'",
+ $$);
+ }
+ ;
+
+maybecomma:
+ /* empty */
+ | ','
+ ;
+
+maybecomma_warn:
+ /* empty */
+ | ','
+ { if (pedantic) pedwarn ("comma at end of enumerator list"); }
+ ;
+
+aggr: AGGR
+ | aggr SCSPEC
+ { error ("storage class specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
+ | aggr TYPESPEC
+ { error ("type specifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
+ | aggr TYPE_QUAL
+ { error ("type qualifier `%s' not allowed after struct or class", IDENTIFIER_POINTER ($2)); }
+ | aggr AGGR
+ { error ("no body nor ';' separates two class, struct or union declarations"); }
+ ;
+
+specialization:
+ aggr template_type_name ';'
+ {
+ yyungetc (';', 1); current_aggr = $$; $$ = $2;
+ if ($<ttype>0 == ridpointers[(int) RID_TEMPLATE])
+ instantiate_class_template ($$, 2);
+ }
+ ;
+
+named_class_head_sans_basetype:
+ aggr identifier
+ { current_aggr = $$; $$ = $2; }
+ | specialization
+ ;
+
+named_class_head_sans_basetype_defn:
+ aggr identifier_defn %prec EMPTY
+ { current_aggr = $$; $$ = $2; }
+ | aggr template_type_name '{'
+ { yyungetc ('{', 1);
+ aggr2:
+ current_aggr = $$;
+ $$ = $2;
+ overload_template_name ($$, 0); }
+ | aggr template_type_name ':'
+ { yyungetc (':', 1); goto aggr2; }
+ ;
+
+named_complex_class_head_sans_basetype:
+ aggr nested_name_specifier identifier
+ { current_aggr = $$; $$ = $3; }
+ | aggr template_type %prec EMPTY
+ { current_aggr = $$; $$ = $2; }
+ ;
+
+do_xref_defn: /* empty */ %prec EMPTY
+ { $<ttype>$ = xref_tag (current_aggr, $<ttype>0, NULL_TREE, 0); }
+ ;
+
+named_class_head:
+ named_class_head_sans_basetype %prec EMPTY
+ { $$ = xref_tag (current_aggr, $1, NULL_TREE, 1); }
+ | named_class_head_sans_basetype_defn do_xref_defn
+ maybe_base_class_list %prec EMPTY
+ {
+ $$ = $<ttype>2;
+ if ($3)
+ xref_basetypes (current_aggr, $1, $<ttype>2, $3);
+ }
+ | named_complex_class_head_sans_basetype maybe_base_class_list
+ {
+ $$ = TREE_TYPE ($1);
+ if ($2)
+ xref_basetypes (current_aggr, $1, TREE_TYPE ($1), $2);
+ }
+ ;
+
+unnamed_class_head: aggr '{'
+ { $$ = xref_tag ($$, make_anon_name (), NULL_TREE, 0);
+ yyungetc ('{', 1); }
+ ;
+
+class_head: unnamed_class_head | named_class_head ;
+
+maybe_base_class_list:
+ %prec EMPTY /* empty */
+ { $$ = NULL_TREE; }
+ | ':' see_typename %prec EMPTY
+ { yyungetc(':', 1); $$ = NULL_TREE; }
+ | ':' see_typename base_class_list %prec EMPTY
+ { $$ = $3; }
+ ;
+
+base_class_list:
+ base_class
+ | base_class_list ',' see_typename base_class
+ { $$ = chainon ($$, $4); }
+ ;
+
+base_class:
+ base_class.1
+ {
+ tree type;
+ type = IDENTIFIER_TYPE_VALUE ($$);
+ if (! is_aggr_typedef ($$, 1))
+ $$ = NULL_TREE;
+ else if (current_aggr == signature_type_node
+ && (! type) && (! IS_SIGNATURE (type)))
+ {
+ error ("class name not allowed as base signature");
+ $$ = NULL_TREE;
+ }
+ else if (current_aggr == signature_type_node)
+ {
+ sorry ("signature inheritance, base type `%s' ignored",
+ IDENTIFIER_POINTER ($$));
+ $$ = build_tree_list ((tree)access_public, $$);
+ }
+ else if (type && IS_SIGNATURE (type))
+ {
+ error ("signature name not allowed as base class");
+ $$ = NULL_TREE;
+ }
+ else
+ $$ = build_tree_list ((tree)access_default, $$);
+ }
+ | base_class_access_list see_typename base_class.1
+ {
+ tree type;
+ type = IDENTIFIER_TYPE_VALUE ($3);
+ if (current_aggr == signature_type_node)
+ error ("access and source specifiers not allowed in signature");
+ if (! is_aggr_typedef ($3, 1))
+ $$ = NULL_TREE;
+ else if (current_aggr == signature_type_node
+ && (! type) && (! IS_SIGNATURE (type)))
+ {
+ error ("class name not allowed as base signature");
+ $$ = NULL_TREE;
+ }
+ else if (current_aggr == signature_type_node)
+ {
+ sorry ("signature inheritance, base type `%s' ignored",
+ IDENTIFIER_POINTER ($$));
+ $$ = build_tree_list ((tree)access_public, $3);
+ }
+ else if (type && IS_SIGNATURE (type))
+ {
+ error ("signature name not allowed as base class");
+ $$ = NULL_TREE;
+ }
+ else
+ $$ = build_tree_list ((tree) $$, $3);
+ }
+ ;
+
+base_class.1:
+ complete_type_name
+ | SIGOF '(' expr ')'
+ {
+ if (current_aggr == signature_type_node)
+ {
+ if (IS_AGGR_TYPE (TREE_TYPE ($3)))
+ {
+ sorry ("`sigof' as base signature specifier");
+ /* need to return some dummy signature identifier */
+ $$ = $3;
+ }
+ else
+ {
+ error ("`sigof' applied to non-aggregate expression");
+ $$ = error_mark_node;
+ }
+ }
+ else
+ {
+ error ("`sigof' in struct or class declaration");
+ $$ = error_mark_node;
+ }
+ }
+ | SIGOF '(' type_id ')'
+ {
+ if (current_aggr == signature_type_node)
+ {
+ if (IS_AGGR_TYPE (groktypename ($3)))
+ {
+ sorry ("`sigof' as base signature specifier");
+ /* need to return some dummy signature identifier */
+ $$ = $3;
+ }
+ else
+ {
+ error ("`sigof' applied to non-aggregate expression");
+ $$ = error_mark_node;
+ }
+ }
+ else
+ {
+ error ("`sigof' in struct or class declaration");
+ $$ = error_mark_node;
+ }
+ }
+ ;
+
+base_class_access_list:
+ VISSPEC see_typename
+ | SCSPEC see_typename
+ { if ($<ttype>$ != ridpointers[(int)RID_VIRTUAL])
+ sorry ("non-virtual access");
+ $$ = access_default_virtual; }
+ | base_class_access_list VISSPEC see_typename
+ { int err = 0;
+ if ($2 == access_protected)
+ {
+ warning ("`protected' access not implemented");
+ $2 = access_public;
+ err++;
+ }
+ else if ($2 == access_public)
+ {
+ if ($1 == access_private)
+ {
+ mixed:
+ error ("base class cannot be public and private");
+ }
+ else if ($1 == access_default_virtual)
+ $$ = access_public_virtual;
+ }
+ else /* $2 == access_private */
+ {
+ if ($1 == access_public)
+ goto mixed;
+ else if ($1 == access_default_virtual)
+ $$ = access_private_virtual;
+ }
+ }
+ | base_class_access_list SCSPEC see_typename
+ { if ($2 != ridpointers[(int)RID_VIRTUAL])
+ sorry ("non-virtual access");
+ if ($$ == access_public)
+ $$ = access_public_virtual;
+ else if ($$ == access_private)
+ $$ = access_private_virtual; }
+ ;
+
+left_curly: '{'
+ { tree t = $<ttype>0;
+ push_obstacks_nochange ();
+ end_temporary_allocation ();
+
+ if (! IS_AGGR_TYPE (t))
+ {
+ t = $<ttype>0 = make_lang_type (RECORD_TYPE);
+ TYPE_NAME (t) = get_identifier ("erroneous type");
+ }
+ if (TYPE_SIZE (t))
+ duplicate_tag_error (t);
+ if (TYPE_SIZE (t) || TYPE_BEING_DEFINED (t))
+ {
+ t = make_lang_type (TREE_CODE (t));
+ pushtag (TYPE_IDENTIFIER ($<ttype>0), t, 0);
+ $<ttype>0 = t;
+ }
+ pushclass (t, 0);
+ TYPE_BEING_DEFINED (t) = 1;
+ /* Reset the interface data, at the earliest possible
+ moment, as it might have been set via a class foo;
+ before. */
+ /* Don't change signatures. */
+ if (! IS_SIGNATURE (t))
+ {
+ extern tree pending_vtables;
+ int needs_writing;
+ tree name = TYPE_IDENTIFIER (t);
+
+ if (! ANON_AGGRNAME_P (name))
+ {
+ CLASSTYPE_INTERFACE_ONLY (t) = interface_only;
+ SET_CLASSTYPE_INTERFACE_UNKNOWN_X
+ (t, interface_unknown);
+ }
+
+ /* Record how to set the access of this class's
+ virtual functions. If write_virtuals == 2 or 3, then
+ inline virtuals are ``extern inline''. */
+ switch (write_virtuals)
+ {
+ case 0:
+ case 1:
+ needs_writing = 1;
+ break;
+ case 2:
+ needs_writing = !! value_member (name, pending_vtables);
+ break;
+ case 3:
+ needs_writing = ! CLASSTYPE_INTERFACE_ONLY (t)
+ && CLASSTYPE_INTERFACE_KNOWN (t);
+ break;
+ default:
+ needs_writing = 0;
+ }
+ CLASSTYPE_VTABLE_NEEDS_WRITING (t) = needs_writing;
+ }
+#if 0
+ t = TYPE_IDENTIFIER ($<ttype>0);
+ if (t && IDENTIFIER_TEMPLATE (t))
+ overload_template_name (t, 1);
+#endif
+ }
+ ;
+
+opt.component_decl_list:
+ /* empty */
+ { $$ = NULL_TREE; }
+ | component_decl_list
+ {
+ if (current_aggr == signature_type_node)
+ $$ = build_tree_list ((tree) access_public, $$);
+ else
+ $$ = build_tree_list ((tree) access_default, $$);
+ }
+ | opt.component_decl_list VISSPEC ':' component_decl_list
+ {
+ tree visspec = (tree) $2;
+
+ if (current_aggr == signature_type_node)
+ {
+ error ("access specifier not allowed in signature");
+ visspec = (tree) access_public;
+ }
+ $$ = chainon ($$, build_tree_list (visspec, $4));
+ }
+ | opt.component_decl_list VISSPEC ':'
+ {
+ if (current_aggr == signature_type_node)
+ error ("access specifier not allowed in signature");
+ }
+ ;
+
+/* Note: we no longer warn about the semicolon after a component_decl_list.
+ ARM $9.2 says that the semicolon is optional, and therefore allowed. */
+component_decl_list:
+ component_decl
+ { if ($$ == void_type_node) $$ = NULL_TREE;
+ }
+ | component_decl_list component_decl
+ { /* In pushdecl, we created a reverse list of names
+ in this binding level. Make sure that the chain
+ of what we're trying to add isn't the item itself
+ (which can happen with what pushdecl's doing). */
+ if ($2 != NULL_TREE && $2 != void_type_node)
+ {
+ if (TREE_CHAIN ($2) != $$)
+ $$ = chainon ($$, $2);
+ else
+ $$ = $2;
+ }
+ }
+ ;
+
+component_decl:
+ component_decl_1 ';'
+ { }
+ | component_decl_1 '}'
+ { error ("missing ';' before right brace");
+ yyungetc ('}', 0); }
+ /* C++: handle constructors, destructors and inline functions */
+ /* note that INLINE is like a TYPESPEC */
+ | fn.def2 ':' /* base_init compstmt */
+ { $$ = finish_method ($$); }
+ | fn.def2 TRY /* base_init compstmt */
+ { $$ = finish_method ($$); }
+ | fn.def2 RETURN /* base_init compstmt */
+ { $$ = finish_method ($$); }
+ | fn.def2 '{' /* nodecls compstmt */
+ { $$ = finish_method ($$); }
+ | ';'
+ { $$ = NULL_TREE; }
+ ;
+
+component_decl_1:
+ /* Do not add a "typed_declspecs declarator" rule here for
+ speed; we need to call grok_x_components for enums, so the
+ speedup would be insignificant. */
+ typed_declspecs components
+ { $$ = grok_x_components ($1, $2); }
+ | declmods notype_components
+ { $$ = grok_x_components ($1, $2); }
+ | notype_declarator exception_specification_opt maybeasm maybe_attribute maybe_init
+ { $$ = grokfield ($$, NULL_TREE, $2, $5, $3,
+ build_tree_list ($4, NULL_TREE)); }
+ | ':' expr_no_commas
+ { $$ = grokbitfield (NULL_TREE, NULL_TREE, $2); }
+ | error
+ { $$ = NULL_TREE; }
+
+ /* These rules introduce a reduce/reduce conflict; in
+ typedef int foo, bar;
+ class A {
+ foo (bar);
+ };
+ should "A::foo" be declared as a function or "A::bar" as a data
+ member? In other words, is "bar" an after_type_declarator or a
+ parmlist? */
+ | typed_declspecs '(' parmlist ')' type_quals exception_specification_opt maybeasm maybe_attribute maybe_init
+ { tree specs, attrs;
+ split_specs_attrs ($1, &specs, &attrs);
+ $$ = build_parse_node (CALL_EXPR, TREE_VALUE (specs),
+ $3, $5);
+ $$ = grokfield ($$, TREE_CHAIN (specs), $6, $9, $7,
+ build_tree_list ($8, attrs)); }
+ | typed_declspecs LEFT_RIGHT type_quals exception_specification_opt maybeasm maybe_attribute maybe_init
+ { tree specs, attrs;
+ split_specs_attrs ($1, &specs, &attrs);
+ $$ = build_parse_node (CALL_EXPR, TREE_VALUE (specs),
+ empty_parms (), $3);
+ $$ = grokfield ($$, TREE_CHAIN (specs), $4, $7, $5,
+ build_tree_list ($6, attrs)); }
+ | using_decl
+ { $$ = do_class_using_decl ($1); }
+ ;
+
+/* The case of exactly one component is handled directly by component_decl. */
+/* ??? Huh? ^^^ */
+components:
+ /* empty: possibly anonymous */
+ { $$ = NULL_TREE; }
+ | component_declarator0
+ | components ',' component_declarator
+ {
+ /* In this context, void_type_node encodes
+ friends. They have been recorded elsewhere. */
+ if ($$ == void_type_node)
+ $$ = $3;
+ else
+ $$ = chainon ($$, $3);
+ }
+ ;
+
+notype_components:
+ /* empty: possibly anonymous */
+ { $$ = NULL_TREE; }
+ | notype_component_declarator0
+ | notype_components ',' notype_component_declarator
+ {
+ /* In this context, void_type_node encodes
+ friends. They have been recorded elsewhere. */
+ if ($$ == void_type_node)
+ $$ = $3;
+ else
+ $$ = chainon ($$, $3);
+ }
+ ;
+
+component_declarator0:
+ after_type_component_declarator0
+ | notype_component_declarator0
+ ;
+
+component_declarator:
+ after_type_component_declarator
+ | notype_component_declarator
+ ;
+
+after_type_component_declarator0:
+ after_type_declarator exception_specification_opt maybeasm maybe_attribute maybe_init
+ { split_specs_attrs ($<ttype>0, &current_declspecs,
+ &prefix_attributes);
+ $<ttype>0 = current_declspecs;
+ $$ = grokfield ($$, current_declspecs, $2, $5, $3,
+ build_tree_list ($4, prefix_attributes)); }
+ | TYPENAME ':' expr_no_commas maybe_attribute
+ { split_specs_attrs ($<ttype>0, &current_declspecs,
+ &prefix_attributes);
+ $<ttype>0 = current_declspecs;
+ $$ = grokbitfield ($$, current_declspecs, $3);
+ cplus_decl_attributes ($$, $4, prefix_attributes); }
+ ;
+
+notype_component_declarator0:
+ notype_declarator exception_specification_opt maybeasm maybe_attribute maybe_init
+ { split_specs_attrs ($<ttype>0, &current_declspecs,
+ &prefix_attributes);
+ $<ttype>0 = current_declspecs;
+ $$ = grokfield ($$, current_declspecs, $2, $5, $3,
+ build_tree_list ($4, prefix_attributes)); }
+ | IDENTIFIER ':' expr_no_commas maybe_attribute
+ { split_specs_attrs ($<ttype>0, &current_declspecs,
+ &prefix_attributes);
+ $<ttype>0 = current_declspecs;
+ $$ = grokbitfield ($$, current_declspecs, $3);
+ cplus_decl_attributes ($$, $4, prefix_attributes); }
+ | ':' expr_no_commas maybe_attribute
+ { split_specs_attrs ($<ttype>0, &current_declspecs,
+ &prefix_attributes);
+ $<ttype>0 = current_declspecs;
+ $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
+ cplus_decl_attributes ($$, $3, prefix_attributes); }
+ ;
+
+after_type_component_declarator:
+ after_type_declarator exception_specification_opt maybeasm maybe_attribute maybe_init
+ { $$ = grokfield ($$, current_declspecs, $2, $5, $3,
+ build_tree_list ($4, prefix_attributes)); }
+ | TYPENAME ':' expr_no_commas maybe_attribute
+ { $$ = grokbitfield ($$, current_declspecs, $3);
+ cplus_decl_attributes ($$, $4, prefix_attributes); }
+ ;
+
+notype_component_declarator:
+ notype_declarator exception_specification_opt maybeasm maybe_attribute maybe_init
+ { $$ = grokfield ($$, current_declspecs, $2, $5, $3,
+ build_tree_list ($4, prefix_attributes)); }
+ | IDENTIFIER ':' expr_no_commas maybe_attribute
+ { $$ = grokbitfield ($$, current_declspecs, $3);
+ cplus_decl_attributes ($$, $4, prefix_attributes); }
+ | ':' expr_no_commas maybe_attribute
+ { $$ = grokbitfield (NULL_TREE, current_declspecs, $2);
+ cplus_decl_attributes ($$, $3, prefix_attributes); }
+ ;
+
+/* We chain the enumerators in reverse order.
+ Because of the way enums are built, the order is
+ insignificant. Take advantage of this fact. */
+
+enumlist:
+ enumerator
+ | enumlist ',' enumerator
+ { TREE_CHAIN ($3) = $$; $$ = $3; }
+ ;
+
+enumerator:
+ identifier
+ { $$ = build_enumerator ($$, NULL_TREE); }
+ | identifier '=' expr_no_commas
+ { $$ = build_enumerator ($$, $3); }
+ ;
+
+/* ANSI new-type-id (5.3.4) */
+new_type_id:
+ type_specifier_seq new_declarator
+ { $$ = build_decl_list ($$, $2); }
+ | type_specifier_seq %prec EMPTY
+ { $$ = build_decl_list ($$, NULL_TREE); }
+ /* GNU extension to allow arrays of arbitrary types with
+ non-constant dimension. */
+ | '(' type_id ')' '[' expr ']'
+ {
+ if (pedantic)
+ pedwarn ("ANSI C++ forbids array dimensions with parenthesized type in new");
+ $$ = build_parse_node (ARRAY_REF, TREE_VALUE ($2), $5);
+ $$ = build_decl_list (TREE_PURPOSE ($2), $$);
+ }
+ ;
+
+type_quals:
+ /* empty */ %prec EMPTY
+ { $$ = NULL_TREE; }
+ | type_quals TYPE_QUAL
+ { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
+ ;
+
+nonempty_type_quals:
+ TYPE_QUAL
+ { $$ = IDENTIFIER_AS_LIST ($$); }
+ | nonempty_type_quals TYPE_QUAL
+ { $$ = decl_tree_cons (NULL_TREE, $2, $$); }
+ ;
+
+/* These rules must follow the rules for function declarations
+ and component declarations. That way, longer rules are preferred. */
+
+suspend_mom:
+ { $<itype>$ = suspend_momentary (); }
+
+/* An expression which will not live on the momentary obstack. */
+nonmomentary_expr:
+ suspend_mom expr
+ { resume_momentary ((int) $<itype>1); $$ = $2; }
+ ;
+
+/* An expression which will not live on the momentary obstack. */
+maybe_parmlist:
+ suspend_mom '(' nonnull_exprlist ')'
+ { resume_momentary ((int) $<itype>1); $$ = $3; }
+ | suspend_mom '(' parmlist ')'
+ { resume_momentary ((int) $<itype>1); $$ = $3; }
+ | suspend_mom LEFT_RIGHT
+ { resume_momentary ((int) $<itype>1); $$ = empty_parms (); }
+ | suspend_mom '(' error ')'
+ { resume_momentary ((int) $<itype>1); $$ = NULL_TREE; }
+ ;
+
+/* A declarator that is allowed only after an explicit typespec. */
+/* may all be followed by prec '.' */
+after_type_declarator:
+ '*' nonempty_type_quals after_type_declarator %prec UNARY
+ { $$ = make_pointer_declarator ($2, $3); }
+ | '&' nonempty_type_quals after_type_declarator %prec UNARY
+ { $$ = make_reference_declarator ($2, $3); }
+ | '*' after_type_declarator %prec UNARY
+ { $$ = make_pointer_declarator (NULL_TREE, $2); }
+ | '&' after_type_declarator %prec UNARY
+ { $$ = make_reference_declarator (NULL_TREE, $2); }
+ | ptr_to_mem type_quals after_type_declarator
+ { tree arg = make_pointer_declarator ($2, $3);
+ $$ = build_parse_node (SCOPE_REF, $1, arg);
+ }
+ | direct_after_type_declarator
+ ;
+
+qualified_type_name:
+ type_name %prec EMPTY
+ {
+ /* Remember that this name has been used in the class
+ definition, as per [class.scope0] */
+ if (current_class_type
+ && TYPE_BEING_DEFINED (current_class_type)
+ && ! IDENTIFIER_CLASS_VALUE ($$))
+ {
+ tree t = lookup_name ($$, -2);
+ if (t)
+ pushdecl_class_level (t);
+ }
+ }
+ | nested_type
+ ;
+
+nested_type:
+ nested_name_specifier type_name %prec EMPTY
+ { $$ = $2; }
+ ;
+
+direct_after_type_declarator:
+ direct_after_type_declarator maybe_parmlist type_quals %prec '.'
+ { $$ = build_parse_node (CALL_EXPR, $$, $2, $3); }
+ | direct_after_type_declarator '[' nonmomentary_expr ']'
+ { $$ = build_parse_node (ARRAY_REF, $$, $3); }
+ | direct_after_type_declarator '[' ']'
+ { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
+ | '(' after_type_declarator ')'
+ { $$ = $2; }
+ | nested_name_specifier type_name %prec EMPTY
+ { push_nested_class (TREE_TYPE ($$), 3);
+ $$ = build_parse_node (SCOPE_REF, $$, $2);
+ TREE_COMPLEXITY ($$) = current_class_depth; }
+ | type_name %prec EMPTY
+ ;
+
+/* A declarator allowed whether or not there has been
+ an explicit typespec. These cannot redeclare a typedef-name. */
+
+notype_declarator:
+ '*' nonempty_type_quals notype_declarator %prec UNARY
+ { $$ = make_pointer_declarator ($2, $3); }
+ | '&' nonempty_type_quals notype_declarator %prec UNARY
+ { $$ = make_reference_declarator ($2, $3); }
+ | '*' notype_declarator %prec UNARY
+ { $$ = make_pointer_declarator (NULL_TREE, $2); }
+ | '&' notype_declarator %prec UNARY
+ { $$ = make_reference_declarator (NULL_TREE, $2); }
+ | ptr_to_mem type_quals notype_declarator
+ { tree arg = make_pointer_declarator ($2, $3);
+ $$ = build_parse_node (SCOPE_REF, $1, arg);
+ }
+ | direct_notype_declarator
+ ;
+
+complex_notype_declarator:
+ '*' nonempty_type_quals notype_declarator %prec UNARY
+ { $$ = make_pointer_declarator ($2, $3); }
+ | '&' nonempty_type_quals notype_declarator %prec UNARY
+ { $$ = make_reference_declarator ($2, $3); }
+ | '*' complex_notype_declarator %prec UNARY
+ { $$ = make_pointer_declarator (NULL_TREE, $2); }
+ | '&' complex_notype_declarator %prec UNARY
+ { $$ = make_reference_declarator (NULL_TREE, $2); }
+ | ptr_to_mem type_quals notype_declarator
+ { tree arg = make_pointer_declarator ($2, $3);
+ $$ = build_parse_node (SCOPE_REF, $1, arg);
+ }
+ | complex_direct_notype_declarator
+ ;
+
+complex_direct_notype_declarator:
+ direct_notype_declarator maybe_parmlist type_quals %prec '.'
+ { $$ = build_parse_node (CALL_EXPR, $$, $2, $3); }
+ | '(' complex_notype_declarator ')'
+ { $$ = $2; }
+ | direct_notype_declarator '[' nonmomentary_expr ']'
+ { $$ = build_parse_node (ARRAY_REF, $$, $3); }
+ | direct_notype_declarator '[' ']'
+ { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
+ | notype_qualified_id
+ { if (TREE_TYPE (OP0 ($$)) != current_class_type)
+ {
+ push_nested_class (TREE_TYPE (OP0 ($$)), 3);
+ TREE_COMPLEXITY ($$) = current_class_depth;
+ }
+ }
+ ;
+
+qualified_id:
+ nested_name_specifier unqualified_id
+ { got_scope = NULL_TREE;
+ $$ = build_parse_node (SCOPE_REF, $$, $2); }
+ ;
+
+notype_qualified_id:
+ nested_name_specifier notype_unqualified_id
+ { got_scope = NULL_TREE;
+ $$ = build_parse_node (SCOPE_REF, $$, $2); }
+ ;
+
+overqualified_id:
+ notype_qualified_id
+ | global_scope notype_qualified_id
+ { $$ = $2; }
+ ;
+
+functional_cast:
+ typespec '(' nonnull_exprlist ')'
+ { $$ = build_functional_cast ($$, $3); }
+ | typespec '(' expr_or_declarator ')'
+ { $$ = reparse_decl_as_expr ($$, $3); }
+ | typespec fcast_or_absdcl %prec EMPTY
+ { $$ = reparse_absdcl_as_expr ($$, $2); }
+ ;
+
+type_name:
+ TYPENAME
+ | template_type %prec EMPTY
+ ;
+
+nested_name_specifier:
+ nested_name_specifier_1
+ | nested_name_specifier nested_name_specifier_1
+ { $$ = $2; }
+ ;
+
+/* Why the @#$%^& do type_name and notype_identifier need to be expanded
+ inline here?!? (jason) */
+nested_name_specifier_1:
+ TYPENAME SCOPE
+ { got_scope = TREE_TYPE ($$); }
+ | NSNAME SCOPE
+ { got_scope = $$; }
+ | template_type SCOPE
+ { got_scope = TREE_TYPE ($$); }
+/* These break 'const i;'
+ | IDENTIFIER SCOPE
+ {
+ failed_scope:
+ cp_error ("`%D' is not an aggregate typedef",
+ lastiddecl ? lastiddecl : $$);
+ $$ = error_mark_node;
+ }
+ | PTYPENAME SCOPE
+ { goto failed_scope; } */
+ ;
+
+complete_type_name:
+ qualified_type_name
+ | global_scope qualified_type_name
+ { $$ = $2; }
+ ;
+
+complex_type_name:
+ nested_type
+ | global_scope qualified_type_name
+ { $$ = $2; }
+ ;
+
+ptr_to_mem:
+ nested_name_specifier '*'
+ { got_scope = NULL_TREE; }
+ | global_scope nested_name_specifier '*'
+ { $$ = $2; got_scope = NULL_TREE; }
+ ;
+
+/* All uses of explicit global scope must go through this nonterminal so
+ that got_scope will be set before yylex is called to get the next token. */
+global_scope:
+ SCOPE
+ { got_scope = void_type_node; }
+ ;
+
+/* ANSI new-declarator (5.3.4) */
+new_declarator:
+ '*' type_quals new_declarator
+ { $$ = make_pointer_declarator ($2, $3); }
+ | '*' type_quals %prec EMPTY
+ { $$ = make_pointer_declarator ($2, NULL_TREE); }
+ | '&' type_quals new_declarator %prec EMPTY
+ { $$ = make_reference_declarator ($2, $3); }
+ | '&' type_quals %prec EMPTY
+ { $$ = make_reference_declarator ($2, NULL_TREE); }
+ | ptr_to_mem type_quals %prec EMPTY
+ { tree arg = make_pointer_declarator ($2, NULL_TREE);
+ $$ = build_parse_node (SCOPE_REF, $1, arg);
+ }
+ | ptr_to_mem type_quals new_declarator
+ { tree arg = make_pointer_declarator ($2, $3);
+ $$ = build_parse_node (SCOPE_REF, $1, arg);
+ }
+ | direct_new_declarator %prec EMPTY
+ ;
+
+/* ANSI direct-new-declarator (5.3.4) */
+direct_new_declarator:
+ '[' expr ']'
+ { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
+ | direct_new_declarator '[' nonmomentary_expr ']'
+ { $$ = build_parse_node (ARRAY_REF, $$, $3); }
+ ;
+
+/* ANSI abstract-declarator (8.1) */
+absdcl:
+ '*' nonempty_type_quals absdcl
+ { $$ = make_pointer_declarator ($2, $3); }
+ | '*' absdcl
+ { $$ = make_pointer_declarator (NULL_TREE, $2); }
+ | '*' nonempty_type_quals %prec EMPTY
+ { $$ = make_pointer_declarator ($2, NULL_TREE); }
+ | '*' %prec EMPTY
+ { $$ = make_pointer_declarator (NULL_TREE, NULL_TREE); }
+ | '&' nonempty_type_quals absdcl
+ { $$ = make_reference_declarator ($2, $3); }
+ | '&' absdcl
+ { $$ = make_reference_declarator (NULL_TREE, $2); }
+ | '&' nonempty_type_quals %prec EMPTY
+ { $$ = make_reference_declarator ($2, NULL_TREE); }
+ | '&' %prec EMPTY
+ { $$ = make_reference_declarator (NULL_TREE, NULL_TREE); }
+ | ptr_to_mem type_quals %prec EMPTY
+ { tree arg = make_pointer_declarator ($2, NULL_TREE);
+ $$ = build_parse_node (SCOPE_REF, $1, arg);
+ }
+ | ptr_to_mem type_quals absdcl
+ { tree arg = make_pointer_declarator ($2, $3);
+ $$ = build_parse_node (SCOPE_REF, $1, arg);
+ }
+ | direct_abstract_declarator %prec EMPTY
+ ;
+
+/* ANSI direct-abstract-declarator (8.1) */
+direct_abstract_declarator:
+ '(' absdcl ')'
+ { $$ = $2; }
+ /* `(typedef)1' is `int'. */
+ | PAREN_STAR_PAREN
+ | direct_abstract_declarator '(' parmlist ')' type_quals %prec '.'
+ { $$ = build_parse_node (CALL_EXPR, $$, $3, $5); }
+ | direct_abstract_declarator LEFT_RIGHT type_quals %prec '.'
+ { $$ = build_parse_node (CALL_EXPR, $$, empty_parms (), $3); }
+ | direct_abstract_declarator '[' nonmomentary_expr ']' %prec '.'
+ { $$ = build_parse_node (ARRAY_REF, $$, $3); }
+ | direct_abstract_declarator '[' ']' %prec '.'
+ { $$ = build_parse_node (ARRAY_REF, $$, NULL_TREE); }
+ | '(' complex_parmlist ')' type_quals %prec '.'
+ { $$ = build_parse_node (CALL_EXPR, NULL_TREE, $2, $4); }
+ | regcast_or_absdcl type_quals %prec '.'
+ { TREE_OPERAND ($$, 2) = $2; }
+ | fcast_or_absdcl type_quals %prec '.'
+ { TREE_OPERAND ($$, 2) = $2; }
+ | '[' nonmomentary_expr ']' %prec '.'
+ { $$ = build_parse_node (ARRAY_REF, NULL_TREE, $2); }
+ | '[' ']' %prec '.'
+ { $$ = build_parse_node (ARRAY_REF, NULL_TREE, NULL_TREE); }
+ ;
+
+/* For C++, decls and stmts can be intermixed, so we don't need to
+ have a special rule that won't start parsing the stmt section
+ until we have a stmt that parses without errors. */
+
+stmts:
+ stmt
+ | errstmt
+ | stmts stmt
+ | stmts errstmt
+ ;
+
+errstmt: error ';'
+ ;
+
+/* build the LET_STMT node before parsing its contents,
+ so that any LET_STMTs within the context can have their display pointers
+ set up to point at this one. */
+
+.pushlevel: /* empty */
+ { emit_line_note (input_filename, lineno);
+ pushlevel (0);
+ clear_last_expr ();
+ push_momentary ();
+ expand_start_bindings (0); }
+ ;
+
+.poplevel: /* empty */
+ { expand_end_bindings (getdecls (), kept_level_p (), 1);
+ $$ = poplevel (kept_level_p (), 1, 0);
+ pop_momentary (); }
+ ;
+
+/* Read zero or more forward-declarations for labels
+ that nested functions can jump to. */
+maybe_label_decls:
+ /* empty */
+ | label_decls
+ { if (pedantic)
+ pedwarn ("ANSI C++ forbids label declarations"); }
+ ;
+
+label_decls:
+ label_decl
+ | label_decls label_decl
+ ;
+
+label_decl:
+ LABEL identifiers_or_typenames ';'
+ { tree link;
+ for (link = $2; link; link = TREE_CHAIN (link))
+ {
+ tree label = shadow_label (TREE_VALUE (link));
+ C_DECLARED_LABEL_FLAG (label) = 1;
+ declare_nonlocal_label (label);
+ }
+ }
+ ;
+
+/* This is the body of a function definition.
+ It causes syntax errors to ignore to the next openbrace. */
+compstmt_or_error:
+ compstmt
+ {}
+ | error compstmt
+ ;
+
+compstmt: '{' .pushlevel compstmtend .poplevel
+ { $$ = $4; }
+ ;
+
+simple_if:
+ IF
+ { cond_stmt_keyword = "if"; }
+ .pushlevel paren_cond_or_null
+ { emit_line_note (input_filename, lineno);
+ expand_start_cond ($4, 0); }
+ implicitly_scoped_stmt
+ ;
+
+implicitly_scoped_stmt:
+ compstmt
+ { finish_stmt (); }
+ | .pushlevel simple_stmt .poplevel
+ { $$ = $3; }
+ ;
+
+stmt:
+ compstmt
+ { finish_stmt (); }
+ | simple_stmt
+ ;
+
+simple_stmt:
+ decl
+ { finish_stmt (); }
+ | expr ';'
+ {
+ tree expr = $1;
+ emit_line_note (input_filename, lineno);
+ /* Do default conversion if safe and possibly important,
+ in case within ({...}). */
+ if ((TREE_CODE (TREE_TYPE (expr)) == ARRAY_TYPE
+ && lvalue_p (expr))
+ || TREE_CODE (TREE_TYPE (expr)) == FUNCTION_TYPE)
+ expr = default_conversion (expr);
+ cplus_expand_expr_stmt (expr);
+ clear_momentary ();
+ finish_stmt (); }
+ | simple_if ELSE
+ { expand_start_else (); }
+ implicitly_scoped_stmt
+ { expand_end_cond (); }
+ .poplevel
+ { finish_stmt (); }
+ | simple_if %prec IF
+ { expand_end_cond ();
+ expand_end_bindings (getdecls (), kept_level_p (), 1);
+ poplevel (kept_level_p (), 1, 0);
+ pop_momentary ();
+ finish_stmt (); }
+ | WHILE
+ { emit_nop ();
+ emit_line_note (input_filename, lineno);
+ expand_start_loop (1);
+ cond_stmt_keyword = "while"; }
+ .pushlevel paren_cond_or_null
+ { expand_exit_loop_if_false (0, $4); }
+ already_scoped_stmt .poplevel
+ { expand_end_loop ();
+ finish_stmt (); }
+ | DO
+ { emit_nop ();
+ emit_line_note (input_filename, lineno);
+ expand_start_loop_continue_elsewhere (1); }
+ implicitly_scoped_stmt WHILE
+ { expand_loop_continue_here ();
+ cond_stmt_keyword = "do"; }
+ paren_expr_or_null ';'
+ { emit_line_note (input_filename, lineno);
+ expand_exit_loop_if_false (0, $6);
+ expand_end_loop ();
+ clear_momentary ();
+ finish_stmt (); }
+ | FOR
+ { emit_line_note (input_filename, lineno);
+ if (flag_new_for_scope > 0)
+ {
+ /* Conditionalize .pushlevel */
+ pushlevel (0);
+ note_level_for_for ();
+ clear_last_expr ();
+ push_momentary ();
+ expand_start_bindings (0);
+ }
+ }
+ '(' for.init.statement
+ { emit_nop ();
+ emit_line_note (input_filename, lineno);
+ expand_start_loop_continue_elsewhere (1); }
+ .pushlevel xcond ';'
+ { emit_line_note (input_filename, lineno);
+ if ($7) expand_exit_loop_if_false (0, $7); }
+ xexpr ')'
+ /* Don't let the tree nodes for $10 be discarded
+ by clear_momentary during the parsing of the next stmt. */
+ { push_momentary (); }
+ already_scoped_stmt .poplevel
+ { emit_line_note (input_filename, lineno);
+ expand_loop_continue_here ();
+ if ($10) cplus_expand_expr_stmt ($10);
+ pop_momentary ();
+ expand_end_loop ();
+ if (flag_new_for_scope > 0)
+ {
+ expand_end_bindings (getdecls (), kept_level_p (), 1);
+ poplevel (kept_level_p (), 1, 0);
+ pop_momentary ();
+ }
+ finish_stmt (); }
+ | SWITCH .pushlevel '(' condition ')'
+ { emit_line_note (input_filename, lineno);
+ c_expand_start_case ($4);
+ push_switch ();
+ /* Don't let the tree nodes for $4 be discarded by
+ clear_momentary during the parsing of the next stmt. */
+ push_momentary (); }
+ implicitly_scoped_stmt
+ { expand_end_case ($4);
+ pop_momentary ();
+ pop_switch (); }
+ .poplevel
+ { finish_stmt (); }
+ | CASE expr_no_commas ':'
+ { register tree value = check_cp_case_value ($2);
+ register tree label
+ = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
+
+ if (value != error_mark_node)
+ {
+ tree duplicate;
+ int success = pushcase (value, convert_and_check,
+ label, &duplicate);
+ if (success == 1)
+ cp_error ("case label `%E' not within a switch statement", $2);
+ else if (success == 2)
+ {
+ cp_error ("duplicate case value `%E'", $2);
+ cp_error_at ("previously used here", duplicate);
+ }
+ else if (success == 3)
+ warning ("case value out of range");
+ else if (success == 5)
+ cp_error ("case label `%E' within scope of cleanup or variable array", $2);
+ }
+ define_case_label (label);
+ }
+ stmt
+ | CASE expr_no_commas ELLIPSIS expr_no_commas ':'
+ { register tree value1 = check_cp_case_value ($2);
+ register tree value2 = check_cp_case_value ($4);
+ register tree label
+ = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
+
+ if (pedantic)
+ pedwarn ("ANSI C++ forbids range expressions in switch statement");
+ if (value1 != error_mark_node
+ && value2 != error_mark_node)
+ {
+ tree duplicate;
+ int success = pushcase_range (value1, value2,
+ convert_and_check, label,
+ &duplicate);
+ if (success == 1)
+ error ("case label not within a switch statement");
+ else if (success == 2)
+ {
+ error ("duplicate (or overlapping) case value");
+ error_with_decl (duplicate, "this is the first entry overlapping that value");
+ }
+ else if (success == 3)
+ warning ("case value out of range");
+ else if (success == 4)
+ warning ("empty range specified");
+ else if (success == 5)
+ error ("case label within scope of cleanup or variable array");
+ }
+ define_case_label (label);
+ }
+ stmt
+ | DEFAULT ':'
+ {
+ tree duplicate;
+ register tree label
+ = build_decl (LABEL_DECL, NULL_TREE, NULL_TREE);
+ int success = pushcase (NULL_TREE, 0, label, &duplicate);
+ if (success == 1)
+ error ("default label not within a switch statement");
+ else if (success == 2)
+ {
+ error ("multiple default labels in one switch");
+ error_with_decl (duplicate, "this is the first default label");
+ }
+ define_case_label (NULL_TREE);
+ }
+ stmt
+ | BREAK ';'
+ { emit_line_note (input_filename, lineno);
+ if ( ! expand_exit_something ())
+ error ("break statement not within loop or switch"); }
+ | CONTINUE ';'
+ { emit_line_note (input_filename, lineno);
+ if (! expand_continue_loop (0))
+ error ("continue statement not within a loop"); }
+ | RETURN ';'
+ { emit_line_note (input_filename, lineno);
+ c_expand_return (NULL_TREE); }
+ | RETURN expr ';'
+ { emit_line_note (input_filename, lineno);
+ c_expand_return ($2);
+ finish_stmt ();
+ }
+ | asm_keyword maybe_type_qual '(' string ')' ';'
+ { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
+ emit_line_note (input_filename, lineno);
+ expand_asm ($4);
+ finish_stmt ();
+ }
+ /* This is the case with just output operands. */
+ | asm_keyword maybe_type_qual '(' string ':' asm_operands ')' ';'
+ { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
+ emit_line_note (input_filename, lineno);
+ c_expand_asm_operands ($4, $6, NULL_TREE, NULL_TREE,
+ $2 == ridpointers[(int)RID_VOLATILE],
+ input_filename, lineno);
+ finish_stmt ();
+ }
+ /* This is the case with input operands as well. */
+ | asm_keyword maybe_type_qual '(' string ':' asm_operands ':' asm_operands ')' ';'
+ { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
+ emit_line_note (input_filename, lineno);
+ c_expand_asm_operands ($4, $6, $8, NULL_TREE,
+ $2 == ridpointers[(int)RID_VOLATILE],
+ input_filename, lineno);
+ finish_stmt ();
+ }
+ /* This is the case with clobbered registers as well. */
+ | asm_keyword maybe_type_qual '(' string ':' asm_operands ':'
+ asm_operands ':' asm_clobbers ')' ';'
+ { if (TREE_CHAIN ($4)) $4 = combine_strings ($4);
+ emit_line_note (input_filename, lineno);
+ c_expand_asm_operands ($4, $6, $8, $10,
+ $2 == ridpointers[(int)RID_VOLATILE],
+ input_filename, lineno);
+ finish_stmt ();
+ }
+ | GOTO '*' expr ';'
+ { emit_line_note (input_filename, lineno);
+ expand_computed_goto ($3); }
+ | GOTO identifier ';'
+ { tree decl;
+ emit_line_note (input_filename, lineno);
+ decl = lookup_label ($2);
+ TREE_USED (decl) = 1;
+ expand_goto (decl); }
+ | label_colon stmt
+ { finish_stmt (); }
+ | label_colon '}'
+ { error ("label must be followed by statement");
+ yyungetc ('}', 0);
+ finish_stmt (); }
+ | ';'
+ { finish_stmt (); }
+ | try_block
+ ;
+
+function_try_block:
+ TRY
+ {
+ if (! current_function_parms_stored)
+ store_parm_decls ();
+ expand_start_early_try_stmts ();
+ }
+ ctor_initializer_opt compstmt_or_error
+ { expand_end_try_stmts ();
+ expand_start_all_catch (); }
+ handler_seq
+ {
+ expand_end_all_catch ();
+ finish_function (lineno, (int)$3, 0);
+ }
+ ;
+
+try_block:
+ TRY
+ { expand_start_try_stmts (); }
+ compstmt
+ { expand_end_try_stmts ();
+ expand_start_all_catch (); }
+ handler_seq
+ { expand_end_all_catch (); }
+ ;
+
+handler_seq:
+ /* empty */
+ | handler_seq CATCH .pushlevel
+ { dont_allow_type_definitions = "inside exception declarations"; }
+ handler_args
+ { dont_allow_type_definitions = 0; }
+ compstmt
+ { expand_end_catch_block (); }
+ .poplevel
+ ;
+
+type_specifier_seq:
+ typed_typespecs %prec EMPTY
+ | nonempty_type_quals %prec EMPTY
+ ;
+
+handler_args:
+ '(' ELLIPSIS ')'
+ { expand_start_catch_block (NULL_TREE, NULL_TREE); }
+ /* This doesn't allow reference parameters, the below does.
+ | '(' type_specifier_seq absdcl ')'
+ { expand_start_catch_block ($2, $3); }
+ | '(' type_specifier_seq ')'
+ { expand_start_catch_block ($2, NULL_TREE); }
+ | '(' type_specifier_seq notype_declarator ')'
+ { expand_start_catch_block ($2, $3); }
+ | '(' typed_typespecs after_type_declarator ')'
+ { expand_start_catch_block ($2, $3); }
+ This allows reference parameters... */
+ | '(' parm ')'
+ { expand_start_catch_block (TREE_PURPOSE ($2),
+ TREE_VALUE ($2)); }
+ ;
+
+label_colon:
+ IDENTIFIER ':'
+ { tree label;
+ do_label:
+ label = define_label (input_filename, lineno, $1);
+ if (label)
+ expand_label (label);
+ }
+ | PTYPENAME ':'
+ { goto do_label; }
+ | TYPENAME ':'
+ { goto do_label; }
+ ;
+
+for.init.statement:
+ xexpr ';'
+ { if ($1) cplus_expand_expr_stmt ($1); }
+ | decl
+ | '{' compstmtend
+ ;
+
+/* Either a type-qualifier or nothing. First thing in an `asm' statement. */
+
+maybe_type_qual:
+ /* empty */
+ { emit_line_note (input_filename, lineno);
+ $$ = NULL_TREE; }
+ | TYPE_QUAL
+ { emit_line_note (input_filename, lineno); }
+ ;
+
+xexpr:
+ /* empty */
+ { $$ = NULL_TREE; }
+ | expr
+ | error
+ { $$ = NULL_TREE; }
+ ;
+
+/* These are the operands other than the first string and colon
+ in asm ("addextend %2,%1": "=dm" (x), "0" (y), "g" (*x)) */
+asm_operands: /* empty */
+ { $$ = NULL_TREE; }
+ | nonnull_asm_operands
+ ;
+
+nonnull_asm_operands:
+ asm_operand
+ | nonnull_asm_operands ',' asm_operand
+ { $$ = chainon ($$, $3); }
+ ;
+
+asm_operand:
+ STRING '(' expr ')'
+ { $$ = build_tree_list ($$, $3); }
+ ;
+
+asm_clobbers:
+ STRING
+ { $$ = tree_cons (NULL_TREE, $$, NULL_TREE); }
+ | asm_clobbers ',' STRING
+ { $$ = tree_cons (NULL_TREE, $3, $$); }
+ ;
+
+/* This is what appears inside the parens in a function declarator.
+ Its value is represented in the format that grokdeclarator expects.
+
+ In C++, declaring a function with no parameters
+ means that that function takes *no* parameters. */
+
+parmlist: /* empty */
+ {
+ if (strict_prototype)
+ $$ = void_list_node;
+ else
+ $$ = NULL_TREE;
+ }
+ | complex_parmlist
+ | type_id
+ { $$ = tree_cons (NULL_TREE, $$, void_list_node);
+ TREE_PARMLIST ($$) = 1; }
+ ;
+
+/* This nonterminal does not include the common sequence '(' type_id ')',
+ as it is ambiguous and must be disambiguated elsewhere. */
+complex_parmlist:
+ parms
+ {
+ $$ = chainon ($$, void_list_node);
+ TREE_PARMLIST ($$) = 1;
+ }
+ | parms_comma ELLIPSIS
+ {
+ TREE_PARMLIST ($$) = 1;
+ }
+ /* C++ allows an ellipsis without a separating ',' */
+ | parms ELLIPSIS
+ {
+ TREE_PARMLIST ($$) = 1;
+ }
+ | type_id ELLIPSIS
+ {
+ $$ = build_tree_list (NULL_TREE, $$);
+ TREE_PARMLIST ($$) = 1;
+ }
+ | ELLIPSIS
+ {
+ /* ARM $8.2.5 has this as a boxed-off comment. */
+ if (pedantic)
+ warning ("use of `...' without a first argument is non-portable");
+ $$ = NULL_TREE;
+ }
+ | TYPENAME_ELLIPSIS
+ {
+ TREE_PARMLIST ($$) = 1;
+ }
+ | parms TYPENAME_ELLIPSIS
+ {
+ TREE_PARMLIST ($$) = 1;
+ }
+ | type_id TYPENAME_ELLIPSIS
+ {
+ $$ = build_tree_list (NULL_TREE, $$);
+ TREE_PARMLIST ($$) = 1;
+ }
+ | parms ':'
+ {
+ /* This helps us recover from really nasty
+ parse errors, for example, a missing right
+ parenthesis. */
+ yyerror ("possibly missing ')'");
+ $$ = chainon ($$, void_list_node);
+ TREE_PARMLIST ($$) = 1;
+ yyungetc (':', 0);
+ yychar = ')';
+ }
+ | type_id ':'
+ {
+ /* This helps us recover from really nasty
+ parse errors, for example, a missing right
+ parenthesis. */
+ yyerror ("possibly missing ')'");
+ $$ = tree_cons (NULL_TREE, $$, void_list_node);
+ TREE_PARMLIST ($$) = 1;
+ yyungetc (':', 0);
+ yychar = ')';
+ }
+ ;
+
+/* A nonempty list of parameter declarations or type names. */
+parms:
+ named_parm
+ { $$ = build_tree_list (NULL_TREE, $$); }
+ | parm '=' init
+ { $$ = build_tree_list ($3, $$); }
+ | parms_comma full_parm
+ { $$ = chainon ($$, $2); }
+ | parms_comma bad_parm
+ { $$ = chainon ($$, build_tree_list (NULL_TREE, $2)); }
+ | parms_comma bad_parm '=' init
+ { $$ = chainon ($$, build_tree_list ($4, $2)); }
+ ;
+
+parms_comma:
+ parms ','
+ | type_id ','
+ { $$ = build_tree_list (NULL_TREE, $$); }
+ ;
+
+/* A single parameter declaration or parameter type name,
+ as found in a parmlist. The first four cases make up for 10%
+ of the time spent parsing C++. We cannot use them because
+ of `int id[]' which won't get parsed properly. */
+named_parm:
+/*
+ typed_declspecs dont_see_typename '*' IDENTIFIER
+ { tree specs = strip_attrs ($1);
+ $$ = build_tree_list (specs, build_parse_node (INDIRECT_REF, $4));
+ see_typename (); }
+ | typed_declspecs dont_see_typename '&' IDENTIFIER
+ { tree specs = strip_attrs ($1);
+ $$ = build_tree_list (specs, build_parse_node (ADDR_EXPR, $4));
+ see_typename (); }
+ | TYPENAME IDENTIFIER
+ { $$ = build_tree_list (get_decl_list ($$), $2); }
+ | TYPESPEC IDENTIFIER
+ { $$ = build_tree_list (get_decl_list ($$), $2); }
+ | */
+ /* Here we expand typed_declspecs inline to avoid mis-parsing of
+ TYPESPEC IDENTIFIER. */
+ typed_declspecs1 declarator
+ { tree specs = strip_attrs ($1);
+ $$ = build_tree_list (specs, $2); }
+ | typed_typespecs declarator
+ { $$ = build_tree_list ($$, $2); }
+ | typespec declarator
+ { $$ = build_tree_list (get_decl_list ($$), $2); }
+ | typed_declspecs1 absdcl
+ { tree specs = strip_attrs ($1);
+ $$ = build_tree_list (specs, $2); }
+ | typed_declspecs1 %prec EMPTY
+ { tree specs = strip_attrs ($1);
+ $$ = build_tree_list (specs, NULL_TREE); }
+ | declmods notype_declarator
+ { tree specs = strip_attrs ($1);
+ $$ = build_tree_list (specs, $2); }
+ ;
+
+full_parm:
+ parm maybe_init
+ { $$ = build_tree_list ($2, $$); }
+ ;
+
+parm:
+ named_parm
+ | type_id
+ ;
+
+see_typename: %prec EMPTY
+ { see_typename (); }
+ ;
+
+/*
+dont_see_typename: %prec EMPTY
+ { dont_see_typename (); }
+ ;
+
+try_for_typename:
+ {
+ if ($<ttype>-1 == error_mark_node)
+ $$ = 0;
+ else
+ {
+ $$ = 1;
+ pushclass ($<ttype>-1, 1);
+ }
+ }
+ ;
+*/
+
+bad_parm:
+ /* empty */ %prec EMPTY
+ {
+ error ("type specifier omitted for parameter");
+ $$ = build_tree_list (integer_type_node, NULL_TREE);
+ }
+ | notype_declarator
+ {
+ error ("type specifier omitted for parameter");
+ $$ = build_tree_list (integer_type_node, $$);
+ }
+ ;
+
+exception_specification_opt:
+ %prec EMPTY /* empty */
+ { $$ = NULL_TREE; }
+ | THROW '(' ansi_raise_identifiers ')' %prec EMPTY
+ { $$ = $3; }
+ | THROW LEFT_RIGHT %prec EMPTY
+ { $$ = build_decl_list (NULL_TREE, NULL_TREE); }
+ ;
+
+ansi_raise_identifier:
+ type_id
+ { $$ = build_decl_list (NULL_TREE, groktypename($$)); }
+ ;
+
+ansi_raise_identifiers:
+ ansi_raise_identifier
+ | ansi_raise_identifiers ',' ansi_raise_identifier
+ {
+ TREE_CHAIN ($3) = $$;
+ $$ = $3;
+ }
+ ;
+
+conversion_declarator:
+ /* empty */ %prec EMPTY
+ { $$ = NULL_TREE; }
+ | '*' type_quals conversion_declarator
+ { $$ = make_pointer_declarator ($2, $3); }
+ | '&' type_quals conversion_declarator
+ { $$ = make_reference_declarator ($2, $3); }
+ | ptr_to_mem type_quals conversion_declarator
+ { tree arg = make_pointer_declarator ($2, $3);
+ $$ = build_parse_node (SCOPE_REF, $1, arg);
+ }
+ ;
+
+operator: OPERATOR
+ { got_scope = NULL_TREE; }
+ ;
+
+operator_name:
+ operator '*'
+ { $$ = ansi_opname[MULT_EXPR]; }
+ | operator '/'
+ { $$ = ansi_opname[TRUNC_DIV_EXPR]; }
+ | operator '%'
+ { $$ = ansi_opname[TRUNC_MOD_EXPR]; }
+ | operator '+'
+ { $$ = ansi_opname[PLUS_EXPR]; }
+ | operator '-'
+ { $$ = ansi_opname[MINUS_EXPR]; }
+ | operator '&'
+ { $$ = ansi_opname[BIT_AND_EXPR]; }
+ | operator '|'
+ { $$ = ansi_opname[BIT_IOR_EXPR]; }
+ | operator '^'
+ { $$ = ansi_opname[BIT_XOR_EXPR]; }
+ | operator '~'
+ { $$ = ansi_opname[BIT_NOT_EXPR]; }
+ | operator ','
+ { $$ = ansi_opname[COMPOUND_EXPR]; }
+ | operator ARITHCOMPARE
+ { $$ = ansi_opname[$2]; }
+ | operator '<'
+ { $$ = ansi_opname[LT_EXPR]; }
+ | operator '>'
+ { $$ = ansi_opname[GT_EXPR]; }
+ | operator EQCOMPARE
+ { $$ = ansi_opname[$2]; }
+ | operator ASSIGN
+ { $$ = ansi_assopname[$2]; }
+ | operator '='
+ { $$ = ansi_opname [MODIFY_EXPR]; }
+ | operator LSHIFT
+ { $$ = ansi_opname[$2]; }
+ | operator RSHIFT
+ { $$ = ansi_opname[$2]; }
+ | operator PLUSPLUS
+ { $$ = ansi_opname[POSTINCREMENT_EXPR]; }
+ | operator MINUSMINUS
+ { $$ = ansi_opname[PREDECREMENT_EXPR]; }
+ | operator ANDAND
+ { $$ = ansi_opname[TRUTH_ANDIF_EXPR]; }
+ | operator OROR
+ { $$ = ansi_opname[TRUTH_ORIF_EXPR]; }
+ | operator '!'
+ { $$ = ansi_opname[TRUTH_NOT_EXPR]; }
+ | operator '?' ':'
+ { $$ = ansi_opname[COND_EXPR]; }
+ | operator MIN_MAX
+ { $$ = ansi_opname[$2]; }
+ | operator POINTSAT %prec EMPTY
+ { $$ = ansi_opname[COMPONENT_REF]; }
+ | operator POINTSAT_STAR %prec EMPTY
+ { $$ = ansi_opname[MEMBER_REF]; }
+ | operator LEFT_RIGHT
+ { $$ = ansi_opname[CALL_EXPR]; }
+ | operator '[' ']'
+ { $$ = ansi_opname[ARRAY_REF]; }
+ | operator NEW %prec EMPTY
+ { $$ = ansi_opname[NEW_EXPR]; }
+ | operator DELETE %prec EMPTY
+ { $$ = ansi_opname[DELETE_EXPR]; }
+ | operator NEW '[' ']'
+ { $$ = ansi_opname[VEC_NEW_EXPR]; }
+ | operator DELETE '[' ']'
+ { $$ = ansi_opname[VEC_DELETE_EXPR]; }
+ /* Names here should be looked up in class scope ALSO. */
+ | operator type_specifier_seq conversion_declarator
+ { $$ = grokoptypename ($2, $3); }
+ | operator error
+ { $$ = ansi_opname[ERROR_MARK]; }
+ ;
+
+%%
+
+#ifdef SPEW_DEBUG
+const char *
+debug_yytranslate (value)
+ int value;
+{
+ return yytname[YYTRANSLATE (value)];
+}
+
+#endif
diff --git a/contrib/gcc/cp/pt.c b/contrib/gcc/cp/pt.c
new file mode 100644
index 0000000..3ce0224
--- /dev/null
+++ b/contrib/gcc/cp/pt.c
@@ -0,0 +1,2694 @@
+/* Handle parameterized types (templates) for GNU C++.
+ Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+ Written by Ken Raeburn (raeburn@cygnus.com) while at Watchmaker Computing.
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+/* Known bugs or deficiencies include:
+ * templates for class static data don't work (methods only)
+ * duplicated method templates can crash the compiler
+ * interface/impl data is taken from file defining the template
+ * all methods must be provided in header files; can't use a source
+ file that contains only the method templates and "just win"
+ * method templates must be seen before the expansion of the
+ class template is done
+ */
+
+#include "config.h"
+#include <stdio.h>
+#include "obstack.h"
+
+#include "tree.h"
+#include "flags.h"
+#include "cp-tree.h"
+#include "decl.h"
+#include "parse.h"
+#include "lex.h"
+#include "output.h"
+#include "defaults.h"
+
+extern struct obstack permanent_obstack;
+
+extern int lineno;
+extern char *input_filename;
+struct pending_inline *pending_template_expansions;
+
+int processing_template_decl;
+int processing_template_defn;
+
+/* This is a kludge to handle instantiation of template methods that are
+ used before their definition. It should not be necessary after the
+ template rewrite. */
+static tree template_classes;
+
+#define obstack_chunk_alloc xmalloc
+#define obstack_chunk_free free
+
+static int unify ();
+static void add_pending_template ();
+
+void overload_template_name (), pop_template_decls ();
+
+/* We've got a template header coming up; set obstacks up to save the
+ nodes created permanently. (There might be cases with nested templates
+ where we don't have to do this, but they aren't implemented, and it
+ probably wouldn't be worth the effort.) */
+void
+begin_template_parm_list ()
+{
+ pushlevel (0);
+ push_obstacks (&permanent_obstack, &permanent_obstack);
+ pushlevel (0);
+}
+
+/* Process information from new template parameter NEXT and append it to the
+ LIST being built. The rules for use of a template parameter type name
+ by later parameters are not well-defined for us just yet. However, the
+ only way to avoid having to parse expressions of unknown complexity (and
+ with tokens of unknown types) is to disallow it completely. So for now,
+ that is what is assumed. */
+tree
+process_template_parm (list, next)
+ tree list, next;
+{
+ tree parm;
+ tree decl = 0;
+ tree defval;
+ int is_type;
+ parm = next;
+ my_friendly_assert (TREE_CODE (parm) == TREE_LIST, 259);
+ defval = TREE_PURPOSE (parm);
+ parm = TREE_VALUE (parm);
+ is_type = TREE_PURPOSE (parm) == class_type_node;
+ if (!is_type)
+ {
+ tree tinfo = 0;
+ my_friendly_assert (TREE_CODE (TREE_PURPOSE (parm)) == TREE_LIST, 260);
+ /* is a const-param */
+ parm = grokdeclarator (TREE_VALUE (parm), TREE_PURPOSE (parm),
+ PARM, 0, NULL_TREE, NULL_TREE);
+ /* A template parameter is not modifiable. */
+ TREE_READONLY (parm) = 1;
+ if (IS_AGGR_TYPE (TREE_TYPE (parm)))
+ {
+ sorry ("aggregate template parameter types");
+ TREE_TYPE (parm) = void_type_node;
+ }
+ tinfo = make_node (TEMPLATE_CONST_PARM);
+ my_friendly_assert (TREE_PERMANENT (tinfo), 260.5);
+ if (TREE_PERMANENT (parm) == 0)
+ {
+ parm = copy_node (parm);
+ TREE_PERMANENT (parm) = 1;
+ }
+ TREE_TYPE (tinfo) = TREE_TYPE (parm);
+ decl = build_decl (CONST_DECL, DECL_NAME (parm), TREE_TYPE (parm));
+ DECL_INITIAL (decl) = tinfo;
+ DECL_INITIAL (parm) = tinfo;
+ }
+ else
+ {
+ tree t = make_node (TEMPLATE_TYPE_PARM);
+ decl = build_decl (TYPE_DECL, TREE_VALUE (parm), t);
+ TYPE_MAIN_DECL (t) = decl;
+ parm = decl;
+ if (defval)
+ {
+ if (IDENTIFIER_HAS_TYPE_VALUE (defval))
+ defval = IDENTIFIER_TYPE_VALUE (defval);
+ else
+ defval = TREE_TYPE (IDENTIFIER_GLOBAL_VALUE (defval));
+ }
+ }
+ SET_DECL_ARTIFICIAL (decl);
+ pushdecl (decl);
+ parm = build_tree_list (defval, parm);
+ return chainon (list, parm);
+}
+
+/* The end of a template parameter list has been reached. Process the
+ tree list into a parameter vector, converting each parameter into a more
+ useful form. Type parameters are saved as IDENTIFIER_NODEs, and others
+ as PARM_DECLs. */
+
+tree
+end_template_parm_list (parms)
+ tree parms;
+{
+ int nparms = 0;
+ int saw_default = 0;
+ tree saved_parmlist;
+ tree parm;
+ for (parm = parms; parm; parm = TREE_CHAIN (parm))
+ nparms++;
+ saved_parmlist = make_tree_vec (nparms);
+
+ for (parm = parms, nparms = 0; parm; parm = TREE_CHAIN (parm), nparms++)
+ {
+ tree p = TREE_VALUE (parm);
+ if (TREE_PURPOSE (parm))
+ saw_default = 1;
+ else if (saw_default)
+ {
+ error ("if a default argument is given for one template parameter");
+ error ("default arguments must be given for all subsequent");
+ error ("parameters as well");
+ }
+
+ if (TREE_CODE (p) == TYPE_DECL)
+ {
+ tree t = TREE_TYPE (p);
+ TEMPLATE_TYPE_SET_INFO (t, saved_parmlist, nparms);
+ }
+ else
+ {
+ tree tinfo = DECL_INITIAL (p);
+ DECL_INITIAL (p) = NULL_TREE;
+ TEMPLATE_CONST_SET_INFO (tinfo, saved_parmlist, nparms);
+ }
+ TREE_VEC_ELT (saved_parmlist, nparms) = parm;
+ }
+ set_current_level_tags_transparency (1);
+ processing_template_decl++;
+ return saved_parmlist;
+}
+
+/* end_template_decl is called after a template declaration is seen.
+ D1 is template header; D2 is class_head_sans_basetype or a
+ TEMPLATE_DECL with its DECL_RESULT field set. */
+void
+end_template_decl (d1, d2, is_class, defn)
+ tree d1, d2, is_class;
+ int defn;
+{
+ tree decl;
+ struct template_info *tmpl;
+
+ tmpl = (struct template_info *) obstack_alloc (&permanent_obstack,
+ sizeof (struct template_info));
+ tmpl->text = 0;
+ tmpl->length = 0;
+ tmpl->aggr = is_class;
+
+ /* cloned from reinit_parse_for_template */
+ tmpl->filename = input_filename;
+ tmpl->lineno = lineno;
+ tmpl->parm_vec = d1; /* [eichin:19911015.2306EST] */
+
+ if (d2 == NULL_TREE || d2 == error_mark_node)
+ {
+ decl = 0;
+ goto lose;
+ }
+
+ if (is_class)
+ {
+ decl = build_lang_decl (TEMPLATE_DECL, d2, NULL_TREE);
+ GNU_xref_decl (current_function_decl, decl);
+ }
+ else
+ {
+ if (TREE_CODE (d2) == TEMPLATE_DECL)
+ decl = d2;
+ else
+ {
+ /* Class destructor templates and operator templates are
+ slipping past as non-template nodes. Process them here, since
+ I haven't figured out where to catch them earlier. I could
+ go do that, but it's a choice between getting that done and
+ staying only N months behind schedule. Sorry.... */
+ enum tree_code code;
+ my_friendly_assert (TREE_CODE (d2) == CALL_EXPR, 263);
+ code = TREE_CODE (TREE_OPERAND (d2, 0));
+ my_friendly_assert (code == BIT_NOT_EXPR
+ || code == OP_IDENTIFIER
+ || code == SCOPE_REF, 264);
+ d2 = grokdeclarator (d2, NULL_TREE, MEMFUNCDEF, 0, NULL_TREE, NULL_TREE);
+ decl = build_lang_decl (TEMPLATE_DECL, DECL_NAME (d2),
+ TREE_TYPE (d2));
+ DECL_TEMPLATE_RESULT (decl) = d2;
+ DECL_CONTEXT (decl) = DECL_CONTEXT (d2);
+ DECL_CLASS_CONTEXT (decl) = DECL_CLASS_CONTEXT (d2);
+ DECL_NAME (decl) = DECL_NAME (d2);
+ TREE_TYPE (decl) = TREE_TYPE (d2);
+ if (interface_unknown && flag_external_templates
+ && ! flag_alt_external_templates
+ && ! DECL_IN_SYSTEM_HEADER (decl))
+ warn_if_unknown_interface (decl);
+ TREE_PUBLIC (decl) = TREE_PUBLIC (d2) = flag_external_templates && !interface_unknown;
+ DECL_EXTERNAL (decl) = (DECL_EXTERNAL (d2)
+ && !(DECL_CLASS_CONTEXT (d2)
+ && !DECL_THIS_EXTERN (d2)));
+ }
+
+ /* All routines creating TEMPLATE_DECL nodes should now be using
+ build_lang_decl, which will have set this up already. */
+ my_friendly_assert (DECL_LANG_SPECIFIC (decl) != 0, 265);
+
+ /* @@ Somewhere, permanent allocation isn't being used. */
+ if (! DECL_TEMPLATE_IS_CLASS (decl)
+ && TREE_CODE (DECL_TEMPLATE_RESULT (decl)) == FUNCTION_DECL)
+ {
+ tree result = DECL_TEMPLATE_RESULT (decl);
+ /* Will do nothing if allocation was already permanent. */
+ DECL_ARGUMENTS (result) = copy_to_permanent (DECL_ARGUMENTS (result));
+ }
+
+ /* If this is for a method, there's an extra binding level here. */
+ if (DECL_CONTEXT (DECL_TEMPLATE_RESULT (decl)) != NULL_TREE)
+ {
+ /* @@ Find out where this should be getting set! */
+ tree r = DECL_TEMPLATE_RESULT (decl);
+ if (DECL_LANG_SPECIFIC (r) && DECL_CLASS_CONTEXT (r) == NULL_TREE)
+ DECL_CLASS_CONTEXT (r) = DECL_CONTEXT (r);
+ }
+ }
+ DECL_TEMPLATE_INFO (decl) = tmpl;
+ DECL_TEMPLATE_PARMS (decl) = d1;
+
+ /* So that duplicate_decls can do the right thing. */
+ if (defn)
+ DECL_INITIAL (decl) = error_mark_node;
+
+ /* If context of decl is non-null (i.e., method template), add it
+ to the appropriate class template, and pop the binding levels. */
+ if (! is_class && DECL_CONTEXT (DECL_TEMPLATE_RESULT (decl)) != NULL_TREE)
+ {
+ tree ctx = DECL_CONTEXT (DECL_TEMPLATE_RESULT (decl));
+ tree tmpl, t;
+ my_friendly_assert (TREE_CODE (ctx) == UNINSTANTIATED_P_TYPE, 266);
+ tmpl = UPT_TEMPLATE (ctx);
+ for (t = DECL_TEMPLATE_MEMBERS (tmpl); t; t = TREE_CHAIN (t))
+ if (TREE_PURPOSE (t) == DECL_NAME (decl)
+ && duplicate_decls (decl, TREE_VALUE (t)))
+ goto already_there;
+ DECL_TEMPLATE_MEMBERS (tmpl) =
+ perm_tree_cons (DECL_NAME (decl), decl, DECL_TEMPLATE_MEMBERS (tmpl));
+ already_there:
+ poplevel (0, 0, 0);
+ poplevel (0, 0, 0);
+ }
+ /* Otherwise, go back to top level first, and push the template decl
+ again there. */
+ else
+ {
+ poplevel (0, 0, 0);
+ poplevel (0, 0, 0);
+ pushdecl (decl);
+ }
+ lose:
+#if 0 /* It happens sometimes, with syntactic or semantic errors.
+
+ One specific case:
+ template <class A, int X, int Y> class Foo { ... };
+ template <class A, int X, int y> Foo<X,Y>::method (Foo& x) { ... }
+ Note the missing "A" in the class containing "method". */
+ my_friendly_assert (global_bindings_p (), 267);
+#else
+ while (! global_bindings_p ())
+ poplevel (0, 0, 0);
+#endif
+ pop_obstacks ();
+ processing_template_decl--;
+ (void) get_pending_sizes ();
+}
+
+tree tsubst PROTO ((tree, tree*, int, tree));
+
+/* Convert all template arguments to their appropriate types, and return
+ a vector containing the resulting values. If any error occurs, return
+ error_mark_node. */
+static tree
+coerce_template_parms (parms, arglist, in_decl)
+ tree parms, arglist;
+ tree in_decl;
+{
+ int nparms, nargs, i, lost = 0;
+ tree vec;
+
+ if (arglist == NULL_TREE)
+ nargs = 0;
+ else if (TREE_CODE (arglist) == TREE_VEC)
+ nargs = TREE_VEC_LENGTH (arglist);
+ else
+ nargs = list_length (arglist);
+
+ nparms = TREE_VEC_LENGTH (parms);
+
+ if (nargs > nparms
+ || (nargs < nparms
+ && TREE_PURPOSE (TREE_VEC_ELT (parms, nargs)) == NULL_TREE))
+ {
+ error ("incorrect number of parameters (%d, should be %d)",
+ nargs, nparms);
+ if (in_decl)
+ cp_error_at ("in template expansion for decl `%D'", in_decl);
+ return error_mark_node;
+ }
+
+ if (arglist && TREE_CODE (arglist) == TREE_VEC)
+ vec = copy_node (arglist);
+ else
+ {
+ vec = make_tree_vec (nparms);
+ for (i = 0; i < nparms; i++)
+ {
+ tree arg;
+
+ if (arglist)
+ {
+ arg = arglist;
+ arglist = TREE_CHAIN (arglist);
+
+ if (arg == error_mark_node)
+ lost++;
+ else
+ arg = TREE_VALUE (arg);
+ }
+ else
+ arg = TREE_PURPOSE (TREE_VEC_ELT (parms, i));
+
+ TREE_VEC_ELT (vec, i) = arg;
+ }
+ }
+ for (i = 0; i < nparms; i++)
+ {
+ tree arg = TREE_VEC_ELT (vec, i);
+ tree parm = TREE_VALUE (TREE_VEC_ELT (parms, i));
+ tree val = 0;
+ int is_type, requires_type;
+
+ is_type = TREE_CODE_CLASS (TREE_CODE (arg)) == 't';
+ requires_type = TREE_CODE (parm) == TYPE_DECL;
+ if (is_type != requires_type)
+ {
+ if (in_decl)
+ cp_error ("type/value mismatch in template parameter list for `%D'",
+ in_decl);
+ lost++;
+ TREE_VEC_ELT (vec, i) = error_mark_node;
+ continue;
+ }
+ if (is_type)
+ val = groktypename (arg);
+ else
+ {
+ tree t = tsubst (TREE_TYPE (parm), &TREE_VEC_ELT (vec, 0),
+ TREE_VEC_LENGTH (vec), in_decl);
+ val = digest_init (t, arg, (tree *) 0);
+
+ if (val == error_mark_node)
+ ;
+
+ /* 14.2: Other template-arguments must be constant-expressions,
+ addresses of objects or functions with external linkage, or of
+ static class members. */
+ else if (!TREE_CONSTANT (val))
+ {
+ cp_error ("non-const `%E' cannot be used as template argument",
+ arg);
+ val = error_mark_node;
+ }
+ else if (POINTER_TYPE_P (TREE_TYPE (val))
+ && ! integer_zerop (val)
+ && TREE_CODE (TREE_TYPE (TREE_TYPE (val))) != OFFSET_TYPE
+ && TREE_CODE (TREE_TYPE (TREE_TYPE (val))) != METHOD_TYPE)
+ {
+ t = val;
+ STRIP_NOPS (t);
+ if (TREE_CODE (t) == ADDR_EXPR)
+ {
+ tree a = TREE_OPERAND (t, 0);
+ STRIP_NOPS (a);
+ if (TREE_CODE (a) == STRING_CST)
+ {
+ cp_error ("string literal %E is not a valid template argument", a);
+ error ("because it is the address of an object with static linkage");
+ val = error_mark_node;
+ }
+ else if (TREE_CODE (a) != VAR_DECL
+ && TREE_CODE (a) != FUNCTION_DECL)
+ goto bad;
+ else if (! DECL_PUBLIC (a))
+ {
+ cp_error ("address of non-extern `%E' cannot be used as template argument", a);
+ val = error_mark_node;
+ }
+ }
+ else
+ {
+ bad:
+ cp_error ("`%E' is not a valid template argument", t);
+ error ("it must be %s%s with external linkage",
+ TREE_CODE (TREE_TYPE (val)) == POINTER_TYPE
+ ? "a pointer to " : "",
+ TREE_CODE (TREE_TYPE (TREE_TYPE (val))) == FUNCTION_TYPE
+ ? "a function" : "an object");
+ val = error_mark_node;
+ }
+ }
+ }
+
+ if (val == error_mark_node)
+ lost++;
+
+ TREE_VEC_ELT (vec, i) = val;
+ }
+ if (lost)
+ return error_mark_node;
+ return vec;
+}
+
+/* Given class template name and parameter list, produce a user-friendly name
+ for the instantiation. */
+static char *
+mangle_class_name_for_template (name, parms, arglist)
+ char *name;
+ tree parms, arglist;
+{
+ static struct obstack scratch_obstack;
+ static char *scratch_firstobj;
+ int i, nparms;
+
+ if (!scratch_firstobj)
+ {
+ gcc_obstack_init (&scratch_obstack);
+ scratch_firstobj = obstack_alloc (&scratch_obstack, 1);
+ }
+ else
+ obstack_free (&scratch_obstack, scratch_firstobj);
+
+#if 0
+#define buflen sizeof(buf)
+#define check if (bufp >= buf+buflen-1) goto too_long
+#define ccat(c) *bufp++=(c); check
+#define advance bufp+=strlen(bufp); check
+#define cat(s) strncpy(bufp, s, buf+buflen-bufp-1); advance
+#else
+#define check
+#define ccat(c) obstack_1grow (&scratch_obstack, (c));
+#define advance
+#define cat(s) obstack_grow (&scratch_obstack, (s), strlen (s))
+#endif
+
+ cat (name);
+ ccat ('<');
+ nparms = TREE_VEC_LENGTH (parms);
+ my_friendly_assert (nparms == TREE_VEC_LENGTH (arglist), 268);
+ for (i = 0; i < nparms; i++)
+ {
+ tree parm = TREE_VALUE (TREE_VEC_ELT (parms, i));
+ tree arg = TREE_VEC_ELT (arglist, i);
+
+ if (i)
+ ccat (',');
+
+ if (TREE_CODE (parm) == TYPE_DECL)
+ {
+ cat (type_as_string (arg, 0));
+ continue;
+ }
+ else
+ my_friendly_assert (TREE_CODE (parm) == PARM_DECL, 269);
+
+ if (TREE_CODE (arg) == TREE_LIST)
+ {
+ /* New list cell was built because old chain link was in
+ use. */
+ my_friendly_assert (TREE_PURPOSE (arg) == NULL_TREE, 270);
+ arg = TREE_VALUE (arg);
+ }
+ /* No need to check arglist against parmlist here; we did that
+ in coerce_template_parms, called from lookup_template_class. */
+ cat (expr_as_string (arg, 0));
+ }
+ {
+ char *bufp = obstack_next_free (&scratch_obstack);
+ int offset = 0;
+ while (bufp[offset - 1] == ' ')
+ offset--;
+ obstack_blank_fast (&scratch_obstack, offset);
+
+ /* B<C<char> >, not B<C<char>> */
+ if (bufp[offset - 1] == '>')
+ ccat (' ');
+ }
+ ccat ('>');
+ ccat ('\0');
+ return (char *) obstack_base (&scratch_obstack);
+
+#if 0
+ too_long:
+#endif
+ fatal ("out of (preallocated) string space creating template instantiation name");
+ /* NOTREACHED */
+ return NULL;
+}
+
+/* Given an IDENTIFIER_NODE (type TEMPLATE_DECL) and a chain of
+ parameters, find the desired type.
+
+ D1 is the PTYPENAME terminal, and ARGLIST is the list of arguments.
+ Since ARGLIST is build on the decl_obstack, we must copy it here
+ to keep it from being reclaimed when the decl storage is reclaimed.
+
+ IN_DECL, if non-NULL, is the template declaration we are trying to
+ instantiate. */
+tree
+lookup_template_class (d1, arglist, in_decl)
+ tree d1, arglist;
+ tree in_decl;
+{
+ tree template, parmlist;
+ char *mangled_name;
+ tree id;
+
+ my_friendly_assert (TREE_CODE (d1) == IDENTIFIER_NODE, 272);
+ template = IDENTIFIER_GLOBAL_VALUE (d1); /* XXX */
+ if (! template)
+ template = IDENTIFIER_CLASS_VALUE (d1);
+ /* With something like `template <class T> class X class X { ... };'
+ we could end up with D1 having nothing but an IDENTIFIER_LOCAL_VALUE.
+ We don't want to do that, but we have to deal with the situation, so
+ let's give them some syntax errors to chew on instead of a crash. */
+ if (! template)
+ return error_mark_node;
+ if (TREE_CODE (template) != TEMPLATE_DECL)
+ {
+ cp_error ("non-template type `%T' used as a template", d1);
+ if (in_decl)
+ cp_error_at ("for template declaration `%D'", in_decl);
+ return error_mark_node;
+ }
+ parmlist = DECL_TEMPLATE_PARMS (template);
+
+ arglist = coerce_template_parms (parmlist, arglist, template);
+ if (arglist == error_mark_node)
+ return error_mark_node;
+ if (uses_template_parms (arglist))
+ {
+ tree t = make_lang_type (UNINSTANTIATED_P_TYPE);
+ tree d;
+ id = make_anon_name ();
+ d = build_decl (TYPE_DECL, id, t);
+ TYPE_NAME (t) = d;
+ TYPE_VALUES (t) = build_tree_list (template, arglist);
+ pushdecl_top_level (d);
+ }
+ else
+ {
+ mangled_name = mangle_class_name_for_template (IDENTIFIER_POINTER (d1),
+ parmlist, arglist);
+ id = get_identifier (mangled_name);
+ }
+ if (!IDENTIFIER_TEMPLATE (id))
+ {
+ arglist = copy_to_permanent (arglist);
+ IDENTIFIER_TEMPLATE (id) = perm_tree_cons (template, arglist, NULL_TREE);
+ }
+ return id;
+}
+
+void
+push_template_decls (parmlist, arglist, class_level)
+ tree parmlist, arglist;
+ int class_level;
+{
+ int i, nparms;
+
+ /* Don't want to push values into global context. */
+ if (!class_level)
+ {
+ pushlevel (1);
+ declare_pseudo_global_level ();
+ }
+
+ nparms = TREE_VEC_LENGTH (parmlist);
+
+ for (i = 0; i < nparms; i++)
+ {
+ int requires_type, is_type;
+ tree parm = TREE_VALUE (TREE_VEC_ELT (parmlist, i));
+ tree arg = TREE_VEC_ELT (arglist, i);
+ tree decl = 0;
+
+ requires_type = TREE_CODE (parm) == TYPE_DECL;
+ is_type = TREE_CODE_CLASS (TREE_CODE (arg)) == 't';
+ if (is_type)
+ {
+ /* add typename to namespace */
+ if (!requires_type)
+ {
+ error ("template use error: type provided where value needed");
+ continue;
+ }
+ decl = arg;
+ my_friendly_assert (TREE_CODE_CLASS (TREE_CODE (decl)) == 't', 273);
+ decl = build_decl (TYPE_DECL, DECL_NAME (parm), decl);
+ }
+ else
+ {
+ /* add const decl to namespace */
+ tree val;
+ tree parmtype;
+ if (requires_type)
+ {
+ error ("template use error: value provided where type needed");
+ continue;
+ }
+ parmtype = tsubst (TREE_TYPE (parm), &TREE_VEC_ELT (arglist, 0),
+ TREE_VEC_LENGTH (arglist), NULL_TREE);
+ val = digest_init (parmtype, arg, (tree *) 0);
+ if (val != error_mark_node)
+ {
+ decl = build_decl (CONST_DECL, DECL_NAME (parm),
+ parmtype);
+ DECL_INITIAL (decl) = val;
+ TREE_READONLY (decl) = 1;
+ }
+ }
+ if (decl != 0)
+ {
+ SET_DECL_ARTIFICIAL (decl);
+ layout_decl (decl, 0);
+ if (class_level)
+ pushdecl_class_level (decl);
+ else
+ pushdecl (decl);
+ }
+ }
+}
+
+void
+pop_template_decls (parmlist, arglist, class_level)
+ tree parmlist, arglist;
+ int class_level;
+{
+ if (!class_level)
+ poplevel (0, 0, 0);
+}
+
+/* Should be defined in parse.h. */
+extern int yychar;
+
+int
+uses_template_parms (t)
+ tree t;
+{
+ if (!t)
+ return 0;
+ switch (TREE_CODE (t))
+ {
+ case INDIRECT_REF:
+ case COMPONENT_REF:
+ /* We assume that the object must be instantiated in order to build
+ the COMPONENT_REF, so we test only whether the type of the
+ COMPONENT_REF uses template parms. */
+ return uses_template_parms (TREE_TYPE (t));
+
+ case IDENTIFIER_NODE:
+ if (!IDENTIFIER_TEMPLATE (t))
+ return 0;
+ return uses_template_parms (TREE_VALUE (IDENTIFIER_TEMPLATE (t)));
+
+ /* aggregates of tree nodes */
+ case TREE_VEC:
+ {
+ int i = TREE_VEC_LENGTH (t);
+ while (i--)
+ if (uses_template_parms (TREE_VEC_ELT (t, i)))
+ return 1;
+ return 0;
+ }
+ case TREE_LIST:
+ if (uses_template_parms (TREE_PURPOSE (t))
+ || uses_template_parms (TREE_VALUE (t)))
+ return 1;
+ return uses_template_parms (TREE_CHAIN (t));
+
+ /* constructed type nodes */
+ case POINTER_TYPE:
+ case REFERENCE_TYPE:
+ return uses_template_parms (TREE_TYPE (t));
+ case RECORD_TYPE:
+ if (TYPE_PTRMEMFUNC_FLAG (t))
+ return uses_template_parms (TYPE_PTRMEMFUNC_FN_TYPE (t));
+ case UNION_TYPE:
+ if (!TYPE_NAME (t))
+ return 0;
+ if (!TYPE_IDENTIFIER (t))
+ return 0;
+ return uses_template_parms (TYPE_IDENTIFIER (t));
+ case FUNCTION_TYPE:
+ if (uses_template_parms (TYPE_ARG_TYPES (t)))
+ return 1;
+ return uses_template_parms (TREE_TYPE (t));
+ case ARRAY_TYPE:
+ if (uses_template_parms (TYPE_DOMAIN (t)))
+ return 1;
+ return uses_template_parms (TREE_TYPE (t));
+ case OFFSET_TYPE:
+ if (uses_template_parms (TYPE_OFFSET_BASETYPE (t)))
+ return 1;
+ return uses_template_parms (TREE_TYPE (t));
+ case METHOD_TYPE:
+ if (uses_template_parms (TYPE_METHOD_BASETYPE (t)))
+ return 1;
+ if (uses_template_parms (TYPE_ARG_TYPES (t)))
+ return 1;
+ return uses_template_parms (TREE_TYPE (t));
+
+ /* decl nodes */
+ case TYPE_DECL:
+ return uses_template_parms (DECL_NAME (t));
+ case FUNCTION_DECL:
+ if (uses_template_parms (TREE_TYPE (t)))
+ return 1;
+ /* fall through */
+ case VAR_DECL:
+ case PARM_DECL:
+ /* ??? What about FIELD_DECLs? */
+ /* The type of a decl can't use template parms if the name of the
+ variable doesn't, because it's impossible to resolve them. So
+ ignore the type field for now. */
+ if (DECL_CONTEXT (t) && uses_template_parms (DECL_CONTEXT (t)))
+ return 1;
+ if (uses_template_parms (TREE_TYPE (t)))
+ {
+ error ("template parms used where they can't be resolved");
+ }
+ return 0;
+
+ case CALL_EXPR:
+ return uses_template_parms (TREE_TYPE (t));
+ case ADDR_EXPR:
+ return uses_template_parms (TREE_OPERAND (t, 0));
+
+ /* template parm nodes */
+ case TEMPLATE_TYPE_PARM:
+ case TEMPLATE_CONST_PARM:
+ return 1;
+
+ /* simple type nodes */
+ case INTEGER_TYPE:
+ if (uses_template_parms (TYPE_MIN_VALUE (t)))
+ return 1;
+ return uses_template_parms (TYPE_MAX_VALUE (t));
+
+ case REAL_TYPE:
+ case VOID_TYPE:
+ case ENUMERAL_TYPE:
+ case BOOLEAN_TYPE:
+ return 0;
+
+ /* constants */
+ case INTEGER_CST:
+ case REAL_CST:
+ case STRING_CST:
+ return 0;
+
+ case ERROR_MARK:
+ /* Non-error_mark_node ERROR_MARKs are bad things. */
+ my_friendly_assert (t == error_mark_node, 274);
+ /* NOTREACHED */
+ return 0;
+
+ case UNINSTANTIATED_P_TYPE:
+ return 1;
+
+ case CONSTRUCTOR:
+ if (TREE_TYPE (t) && TYPE_PTRMEMFUNC_P (TREE_TYPE (t)))
+ return uses_template_parms (TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (t)));
+ /* else fall through */
+
+ default:
+ switch (TREE_CODE_CLASS (TREE_CODE (t)))
+ {
+ case '1':
+ case '2':
+ case '3':
+ case '<':
+ {
+ int i;
+ for (i = tree_code_length[(int) TREE_CODE (t)]; --i >= 0;)
+ if (uses_template_parms (TREE_OPERAND (t, i)))
+ return 1;
+ return 0;
+ }
+ default:
+ break;
+ }
+ sorry ("testing %s for template parms",
+ tree_code_name [(int) TREE_CODE (t)]);
+ my_friendly_abort (82);
+ /* NOTREACHED */
+ return 0;
+ }
+}
+
+void
+instantiate_member_templates (classname)
+ tree classname;
+{
+ tree t;
+ tree id = classname;
+ tree members = DECL_TEMPLATE_MEMBERS (TREE_PURPOSE (IDENTIFIER_TEMPLATE (id)));
+
+ for (t = members; t; t = TREE_CHAIN (t))
+ {
+ tree parmvec, type, classparms, tdecl, t2;
+ int nparms, xxx = 0, i;
+
+ my_friendly_assert (TREE_VALUE (t) != NULL_TREE, 275);
+ my_friendly_assert (TREE_CODE (TREE_VALUE (t)) == TEMPLATE_DECL, 276);
+ /* @@ Should verify that class parm list is a list of
+ distinct template parameters, and covers all the template
+ parameters. */
+ tdecl = TREE_VALUE (t);
+ type = DECL_CONTEXT (DECL_TEMPLATE_RESULT (tdecl));
+ classparms = UPT_PARMS (type);
+ nparms = TREE_VEC_LENGTH (classparms);
+ parmvec = make_tree_vec (nparms);
+ for (i = 0; i < nparms; i++)
+ TREE_VEC_ELT (parmvec, i) = NULL_TREE;
+ switch (unify (DECL_TEMPLATE_PARMS (tdecl),
+ &TREE_VEC_ELT (parmvec, 0), nparms,
+ type, IDENTIFIER_TYPE_VALUE (classname),
+ &xxx))
+ {
+ case 0:
+ /* Success -- well, no inconsistency, at least. */
+ for (i = 0; i < nparms; i++)
+ if (TREE_VEC_ELT (parmvec, i) == NULL_TREE)
+ goto failure;
+ t2 = instantiate_template (tdecl,
+ &TREE_VEC_ELT (parmvec, 0));
+ type = IDENTIFIER_TYPE_VALUE (id);
+ my_friendly_assert (type != 0, 277);
+ break;
+ case 1:
+ /* Failure. */
+ failure:
+ cp_error_at ("type unification error instantiating `%D'", tdecl);
+ cp_error ("while instantiating members of `%T'", classname);
+
+ continue /* loop of members */;
+ default:
+ /* Eek, a bug. */
+ my_friendly_abort (83);
+ }
+ }
+}
+
+static struct tinst_level *current_tinst_level = 0;
+static struct tinst_level *free_tinst_level = 0;
+static int tinst_depth = 0;
+int max_tinst_depth = 17;
+
+int
+push_tinst_level (name)
+ tree name;
+{
+ struct tinst_level *new;
+ tree global = IDENTIFIER_GLOBAL_VALUE (name);
+
+ if (tinst_depth >= max_tinst_depth)
+ {
+ error ("template instantiation depth exceeds maximum of %d",
+ max_tinst_depth);
+ cp_error (" instantiating `%D'", name);
+ return 0;
+ }
+
+ if (free_tinst_level)
+ {
+ new = free_tinst_level;
+ free_tinst_level = new->next;
+ }
+ else
+ new = (struct tinst_level *) xmalloc (sizeof (struct tinst_level));
+
+ new->classname = name;
+ if (global)
+ {
+ new->line = DECL_SOURCE_LINE (global);
+ new->file = DECL_SOURCE_FILE (global);
+ }
+ else
+ {
+ new->line = lineno;
+ new->file = input_filename;
+ }
+ new->next = current_tinst_level;
+ current_tinst_level = new;
+ ++tinst_depth;
+ return 1;
+}
+
+void
+pop_tinst_level ()
+{
+ struct tinst_level *old = current_tinst_level;
+
+ current_tinst_level = old->next;
+ old->next = free_tinst_level;
+ free_tinst_level = old;
+ --tinst_depth;
+}
+
+struct tinst_level *
+tinst_for_decl ()
+{
+ struct tinst_level *p = current_tinst_level;
+
+ if (p)
+ for (; p->next ; p = p->next )
+ ;
+ return p;
+}
+
+tree
+instantiate_class_template (classname, setup_parse)
+ tree classname;
+ int setup_parse;
+{
+ struct template_info *template_info;
+ tree template, t1;
+
+ if (classname == error_mark_node)
+ return error_mark_node;
+
+ my_friendly_assert (TREE_CODE (classname) == IDENTIFIER_NODE, 278);
+ template = IDENTIFIER_TEMPLATE (classname);
+
+ if (IDENTIFIER_HAS_TYPE_VALUE (classname))
+ {
+ tree type = IDENTIFIER_TYPE_VALUE (classname);
+ if (TREE_CODE (type) == UNINSTANTIATED_P_TYPE)
+ return type;
+ if (TYPE_BEING_DEFINED (type)
+ || TYPE_SIZE (type)
+ || CLASSTYPE_USE_TEMPLATE (type) != 0)
+ return type;
+ }
+
+ /* If IDENTIFIER_LOCAL_VALUE is already set on this template classname
+ (it's something like `foo<int>'), that means we're already working on
+ the instantiation for it. Normally, a classname comes in with nothing
+ but its IDENTIFIER_TEMPLATE slot set. If we were to try to instantiate
+ this again, we'd get a redeclaration error. Since we're already working
+ on it, we'll pass back this classname's TYPE_DECL (it's the value of
+ the classname's IDENTIFIER_LOCAL_VALUE). Only do this if we're setting
+ things up for the parser, though---if we're just trying to instantiate
+ it (e.g., via tsubst) we can trip up cuz it may not have an
+ IDENTIFIER_TYPE_VALUE when it will need one. */
+ if (setup_parse && IDENTIFIER_LOCAL_VALUE (classname))
+ return IDENTIFIER_LOCAL_VALUE (classname);
+
+ if (uses_template_parms (classname))
+ {
+ if (!TREE_TYPE (classname))
+ {
+ tree t = make_lang_type (RECORD_TYPE);
+ tree d = build_decl (TYPE_DECL, classname, t);
+ DECL_NAME (d) = classname;
+ TYPE_NAME (t) = d;
+ pushdecl (d);
+ }
+ return NULL_TREE;
+ }
+
+ t1 = TREE_PURPOSE (template);
+ my_friendly_assert (TREE_CODE (t1) == TEMPLATE_DECL, 279);
+
+ /* If a template is declared but not defined, accept it; don't crash.
+ Later uses requiring the definition will be flagged as errors by
+ other code. Thanks to niklas@appli.se for this bug fix. */
+ if (DECL_TEMPLATE_INFO (t1)->text == 0)
+ setup_parse = 0;
+
+ push_to_top_level ();
+ template_info = DECL_TEMPLATE_INFO (t1);
+ if (setup_parse && push_tinst_level (classname))
+ {
+ push_template_decls (DECL_TEMPLATE_PARMS (TREE_PURPOSE (template)),
+ TREE_VALUE (template), 0);
+ set_current_level_tags_transparency (1);
+ feed_input (template_info->text, template_info->length, (struct obstack *)0);
+ lineno = template_info->lineno;
+ input_filename = template_info->filename;
+ /* Get interface/implementation back in sync. */
+ extract_interface_info ();
+ overload_template_name (classname, 0);
+ /* Kludge so that we don't get screwed by our own base classes. */
+ TYPE_BEING_DEFINED (TREE_TYPE (classname)) = 1;
+ yychar = PRE_PARSED_CLASS_DECL;
+ yylval.ttype = classname;
+ processing_template_defn++;
+ if (!flag_external_templates)
+ interface_unknown++;
+ template_classes
+ = perm_tree_cons (classname, NULL_TREE, template_classes);
+ }
+ else
+ {
+ tree t, decl, id, tmpl;
+
+ id = classname;
+ tmpl = TREE_PURPOSE (IDENTIFIER_TEMPLATE (id));
+ t = xref_tag (DECL_TEMPLATE_INFO (tmpl)->aggr, id, NULL_TREE, 0);
+ my_friendly_assert (TREE_CODE (t) == RECORD_TYPE
+ || TREE_CODE (t) == UNION_TYPE, 280);
+
+ /* Now, put a copy of the decl in global scope, to avoid
+ * recursive expansion. */
+ decl = IDENTIFIER_LOCAL_VALUE (id);
+ if (!decl)
+ decl = IDENTIFIER_CLASS_VALUE (id);
+ if (decl)
+ {
+ my_friendly_assert (TREE_CODE (decl) == TYPE_DECL, 281);
+ /* We'd better make sure we're on the permanent obstack or else
+ * we'll get a "friendly" abort 124 in pushdecl. Perhaps a
+ * copy_to_permanent would be sufficient here, but then a
+ * sharing problem might occur. I don't know -- niklas@appli.se */
+ push_obstacks (&permanent_obstack, &permanent_obstack);
+ pushdecl_top_level (copy_node (decl));
+ pop_obstacks ();
+ }
+ pop_from_top_level ();
+ }
+
+ return NULL_TREE;
+}
+
+static int
+list_eq (t1, t2)
+ tree t1, t2;
+{
+ if (t1 == NULL_TREE)
+ return t2 == NULL_TREE;
+ if (t2 == NULL_TREE)
+ return 0;
+ /* Don't care if one declares its arg const and the other doesn't -- the
+ main variant of the arg type is all that matters. */
+ if (TYPE_MAIN_VARIANT (TREE_VALUE (t1))
+ != TYPE_MAIN_VARIANT (TREE_VALUE (t2)))
+ return 0;
+ return list_eq (TREE_CHAIN (t1), TREE_CHAIN (t2));
+}
+
+static tree
+lookup_nested_type_by_name (ctype, name)
+ tree ctype, name;
+{
+ tree t;
+
+ for (t = CLASSTYPE_TAGS (ctype); t; t = TREE_CHAIN (t))
+ {
+ if (name == TREE_PURPOSE (t))
+ return TREE_VALUE (t);
+ }
+ return NULL_TREE;
+}
+
+static tree
+search_nested_type_in_tmpl (tmpl, type)
+ tree tmpl, type;
+{
+ tree t;
+
+ if (tmpl == NULL || TYPE_CONTEXT(type) == NULL)
+ return tmpl;
+ t = search_nested_type_in_tmpl (tmpl, TYPE_CONTEXT(type));
+ if (t == NULL) return t;
+ t = lookup_nested_type_by_name(t, DECL_NAME(TYPE_NAME(type)));
+ return t;
+}
+
+tree
+tsubst (t, args, nargs, in_decl)
+ tree t, *args;
+ int nargs;
+ tree in_decl;
+{
+ tree type;
+
+ if (t == NULL_TREE || t == error_mark_node)
+ return t;
+
+ type = TREE_TYPE (t);
+ if (type
+ /* Minor optimization.
+ ?? Are these really the most frequent cases? Is the savings
+ significant? */
+ && type != integer_type_node
+ && type != void_type_node
+ && type != char_type_node)
+ type = tsubst (type, args, nargs, in_decl);
+
+ switch (TREE_CODE (t))
+ {
+ case RECORD_TYPE:
+ if (TYPE_PTRMEMFUNC_P (t))
+ return build_ptrmemfunc_type
+ (tsubst (TYPE_PTRMEMFUNC_FN_TYPE (t), args, nargs, in_decl));
+
+ /* else fall through */
+
+ case ERROR_MARK:
+ case IDENTIFIER_NODE:
+ case OP_IDENTIFIER:
+ case VOID_TYPE:
+ case REAL_TYPE:
+ case ENUMERAL_TYPE:
+ case BOOLEAN_TYPE:
+ case INTEGER_CST:
+ case REAL_CST:
+ case STRING_CST:
+ case UNION_TYPE:
+ return t;
+
+ case INTEGER_TYPE:
+ if (t == integer_type_node)
+ return t;
+
+ if (TREE_CODE (TYPE_MIN_VALUE (t)) == INTEGER_CST
+ && TREE_CODE (TYPE_MAX_VALUE (t)) == INTEGER_CST)
+ return t;
+ return build_index_2_type
+ (tsubst (TYPE_MIN_VALUE (t), args, nargs, in_decl),
+ tsubst (TYPE_MAX_VALUE (t), args, nargs, in_decl));
+
+ case TEMPLATE_TYPE_PARM:
+ {
+ tree arg = args[TEMPLATE_TYPE_IDX (t)];
+ return cp_build_type_variant
+ (arg, TYPE_READONLY (arg) || TYPE_READONLY (t),
+ TYPE_VOLATILE (arg) || TYPE_VOLATILE (t));
+ }
+
+ case TEMPLATE_CONST_PARM:
+ return args[TEMPLATE_CONST_IDX (t)];
+
+ case FUNCTION_DECL:
+ {
+ tree r;
+ tree fnargs, result;
+
+ if (type == TREE_TYPE (t)
+ && (DECL_CONTEXT (t) == NULL_TREE
+ || TREE_CODE_CLASS (TREE_CODE (DECL_CONTEXT (t))) != 't'))
+ return t;
+ fnargs = tsubst (DECL_ARGUMENTS (t), args, nargs, t);
+ result = tsubst (DECL_RESULT (t), args, nargs, t);
+ if (DECL_CONTEXT (t) != NULL_TREE
+ && TREE_CODE_CLASS (TREE_CODE (DECL_CONTEXT (t))) == 't')
+ {
+ /* Look it up in that class, and return the decl node there,
+ instead of creating a new one. */
+ tree ctx, methods, name, method;
+ int n_methods;
+ int i, found = 0;
+
+ name = DECL_NAME (t);
+ ctx = tsubst (DECL_CONTEXT (t), args, nargs, t);
+ methods = CLASSTYPE_METHOD_VEC (ctx);
+ if (methods == NULL_TREE)
+ /* No methods at all -- no way this one can match. */
+ goto no_match;
+ n_methods = TREE_VEC_LENGTH (methods);
+
+ r = NULL_TREE;
+
+ if (!strncmp (OPERATOR_TYPENAME_FORMAT,
+ IDENTIFIER_POINTER (name),
+ sizeof (OPERATOR_TYPENAME_FORMAT) - 1))
+ {
+ /* Type-conversion operator. Reconstruct the name, in
+ case it's the name of one of the template's parameters. */
+ name = build_typename_overload (TREE_TYPE (type));
+ }
+
+ if (DECL_CONTEXT (t) != NULL_TREE
+ && TREE_CODE_CLASS (TREE_CODE (DECL_CONTEXT (t))) == 't'
+ && constructor_name (DECL_CONTEXT (t)) == DECL_NAME (t))
+ name = constructor_name (ctx);
+
+ if (DECL_CONSTRUCTOR_P (t) && TYPE_USES_VIRTUAL_BASECLASSES (ctx))
+ {
+ /* Since we didn't know that this class had virtual bases until after
+ we instantiated it, we have to recreate the arguments to this
+ constructor, as otherwise it would miss the __in_chrg parameter. */
+ tree newtype, parm;
+ tree parms = TREE_CHAIN (TYPE_ARG_TYPES (type));
+ parms = hash_tree_chain (integer_type_node, parms);
+ newtype = build_cplus_method_type (ctx,
+ TREE_TYPE (type),
+ parms);
+ newtype = build_type_variant (newtype,
+ TYPE_READONLY (type),
+ TYPE_VOLATILE (type));
+ type = newtype;
+
+ fnargs = copy_node (DECL_ARGUMENTS (t));
+ TREE_CHAIN (fnargs) = TREE_CHAIN (DECL_ARGUMENTS (t));
+
+ /* In this case we need "in-charge" flag saying whether
+ this constructor is responsible for initialization
+ of virtual baseclasses or not. */
+ parm = build_decl (PARM_DECL, in_charge_identifier, integer_type_node);
+ /* Mark the artificial `__in_chrg' parameter as "artificial". */
+ SET_DECL_ARTIFICIAL (parm);
+ DECL_ARG_TYPE (parm) = integer_type_node;
+ DECL_REGISTER (parm) = 1;
+ TREE_CHAIN (parm) = TREE_CHAIN (fnargs);
+ TREE_CHAIN (fnargs) = parm;
+
+ fnargs = tsubst (fnargs, args, nargs, t);
+ }
+#if 0
+ fprintf (stderr, "\nfor function %s in class %s:\n",
+ IDENTIFIER_POINTER (name),
+ IDENTIFIER_POINTER (TYPE_IDENTIFIER (ctx)));
+#endif
+ for (i = 0; i < n_methods; i++)
+ {
+ int pass;
+
+ method = TREE_VEC_ELT (methods, i);
+ if (method == NULL_TREE || DECL_NAME (method) != name)
+ continue;
+
+ pass = 0;
+ maybe_error:
+ for (; method; method = DECL_CHAIN (method))
+ {
+ my_friendly_assert (TREE_CODE (method) == FUNCTION_DECL,
+ 282);
+ if (! comptypes (type, TREE_TYPE (method), 1))
+ {
+ tree mtype = TREE_TYPE (method);
+ tree t1, t2;
+
+ /* Keep looking for a method that matches
+ perfectly. This takes care of the problem
+ where destructors (which have implicit int args)
+ look like constructors which have an int arg. */
+ if (pass == 0)
+ continue;
+
+ t1 = TYPE_ARG_TYPES (mtype);
+ t2 = TYPE_ARG_TYPES (type);
+ if (TREE_CODE (mtype) == FUNCTION_TYPE)
+ t2 = TREE_CHAIN (t2);
+
+ if (list_eq (t1, t2))
+ {
+ if (TREE_CODE (mtype) == FUNCTION_TYPE)
+ {
+ tree newtype;
+ newtype = build_function_type (TREE_TYPE (type),
+ TYPE_ARG_TYPES (type));
+ newtype = build_type_variant (newtype,
+ TYPE_READONLY (type),
+ TYPE_VOLATILE (type));
+ type = newtype;
+ if (TREE_TYPE (type) != TREE_TYPE (mtype))
+ goto maybe_bad_return_type;
+ }
+ else if (TYPE_METHOD_BASETYPE (mtype)
+ == TYPE_METHOD_BASETYPE (type))
+ {
+ /* Types didn't match, but arg types and
+ `this' do match, so the return type is
+ all that should be messing it up. */
+ maybe_bad_return_type:
+ if (TREE_TYPE (type) != TREE_TYPE (mtype))
+ error ("inconsistent return types for method `%s' in class `%s'",
+ IDENTIFIER_POINTER (name),
+ IDENTIFIER_POINTER (TYPE_IDENTIFIER (ctx)));
+ }
+ r = method;
+ break;
+ }
+ found = 1;
+ continue;
+ }
+#if 0
+ fprintf (stderr, "\tfound %s\n\n",
+ IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (method)));
+#endif
+ if (DECL_ARTIFICIAL (method))
+ {
+ cp_error ("template for method `%D' which has default implementation in class `%T'", name, ctx);
+ if (in_decl)
+ cp_error_at ("in attempt to instantiate `%D' declared at this point in file", in_decl);
+ return error_mark_node;
+ }
+
+ if (DECL_ARGUMENTS (method)
+ && ! TREE_PERMANENT (DECL_ARGUMENTS (method)))
+ /* @@ Is this early enough? Might we want to do
+ this instead while processing the expansion? */
+ DECL_ARGUMENTS (method)
+ = tsubst (DECL_ARGUMENTS (t), args, nargs, t);
+ r = method;
+ break;
+ }
+ if (r == NULL_TREE && pass == 0)
+ {
+ pass = 1;
+ method = TREE_VEC_ELT (methods, i);
+ goto maybe_error;
+ }
+ }
+ if (r == NULL_TREE)
+ {
+ no_match:
+ cp_error
+ (found
+ ? "template for method `%D' doesn't match any in class `%T'"
+ : "method `%D' not found in class `%T'", name, ctx);
+ if (in_decl)
+ cp_error_at ("in attempt to instantiate `%D' declared at this point in file", in_decl);
+ return error_mark_node;
+ }
+ }
+ else
+ {
+ r = DECL_NAME (t);
+ {
+ tree decls;
+ int got_it = 0;
+
+ decls = lookup_name_nonclass (r);
+ if (decls == NULL_TREE)
+ /* no match */;
+ else if (TREE_CODE (decls) == TREE_LIST)
+ for (decls = TREE_VALUE (decls); decls ;
+ decls = DECL_CHAIN (decls))
+ {
+ if (TREE_CODE (decls) == FUNCTION_DECL
+ && TREE_TYPE (decls) == type)
+ {
+ got_it = 1;
+ r = decls;
+ break;
+ }
+ }
+ else
+ {
+ tree val = decls;
+ decls = NULL_TREE;
+ if (TREE_CODE (val) == FUNCTION_DECL
+ && TREE_TYPE (val) == type)
+ {
+ got_it = 1;
+ r = val;
+ }
+ }
+
+ if (!got_it)
+ {
+ tree a = build_decl_overload (r, TYPE_VALUES (type),
+ DECL_CONTEXT (t) != NULL_TREE);
+ r = build_lang_decl (FUNCTION_DECL, r, type);
+ DECL_ASSEMBLER_NAME (r) = a;
+ }
+ else if (TREE_STATIC (r))
+ {
+ /* This overrides the template version, use it. */
+ return r;
+ }
+ }
+ }
+ TREE_PUBLIC (r) = 1;
+ DECL_EXTERNAL (r) = 1;
+ TREE_STATIC (r) = 0;
+ DECL_INTERFACE_KNOWN (r) = 0;
+ DECL_INLINE (r) = DECL_INLINE (t);
+ DECL_THIS_INLINE (r) = DECL_THIS_INLINE (t);
+ TREE_READONLY (r) = TREE_READONLY (t);
+ TREE_THIS_VOLATILE (r) = TREE_THIS_VOLATILE (t);
+ {
+#if 0 /* Maybe later. -jason */
+ struct tinst_level *til = tinst_for_decl();
+
+ /* should always be true under new approach */
+ if (til)
+ {
+ DECL_SOURCE_FILE (r) = til->file;
+ DECL_SOURCE_LINE (r) = til->line;
+ }
+ else
+#endif
+ {
+ DECL_SOURCE_FILE (r) = DECL_SOURCE_FILE (t);
+ DECL_SOURCE_LINE (r) = DECL_SOURCE_LINE (t);
+ }
+ }
+ DECL_CLASS_CONTEXT (r) = tsubst (DECL_CLASS_CONTEXT (t), args, nargs, t);
+ make_decl_rtl (r, NULL_PTR, 1);
+ DECL_ARGUMENTS (r) = fnargs;
+ DECL_RESULT (r) = result;
+#if 0
+ if (DECL_CONTEXT (t) == NULL_TREE
+ || TREE_CODE_CLASS (TREE_CODE (DECL_CONTEXT (t))) != 't')
+ push_overloaded_decl_top_level (r, 0);
+#endif
+ return r;
+ }
+
+ case PARM_DECL:
+ {
+ tree r;
+ r = build_decl (PARM_DECL, DECL_NAME (t), type);
+ DECL_INITIAL (r) = TREE_TYPE (r);
+ DECL_ARTIFICIAL (r) = DECL_ARTIFICIAL (t);
+#ifdef PROMOTE_PROTOTYPES
+ if ((TREE_CODE (type) == INTEGER_TYPE
+ || TREE_CODE (type) == ENUMERAL_TYPE)
+ && TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
+ DECL_ARG_TYPE (r) = integer_type_node;
+#endif
+ if (TREE_CHAIN (t))
+ TREE_CHAIN (r) = tsubst (TREE_CHAIN (t), args, nargs, TREE_CHAIN (t));
+ return r;
+ }
+
+ case TREE_LIST:
+ {
+ tree purpose, value, chain, result;
+ int via_public, via_virtual, via_protected;
+
+ if (t == void_list_node)
+ return t;
+
+ via_public = TREE_VIA_PUBLIC (t);
+ via_protected = TREE_VIA_PROTECTED (t);
+ via_virtual = TREE_VIA_VIRTUAL (t);
+
+ purpose = TREE_PURPOSE (t);
+ if (purpose)
+ purpose = tsubst (purpose, args, nargs, in_decl);
+ value = TREE_VALUE (t);
+ if (value)
+ value = tsubst (value, args, nargs, in_decl);
+ chain = TREE_CHAIN (t);
+ if (chain && chain != void_type_node)
+ chain = tsubst (chain, args, nargs, in_decl);
+ if (purpose == TREE_PURPOSE (t)
+ && value == TREE_VALUE (t)
+ && chain == TREE_CHAIN (t))
+ return t;
+ result = hash_tree_cons (via_public, via_virtual, via_protected,
+ purpose, value, chain);
+ TREE_PARMLIST (result) = TREE_PARMLIST (t);
+ return result;
+ }
+ case TREE_VEC:
+ {
+ int len = TREE_VEC_LENGTH (t), need_new = 0, i;
+ tree *elts = (tree *) alloca (len * sizeof (tree));
+ bzero ((char *) elts, len * sizeof (tree));
+
+ for (i = 0; i < len; i++)
+ {
+ elts[i] = tsubst (TREE_VEC_ELT (t, i), args, nargs, in_decl);
+ if (elts[i] != TREE_VEC_ELT (t, i))
+ need_new = 1;
+ }
+
+ if (!need_new)
+ return t;
+
+ t = make_tree_vec (len);
+ for (i = 0; i < len; i++)
+ TREE_VEC_ELT (t, i) = elts[i];
+ return t;
+ }
+ case POINTER_TYPE:
+ case REFERENCE_TYPE:
+ {
+ tree r;
+ enum tree_code code;
+ if (type == TREE_TYPE (t))
+ return t;
+
+ code = TREE_CODE (t);
+ if (code == POINTER_TYPE)
+ r = build_pointer_type (type);
+ else
+ r = build_reference_type (type);
+ r = cp_build_type_variant (r, TYPE_READONLY (t), TYPE_VOLATILE (t));
+ /* Will this ever be needed for TYPE_..._TO values? */
+ layout_type (r);
+ return r;
+ }
+ case OFFSET_TYPE:
+ return build_offset_type
+ (tsubst (TYPE_OFFSET_BASETYPE (t), args, nargs, in_decl), type);
+ case FUNCTION_TYPE:
+ case METHOD_TYPE:
+ {
+ tree values = TYPE_ARG_TYPES (t);
+ tree context = TYPE_CONTEXT (t);
+ tree new_value;
+
+ /* Don't bother recursing if we know it won't change anything. */
+ if (values != void_list_node)
+ values = tsubst (values, args, nargs, in_decl);
+ if (context)
+ context = tsubst (context, args, nargs, in_decl);
+ /* Could also optimize cases where return value and
+ values have common elements (e.g., T min(const &T, const T&). */
+
+ /* If the above parameters haven't changed, just return the type. */
+ if (type == TREE_TYPE (t)
+ && values == TYPE_VALUES (t)
+ && context == TYPE_CONTEXT (t))
+ return t;
+
+ /* Construct a new type node and return it. */
+ if (TREE_CODE (t) == FUNCTION_TYPE
+ && context == NULL_TREE)
+ {
+ new_value = build_function_type (type, values);
+ }
+ else if (context == NULL_TREE)
+ {
+ tree base = tsubst (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t))),
+ args, nargs, in_decl);
+ new_value = build_cplus_method_type (base, type,
+ TREE_CHAIN (values));
+ }
+ else
+ {
+ new_value = make_node (TREE_CODE (t));
+ TREE_TYPE (new_value) = type;
+ TYPE_CONTEXT (new_value) = context;
+ TYPE_VALUES (new_value) = values;
+ TYPE_SIZE (new_value) = TYPE_SIZE (t);
+ TYPE_ALIGN (new_value) = TYPE_ALIGN (t);
+ TYPE_MODE (new_value) = TYPE_MODE (t);
+ if (TYPE_METHOD_BASETYPE (t))
+ TYPE_METHOD_BASETYPE (new_value) = tsubst (TYPE_METHOD_BASETYPE (t),
+ args, nargs, in_decl);
+ /* Need to generate hash value. */
+ my_friendly_abort (84);
+ }
+ new_value = build_type_variant (new_value,
+ TYPE_READONLY (t),
+ TYPE_VOLATILE (t));
+ return new_value;
+ }
+ case ARRAY_TYPE:
+ {
+ tree domain = tsubst (TYPE_DOMAIN (t), args, nargs, in_decl);
+ tree r;
+ if (type == TREE_TYPE (t) && domain == TYPE_DOMAIN (t))
+ return t;
+ r = build_cplus_array_type (type, domain);
+ return r;
+ }
+
+ case UNINSTANTIATED_P_TYPE:
+ {
+ int nparms = TREE_VEC_LENGTH (DECL_TEMPLATE_PARMS (UPT_TEMPLATE (t)));
+ tree argvec = make_tree_vec (nparms);
+ tree parmvec = UPT_PARMS (t);
+ int i;
+ tree id, rt;
+ for (i = 0; i < nparms; i++)
+ TREE_VEC_ELT (argvec, i) = tsubst (TREE_VEC_ELT (parmvec, i),
+ args, nargs, in_decl);
+ id = lookup_template_class (DECL_NAME (UPT_TEMPLATE (t)), argvec, NULL_TREE);
+ if (! IDENTIFIER_HAS_TYPE_VALUE (id)) {
+ instantiate_class_template(id, 0);
+ /* set up pending_classes */
+ add_pending_template (id);
+
+ TYPE_MAIN_VARIANT (IDENTIFIER_TYPE_VALUE (id)) =
+ IDENTIFIER_TYPE_VALUE (id);
+ }
+ rt = IDENTIFIER_TYPE_VALUE (id);
+
+ /* kung: this part handles nested type in template definition */
+
+ if ( !ANON_AGGRNAME_P (DECL_NAME(TYPE_NAME(t))))
+ {
+ rt = search_nested_type_in_tmpl (rt, t);
+ }
+
+ return build_type_variant (rt, TYPE_READONLY (t), TYPE_VOLATILE (t));
+ }
+
+ case MINUS_EXPR:
+ case PLUS_EXPR:
+ return fold (build (TREE_CODE (t), TREE_TYPE (t),
+ tsubst (TREE_OPERAND (t, 0), args, nargs, in_decl),
+ tsubst (TREE_OPERAND (t, 1), args, nargs, in_decl)));
+
+ case NEGATE_EXPR:
+ case NOP_EXPR:
+ return fold (build1 (TREE_CODE (t), TREE_TYPE (t),
+ tsubst (TREE_OPERAND (t, 0), args, nargs, in_decl)));
+
+ default:
+ sorry ("use of `%s' in function template",
+ tree_code_name [(int) TREE_CODE (t)]);
+ return error_mark_node;
+ }
+}
+
+tree
+instantiate_template (tmpl, targ_ptr)
+ tree tmpl, *targ_ptr;
+{
+ tree targs, fndecl;
+ int i, len;
+ struct pending_inline *p;
+ struct template_info *t;
+ struct obstack *old_fmp_obstack;
+ extern struct obstack *function_maybepermanent_obstack;
+
+ push_obstacks (&permanent_obstack, &permanent_obstack);
+ old_fmp_obstack = function_maybepermanent_obstack;
+ function_maybepermanent_obstack = &permanent_obstack;
+
+ my_friendly_assert (TREE_CODE (tmpl) == TEMPLATE_DECL, 283);
+ len = TREE_VEC_LENGTH (DECL_TEMPLATE_PARMS (tmpl));
+
+ i = len;
+ while (i--)
+ targ_ptr[i] = copy_to_permanent (targ_ptr[i]);
+
+ for (fndecl = DECL_TEMPLATE_INSTANTIATIONS (tmpl);
+ fndecl; fndecl = TREE_CHAIN (fndecl))
+ {
+ tree *t1 = &TREE_VEC_ELT (TREE_PURPOSE (fndecl), 0);
+ for (i = len - 1; i >= 0; i--)
+ if (simple_cst_equal (t1[i], targ_ptr[i]) <= 0)
+ goto no_match;
+
+ /* Here, we have a match. */
+ fndecl = TREE_VALUE (fndecl);
+ goto exit;
+
+ no_match:
+ ;
+ }
+
+ targs = make_tree_vec (len);
+ i = len;
+ while (i--)
+ TREE_VEC_ELT (targs, i) = targ_ptr[i];
+
+ /* substitute template parameters */
+ fndecl = tsubst (DECL_RESULT (tmpl), targ_ptr,
+ TREE_VEC_LENGTH (targs), tmpl);
+
+ if (fndecl == error_mark_node)
+ goto exit;
+
+ assemble_external (fndecl);
+
+ /* If it's a static member fn in the template, we need to change it
+ into a FUNCTION_TYPE and chop off its this pointer. */
+ if (TREE_CODE (TREE_TYPE (DECL_RESULT (tmpl))) == METHOD_TYPE
+ && DECL_STATIC_FUNCTION_P (fndecl))
+ {
+ revert_static_member_fn (&DECL_RESULT (tmpl), NULL, NULL);
+ /* Chop off the this pointer that grokclassfn so kindly added
+ for us (it didn't know yet if the fn was static or not). */
+ DECL_ARGUMENTS (fndecl) = TREE_CHAIN (DECL_ARGUMENTS (fndecl));
+ }
+
+ t = DECL_TEMPLATE_INFO (tmpl);
+
+ /* If we have a preexisting version of this function, don't expand
+ the template version, use the other instead. */
+ if (TREE_STATIC (fndecl) || DECL_TEMPLATE_SPECIALIZATION (fndecl))
+ {
+ SET_DECL_TEMPLATE_SPECIALIZATION (fndecl);
+ p = (struct pending_inline *)0;
+ }
+ else if (t->text)
+ {
+ SET_DECL_IMPLICIT_INSTANTIATION (fndecl);
+ repo_template_used (fndecl);
+ p = (struct pending_inline *) permalloc (sizeof (struct pending_inline));
+ p->parm_vec = t->parm_vec;
+ p->bindings = targs;
+ p->can_free = 0;
+ p->deja_vu = 0;
+ p->buf = t->text;
+ p->len = t->length;
+ p->fndecl = fndecl;
+ {
+ int l = lineno;
+ char * f = input_filename;
+
+ lineno = p->lineno = t->lineno;
+ input_filename = p->filename = t->filename;
+
+ extract_interface_info ();
+
+ if (interface_unknown && flag_external_templates)
+ {
+ if (DECL_CLASS_CONTEXT (fndecl)
+ && CLASSTYPE_INTERFACE_KNOWN (DECL_CLASS_CONTEXT (fndecl)))
+ {
+ interface_unknown = 0;
+ interface_only
+ = CLASSTYPE_INTERFACE_ONLY (DECL_CLASS_CONTEXT (fndecl));
+ }
+ else if (! DECL_IN_SYSTEM_HEADER (tmpl))
+ warn_if_unknown_interface (tmpl);
+ }
+
+ if (interface_unknown || ! flag_external_templates)
+ p->interface = 1; /* unknown */
+ else
+ p->interface = interface_only ? 0 : 2;
+
+ lineno = l;
+ input_filename = f;
+
+ extract_interface_info ();
+ }
+ }
+ else
+ p = (struct pending_inline *)0;
+
+ DECL_TEMPLATE_INSTANTIATIONS (tmpl) =
+ tree_cons (targs, fndecl, DECL_TEMPLATE_INSTANTIATIONS (tmpl));
+
+ if (p == (struct pending_inline *)0)
+ {
+ /* do nothing */
+ }
+ else if (DECL_INLINE (fndecl))
+ {
+ DECL_PENDING_INLINE_INFO (fndecl) = p;
+ p->next = pending_inlines;
+ pending_inlines = p;
+ }
+ else
+ {
+ p->next = pending_template_expansions;
+ pending_template_expansions = p;
+ }
+ exit:
+ function_maybepermanent_obstack = old_fmp_obstack;
+ pop_obstacks ();
+
+ return fndecl;
+}
+
+/* classlevel should now never be true. jason 4/12/94 */
+void
+undo_template_name_overload (id, classlevel)
+ tree id;
+ int classlevel;
+{
+ tree template;
+
+ template = IDENTIFIER_TEMPLATE (id);
+ if (!template)
+ return;
+
+#if 0 /* not yet, should get fixed properly later */
+ poplevel (0, 0, 0);
+#endif
+#if 1 /* XXX */
+ /* This was a botch... See `overload_template_name' just below. */
+ if (!classlevel)
+ poplevel (0, 0, 0);
+#endif
+}
+
+/* classlevel should now never be true. jason 4/12/94 */
+void
+overload_template_name (id, classlevel)
+ tree id;
+ int classlevel;
+{
+ tree template, t, decl;
+ struct template_info *tinfo;
+
+ my_friendly_assert (TREE_CODE (id) == IDENTIFIER_NODE, 284);
+ template = IDENTIFIER_TEMPLATE (id);
+ if (!template)
+ return;
+
+ template = TREE_PURPOSE (template);
+ tinfo = DECL_TEMPLATE_INFO (template);
+ template = DECL_NAME (template);
+ my_friendly_assert (template != NULL_TREE, 285);
+
+#if 1 /* XXX */
+ /* This was a botch... names of templates do not get their own private
+ scopes. Rather, they should go into the binding level already created
+ by push_template_decls. Except that there isn't one of those for
+ specializations. */
+ if (!classlevel)
+ {
+ pushlevel (1);
+ declare_pseudo_global_level ();
+ }
+#endif
+
+ t = xref_tag (tinfo->aggr, id, NULL_TREE, 1);
+ my_friendly_assert (TREE_CODE (t) == RECORD_TYPE
+ || TREE_CODE (t) == UNION_TYPE
+ || TREE_CODE (t) == UNINSTANTIATED_P_TYPE, 286);
+
+ decl = build_decl (TYPE_DECL, template, t);
+ SET_DECL_ARTIFICIAL (decl);
+
+#if 0 /* fix this later */
+ /* We don't want to call here if the work has already been done. */
+ t = (classlevel
+ ? IDENTIFIER_CLASS_VALUE (template)
+ : IDENTIFIER_LOCAL_VALUE (template));
+ if (t
+ && TREE_CODE (t) == TYPE_DECL
+ && TREE_TYPE (t) == t)
+ my_friendly_abort (85);
+#endif
+
+ if (classlevel)
+ pushdecl_class_level (decl);
+ else
+ pushdecl (decl);
+
+#if 0 /* This seems bogus to me; if it isn't, explain why. (jason) */
+ /* Fake this for now, just to make dwarfout.c happy. It will have to
+ be done in a proper way later on. */
+ DECL_CONTEXT (decl) = t;
+#endif
+}
+
+extern struct pending_input *to_be_restored;
+
+/* NAME is the IDENTIFIER value of a PRE_PARSED_CLASS_DECL. */
+void
+end_template_instantiation (name)
+ tree name;
+{
+ tree t, decl;
+
+ processing_template_defn--;
+ if (!flag_external_templates)
+ interface_unknown--;
+
+ /* Restore the old parser input state. */
+ if (yychar == YYEMPTY)
+ yychar = yylex ();
+ if (yychar != END_OF_SAVED_INPUT)
+ error ("parse error at end of class template");
+ else
+ {
+ restore_pending_input (to_be_restored);
+ to_be_restored = 0;
+ }
+
+ /* Our declarations didn't get stored in the global slot, since
+ there was a (supposedly tags-transparent) scope in between. */
+ t = IDENTIFIER_TYPE_VALUE (name);
+ my_friendly_assert (t != NULL_TREE
+ && TREE_CODE_CLASS (TREE_CODE (t)) == 't',
+ 287);
+ SET_CLASSTYPE_IMPLICIT_INSTANTIATION (t);
+ /* Make methods of template classes static, unless
+ -fexternal-templates is given. */
+ if (!flag_external_templates)
+ SET_CLASSTYPE_INTERFACE_UNKNOWN (t);
+ decl = IDENTIFIER_GLOBAL_VALUE (name);
+ my_friendly_assert (TREE_CODE (decl) == TYPE_DECL, 288);
+
+ undo_template_name_overload (name, 0);
+ t = IDENTIFIER_TEMPLATE (name);
+ pop_template_decls (DECL_TEMPLATE_PARMS (TREE_PURPOSE (t)), TREE_VALUE (t),
+ 0);
+ /* This will fix up the type-value field. */
+ pushdecl (decl);
+ pop_from_top_level ();
+
+#ifdef DWARF_DEBUGGING_INFO
+ if (write_symbols == DWARF_DEBUG && TREE_CODE (decl) == TYPE_DECL)
+ {
+ /* We just completed the definition of a new file-scope type,
+ so we can go ahead and output debug-info for it now. */
+ TYPE_STUB_DECL (TREE_TYPE (decl)) = decl;
+ rest_of_type_compilation (TREE_TYPE (decl), 1);
+ }
+#endif /* DWARF_DEBUGGING_INFO */
+
+ /* Restore interface/implementation settings. */
+ extract_interface_info ();
+}
+
+/* Store away the text of an template. */
+
+void
+reinit_parse_for_template (yychar, d1, d2)
+ int yychar;
+ tree d1, d2;
+{
+ struct template_info *template_info;
+ extern struct obstack inline_text_obstack; /* see comment in lex.c */
+
+ if (d2 == NULL_TREE || d2 == error_mark_node)
+ {
+ lose:
+ /* @@ Should use temp obstack, and discard results. */
+ reinit_parse_for_block (yychar, &inline_text_obstack, 1);
+ return;
+ }
+
+ if (TREE_CODE (d2) == IDENTIFIER_NODE)
+ d2 = IDENTIFIER_GLOBAL_VALUE (d2);
+ if (!d2)
+ goto lose;
+ template_info = DECL_TEMPLATE_INFO (d2);
+ if (!template_info)
+ {
+ template_info = (struct template_info *) permalloc (sizeof (struct template_info));
+ bzero ((char *) template_info, sizeof (struct template_info));
+ DECL_TEMPLATE_INFO (d2) = template_info;
+ }
+ template_info->filename = input_filename;
+ template_info->lineno = lineno;
+ reinit_parse_for_block (yychar, &inline_text_obstack, 1);
+ template_info->text = obstack_base (&inline_text_obstack);
+ template_info->length = obstack_object_size (&inline_text_obstack);
+ obstack_finish (&inline_text_obstack);
+ template_info->parm_vec = d1;
+}
+
+/* Type unification.
+
+ We have a function template signature with one or more references to
+ template parameters, and a parameter list we wish to fit to this
+ template. If possible, produce a list of parameters for the template
+ which will cause it to fit the supplied parameter list.
+
+ Return zero for success, 2 for an incomplete match that doesn't resolve
+ all the types, and 1 for complete failure. An error message will be
+ printed only for an incomplete match.
+
+ TPARMS[NTPARMS] is an array of template parameter types;
+ TARGS[NTPARMS] is the array of template parameter values. PARMS is
+ the function template's signature (using TEMPLATE_PARM_IDX nodes),
+ and ARGS is the argument list we're trying to match against it.
+
+ If SUBR is 1, we're being called recursively (to unify the arguments of
+ a function or method parameter of a function template), so don't zero
+ out targs and don't fail on an incomplete match. */
+
+int
+type_unification (tparms, targs, parms, args, nsubsts, subr)
+ tree tparms, *targs, parms, args;
+ int *nsubsts, subr;
+{
+ tree parm, arg;
+ int i;
+ int ntparms = TREE_VEC_LENGTH (tparms);
+
+ my_friendly_assert (TREE_CODE (tparms) == TREE_VEC, 289);
+ my_friendly_assert (TREE_CODE (parms) == TREE_LIST, 290);
+ /* ARGS could be NULL (via a call from parse.y to
+ build_x_function_call). */
+ if (args)
+ my_friendly_assert (TREE_CODE (args) == TREE_LIST, 291);
+ my_friendly_assert (ntparms > 0, 292);
+
+ if (!subr)
+ bzero ((char *) targs, sizeof (tree) * ntparms);
+
+ while (parms
+ && parms != void_list_node
+ && args
+ && args != void_list_node)
+ {
+ parm = TREE_VALUE (parms);
+ parms = TREE_CHAIN (parms);
+ arg = TREE_VALUE (args);
+ args = TREE_CHAIN (args);
+
+ if (arg == error_mark_node)
+ return 1;
+ if (arg == unknown_type_node)
+ return 1;
+
+ if (! uses_template_parms (parm)
+ && TREE_CODE_CLASS (TREE_CODE (arg)) != 't')
+ {
+ if (can_convert_arg (parm, TREE_TYPE (arg), arg))
+ continue;
+ return 1;
+ }
+
+#if 0
+ if (TREE_CODE (arg) == VAR_DECL)
+ arg = TREE_TYPE (arg);
+ else if (TREE_CODE_CLASS (TREE_CODE (arg)) == 'e')
+ arg = TREE_TYPE (arg);
+#else
+ if (TREE_CODE_CLASS (TREE_CODE (arg)) != 't')
+ {
+ my_friendly_assert (TREE_TYPE (arg) != NULL_TREE, 293);
+ if (TREE_CODE (arg) == TREE_LIST
+ && TREE_TYPE (arg) == unknown_type_node
+ && TREE_CODE (TREE_VALUE (arg)) == TEMPLATE_DECL)
+ {
+ int nsubsts, ntparms;
+ tree *targs;
+
+ /* Have to back unify here */
+ arg = TREE_VALUE (arg);
+ nsubsts = 0;
+ ntparms = TREE_VEC_LENGTH (DECL_TEMPLATE_PARMS (arg));
+ targs = (tree *) alloca (sizeof (tree) * ntparms);
+ parm = tree_cons (NULL_TREE, parm, NULL_TREE);
+ return type_unification (DECL_TEMPLATE_PARMS (arg), targs,
+ TYPE_ARG_TYPES (TREE_TYPE (arg)),
+ parm, &nsubsts, 0);
+ }
+ arg = TREE_TYPE (arg);
+ }
+#endif
+ if (TREE_CODE (arg) == REFERENCE_TYPE)
+ arg = TREE_TYPE (arg);
+
+ if (TREE_CODE (parm) != REFERENCE_TYPE)
+ {
+ if (TREE_CODE (arg) == FUNCTION_TYPE
+ || TREE_CODE (arg) == METHOD_TYPE)
+ arg = build_pointer_type (arg);
+ else if (TREE_CODE (arg) == ARRAY_TYPE)
+ arg = build_pointer_type (TREE_TYPE (arg));
+ else
+ arg = TYPE_MAIN_VARIANT (arg);
+ }
+
+ switch (unify (tparms, targs, ntparms, parm, arg, nsubsts))
+ {
+ case 0:
+ break;
+ case 1:
+ return 1;
+ }
+ }
+ /* Fail if we've reached the end of the parm list, and more args
+ are present, and the parm list isn't variadic. */
+ if (args && args != void_list_node && parms == void_list_node)
+ return 1;
+ /* Fail if parms are left and they don't have default values. */
+ if (parms
+ && parms != void_list_node
+ && TREE_PURPOSE (parms) == NULL_TREE)
+ return 1;
+ if (!subr)
+ for (i = 0; i < ntparms; i++)
+ if (!targs[i])
+ {
+ error ("incomplete type unification");
+ return 2;
+ }
+ return 0;
+}
+
+/* Tail recursion is your friend. */
+static int
+unify (tparms, targs, ntparms, parm, arg, nsubsts)
+ tree tparms, *targs, parm, arg;
+ int *nsubsts, ntparms;
+{
+ int idx;
+
+ /* I don't think this will do the right thing with respect to types.
+ But the only case I've seen it in so far has been array bounds, where
+ signedness is the only information lost, and I think that will be
+ okay. */
+ while (TREE_CODE (parm) == NOP_EXPR)
+ parm = TREE_OPERAND (parm, 0);
+
+ if (arg == error_mark_node)
+ return 1;
+ if (arg == unknown_type_node)
+ return 1;
+ if (arg == parm)
+ return 0;
+
+ switch (TREE_CODE (parm))
+ {
+ case TEMPLATE_TYPE_PARM:
+ (*nsubsts)++;
+ if (TEMPLATE_TYPE_TPARMLIST (parm) != tparms)
+ {
+ error ("mixed template headers?!");
+ my_friendly_abort (86);
+ return 1;
+ }
+ idx = TEMPLATE_TYPE_IDX (parm);
+#if 0
+ /* Template type parameters cannot contain cv-quals; i.e.
+ template <class T> void f (T& a, T& b) will not generate
+ void f (const int& a, const int& b). */
+ if (TYPE_READONLY (arg) > TYPE_READONLY (parm)
+ || TYPE_VOLATILE (arg) > TYPE_VOLATILE (parm))
+ return 1;
+ arg = TYPE_MAIN_VARIANT (arg);
+#else
+ {
+ int constp = TYPE_READONLY (arg) > TYPE_READONLY (parm);
+ int volatilep = TYPE_VOLATILE (arg) > TYPE_VOLATILE (parm);
+ arg = cp_build_type_variant (arg, constp, volatilep);
+ }
+#endif
+ /* Simple cases: Value already set, does match or doesn't. */
+ if (targs[idx] == arg)
+ return 0;
+ else if (targs[idx])
+ return 1;
+ /* Check for mixed types and values. */
+ if (TREE_CODE (TREE_VALUE (TREE_VEC_ELT (tparms, idx))) != TYPE_DECL)
+ return 1;
+ targs[idx] = arg;
+ return 0;
+ case TEMPLATE_CONST_PARM:
+ (*nsubsts)++;
+ idx = TEMPLATE_CONST_IDX (parm);
+ if (targs[idx] == arg)
+ return 0;
+ else if (targs[idx])
+ {
+ tree t = targs[idx];
+ if (TREE_CODE (t) == TREE_CODE (arg))
+ switch (TREE_CODE (arg))
+ {
+ case INTEGER_CST:
+ if (tree_int_cst_equal (t, arg))
+ return 0;
+ break;
+ case REAL_CST:
+ if (REAL_VALUES_EQUAL (TREE_REAL_CST (t), TREE_REAL_CST (arg)))
+ return 0;
+ break;
+ /* STRING_CST values are not valid template const parms. */
+ default:
+ ;
+ }
+ my_friendly_abort (87);
+ return 1;
+ }
+/* else if (typeof arg != tparms[idx])
+ return 1;*/
+
+ targs[idx] = copy_to_permanent (arg);
+ return 0;
+
+ case POINTER_TYPE:
+ if (TREE_CODE (arg) != POINTER_TYPE)
+ return 1;
+ return unify (tparms, targs, ntparms, TREE_TYPE (parm), TREE_TYPE (arg),
+ nsubsts);
+
+ case REFERENCE_TYPE:
+ if (TREE_CODE (arg) == REFERENCE_TYPE)
+ arg = TREE_TYPE (arg);
+ return unify (tparms, targs, ntparms, TREE_TYPE (parm), arg, nsubsts);
+
+ case ARRAY_TYPE:
+ if (TREE_CODE (arg) != ARRAY_TYPE)
+ return 1;
+ if (unify (tparms, targs, ntparms, TYPE_DOMAIN (parm), TYPE_DOMAIN (arg),
+ nsubsts) != 0)
+ return 1;
+ return unify (tparms, targs, ntparms, TREE_TYPE (parm), TREE_TYPE (arg),
+ nsubsts);
+
+ case REAL_TYPE:
+ case INTEGER_TYPE:
+ if (TREE_CODE (arg) != TREE_CODE (parm))
+ return 1;
+
+ if (TREE_CODE (parm) == INTEGER_TYPE)
+ {
+ if (TYPE_MIN_VALUE (parm) && TYPE_MIN_VALUE (arg)
+ && unify (tparms, targs, ntparms,
+ TYPE_MIN_VALUE (parm), TYPE_MIN_VALUE (arg), nsubsts))
+ return 1;
+ if (TYPE_MAX_VALUE (parm) && TYPE_MAX_VALUE (arg)
+ && unify (tparms, targs, ntparms,
+ TYPE_MAX_VALUE (parm), TYPE_MAX_VALUE (arg), nsubsts))
+ return 1;
+ }
+ /* As far as unification is concerned, this wins. Later checks
+ will invalidate it if necessary. */
+ return 0;
+
+ /* Types INTEGER_CST and MINUS_EXPR can come from array bounds. */
+ case INTEGER_CST:
+ if (TREE_CODE (arg) != INTEGER_CST)
+ return 1;
+ return !tree_int_cst_equal (parm, arg);
+
+ case MINUS_EXPR:
+ {
+ tree t1, t2;
+ t1 = TREE_OPERAND (parm, 0);
+ t2 = TREE_OPERAND (parm, 1);
+ return unify (tparms, targs, ntparms, t1,
+ fold (build (PLUS_EXPR, integer_type_node, arg, t2)),
+ nsubsts);
+ }
+
+ case TREE_VEC:
+ {
+ int i;
+ if (TREE_CODE (arg) != TREE_VEC)
+ return 1;
+ if (TREE_VEC_LENGTH (parm) != TREE_VEC_LENGTH (arg))
+ return 1;
+ for (i = TREE_VEC_LENGTH (parm) - 1; i >= 0; i--)
+ if (unify (tparms, targs, ntparms,
+ TREE_VEC_ELT (parm, i), TREE_VEC_ELT (arg, i),
+ nsubsts))
+ return 1;
+ return 0;
+ }
+
+ case UNINSTANTIATED_P_TYPE:
+ {
+ tree a;
+ /* Unification of something that is not a class fails. */
+ if (! IS_AGGR_TYPE (arg))
+ return 1;
+ a = IDENTIFIER_TEMPLATE (TYPE_IDENTIFIER (arg));
+ if (a && UPT_TEMPLATE (parm) == TREE_PURPOSE (a))
+ return unify (tparms, targs, ntparms, UPT_PARMS (parm),
+ TREE_VALUE (a), nsubsts);
+ /* FIXME: Should check base conversions here. */
+ return 1;
+ }
+
+ case RECORD_TYPE:
+ if (TYPE_PTRMEMFUNC_FLAG (parm))
+ return unify (tparms, targs, ntparms, TYPE_PTRMEMFUNC_FN_TYPE (parm),
+ arg, nsubsts);
+
+ /* Allow trivial conversions. */
+ if (TYPE_MAIN_VARIANT (parm) != TYPE_MAIN_VARIANT (arg)
+ || TYPE_READONLY (parm) < TYPE_READONLY (arg)
+ || TYPE_VOLATILE (parm) < TYPE_VOLATILE (arg))
+ return 1;
+ return 0;
+
+ case METHOD_TYPE:
+ if (TREE_CODE (arg) != METHOD_TYPE)
+ return 1;
+ goto check_args;
+
+ case FUNCTION_TYPE:
+ if (TREE_CODE (arg) != FUNCTION_TYPE)
+ return 1;
+ check_args:
+ if (unify (tparms, targs, ntparms, TREE_TYPE (parm),
+ TREE_TYPE (arg), nsubsts))
+ return 1;
+ return type_unification (tparms, targs, TYPE_ARG_TYPES (parm),
+ TYPE_ARG_TYPES (arg), nsubsts, 1);
+
+ case OFFSET_TYPE:
+ if (TREE_CODE (arg) != OFFSET_TYPE)
+ return 1;
+ if (unify (tparms, targs, ntparms, TYPE_OFFSET_BASETYPE (parm),
+ TYPE_OFFSET_BASETYPE (arg), nsubsts))
+ return 1;
+ return unify (tparms, targs, ntparms, TREE_TYPE (parm),
+ TREE_TYPE (arg), nsubsts);
+
+ default:
+ sorry ("use of `%s' in template type unification",
+ tree_code_name [(int) TREE_CODE (parm)]);
+ return 1;
+ }
+}
+
+
+#undef DEBUG
+
+int
+do_pending_expansions ()
+{
+ struct pending_inline *i, *new_list = 0;
+
+ {
+ tree t;
+ for (t = template_classes; t; t = TREE_CHAIN (t))
+ instantiate_member_templates (TREE_PURPOSE (t));
+ }
+
+ if (!pending_template_expansions)
+ return 0;
+
+#ifdef DEBUG
+ fprintf (stderr, "\n\n\t\t IN DO_PENDING_EXPANSIONS\n\n");
+#endif
+
+ i = pending_template_expansions;
+ while (i)
+ {
+ tree context;
+
+ struct pending_inline *next = i->next;
+ tree t = i->fndecl;
+
+ int decision = 0;
+#define DECIDE(N) do {decision=(N); goto decided;} while(0)
+
+ my_friendly_assert (TREE_CODE (t) == FUNCTION_DECL
+ || TREE_CODE (t) == VAR_DECL, 294);
+ if (TREE_ASM_WRITTEN (t))
+ DECIDE (0);
+
+ if (DECL_EXPLICIT_INSTANTIATION (t))
+ DECIDE (DECL_NOT_REALLY_EXTERN (t));
+ else if (! flag_implicit_templates)
+ DECIDE (0);
+
+ if (i->interface == 1)
+ /* OK, it was an implicit instantiation. */
+ {
+ if (SUPPORTS_WEAK)
+ DECL_WEAK (t) = 1;
+ else
+ TREE_PUBLIC (t) = 0;
+ }
+
+ /* If it's a method, let the class type decide it.
+ @@ What if the method template is in a separate file?
+ Maybe both file contexts should be taken into account?
+ Maybe only do this if i->interface == 1 (unknown)? */
+ context = DECL_CONTEXT (t);
+ if (context != NULL_TREE
+ && TREE_CODE_CLASS (TREE_CODE (context)) == 't')
+ {
+ /* I'm interested in the context of this version of the function,
+ not the original virtual declaration. */
+ context = DECL_CLASS_CONTEXT (t);
+
+ /* If `unknown', we might want a static copy.
+ If `implementation', we want a global one.
+ If `interface', ext ref. */
+ if (CLASSTYPE_INTERFACE_KNOWN (context))
+ DECIDE (!CLASSTYPE_INTERFACE_ONLY (context));
+#if 1 /* This doesn't get us stuff needed only by the file initializer. */
+ DECIDE (TREE_USED (t));
+#else /* This compiles too much stuff, but that's probably better in
+ most cases than never compiling the stuff we need. */
+ DECIDE (1);
+#endif
+ }
+
+ if (i->interface == 1)
+ DECIDE (TREE_USED (t));
+ else
+ DECIDE (i->interface);
+
+ decided:
+#ifdef DEBUG
+ print_node_brief (stderr, decision ? "yes: " : "no: ", t, 0);
+ fprintf (stderr, "\t%s\n",
+ (DECL_ASSEMBLER_NAME (t)
+ ? IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (t))
+ : ""));
+#endif
+ if (decision)
+ {
+ i->next = pending_inlines;
+ pending_inlines = i;
+ }
+ else
+ {
+ i->next = new_list;
+ new_list = i;
+ }
+ i = next;
+ }
+ pending_template_expansions = new_list;
+ if (!pending_inlines)
+ return 0;
+ do_pending_inlines ();
+ return 1;
+}
+
+
+struct pending_template {
+ struct pending_template *next;
+ tree id;
+};
+
+static struct pending_template* pending_templates;
+
+void
+do_pending_templates ()
+{
+ struct pending_template* t;
+
+ for ( t = pending_templates; t; t = t->next)
+ {
+ instantiate_class_template (t->id, 1);
+ }
+
+ for ( t = pending_templates; t; t = pending_templates)
+ {
+ pending_templates = t->next;
+ free(t);
+ }
+}
+
+static void
+add_pending_template (pt)
+ tree pt;
+{
+ struct pending_template *p;
+
+ p = (struct pending_template *) malloc (sizeof (struct pending_template));
+ p->next = pending_templates;
+ pending_templates = p;
+ p->id = pt;
+}
+
+void
+mark_function_instantiated (result, extern_p)
+ tree result;
+ int extern_p;
+{
+ if (DECL_TEMPLATE_INSTANTIATION (result))
+ SET_DECL_EXPLICIT_INSTANTIATION (result);
+ TREE_PUBLIC (result) = 1;
+
+ if (! extern_p)
+ {
+ DECL_INTERFACE_KNOWN (result) = 1;
+ DECL_NOT_REALLY_EXTERN (result) = 1;
+ }
+}
+
+/* called from the parser. */
+void
+do_function_instantiation (declspecs, declarator, storage)
+ tree declspecs, declarator, storage;
+{
+ tree decl = grokdeclarator (declarator, declspecs, NORMAL, 0,
+ NULL_TREE, NULL_TREE);
+ tree name;
+ tree fn;
+ tree result = NULL_TREE;
+ int extern_p = 0;
+
+ /* If we've already seen this template instance, use it. */
+ if (name = DECL_ASSEMBLER_NAME (decl),
+ fn = IDENTIFIER_GLOBAL_VALUE (name),
+ fn && DECL_TEMPLATE_INSTANTIATION (fn))
+ result = fn;
+ else if (name = DECL_NAME (decl), fn = IDENTIFIER_GLOBAL_VALUE (name), fn)
+ {
+ for (fn = get_first_fn (fn); fn; fn = DECL_CHAIN (fn))
+ if (decls_match (fn, decl)
+ && DECL_DEFER_OUTPUT (fn))
+ {
+ result = fn;
+ break;
+ }
+ else if (TREE_CODE (fn) == TEMPLATE_DECL)
+ {
+ int ntparms = TREE_VEC_LENGTH (DECL_TEMPLATE_PARMS (fn));
+ tree *targs = (tree *) malloc (sizeof (tree) * ntparms);
+ int i, dummy = 0;
+ i = type_unification (DECL_TEMPLATE_PARMS (fn), targs,
+ TYPE_ARG_TYPES (TREE_TYPE (fn)),
+ TYPE_ARG_TYPES (TREE_TYPE (decl)),
+ &dummy, 0);
+ if (i == 0)
+ {
+ if (result)
+ cp_error ("ambiguous template instantiation for `%D' requested", decl);
+ else
+ result = instantiate_template (fn, targs);
+ }
+ free (targs);
+ }
+ }
+ if (! result)
+ {
+ cp_error ("no matching template for `%D' found", decl);
+ return;
+ }
+
+ if (flag_external_templates)
+ return;
+
+ if (storage == NULL_TREE)
+ ;
+ else if (storage == ridpointers[(int) RID_EXTERN])
+ extern_p = 1;
+ else
+ cp_error ("storage class `%D' applied to template instantiation",
+ storage);
+ mark_function_instantiated (result, extern_p);
+ repo_template_instantiated (result, extern_p);
+}
+
+void
+mark_class_instantiated (t, extern_p)
+ tree t;
+ int extern_p;
+{
+ SET_CLASSTYPE_EXPLICIT_INSTANTIATION (t);
+ SET_CLASSTYPE_INTERFACE_KNOWN (t);
+ CLASSTYPE_INTERFACE_ONLY (t) = extern_p;
+ CLASSTYPE_VTABLE_NEEDS_WRITING (t) = ! extern_p;
+ TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (t)) = extern_p;
+ if (! extern_p)
+ {
+ CLASSTYPE_DEBUG_REQUESTED (t) = 1;
+ rest_of_type_compilation (t, 1);
+ }
+}
+
+void
+do_type_instantiation (name, storage)
+ tree name, storage;
+{
+ tree t = TREE_TYPE (name);
+ int extern_p = 0;
+ int nomem_p = 0;
+
+ /* With -fexternal-templates, explicit instantiations are treated the same
+ as implicit ones. */
+ if (flag_external_templates)
+ return;
+
+ if (TYPE_SIZE (t) == NULL_TREE)
+ {
+ cp_error ("explicit instantiation of `%#T' before definition of template",
+ t);
+ return;
+ }
+
+ if (storage == NULL_TREE)
+ /* OK */;
+ else if (storage == ridpointers[(int) RID_INLINE])
+ nomem_p = 1;
+ else if (storage == ridpointers[(int) RID_EXTERN])
+ extern_p = 1;
+ else
+ {
+ cp_error ("storage class `%D' applied to template instantiation",
+ storage);
+ extern_p = 0;
+ }
+
+ /* We've already instantiated this. */
+ if (CLASSTYPE_EXPLICIT_INSTANTIATION (t) && ! CLASSTYPE_INTERFACE_ONLY (t)
+ && extern_p)
+ return;
+
+ if (! CLASSTYPE_TEMPLATE_SPECIALIZATION (t))
+ {
+ mark_class_instantiated (t, extern_p);
+ repo_template_instantiated (t, extern_p);
+ }
+
+ if (nomem_p)
+ return;
+
+ {
+ tree tmp;
+ /* Classes nested in template classes currently don't have an
+ IDENTIFIER_TEMPLATE--their out-of-line members are handled
+ by the enclosing template class. Note that there are name
+ conflict bugs with this approach. */
+ tmp = TYPE_IDENTIFIER (t);
+ if (IDENTIFIER_TEMPLATE (tmp))
+ instantiate_member_templates (tmp);
+
+ /* this should really be done by instantiate_member_templates */
+ tmp = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (t), 0);
+ for (; tmp; tmp = TREE_CHAIN (tmp))
+ if (DECL_TEMPLATE_INSTANTIATION (tmp))
+ {
+ mark_function_instantiated (tmp, extern_p);
+ repo_template_instantiated (tmp, extern_p);
+ }
+
+#if 0
+ for (tmp = TYPE_FIELDS (t); tmp; tmp = TREE_CHAIN (tmp))
+ {
+ if (TREE_CODE (tmp) == VAR_DECL)
+ /* eventually do something */;
+ }
+#endif
+
+ for (tmp = CLASSTYPE_TAGS (t); tmp; tmp = TREE_CHAIN (tmp))
+ if (IS_AGGR_TYPE (TREE_VALUE (tmp)))
+ do_type_instantiation (TYPE_MAIN_DECL (TREE_VALUE (tmp)), storage);
+ }
+}
+
+tree
+create_nested_upt (scope, name)
+ tree scope, name;
+{
+ tree t = make_lang_type (UNINSTANTIATED_P_TYPE);
+ tree d = build_decl (TYPE_DECL, name, t);
+
+ TYPE_NAME (t) = d;
+ TYPE_VALUES (t) = TYPE_VALUES (scope);
+ TYPE_CONTEXT (t) = scope;
+
+ pushdecl (d);
+ return d;
+}
diff --git a/contrib/gcc/cp/ptree.c b/contrib/gcc/cp/ptree.c
new file mode 100644
index 0000000..ad1480a
--- /dev/null
+++ b/contrib/gcc/cp/ptree.c
@@ -0,0 +1,168 @@
+/* Prints out trees in human readable form.
+ Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+ Hacked by Michael Tiemann (tiemann@cygnus.com)
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+#include "config.h"
+#include "tree.h"
+#include <stdio.h>
+#include "cp-tree.h"
+
+void
+print_lang_decl (file, node, indent)
+ FILE *file;
+ tree node;
+ int indent;
+{
+ if (!DECL_LANG_SPECIFIC (node))
+ return;
+ /* A FIELD_DECL only has the flags structure, which we aren't displaying
+ anyways. */
+ if (DECL_MUTABLE_P (node))
+ {
+ indent_to (file, indent + 3);
+ fprintf (file, " mutable ");
+ }
+ if (TREE_CODE (node) == FIELD_DECL)
+ return;
+ indent_to (file, indent + 3);
+ if (DECL_MAIN_VARIANT (node))
+ {
+ fprintf (file, " decl-main-variant ");
+ fprintf (file, HOST_PTR_PRINTF, DECL_MAIN_VARIANT (node));
+ }
+ if (DECL_PENDING_INLINE_INFO (node))
+ {
+ fprintf (file, " pending-inline-info ");
+ fprintf (file, HOST_PTR_PRINTF, DECL_PENDING_INLINE_INFO (node));
+ }
+ if (DECL_TEMPLATE_INFO (node))
+ {
+ fprintf (file, " template-info ");
+ fprintf (file, HOST_PTR_PRINTF, DECL_TEMPLATE_INFO (node));
+ }
+}
+
+void
+print_lang_type (file, node, indent)
+ FILE *file;
+ register tree node;
+ int indent;
+{
+ if (TREE_CODE (node) == TEMPLATE_TYPE_PARM)
+ {
+ print_node (file, "tinfo", TYPE_VALUES (node), indent + 4);
+ return;
+ }
+
+ if (TREE_CODE (node) == UNINSTANTIATED_P_TYPE)
+ {
+ print_node (file, "template", UPT_TEMPLATE (node), indent + 4);
+ print_node (file, "parameters", UPT_PARMS (node), indent + 4);
+ return;
+ }
+
+ if (! (TREE_CODE (node) == RECORD_TYPE
+ || TREE_CODE (node) == UNION_TYPE))
+ return;
+
+ if (!TYPE_LANG_SPECIFIC (node))
+ return;
+
+ indent_to (file, indent + 3);
+
+ if (TYPE_NEEDS_CONSTRUCTING (node))
+ fputs ( "needs-constructor", file);
+ if (TYPE_NEEDS_DESTRUCTOR (node))
+ fputs (" needs-destructor", file);
+ if (TYPE_HAS_DESTRUCTOR (node))
+ fputs (" ~X()", file);
+ if (TYPE_HAS_DEFAULT_CONSTRUCTOR (node))
+ fputs (" X()", file);
+ if (TYPE_HAS_CONVERSION (node))
+ fputs (" has-type-conversion", file);
+ if (TYPE_HAS_INT_CONVERSION (node))
+ fputs (" has-int-conversion", file);
+ if (TYPE_HAS_REAL_CONVERSION (node))
+ fputs (" has-float-conversion", file);
+ if (TYPE_HAS_INIT_REF (node))
+ {
+ if (TYPE_HAS_CONST_INIT_REF (node))
+ fputs (" X(constX&)", file);
+ else
+ fputs (" X(X&)", file);
+ }
+ if (TYPE_GETS_NEW (node) & 1)
+ fputs (" new", file);
+ if (TYPE_GETS_NEW (node) & 2)
+ fputs (" new[]", file);
+ if (TYPE_GETS_DELETE (node) & 1)
+ fputs (" delete", file);
+ if (TYPE_GETS_DELETE (node) & 2)
+ fputs (" delete[]", file);
+ if (TYPE_HAS_ASSIGNMENT (node))
+ fputs (" has=", file);
+ if (TYPE_HAS_ASSIGN_REF (node))
+ fputs (" this=(X&)", file);
+ if (TYPE_OVERLOADS_METHOD_CALL_EXPR (node))
+ fputs (" op->()", file);
+ if (TYPE_GETS_INIT_AGGR (node))
+ fputs (" gets X(X, ...)", file);
+ if (TYPE_OVERLOADS_CALL_EXPR (node))
+ fputs (" op()", file);
+ if (TYPE_OVERLOADS_ARRAY_REF (node))
+ fputs (" op[]", file);
+ if (TYPE_OVERLOADS_ARROW (node))
+ fputs (" op->", file);
+ if (TYPE_USES_MULTIPLE_INHERITANCE (node))
+ fputs (" uses-multiple-inheritance", file);
+
+ if (TREE_CODE (node) == RECORD_TYPE)
+ {
+ fprintf (file, " n_parents %d n_ancestors %d",
+ CLASSTYPE_N_BASECLASSES (node),
+ CLASSTYPE_N_SUPERCLASSES (node));
+ fprintf (file, " use_template=%d", CLASSTYPE_USE_TEMPLATE (node));
+ if (CLASSTYPE_INTERFACE_ONLY (node))
+ fprintf (file, " interface-only");
+ if (CLASSTYPE_INTERFACE_UNKNOWN (node))
+ fprintf (file, " interface-unknown");
+ print_node (file, "member-functions", CLASSTYPE_METHOD_VEC (node),
+ indent + 4);
+ print_node (file, "baselinks",
+ TYPE_BINFO_BASETYPES (node) ? CLASSTYPE_BASELINK_VEC (node) : NULL_TREE,
+ indent + 4);
+ }
+}
+
+void
+print_lang_identifier (file, node, indent)
+ FILE *file;
+ tree node;
+ int indent;
+{
+ print_node (file, "global", IDENTIFIER_GLOBAL_VALUE (node), indent + 4);
+ print_node (file, "class", IDENTIFIER_CLASS_VALUE (node), indent + 4);
+ print_node (file, "local", IDENTIFIER_LOCAL_VALUE (node), indent + 4);
+ print_node (file, "label", IDENTIFIER_LABEL_VALUE (node), indent + 4);
+ print_node (file, "template", IDENTIFIER_TEMPLATE (node), indent + 4);
+ print_node (file, "implicit", IDENTIFIER_IMPLICIT_DECL (node), indent + 4);
+ print_node (file, "error locus", IDENTIFIER_ERROR_LOCUS (node), indent + 4);
+}
diff --git a/contrib/gcc/cp/reno.texi b/contrib/gcc/cp/reno.texi
new file mode 100644
index 0000000..59c3448
--- /dev/null
+++ b/contrib/gcc/cp/reno.texi
@@ -0,0 +1,752 @@
+\input texinfo @c -*- Texinfo -*-
+@setfilename reno-1.info
+
+@ifinfo
+@format
+START-INFO-DIR-ENTRY
+* Reno 1: (reno-1). The GNU C++ Renovation Project, Phase 1.
+END-INFO-DIR-ENTRY
+@end format
+@end ifinfo
+
+@ifinfo
+Copyright @copyright{} 1992, 1993, 1994 Free Software Foundation, Inc.
+
+Permission is granted to make and distribute verbatim copies of
+this manual provided the copyright notice and this permission notice
+are preserved on all copies.
+
+@ignore
+Permission is granted to process this file through TeX and print the
+results, provided the printed document carries a copying permission
+notice identical to this one except for the removal of this paragraph
+(this paragraph not being relevant to the printed manual).
+
+@end ignore
+
+Permission is granted to copy and distribute modified versions of this
+manual under the conditions for verbatim copying, provided also that
+the entire resulting derived work is distributed under the terms of a
+permission notice identical to this one.
+
+Permission is granted to copy and distribute translations of this manual
+into another language, under the above conditions for modified versions.
+@end ifinfo
+
+@setchapternewpage odd
+@settitle GNU C++ Renovation Project
+@c @smallbook
+
+@titlepage
+@finalout
+@title GNU C++ Renovation Project
+@subtitle Phase 1.3
+@author Brendan Kehoe, Jason Merrill,
+@author Mike Stump, Michael Tiemann
+@page
+
+Edited March, 1994 by Roland Pesch (@code{pesch@@cygnus.com})
+@vskip 0pt plus 1filll
+Copyright @copyright{} 1992, 1993, 1994 Free Software Foundation, Inc.
+
+Permission is granted to make and distribute verbatim copies of
+this manual provided the copyright notice and this permission notice
+are preserved on all copies.
+
+@ignore
+Permission is granted to process this file through Tex and print the
+results, provided the printed document carries copying permission
+notice identical to this one except for the removal of this paragraph
+(this paragraph not being relevant to the printed manual).
+@end ignore
+
+Permission is granted to copy and distribute modified versions of this
+manual under the conditions for verbatim copying, provided also that
+the entire resulting derived work is distributed under the terms of a
+permission notice identical to this one.
+
+Permission is granted to copy and distribute translations of this manual
+into another language, under the above conditions for modified versions.
+@end titlepage
+
+@ifinfo
+@node Top
+@top @sc{gnu} C++ Renovation Project
+
+This file describes the goals of the @sc{gnu} C++ Renovation Project,
+and its accomplishments to date (as of Phase 1.3).
+
+It also discusses the remaining divergences from @sc{gnu} C++, and how the
+name encoding in @sc{gnu} C++ differs from the sample encoding in
+@cite{The Annotated C++ Reference Manual}.
+@c This is not a good place to introduce the acronym ARM because it's
+@c info-only.
+
+@menu
+* Introduction:: What is the GNU C++ Renovation Project?
+* Changes:: Summary of changes since previous GNU C++ releases.
+* Plans:: Plans for Reno-2.
+* Templates:: The template implementation.
+* ANSI:: GNU C++ conformance to ANSI C++.
+* Encoding:: Name encoding in GNU C++.
+@end menu
+
+@end ifinfo
+
+@node Introduction
+@chapter Introduction
+
+As you may remember, @sc{gnu} C++ was the first native-code C++
+compiler available under Unix (December 1987). In November 1988, it was
+judged superior to the AT&T compiler in a Unix World review. In 1990 it
+won a Sun Observer ``Best-Of'' award. But now, with new requirements
+coming out of the @sc{ansi} C++ committee and a growing backlog of bugs, it's
+clear that @sc{gnu} C++ needs an overhaul.
+
+The C++ language has been under development since 1982. It has
+evolved significantly since its original incarnation (C with Classes),
+addressing many commercial needs and incorporating many lessons
+learned as more and more people started using ``object-oriented''
+programming techniques. In 1989, the first X3J16 committee meeting
+was held in Washington DC; in the interest of users, C++ was going to
+be standardized.
+
+As C++ has become more popular, more demands have been placed on its
+compilers. Some compilers are up to the demands, others are not.
+@sc{gnu} C++ was used to prototype several features which have since
+been incorporated into the standard, most notably exception handling.
+While @sc{gnu} C++ has been an excellent experimental vehicle, it did
+not have the resources that AT&T, Borland, or Microsoft have at their
+disposal.
+
+We believe that @sc{gnu} C++ is an important compiler, providing users with
+many of the features that have made @sc{gnu} C so popular: fast compilation,
+good error messages, innovative features, and full sources that may be
+freely redistributed. The purpose of this overhaul, dubbed the @var{@sc{gnu}
+C++ Renovation Project}, is to take advantage of the functionality that
+@sc{gnu} C++ offers today, to strengthen its base technology, and put it in a
+position to remain---as other @sc{gnu} software currently is---the technical
+leader in the field.
+
+This release represents the latest phase of work in strengthening the
+compiler on a variety of points. It includes many months of
+work concentrated on fixing many of the more egregious bugs that
+presented themselves in the compiler recently.
+@ignore
+@c FIXME-- update?
+Nearly 85% of all bugs reported in the period of February to September
+of 1992 were fixed as part of the work in the first phase.
+@end ignore
+In the coming months, we hope to continue expanding and enhancing the
+quality and dependability of the industry's only freely redistributable
+C++ compiler.
+
+@node Changes
+@chapter Changes in Behavior in @sc{gnu} C++
+
+The @sc{gnu} C++ compiler continues to improve and change. A major goal
+of our work has been to continue to bring the compiler into compliance
+with the draft @sc{ansi} C++ standard, and with @cite{The Annotated C++
+Reference Manual} (the @sc{arm}). This section outlines most of the
+user-noticeable changes that might be encountered during the normal
+course of use.
+
+@menu
+* Summary of Phase 1.3::
+* Major changes::
+* New features::
+* Enhancements and bug fixes::
+* Problems with debugging::
+@end menu
+
+@node Summary of Phase 1.3
+@section Summary of Changes in Phase 1.3
+
+The bulk of this note discusses the cumulative effects of the @sc{gnu} C++
+Renovation Project to date. The work during its most recent phase (1.3)
+had these major effects:
+
+@itemize @bullet
+@item The standard compiler driver @code{g++} is now the faster compiled
+version, rather than a shell script.
+
+@item Nested types work much better; notably, nesting is no longer
+restricted to nine levels.
+
+@item Better @sc{arm} conformance on member access control.
+
+@item The compiler now always generates default assignment operators
+(@samp{operator =}), copy constructors (@samp{X::X(X&)}), and default
+constructors (@samp{X::X()}) whenever they are required.
+
+@item The new draft @sc{ansi} standard keyword @code{mutable} is supported.
+
+@item @samp{-fansi-overloading} is the default, to comply better with
+the @sc{arm} (at some cost in compatibility to earlier versions of @sc{gnu} C++).
+
+@item More informative error messages.
+
+@item System include files are automatically treated as if they were
+wrapped in @samp{extern "C" @{ @}}.
+
+@item The new option @samp{-falt-external-templates} provides alternate
+template instantiation semantics.
+
+@item Operator declarations are now checked more strictly.
+
+@item You can now use template type arguments in the template parameter list.
+
+@item You can call the destructor for any type.
+
+@item The compiler source code is better organized.
+
+@item You can specify where to instantiate template definitions explicitly.
+@end itemize
+
+Much of the work in Phase 1.3 went to elimination of known bugs, as well
+as the major items above.
+
+During the span of Phase 1.3, there were also two changes associated
+with the compiler that, while not specifically part of the C++
+Renovation project, may be of interest:
+
+@itemize @bullet
+@item @code{gcov}, a code coverage tool for @sc{gnu cc}, is now available
+from Cygnus Support. (@code{gcov} is free software, but the @sc{fsf} has not
+yet accepted it.) @xref{Gcov,, @code{gcov}: a Test Coverage Program,
+gcc.info, Using GNU CC}, for more information (in Cygnus releases of
+that manual).
+
+@item @sc{gnu} C++ now supports @dfn{signatures}, a language extension to
+provide more flexibility in abstract type definitions. @xref{C++
+Signatures,, Type Abstraction using Signatures, gcc.info, Using GNU CC}.
+@end itemize
+
+@node Major changes
+@section Major Changes
+
+This release includes four wholesale rewrites of certain areas of
+compiler functionality:
+
+@enumerate 1
+@item Argument matching. @sc{gnu} C++ is more compliant with the rules
+described in Chapter 13, ``Overloading'', of the @sc{arm}. This behavior is
+the default, though you can specify it explicitly with
+@samp{-fansi-overloading}. For compatibility with earlier releases of
+@sc{gnu} C++, specify @samp{-fno-ansi-overloading}; this makes the compiler
+behave as it used to with respect to argument matching and name overloading.
+
+@item Default constructors/destructors. Section 12.8 of the @sc{arm}, ``Copying
+Class Objects'', and Section 12.1, ``Constructors'', state that a
+compiler must declare such default functions if the user does not
+specify them. @sc{gnu} C++ now declares, and generates when necessary,
+the defaults for constructors and destructors you might omit. In
+particular, assignment operators (@samp{operator =}) behave the same way
+whether you define them, or whether the compiler generates them by
+default; taking the address of the default @samp{operator =} is now
+guaranteed to work. Default copy constructors (@samp{X::X(X&)}) now
+function correctly, rather than calling the copy assignment operator for
+the base class. Finally, constructors (@samp{X::X()}), as well as
+assignment operators and copy constructors, are now available whenever
+they are required.
+
+@c XXX This may be taken out eventually...
+@item Binary incompatibility. There are no new binary incompatibilities
+in Phase 1.3, but Phase 1.2 introduced two binary incompatibilities with
+earlier releases. First, the functionality of @samp{operator
+new} and @samp{operator delete} changed. Name encoding
+(``mangling'') of virtual table names changed as well. Libraries
+built with versions of the compiler earlier than Phase 1.2 must be
+compiled with the new compiler. (This includes the Cygnus Q2
+progressive release and the FSF 2.4.5 release.)
+
+@item New @code{g++} driver.
+A new binary @code{g++} compiler driver replaces the shell script.
+The new driver executes faster.
+@end enumerate
+
+@node New features
+@section New features
+
+@itemize @bullet
+@item
+The compiler warns when a class contains only private constructors
+or destructors, and has no friends. At the request of some of our
+customers, we have added a new option, @samp{-Wctor-dtor-privacy} (on by
+default), and its negation, @samp{-Wno-ctor-dtor-privacy}, to control
+the emission of this warning. If, for example, you are working towards
+making your code compile warning-free, you can use @w{@samp{-Wall
+-Wno-ctor-dtor-privacy}} to find the most common warnings.
+
+@item
+There is now a mechanism which controls exactly when templates are
+expanded, so that you can reduce memory usage and program size and also
+instantiate them exactly once. You can control this mechanism with the
+option @samp{-fexternal-templates} and its corresponding negation
+@samp{-fno-external-templates}. Without this feature, space consumed by
+template instantiations can grow unacceptably in large-scale projects
+with many different source files. The default is
+@samp{-fno-external-templates}.
+
+You do not need to use the @samp{-fexternal-templates} option when
+compiling a file that does not define and instantiate templates used in
+other files, even if those files @emph{are} compiled with
+@samp{-fexternal-templates}. The only side effect is an increase in
+object size for each file that was compiled without
+@samp{-fexternal-templates}.
+
+When your code is compiled with @samp{-fexternal-templates}, all
+template instantiations are external; this requires that the templates
+be under the control of @samp{#pragma interface} and @samp{#pragma
+implementation}. All instantiations that will be needed should be in
+the implementation file; you can do this with a @code{typedef} that
+references the instantiation needed. Conversely, when you compile using
+the option @samp{-fno-external-templates}, all template instantiations are
+explicitly internal.
+
+@samp{-fexternal-templates} also allows you to finally separate class
+template function definitions from their declarations, thus speeding up
+compilation times for every file that includes the template declaration.
+Now you can have tens or even hundreds of lines in template
+declarations, and thousands or tens of thousands of lines in template
+definitions, with the definitions only going through the compiler once
+instead of once for each source file. It is important to note that you
+must remember to externally instantiate @emph{all} templates that are
+used from template declarations in interface files. If you forget to do
+this, unresolved externals will occur.
+
+In the example below, the object file generated (@file{example.o}) will
+contain the global instantiation for @samp{Stack<int>}. If other types
+of @samp{Stack} are needed, they can be added to @file{example.cc} or
+placed in a new file, in the same spirit as @file{example.cc}.
+
+@code{foo.h}:
+@smallexample
+@group
+#pragma interface "foo.h"
+template<class T>
+class Stack @{
+ static int statc;
+ static T statc2;
+ Stack() @{ @}
+ virtual ~Stack() @{ @}
+ int bar();
+@};
+@end group
+@end smallexample
+
+@code{example.cc}:
+@smallexample
+@group
+#pragma implementation "foo.h"
+#include "foo.h"
+
+typedef Stack<int> t;
+int Stack<int>::statc;
+int Stack<int>::statc2;
+int Stack<int>::bar() @{ @}
+@end group
+@end smallexample
+
+Note that using @samp{-fexternal-templates} does not reduce memory usage
+from completely different instantiations (@samp{Stack<Name>} vs.
+@samp{Stack<Net_Connection>}), but only collapses different occurrences
+of @samp{Stack<Name>} so that only one @samp{Stack<Name>} is generated.
+
+@samp{-falt-external-templates} selects a slight variation in the
+semantics described above (incidentally, you need not specify both
+options; @samp{-falt-external-templates} implies
+@samp{-fexternal-templates}).
+
+With @samp{-fexternal-templates}, the compiler emits a definition in the
+implementation file that includes the header definition, @emph{even if}
+instantiation is triggered from a @emph{different} implementation file
+(e.g. with a template that uses another template).
+
+With @samp{-falt-external-templates}, the definition always goes in the
+implementation file that triggers instantiation.
+
+For instance, with these two header files---
+
+@example
+@exdent @file{a.h}:
+#pragma interface
+template <class T> class A @{ @dots{} @};
+
+@exdent @file{b.h}:
+#pragma interface
+class B @{ @dots{} @};
+void f (A<B>);
+@end example
+
+Under @samp{-fexternal-templates}, the definition of @samp{A<B>} ends up
+in the implementation file that includes @file{a.h}. Under
+@samp{-falt-external-templates}, the same definition ends up in the
+implementation file that includes @file{b.h}.
+
+@item
+You can control explicitly where a template is instantiated, without
+having to @emph{use} the template to get an instantiation.
+
+To instantiate a class template explicitly, write @samp{template
+class @var{name}<paramvals>}, where @var{paramvals} is a list of values
+for the template parameters. For example, you might write
+
+@example
+template class A<int>
+@end example
+
+Similarly, to instantiate a function template explicitly, write
+@samp{template @var{fnsign}} where @var{fnsign} is the particular
+function signature you need. For example, you might write
+
+@example
+template void foo (int, int)
+@end example
+
+This syntax for explicit template instantiation agrees with recent
+extensions to the draft @sc{ansi} standard.
+
+@item
+The compiler's actions on @sc{ansi}-related warnings and errors have
+been further enhanced. The @samp{-pedantic-errors} option produces
+error messages in a number of new situations: using @code{return} in a
+non-@code{void} function (one returning a value); declaring a local
+variable that shadows a parameter (e.g., the function takes an argument
+@samp{a}, and has a local variable @samp{a}); and use of the @samp{asm}
+keyword. Finally, the compiler by default now issues a warning when
+converting from an @code{int} to an enumerated type. This is likely to
+cause many new warnings in code that hadn't triggered them before. For
+example, when you compile this code,
+
+@smallexample
+@group
+enum boolean @{ false, true @};
+void
+f ()
+@{
+ boolean x;
+
+ x = 1; //@i{assigning an @code{int} to an @code{enum} now triggers a warning}
+@}
+@end group
+@end smallexample
+
+@noindent
+you should see the warning ``@code{anachronistic conversion from integer
+type to enumeral type `boolean'}''. Instead of assigning the value 1,
+assign the original enumerated value @samp{true}.
+@end itemize
+
+@node Enhancements and bug fixes
+@section Enhancements and bug fixes
+
+@itemize @bullet
+@cindex nested types in template parameters
+@item
+You can now use nested types in a template parameter list, even if the nested
+type is defined within the same class that attempts to use the template.
+For example, given a template @code{list}, the following now works:
+
+@smallexample
+struct glyph @{
+ @dots{}
+ struct stroke @{ @dots{} @};
+ list<stroke> l;
+ @dots{}
+@}
+@end smallexample
+
+@cindex function pointers vs template parameters
+@item
+Function pointers now work in template parameter lists. For
+example, you might want to instantiate a parameterized @code{list} class
+in terms of a pointer to a function like this:
+
+@smallexample
+list<int (*)(int, void *)> fnlist;
+@end smallexample
+
+@item
+@c FIXME! Really no limit? Jason said "deeper than 9" now OK...
+Nested types are now handled correctly. In particular, there is no
+longer a limit to how deeply you can nest type definitions.
+
+@item
+@sc{gnu} C++ now conforms to the specifications in Chapter 11 of the
+@sc{arm}, ``Member Access Control''.
+
+@item
+The @sc{ansi} C++ committee has introduced a new keyword @code{mutable}.
+@sc{gnu} C++ supports it. Use @code{mutable} to specify that some
+particular members of a @code{const} class are @emph{not} constant. For
+example, you can use this to include a cache in a data structure that
+otherwise represents a read-only database.
+
+@item
+Error messages now explicitly specify the declaration, type, or
+expression that contains an error.
+
+@item
+To avoid copying and editing all system include files during @sc{gnu}
+C++ installation, the compiler now automatically recognizes system
+include files as C language definitions, as if they were wrapped in
+@samp{extern "C" @{ @dots{} @}}.
+
+@item
+The compiler checks operator declarations more strictly. For example,
+you may no longer declare an @samp{operator +} with three arguments.
+
+@item
+You can now use template type arguments in the same template
+parameter list where the type argument is specified (as well as in the
+template body). For example, you may write
+
+@example
+template <class T, T t> class A @{ @dots{} @};
+@end example
+
+@item
+Destructors are now available for all types, even built-in ones; for
+example, you can call @samp{int::~int}. (Destructors for types like
+@code{int} do not actually do anything, but their existence provides a
+level of generality that permits smooth template expansion in more
+cases.)
+
+@item
+Enumerated types declared inside a class are now handled correctly.
+
+@item
+An argument list for a function may not use an initializer list for its default
+value. For example, @w{@samp{void foo ( T x = @{ 1, 2 @} )}} is not permitted.
+
+@item
+A significant amount of work went into improving the ability of the
+compiler to act accurately on multiple inheritance and virtual
+functions. Virtual function dispatch has been enhanced as well.
+
+@item
+The warning concerning a virtual inheritance environment with a
+non-virtual destructor has been disabled, since it is not clear that
+such a warning is warranted.
+
+@item
+Until exception handling is fully implemented in the Reno-2 release, use
+of the identifiers @samp{catch}, @samp{throw}, or @samp{try} results
+in the warning:
+
+@smallexample
+t.C:1: warning: `catch', `throw', and `try'
+ are all C++ reserved words
+@end smallexample
+
+@item
+When giving a warning or error concerning initialization of a member in a
+class, the compiler gives the name of the member if it has one.
+
+@item
+Detecting friendship between classes is more accurately checked.
+
+@item
+The syntaxes of @w{@samp{#pragma implementation "file.h"}} and
+@samp{#pragma interface} are now more strictly controlled. The compiler
+notices (and warns) when any text follows @file{file.h} in the
+implementation pragma, or follows the word @samp{interface}. Any such
+text is otherwise ignored.
+
+@item
+Trying to declare a template on a variable or type is now considered an
+error, not an unimplemented feature.
+
+@item
+When an error occurs involving a template, the compiler attempts to
+tell you at which point of instantiation the error occurred, in
+addition to noting the line in the template declaration which had the
+actual error.
+
+@item
+The symbol names for function templates in the resulting assembly file
+are now encoded according to the arguments, rather than just being
+emitted as, for example, two definitions of a function @samp{foo}.
+
+@item
+Template member functions that are declared @code{static} no longer
+receive a @code{this} pointer.
+
+@item
+Case labels are no longer allowed to have commas to make up their
+expressions.
+
+@item
+Warnings concerning the shift count of a left or right shift now tell
+you if it was a @samp{left} or @samp{right} shift.
+
+@item
+The compiler now warns when a decimal constant is so large that it
+becomes @code{unsigned}.
+
+@item
+Union initializers which are raw constructors are now handled properly.
+
+@item
+The compiler no longer gives incorrect errors when initializing a
+union with an empty initializer list.
+
+@item
+Anonymous unions are now correctly used when nested inside a class.
+
+@item
+Anonymous unions declared as static class members are now handled
+properly.
+
+@item
+The compiler now notices when a field in a class is declared both as
+a type and a non-type.
+
+@item
+The compiler now warns when a user-defined function shadows a
+built-in function, rather than emitting an error.
+
+@item
+A conflict between two function declarations now produces an error
+regardless of their language context.
+
+@item
+Duplicate definitions of variables with @samp{extern "C"} linkage are no
+longer considered in error. (Note in C++ linkage---the default---you may
+not have more than one definition of a variable.)
+
+@item
+Referencing a label that is not defined in any function is now an error.
+
+@item
+The syntax for pointers to methods has been improved; there are still
+some minor bugs, but a number of cases should now be accepted by the
+compiler.
+
+@item
+In error messages, arguments are now numbered starting at 1, instead of
+0. Therefore, in the function @samp{void foo (int a, int b)}, the
+argument @samp{a} is argument 1, and @samp{b} is argument 2. There is
+no longer an argument 0.
+
+@item
+The tag for an enumerator, rather than its value, used as a default
+argument is now shown in all error messages. For example, @w{@samp{void
+foo (enum x (= true))}} is shown instead of @w{@samp{void foo (enum x (=
+1))}}.
+
+@item
+The @samp{__asm__} keyword is now accepted by the C++ front-end.
+
+@item
+Expressions of the form @samp{foo->~Class()} are now handled properly.
+
+@item
+The compiler now gives better warnings for situations which result in
+integer overflows (e.g., in storage sizes, enumerators, unary
+expressions, etc).
+
+@item
+@code{unsigned} bitfields are now promoted to @code{signed int} if the
+field isn't as wide as an @code{int}.
+
+@item
+Declaration and usage of prefix and postfix @samp{operator ++} and
+@samp{operator --} are now handled correctly. For example,
+
+@smallexample
+@group
+class foo
+@{
+public:
+ operator ++ ();
+ operator ++ (int);
+ operator -- ();
+ operator -- (int);
+@};
+
+void
+f (foo *f)
+@{
+ f++; // @i{call @code{f->operator++(int)}}
+ ++f; // @i{call @code{f->operator++()}}
+ f--; // @i{call @code{f->operator++(int)}}
+ --f; // @i{call @code{f->operator++()}}
+@}
+@end group
+@end smallexample
+
+@item
+In accordance with @sc{arm} section 10.1.1, ambiguities and dominance are now
+handled properly. The rules described in section 10.1.1 are now fully
+implemented.
+
+@end itemize
+
+@node Problems with debugging
+@section Problems with debugging
+
+Two problems remain with regard to debugging:
+
+@itemize @bullet
+@item
+Debugging of anonymous structures on the IBM RS/6000 host is incorrect.
+
+@item
+Symbol table size is overly large due to redundant symbol information;
+this can make @code{gdb} coredump under certain circumstances. This
+problem is not host-specific.
+@end itemize
+
+@node Plans
+@chapter Plans for Reno-2
+
+The overall goal for the second phase of the @sc{gnu} C++ Renovation
+Project is to bring @sc{gnu} C++ to a new level of reliability, quality,
+and competitiveness. As particular elements of this strategy, we intend
+to:
+
+@enumerate 0
+@item
+Fully implement @sc{ansi} exception handling.
+
+@item
+With the exception handling, add Runtime Type Identification
+(@sc{rtti}), if the @sc{ansi} committee adopts it into the standard.
+
+@item
+Bring the compiler into closer compliance with the @sc{arm} and the draft
+@sc{ansi} standard, and document what points in the @sc{arm} we do not yet comply,
+or agree, with.
+
+@item
+Add further support for the @sc{dwarf} debugging format.
+
+@item
+Finish the work to make the compiler compliant with @sc{arm} Section 12.6.2,
+initializing base classes in declaration order, rather than in the order
+that you specify them in a @var{mem-initializer} list.
+
+@item
+Perform a full coverage analysis on the compiler, and weed out unused
+code, for a gain in performance and a reduction in the size of the compiler.
+
+@item
+Further improve the multiple inheritance implementation in the
+compiler to make it cleaner and more complete.
+@end enumerate
+
+@noindent
+As always, we encourage you to make suggestions and ask questions about
+@sc{gnu} C++ as a whole, so we can be sure that the end of this project
+will bring a compiler that everyone will find essential for C++ and will
+meet the needs of the world's C++ community.
+
+@include templates.texi
+
+@include gpcompare.texi
+
+@contents
+
+@bye
diff --git a/contrib/gcc/cp/repo.c b/contrib/gcc/cp/repo.c
new file mode 100644
index 0000000..50fc9f8
--- /dev/null
+++ b/contrib/gcc/cp/repo.c
@@ -0,0 +1,409 @@
+/* Code to maintain a C++ template repository.
+ Copyright (C) 1995 Free Software Foundation, Inc.
+ Contributed by Jason Merrill (jason@cygnus.com)
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+/* My strategy here is as follows:
+
+ Everything should be emitted in a translation unit where it is used.
+ The results of the automatic process should be easily reproducible with
+ explicit code. */
+
+#include <stdio.h>
+#include "config.h"
+#include "tree.h"
+#include "cp-tree.h"
+#include "input.h"
+#include "obstack.h"
+
+extern char * rindex ();
+extern char * getenv ();
+extern char * getpwd ();
+
+static tree pending_repo;
+static tree original_repo;
+static char *repo_name;
+static FILE *repo_file;
+
+extern int flag_use_repository;
+extern int errorcount, sorrycount;
+extern struct obstack temporary_obstack;
+extern struct obstack permanent_obstack;
+
+#define IDENTIFIER_REPO_USED(NODE) (TREE_LANG_FLAG_3 (NODE))
+#define IDENTIFIER_REPO_CHOSEN(NODE) (TREE_LANG_FLAG_4 (NODE))
+
+/* Record the flags used to compile this translation unit. */
+
+void
+repo_compile_flags (argc, argv)
+ int argc;
+ char **argv;
+{
+}
+
+/* If this template has not been seen before, add a note to the repository
+ saying where the declaration was. This may be used to find the
+ definition at link time. */
+
+void
+repo_template_declared (t)
+ tree t;
+{}
+
+/* Note where the definition of a template lives so that instantiations can
+ be generated later. */
+
+void
+repo_template_defined (t)
+ tree t;
+{}
+
+/* Note where the definition of a class lives to that template
+ instantiations can use it. */
+
+void
+repo_class_defined (t)
+ tree t;
+{}
+
+tree
+repo_get_id (t)
+ tree t;
+{
+ if (TREE_CODE_CLASS (TREE_CODE (t)) == 't')
+ {
+ t = TYPE_BINFO_VTABLE (t);
+ if (t == NULL_TREE)
+ return t;
+ }
+ return DECL_ASSEMBLER_NAME (t);
+}
+
+/* Note that a template has been used. If we can see the definition, offer
+ to emit it. */
+
+void
+repo_template_used (t)
+ tree t;
+{
+ tree id;
+
+ if (! flag_use_repository)
+ return;
+
+ id = repo_get_id (t);
+ if (id == NULL_TREE)
+ return;
+
+ if (TREE_CODE_CLASS (TREE_CODE (t)) == 't')
+ {
+ if (IDENTIFIER_REPO_CHOSEN (id))
+ mark_class_instantiated (t, 0);
+ }
+ else if (TREE_CODE_CLASS (TREE_CODE (t)) == 'd')
+ {
+ if (IDENTIFIER_REPO_CHOSEN (id))
+ mark_function_instantiated (t, 0);
+ }
+ else
+ my_friendly_abort (1);
+
+ if (! IDENTIFIER_REPO_USED (id))
+ {
+ IDENTIFIER_REPO_USED (id) = 1;
+ pending_repo = perm_tree_cons (NULL_TREE, id, pending_repo);
+ }
+}
+
+/* Note that the vtable for a class has been used, and offer to emit it. */
+
+void
+repo_vtable_used (t)
+ tree t;
+{
+ if (! flag_use_repository)
+ return;
+
+ pending_repo = perm_tree_cons (NULL_TREE, t, pending_repo);
+}
+
+/* Note that an inline with external linkage has been used, and offer to
+ emit it. */
+
+void
+repo_inline_used (fn)
+ tree fn;
+{
+ if (! flag_use_repository)
+ return;
+
+ /* Member functions of polymorphic classes go with their vtables. */
+ if (DECL_FUNCTION_MEMBER_P (fn) && TYPE_VIRTUAL_P (DECL_CLASS_CONTEXT (fn)))
+ {
+ repo_vtable_used (DECL_CLASS_CONTEXT (fn));
+ return;
+ }
+
+ pending_repo = perm_tree_cons (NULL_TREE, fn, pending_repo);
+}
+
+/* Note that a particular typeinfo node has been used, and offer to
+ emit it. */
+
+void
+repo_tinfo_used (ti)
+ tree ti;
+{
+}
+
+void
+repo_template_instantiated (t, extern_p)
+ tree t;
+ int extern_p;
+{
+ if (! extern_p)
+ {
+ tree id = repo_get_id (t);
+ if (id)
+ IDENTIFIER_REPO_CHOSEN (id) = 1;
+ }
+}
+
+static char *
+save_string (s, len)
+ char *s;
+ int len;
+{
+ return obstack_copy0 (&temporary_obstack, s, len);
+}
+
+static char *
+get_base_filename (filename)
+ char *filename;
+{
+ char *p = getenv ("COLLECT_GCC_OPTIONS");
+ char *output = 0;
+ int compiling = 0;
+
+ if (p)
+ while (*p)
+ {
+ char *q = p;
+ while (*q && *q != ' ') q++;
+ if (*p == '-' && p[1] == 'o')
+ {
+ p += 2;
+ if (p == q)
+ {
+ p++; q++;
+ if (*q)
+ while (*q && *q != ' ') q++;
+ }
+
+ output = save_string (p, q - p);
+ }
+ else if (*p == '-' && p[1] == 'c')
+ compiling = 1;
+ if (*q) q++;
+ p = q;
+ }
+
+ if (compiling && output)
+ return output;
+
+ if (p && ! compiling)
+ {
+ warning ("-frepo must be used with -c");
+ flag_use_repository = 0;
+ return NULL;
+ }
+
+ p = rindex (filename, '/');
+ if (p)
+ return p+1;
+ else
+ return filename;
+}
+
+static void
+open_repo_file (filename)
+ char *filename;
+{
+ register char *p, *q;
+ char *s = get_base_filename (filename);
+
+ if (s == NULL)
+ return;
+
+ p = rindex (s, '/');
+ if (! p)
+ p = s;
+ p = rindex (p, '.');
+ if (! p)
+ p = s + strlen (s);
+
+ obstack_grow (&permanent_obstack, s, p - s);
+ repo_name = obstack_copy0 (&permanent_obstack, ".rpo", 4);
+
+ repo_file = fopen (repo_name, "r");
+}
+
+static char *
+afgets (stream)
+ FILE *stream;
+{
+ int c;
+ while ((c = getc (stream)) != EOF && c != '\n')
+ obstack_1grow (&temporary_obstack, c);
+ if (obstack_object_size (&temporary_obstack) == 0)
+ return NULL;
+ obstack_1grow (&temporary_obstack, '\0');
+ return obstack_finish (&temporary_obstack);
+}
+
+void
+init_repo (filename)
+ char *filename;
+{
+ char *buf;
+
+ if (! flag_use_repository)
+ return;
+
+ open_repo_file (filename);
+
+ if (repo_file == 0)
+ return;
+
+ while (buf = afgets (repo_file))
+ {
+ switch (buf[0])
+ {
+ case 'A':
+ case 'D':
+ case 'M':
+ break;
+ case 'C':
+ case 'O':
+ {
+ tree id = get_identifier (buf + 2);
+ tree orig;
+
+ if (buf[0] == 'C')
+ {
+ IDENTIFIER_REPO_CHOSEN (id) = 1;
+ orig = integer_one_node;
+ }
+ else
+ orig = NULL_TREE;
+
+ original_repo = perm_tree_cons (orig, id, original_repo);
+ }
+ break;
+ default:
+ error ("mysterious repository information in %s", repo_name);
+ }
+ obstack_free (&temporary_obstack, buf);
+ }
+}
+
+static void
+reopen_repo_file_for_write ()
+{
+ if (repo_file)
+ fclose (repo_file);
+ repo_file = fopen (repo_name, "w");
+
+ if (repo_file == 0)
+ {
+ error ("can't create repository information file `%s'", repo_name);
+ flag_use_repository = 0;
+ }
+}
+
+/* Emit any pending repos. */
+
+void
+finish_repo ()
+{
+ tree t;
+ char *p;
+ int repo_changed = 0;
+
+ if (! flag_use_repository)
+ return;
+
+ /* Do we have to write out a new info file? */
+
+ /* Are there any old templates that aren't used any longer or that are
+ newly chosen? */
+
+ for (t = original_repo; t; t = TREE_CHAIN (t))
+ {
+ if (! IDENTIFIER_REPO_USED (TREE_VALUE (t))
+ || (! TREE_PURPOSE (t) && IDENTIFIER_REPO_CHOSEN (TREE_VALUE (t))))
+ {
+ repo_changed = 1;
+ break;
+ }
+ IDENTIFIER_REPO_USED (TREE_VALUE (t)) = 0;
+ }
+
+ /* Are there any templates that are newly used? */
+
+ if (! repo_changed)
+ for (t = pending_repo; t; t = TREE_CHAIN (t))
+ {
+ if (IDENTIFIER_REPO_USED (TREE_VALUE (t)))
+ {
+ repo_changed = 1;
+ break;
+ }
+ }
+
+ if (! repo_changed || errorcount || sorrycount)
+ goto out;
+
+ reopen_repo_file_for_write ();
+
+ if (repo_file == 0)
+ goto out;
+
+ fprintf (repo_file, "M %s\n", main_input_filename);
+
+ p = getpwd ();
+ fprintf (repo_file, "D %s\n", p);
+
+ p = getenv ("COLLECT_GCC_OPTIONS");
+ if (p != 0)
+ fprintf (repo_file, "A %s\n", p);
+
+ for (t = pending_repo; t; t = TREE_CHAIN (t))
+ {
+ tree val = TREE_VALUE (t);
+ char type = IDENTIFIER_REPO_CHOSEN (val) ? 'C' : 'O';
+
+ fprintf (repo_file, "%c %s\n", type, IDENTIFIER_POINTER (val));
+ }
+
+ out:
+ if (repo_file)
+ fclose (repo_file);
+}
diff --git a/contrib/gcc/cp/search.c b/contrib/gcc/cp/search.c
new file mode 100644
index 0000000..0ac50a1
--- /dev/null
+++ b/contrib/gcc/cp/search.c
@@ -0,0 +1,3524 @@
+/* Breadth-first and depth-first routines for
+ searching multiple-inheritance lattice for GNU C++.
+ Copyright (C) 1987, 89, 92, 93, 94, 1995 Free Software Foundation, Inc.
+ Contributed by Michael Tiemann (tiemann@cygnus.com)
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+/* High-level class interface. */
+
+#include "config.h"
+#include "tree.h"
+#include <stdio.h>
+#include "cp-tree.h"
+#include "obstack.h"
+#include "flags.h"
+#include "rtl.h"
+#include "output.h"
+
+#define obstack_chunk_alloc xmalloc
+#define obstack_chunk_free free
+
+void init_search ();
+extern struct obstack *current_obstack;
+extern tree abort_fndecl;
+
+#include "stack.h"
+
+/* Obstack used for remembering decision points of breadth-first. */
+static struct obstack search_obstack;
+
+/* Methods for pushing and popping objects to and from obstacks. */
+struct stack_level *
+push_stack_level (obstack, tp, size)
+ struct obstack *obstack;
+ char *tp; /* Sony NewsOS 5.0 compiler doesn't like void * here. */
+ int size;
+{
+ struct stack_level *stack;
+ obstack_grow (obstack, tp, size);
+ stack = (struct stack_level *) ((char*)obstack_next_free (obstack) - size);
+ obstack_finish (obstack);
+ stack->obstack = obstack;
+ stack->first = (tree *) obstack_base (obstack);
+ stack->limit = obstack_room (obstack) / sizeof (tree *);
+ return stack;
+}
+
+struct stack_level *
+pop_stack_level (stack)
+ struct stack_level *stack;
+{
+ struct stack_level *tem = stack;
+ struct obstack *obstack = tem->obstack;
+ stack = tem->prev;
+ obstack_free (obstack, tem);
+ return stack;
+}
+
+#define search_level stack_level
+static struct search_level *search_stack;
+
+static tree lookup_field_1 ();
+static int lookup_fnfields_1 ();
+static void dfs_walk ();
+static int markedp ();
+static void dfs_unmark ();
+static void dfs_init_vbase_pointers ();
+
+static tree vbase_types;
+static tree vbase_decl, vbase_decl_ptr;
+static tree vbase_decl_ptr_intermediate;
+static tree vbase_init_result;
+
+/* Allocate a level of searching. */
+static struct search_level *
+push_search_level (stack, obstack)
+ struct stack_level *stack;
+ struct obstack *obstack;
+{
+ struct search_level tem;
+
+ tem.prev = stack;
+ return push_stack_level (obstack, (char *)&tem, sizeof (tem));
+}
+
+/* Discard a level of search allocation. */
+static struct search_level *
+pop_search_level (obstack)
+ struct stack_level *obstack;
+{
+ register struct search_level *stack = pop_stack_level (obstack);
+
+ return stack;
+}
+
+/* Search memoization. */
+struct type_level
+{
+ struct stack_level base;
+
+ /* First object allocated in obstack of entries. */
+ char *entries;
+
+ /* Number of types memoized in this context. */
+ int len;
+
+ /* Type being memoized; save this if we are saving
+ memoized contexts. */
+ tree type;
+};
+
+/* Obstack used for memoizing member and member function lookup. */
+
+static struct obstack type_obstack, type_obstack_entries;
+static struct type_level *type_stack;
+static tree _vptr_name;
+
+/* Make things that look like tree nodes, but allocate them
+ on type_obstack_entries. */
+static int my_tree_node_counter;
+static tree my_tree_cons (), my_build_string ();
+
+extern int flag_memoize_lookups, flag_save_memoized_contexts;
+
+/* Variables for gathering statistics. */
+static int my_memoized_entry_counter;
+static int memoized_fast_finds[2], memoized_adds[2], memoized_fast_rejects[2];
+static int memoized_fields_searched[2];
+static int n_fields_searched;
+static int n_calls_lookup_field, n_calls_lookup_field_1;
+static int n_calls_lookup_fnfields, n_calls_lookup_fnfields_1;
+static int n_calls_get_base_type;
+static int n_outer_fields_searched;
+static int n_contexts_saved;
+
+/* Local variables to help save memoization contexts. */
+static tree prev_type_memoized;
+static struct type_level *prev_type_stack;
+
+/* This list is used by push_class_decls to know what decls need to
+ be pushed into class scope. */
+static tree closed_envelopes = NULL_TREE;
+
+/* Allocate a level of type memoization context. */
+static struct type_level *
+push_type_level (stack, obstack)
+ struct stack_level *stack;
+ struct obstack *obstack;
+{
+ struct type_level tem;
+
+ tem.base.prev = stack;
+
+ obstack_finish (&type_obstack_entries);
+ tem.entries = (char *) obstack_base (&type_obstack_entries);
+ tem.len = 0;
+ tem.type = NULL_TREE;
+
+ return (struct type_level *)push_stack_level (obstack, (char *)&tem, sizeof (tem));
+}
+
+/* Discard a level of type memoization context. */
+
+static struct type_level *
+pop_type_level (stack)
+ struct type_level *stack;
+{
+ obstack_free (&type_obstack_entries, stack->entries);
+ return (struct type_level *)pop_stack_level ((struct stack_level *)stack);
+}
+
+/* Make something that looks like a TREE_LIST, but
+ do it on the type_obstack_entries obstack. */
+static tree
+my_tree_cons (purpose, value, chain)
+ tree purpose, value, chain;
+{
+ tree p = (tree)obstack_alloc (&type_obstack_entries, sizeof (struct tree_list));
+ ++my_tree_node_counter;
+ TREE_TYPE (p) = NULL_TREE;
+ ((HOST_WIDE_INT *)p)[3] = 0;
+ TREE_SET_CODE (p, TREE_LIST);
+ TREE_PURPOSE (p) = purpose;
+ TREE_VALUE (p) = value;
+ TREE_CHAIN (p) = chain;
+ return p;
+}
+
+static tree
+my_build_string (str)
+ char *str;
+{
+ tree p = (tree)obstack_alloc (&type_obstack_entries, sizeof (struct tree_string));
+ ++my_tree_node_counter;
+ TREE_TYPE (p) = 0;
+ ((int *)p)[3] = 0;
+ TREE_SET_CODE (p, STRING_CST);
+ TREE_STRING_POINTER (p) = str;
+ TREE_STRING_LENGTH (p) = strlen (str);
+ return p;
+}
+
+/* Memoizing machinery to make searches for multiple inheritance
+ reasonably efficient. */
+#define MEMOIZE_HASHSIZE 8
+typedef struct memoized_entry
+{
+ struct memoized_entry *chain;
+ int uid;
+ tree data_members[MEMOIZE_HASHSIZE];
+ tree function_members[MEMOIZE_HASHSIZE];
+} *ME;
+
+#define MEMOIZED_CHAIN(ENTRY) (((ME)ENTRY)->chain)
+#define MEMOIZED_UID(ENTRY) (((ME)ENTRY)->uid)
+#define MEMOIZED_FIELDS(ENTRY,INDEX) (((ME)ENTRY)->data_members[INDEX])
+#define MEMOIZED_FNFIELDS(ENTRY,INDEX) (((ME)ENTRY)->function_members[INDEX])
+/* The following is probably a lousy hash function. */
+#define MEMOIZED_HASH_FN(NODE) (((long)(NODE)>>4)&(MEMOIZE_HASHSIZE - 1))
+
+static struct memoized_entry *
+my_new_memoized_entry (chain)
+ struct memoized_entry *chain;
+{
+ struct memoized_entry *p =
+ (struct memoized_entry *)obstack_alloc (&type_obstack_entries,
+ sizeof (struct memoized_entry));
+ bzero ((char *) p, sizeof (struct memoized_entry));
+ MEMOIZED_CHAIN (p) = chain;
+ MEMOIZED_UID (p) = ++my_memoized_entry_counter;
+ return p;
+}
+
+/* Make an entry in the memoized table for type TYPE
+ that the entry for NAME is FIELD. */
+
+tree
+make_memoized_table_entry (type, name, function_p)
+ tree type, name;
+ int function_p;
+{
+ int index = MEMOIZED_HASH_FN (name);
+ tree entry, *prev_entry;
+
+ memoized_adds[function_p] += 1;
+ if (CLASSTYPE_MTABLE_ENTRY (type) == 0)
+ {
+ obstack_ptr_grow (&type_obstack, type);
+ obstack_blank (&type_obstack, sizeof (struct memoized_entry *));
+ CLASSTYPE_MTABLE_ENTRY (type) = (char *)my_new_memoized_entry ((struct memoized_entry *)0);
+ type_stack->len++;
+ if (type_stack->len * 2 >= type_stack->base.limit)
+ my_friendly_abort (88);
+ }
+ if (function_p)
+ prev_entry = &MEMOIZED_FNFIELDS (CLASSTYPE_MTABLE_ENTRY (type), index);
+ else
+ prev_entry = &MEMOIZED_FIELDS (CLASSTYPE_MTABLE_ENTRY (type), index);
+
+ entry = my_tree_cons (name, NULL_TREE, *prev_entry);
+ *prev_entry = entry;
+
+ /* Don't know the error message to give yet. */
+ TREE_TYPE (entry) = error_mark_node;
+
+ return entry;
+}
+
+/* When a new function or class context is entered, we build
+ a table of types which have been searched for members.
+ The table is an array (obstack) of types. When a type is
+ entered into the obstack, its CLASSTYPE_MTABLE_ENTRY
+ field is set to point to a new record, of type struct memoized_entry.
+
+ A non-NULL TREE_TYPE of the entry contains an access control error message.
+
+ The slots for the data members are arrays of tree nodes.
+ These tree nodes are lists, with the TREE_PURPOSE
+ of this list the known member name, and the TREE_VALUE
+ as the FIELD_DECL for the member.
+
+ For member functions, the TREE_PURPOSE is again the
+ name of the member functions for that class,
+ and the TREE_VALUE of the list is a pairs
+ whose TREE_PURPOSE is a member functions of this name,
+ and whose TREE_VALUE is a list of known argument lists this
+ member function has been called with. The TREE_TYPE of the pair,
+ if non-NULL, is an error message to print. */
+
+/* Tell search machinery that we are entering a new context, and
+ to update tables appropriately.
+
+ TYPE is the type of the context we are entering, which can
+ be NULL_TREE if we are not in a class's scope.
+
+ USE_OLD, if nonzero tries to use previous context. */
+void
+push_memoized_context (type, use_old)
+ tree type;
+ int use_old;
+{
+ int len;
+ tree *tem;
+
+ if (prev_type_stack)
+ {
+ if (use_old && prev_type_memoized == type)
+ {
+#ifdef GATHER_STATISTICS
+ n_contexts_saved++;
+#endif
+ type_stack = prev_type_stack;
+ prev_type_stack = 0;
+
+ tem = &type_stack->base.first[0];
+ len = type_stack->len;
+ while (len--)
+ CLASSTYPE_MTABLE_ENTRY (tem[len*2]) = (char *)tem[len*2+1];
+ return;
+ }
+ /* Otherwise, need to pop old stack here. */
+ type_stack = pop_type_level (prev_type_stack);
+ prev_type_memoized = 0;
+ prev_type_stack = 0;
+ }
+
+ type_stack = push_type_level ((struct stack_level *)type_stack,
+ &type_obstack);
+ type_stack->type = type;
+}
+
+/* Tell search machinery that we have left a context.
+ We do not currently save these contexts for later use.
+ If we wanted to, we could not use pop_search_level, since
+ poping that level allows the data we have collected to
+ be clobbered; a stack of obstacks would be needed. */
+void
+pop_memoized_context (use_old)
+ int use_old;
+{
+ int len;
+ tree *tem = &type_stack->base.first[0];
+
+ if (! flag_save_memoized_contexts)
+ use_old = 0;
+ else if (use_old)
+ {
+ len = type_stack->len;
+ while (len--)
+ tem[len*2+1] = (tree)CLASSTYPE_MTABLE_ENTRY (tem[len*2]);
+
+ prev_type_stack = type_stack;
+ prev_type_memoized = type_stack->type;
+ }
+
+ if (flag_memoize_lookups)
+ {
+ len = type_stack->len;
+ while (len--)
+ CLASSTYPE_MTABLE_ENTRY (tem[len*2])
+ = (char *)MEMOIZED_CHAIN (CLASSTYPE_MTABLE_ENTRY (tem[len*2]));
+ }
+ if (! use_old)
+ type_stack = pop_type_level (type_stack);
+ else
+ type_stack = (struct type_level *)type_stack->base.prev;
+}
+
+/* Get a virtual binfo that is found inside BINFO's hierarchy that is
+ the same type as the type given in PARENT. To be optimal, we want
+ the first one that is found by going through the least number of
+ virtual bases. DEPTH should be NULL_PTR. */
+static tree
+get_vbase (parent, binfo, depth)
+ tree parent, binfo;
+ unsigned int *depth;
+{
+ tree binfos;
+ int i, n_baselinks;
+ tree rval = NULL_TREE;
+
+ if (depth == 0)
+ {
+ unsigned int d = (unsigned int)-1;
+ return get_vbase (parent, binfo, &d);
+ }
+
+ if (BINFO_TYPE (binfo) == parent && TREE_VIA_VIRTUAL (binfo))
+ {
+ *depth = 0;
+ return binfo;
+ }
+
+ *depth = *depth - 1;
+
+ binfos = BINFO_BASETYPES (binfo);
+ n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+
+ /* Process base types. */
+ for (i = 0; i < n_baselinks; i++)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ tree nrval;
+
+ if (*depth == 0)
+ break;
+
+ nrval = get_vbase (parent, base_binfo, depth);
+ if (nrval)
+ rval = nrval;
+ }
+ *depth = *depth+1;
+ return rval;
+}
+
+/* Convert EXPR to a virtual base class of type TYPE. We know that
+ EXPR is a non-null POINTER_TYPE to RECORD_TYPE. We also know that
+ the type of what expr points to has a virtual base of type TYPE. */
+tree
+convert_pointer_to_vbase (type, expr)
+ tree type;
+ tree expr;
+{
+ tree vb = get_vbase (type, TYPE_BINFO (TREE_TYPE (TREE_TYPE (expr))), NULL_PTR);
+ return convert_pointer_to_real (vb, expr);
+}
+
+/* This is the newer recursive depth first search routine. */
+#if 0 /* unused */
+/* Return non-zero if PARENT is directly derived from TYPE. By directly
+ we mean it's only one step up the inheritance lattice. We check this
+ by walking horizontally across the types that TYPE directly inherits
+ from, to see if PARENT is among them. This is used by get_binfo and
+ by compute_access. */
+static int
+immediately_derived (parent, type)
+ tree parent, type;
+{
+ if (TYPE_BINFO (type))
+ {
+ tree binfos = BINFO_BASETYPES (TYPE_BINFO (type));
+ int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+
+ for (i = 0; i < n_baselinks; i++)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+
+ if (parent == BINFO_TYPE (base_binfo))
+ return 1;
+ }
+ }
+ return 0;
+}
+#endif
+
+/* Check whether the type given in BINFO is derived from PARENT. If
+ it isn't, return 0. If it is, but the derivation is MI-ambiguous
+ AND protect != 0, emit an error message and return error_mark_node.
+
+ Otherwise, if TYPE is derived from PARENT, return the actual base
+ information, unless a one of the protection violations below
+ occurs, in which case emit an error message and return error_mark_node.
+
+ If PROTECT is 1, then check if access to a public field of PARENT
+ would be private. Also check for ambiguity. */
+
+tree
+get_binfo (parent, binfo, protect)
+ register tree parent, binfo;
+ int protect;
+{
+ tree type;
+ int dist;
+ tree rval = NULL_TREE;
+
+ if (TREE_CODE (parent) == TREE_VEC)
+ parent = BINFO_TYPE (parent);
+ else if (! IS_AGGR_TYPE_CODE (TREE_CODE (parent)))
+ my_friendly_abort (89);
+
+ if (TREE_CODE (binfo) == TREE_VEC)
+ type = BINFO_TYPE (binfo);
+ else if (IS_AGGR_TYPE_CODE (TREE_CODE (binfo)))
+ type = binfo;
+ else
+ my_friendly_abort (90);
+
+ dist = get_base_distance (parent, binfo, protect, &rval);
+
+ if (dist == -3)
+ {
+ cp_error ("fields of `%T' are inaccessible in `%T' due to private inheritance",
+ parent, type);
+ return error_mark_node;
+ }
+ else if (dist == -2 && protect)
+ {
+ cp_error ("type `%T' is ambiguous base class for type `%T'", parent,
+ type);
+ return error_mark_node;
+ }
+
+ return rval;
+}
+
+/* This is the newer depth first get_base_distance routine. */
+static int
+get_base_distance_recursive (binfo, depth, is_private, basetype_path, rval,
+ rval_private_ptr, new_binfo_ptr, parent, path_ptr,
+ protect, via_virtual_ptr, via_virtual)
+ tree binfo, basetype_path, *new_binfo_ptr, parent, *path_ptr;
+ int *rval_private_ptr, depth, is_private, rval, protect, *via_virtual_ptr,
+ via_virtual;
+{
+ tree binfos;
+ int i, n_baselinks;
+
+ if (BINFO_TYPE (binfo) == parent || binfo == parent)
+ {
+ if (rval == -1)
+ {
+ rval = depth;
+ *rval_private_ptr = is_private;
+ *new_binfo_ptr = binfo;
+ *via_virtual_ptr = via_virtual;
+ }
+ else
+ {
+ int same_object = (tree_int_cst_equal (BINFO_OFFSET (*new_binfo_ptr),
+ BINFO_OFFSET (binfo))
+ && *via_virtual_ptr && via_virtual);
+
+ if (*via_virtual_ptr && via_virtual==0)
+ {
+ *rval_private_ptr = is_private;
+ *new_binfo_ptr = binfo;
+ *via_virtual_ptr = via_virtual;
+ }
+ else if (same_object)
+ {
+ if (*rval_private_ptr && ! is_private)
+ {
+ *rval_private_ptr = is_private;
+ *new_binfo_ptr = binfo;
+ *via_virtual_ptr = via_virtual;
+ }
+ return rval;
+ }
+
+ rval = -2;
+ }
+ return rval;
+ }
+
+ binfos = BINFO_BASETYPES (binfo);
+ n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+ depth += 1;
+
+ /* Process base types. */
+ for (i = 0; i < n_baselinks; i++)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+
+ /* Find any specific instance of a virtual base, when searching with
+ a binfo... */
+ if (BINFO_MARKED (base_binfo) == 0 || TREE_CODE (parent) == TREE_VEC)
+ {
+ int via_private
+ = (protect
+ && (is_private
+ || (!TREE_VIA_PUBLIC (base_binfo)
+ && !is_friend (BINFO_TYPE (binfo), current_scope ()))));
+ int this_virtual = via_virtual || TREE_VIA_VIRTUAL (base_binfo);
+ int was;
+
+ /* When searching for a non-virtual, we cannot mark
+ virtually found binfos. */
+ if (! this_virtual)
+ SET_BINFO_MARKED (base_binfo);
+
+#define WATCH_VALUES(rval, via_private) (rval == -1 ? 3 : via_private)
+
+ was = WATCH_VALUES (rval, *via_virtual_ptr);
+ rval = get_base_distance_recursive (base_binfo, depth, via_private,
+ binfo, rval, rval_private_ptr,
+ new_binfo_ptr, parent, path_ptr,
+ protect, via_virtual_ptr,
+ this_virtual);
+ /* watch for updates; only update if path is good. */
+ if (path_ptr && WATCH_VALUES (rval, *via_virtual_ptr) != was)
+ BINFO_INHERITANCE_CHAIN (base_binfo) = binfo;
+ if (rval == -2 && *via_virtual_ptr == 0)
+ return rval;
+
+#undef WATCH_VALUES
+
+ }
+ }
+
+ return rval;
+}
+
+/* Return the number of levels between type PARENT and the type given
+ in BINFO, following the leftmost path to PARENT not found along a
+ virtual path, if there are no real PARENTs (all come from virtual
+ base classes), then follow the leftmost path to PARENT.
+
+ Return -1 if TYPE is not derived from PARENT.
+ Return -2 if PARENT is an ambiguous base class of TYPE, and PROTECT is
+ non-negative.
+ Return -3 if PARENT is private to TYPE, and PROTECT is non-zero.
+
+ If PATH_PTR is non-NULL, then also build the list of types
+ from PARENT to TYPE, with TREE_VIA_VIRTUAL and TREE_VIA_PUBLIC
+ set.
+
+ PARENT can also be a binfo, in which case that exact parent is found
+ and no other. convert_pointer_to_real uses this functionality.
+
+ If BINFO is a binfo, its BINFO_INHERITANCE_CHAIN will be left alone. */
+
+int
+get_base_distance (parent, binfo, protect, path_ptr)
+ register tree parent, binfo;
+ int protect;
+ tree *path_ptr;
+{
+ int rval;
+ int rval_private = 0;
+ tree type;
+ tree new_binfo = NULL_TREE;
+ int via_virtual;
+ int watch_access = protect;
+
+ if (TREE_CODE (parent) != TREE_VEC)
+ parent = TYPE_MAIN_VARIANT (parent);
+
+ if (TREE_CODE (binfo) == TREE_VEC)
+ type = BINFO_TYPE (binfo);
+ else if (IS_AGGR_TYPE_CODE (TREE_CODE (binfo)))
+ {
+ type = binfo;
+ binfo = TYPE_BINFO (type);
+
+ if (path_ptr)
+ BINFO_INHERITANCE_CHAIN (binfo) = NULL_TREE;
+ }
+ else
+ my_friendly_abort (92);
+
+ if (parent == type || parent == binfo)
+ {
+ /* If the distance is 0, then we don't really need
+ a path pointer, but we shouldn't let garbage go back. */
+ if (path_ptr)
+ *path_ptr = binfo;
+ return 0;
+ }
+
+ if (path_ptr)
+ watch_access = 1;
+
+ rval = get_base_distance_recursive (binfo, 0, 0, NULL_TREE, -1,
+ &rval_private, &new_binfo, parent,
+ path_ptr, watch_access, &via_virtual, 0);
+
+ dfs_walk (binfo, dfs_unmark, markedp);
+
+ /* Access restrictions don't count if we found an ambiguous basetype. */
+ if (rval == -2 && protect >= 0)
+ rval_private = 0;
+
+ if (rval && protect && rval_private)
+ return -3;
+
+ /* find real virtual base classes. */
+ if (rval == -1 && TREE_CODE (parent) == TREE_VEC
+ && parent == binfo_member (BINFO_TYPE (parent),
+ CLASSTYPE_VBASECLASSES (type)))
+ {
+ BINFO_INHERITANCE_CHAIN (parent) = binfo;
+ new_binfo = parent;
+ rval = 1;
+ }
+
+ if (path_ptr)
+ *path_ptr = new_binfo;
+ return rval;
+}
+
+/* Search for a member with name NAME in a multiple inheritance lattice
+ specified by TYPE. If it does not exist, return NULL_TREE.
+ If the member is ambiguously referenced, return `error_mark_node'.
+ Otherwise, return the FIELD_DECL. */
+
+/* Do a 1-level search for NAME as a member of TYPE. The caller must
+ figure out whether it can access this field. (Since it is only one
+ level, this is reasonable.) */
+static tree
+lookup_field_1 (type, name)
+ tree type, name;
+{
+ register tree field = TYPE_FIELDS (type);
+
+#ifdef GATHER_STATISTICS
+ n_calls_lookup_field_1++;
+#endif
+ while (field)
+ {
+#ifdef GATHER_STATISTICS
+ n_fields_searched++;
+#endif
+ if (DECL_NAME (field) == NULL_TREE
+ && TREE_CODE (TREE_TYPE (field)) == UNION_TYPE)
+ {
+ tree temp = lookup_field_1 (TREE_TYPE (field), name);
+ if (temp)
+ return temp;
+ }
+ if (DECL_NAME (field) == name)
+ {
+ if ((TREE_CODE(field) == VAR_DECL || TREE_CODE(field) == CONST_DECL)
+ && DECL_ASSEMBLER_NAME (field) != NULL)
+ GNU_xref_ref(current_function_decl,
+ IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (field)));
+ return field;
+ }
+ field = TREE_CHAIN (field);
+ }
+ /* Not found. */
+ if (name == _vptr_name)
+ {
+ /* Give the user what s/he thinks s/he wants. */
+ if (TYPE_VIRTUAL_P (type))
+ return CLASSTYPE_VFIELD (type);
+ }
+ return NULL_TREE;
+}
+
+/* There are a number of cases we need to be aware of here:
+ current_class_type current_function_decl
+ * global NULL NULL
+ * fn-local NULL SET
+ * class-local SET NULL
+ * class->fn SET SET
+ * fn->class SET SET
+
+ Those last two make life interesting. If we're in a function which is
+ itself inside a class, we need decls to go into the fn's decls (our
+ second case below). But if we're in a class and the class itself is
+ inside a function, we need decls to go into the decls for the class. To
+ achieve this last goal, we must see if, when both current_class_decl and
+ current_function_decl are set, the class was declared inside that
+ function. If so, we know to put the decls into the class's scope. */
+
+tree
+current_scope ()
+{
+ if (current_function_decl == NULL_TREE)
+ return current_class_type;
+ if (current_class_type == NULL_TREE)
+ return current_function_decl;
+ if (DECL_CLASS_CONTEXT (current_function_decl) == current_class_type)
+ return current_function_decl;
+
+ return current_class_type;
+}
+
+/* Compute the access of FIELD. This is done by computing
+ the access available to each type in BASETYPES (which comes
+ as a list of [via_public/basetype] in reverse order, namely base
+ class before derived class). The first one which defines a
+ access defines the access for the field. Otherwise, the
+ access of the field is that which occurs normally.
+
+ Uses global variables CURRENT_CLASS_TYPE and
+ CURRENT_FUNCTION_DECL to use friend relationships
+ if necessary.
+
+ This will be static when lookup_fnfield comes into this file.
+
+ access_public means that the field can be accessed by the current lexical
+ scope.
+
+ access_protected means that the field cannot be accessed by the current
+ lexical scope because it is protected.
+
+ access_private means that the field cannot be accessed by the current
+ lexical scope because it is private. */
+
+#if 0
+#define PUBLIC_RETURN return (DECL_PUBLIC (field) = 1), access_public
+#define PROTECTED_RETURN return (DECL_PROTECTED (field) = 1), access_protected
+#define PRIVATE_RETURN return (DECL_PRIVATE (field) = 1), access_private
+#else
+#define PUBLIC_RETURN return access_public
+#define PROTECTED_RETURN return access_protected
+#define PRIVATE_RETURN return access_private
+#endif
+
+#if 0
+/* Disabled with DECL_PUBLIC &c. */
+static tree previous_scope = NULL_TREE;
+#endif
+
+enum access_type
+compute_access (basetype_path, field)
+ tree basetype_path, field;
+{
+ enum access_type access;
+ tree types;
+ tree context;
+ int protected_ok, via_protected;
+ extern int flag_access_control;
+#if 1
+ /* Replaces static decl above. */
+ tree previous_scope;
+#endif
+ int static_mem =
+ ((TREE_CODE (field) == FUNCTION_DECL && DECL_STATIC_FUNCTION_P (field))
+ || (TREE_CODE (field) != FUNCTION_DECL && TREE_STATIC (field)));
+
+ if (! flag_access_control)
+ return access_public;
+
+ /* The field lives in the current class. */
+ if (BINFO_TYPE (basetype_path) == current_class_type)
+ return access_public;
+
+#if 0
+ /* Disabled until pushing function scope clears these out. If ever. */
+ /* Make these special cases fast. */
+ if (current_scope () == previous_scope)
+ {
+ if (DECL_PUBLIC (field))
+ return access_public;
+ if (DECL_PROTECTED (field))
+ return access_protected;
+ if (DECL_PRIVATE (field))
+ return access_private;
+ }
+#endif
+
+ /* We don't currently support access control on nested types. */
+ if (TREE_CODE (field) == TYPE_DECL)
+ return access_public;
+
+ previous_scope = current_scope ();
+
+ context = DECL_CLASS_CONTEXT (field);
+ if (context == NULL_TREE)
+ context = DECL_CONTEXT (field);
+
+ /* Fields coming from nested anonymous unions have their DECL_CLASS_CONTEXT
+ slot set to the union type rather than the record type containing
+ the anonymous union. In this case, DECL_FIELD_CONTEXT is correct. */
+ if (context && TREE_CODE (context) == UNION_TYPE
+ && ANON_AGGRNAME_P (TYPE_IDENTIFIER (context)))
+ context = DECL_FIELD_CONTEXT (field);
+
+ /* Virtual function tables are never private. But we should know that
+ we are looking for this, and not even try to hide it. */
+ if (DECL_NAME (field) && VFIELD_NAME_P (DECL_NAME (field)) == 1)
+ PUBLIC_RETURN;
+
+ /* Member found immediately within object. */
+ if (BINFO_INHERITANCE_CHAIN (basetype_path) == NULL_TREE)
+ {
+ /* Are we (or an enclosing scope) friends with the class that has
+ FIELD? */
+ if (is_friend (context, previous_scope))
+ PUBLIC_RETURN;
+
+ /* If it's private, it's private, you letch. */
+ if (TREE_PRIVATE (field))
+ PRIVATE_RETURN;
+
+ /* ARM $11.5. Member functions of a derived class can access the
+ non-static protected members of a base class only through a
+ pointer to the derived class, a reference to it, or an object
+ of it. Also any subsequently derived classes also have
+ access. */
+ else if (TREE_PROTECTED (field))
+ {
+ if (current_class_type
+ && static_mem
+ && ACCESSIBLY_DERIVED_FROM_P (context, current_class_type))
+ PUBLIC_RETURN;
+ else
+ PROTECTED_RETURN;
+ }
+ else
+ PUBLIC_RETURN;
+ }
+
+ /* must reverse more than one element */
+ basetype_path = reverse_path (basetype_path);
+ types = basetype_path;
+ via_protected = 0;
+ access = access_default;
+ protected_ok = static_mem && current_class_type
+ && ACCESSIBLY_DERIVED_FROM_P (BINFO_TYPE (types), current_class_type);
+
+ while (1)
+ {
+ tree member;
+ tree binfo = types;
+ tree type = BINFO_TYPE (binfo);
+ int private_ok = 0;
+
+ /* Friends of a class can see protected members of its bases.
+ Note that classes are their own friends. */
+ if (is_friend (type, previous_scope))
+ {
+ protected_ok = 1;
+ private_ok = 1;
+ }
+
+ member = purpose_member (type, DECL_ACCESS (field));
+ if (member)
+ {
+ access = (enum access_type) TREE_VALUE (member);
+ break;
+ }
+
+ types = BINFO_INHERITANCE_CHAIN (types);
+
+ /* If the next type was VIA_PROTECTED, then fields of all remaining
+ classes past that one are *at least* protected. */
+ if (types)
+ {
+ if (TREE_VIA_PROTECTED (types))
+ via_protected = 1;
+ else if (! TREE_VIA_PUBLIC (types) && ! private_ok)
+ {
+ access = access_private;
+ break;
+ }
+ }
+ else
+ break;
+ }
+ reverse_path (basetype_path);
+
+ /* No special visibilities apply. Use normal rules. */
+
+ if (access == access_default)
+ {
+ if (is_friend (context, previous_scope))
+ access = access_public;
+ else if (TREE_PRIVATE (field))
+ access = access_private;
+ else if (TREE_PROTECTED (field))
+ access = access_protected;
+ else
+ access = access_public;
+ }
+
+ if (access == access_public && via_protected)
+ access = access_protected;
+
+ if (access == access_protected && protected_ok)
+ access = access_public;
+
+#if 0
+ if (access == access_public)
+ DECL_PUBLIC (field) = 1;
+ else if (access == access_protected)
+ DECL_PROTECTED (field) = 1;
+ else if (access == access_private)
+ DECL_PRIVATE (field) = 1;
+ else my_friendly_abort (96);
+#endif
+ return access;
+}
+
+/* Routine to see if the sub-object denoted by the binfo PARENT can be
+ found as a base class and sub-object of the object denoted by
+ BINFO. This routine relies upon binfos not being shared, except
+ for binfos for virtual bases. */
+static int
+is_subobject_of_p (parent, binfo)
+ tree parent, binfo;
+{
+ tree binfos = BINFO_BASETYPES (binfo);
+ int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+
+ if (parent == binfo)
+ return 1;
+
+ /* Process and/or queue base types. */
+ for (i = 0; i < n_baselinks; i++)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ if (TREE_VIA_VIRTUAL (base_binfo))
+ base_binfo = TYPE_BINFO (BINFO_TYPE (base_binfo));
+ if (is_subobject_of_p (parent, base_binfo))
+ return 1;
+ }
+ return 0;
+}
+
+/* See if a one FIELD_DECL hides another. This routine is meant to
+ correspond to ANSI working paper Sept 17, 1992 10p4. The two
+ binfos given are the binfos corresponding to the particular places
+ the FIELD_DECLs are found. This routine relies upon binfos not
+ being shared, except for virtual bases. */
+static int
+hides (hider_binfo, hidee_binfo)
+ tree hider_binfo, hidee_binfo;
+{
+ /* hider hides hidee, if hider has hidee as a base class and
+ the instance of hidee is a sub-object of hider. The first
+ part is always true is the second part is true.
+
+ When hider and hidee are the same (two ways to get to the exact
+ same member) we consider either one as hiding the other. */
+ return is_subobject_of_p (hidee_binfo, hider_binfo);
+}
+
+/* Very similar to lookup_fnfields_1 but it ensures that at least one
+ function was declared inside the class given by TYPE. It really should
+ only return functions that match the given TYPE. */
+static int
+lookup_fnfields_here (type, name)
+ tree type, name;
+{
+ int index = lookup_fnfields_1 (type, name);
+ tree fndecls;
+
+ if (index <= 0)
+ return index;
+ fndecls = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), index);
+ while (fndecls)
+ {
+ if (TYPE_MAIN_VARIANT (DECL_CLASS_CONTEXT (fndecls))
+ == TYPE_MAIN_VARIANT (type))
+ return index;
+ fndecls = TREE_CHAIN (fndecls);
+ }
+ return -1;
+}
+
+/* Look for a field named NAME in an inheritance lattice dominated by
+ XBASETYPE. PROTECT is zero if we can avoid computing access
+ information, otherwise it is 1. WANT_TYPE is 1 when we should only
+ return TYPE_DECLs, if no TYPE_DECL can be found return NULL_TREE.
+
+ It was not clear what should happen if WANT_TYPE is set, and an
+ ambiguity is found. At least one use (lookup_name) to not see
+ the error. */
+tree
+lookup_field (xbasetype, name, protect, want_type)
+ register tree xbasetype, name;
+ int protect, want_type;
+{
+ int head = 0, tail = 0;
+ tree rval, rval_binfo = NULL_TREE, rval_binfo_h;
+ tree type, basetype_chain, basetype_path;
+ enum access_type this_v = access_default;
+ tree entry, binfo, binfo_h;
+ enum access_type own_access = access_default;
+ int vbase_name_p = VBASE_NAME_P (name);
+
+ /* rval_binfo is the binfo associated with the found member, note,
+ this can be set with useful information, even when rval is not
+ set, because it must deal with ALL members, not just non-function
+ members. It is used for ambiguity checking and the hidden
+ checks. Whereas rval is only set if a proper (not hidden)
+ non-function member is found. */
+
+ /* rval_binfo_h and binfo_h are binfo values used when we perform the
+ hiding checks, as virtual base classes may not be shared. The strategy
+ is we always go into the the binfo hierarchy owned by TYPE_BINFO of
+ virtual base classes, as we cross virtual base class lines. This way
+ we know that binfo of a virtual base class will always == itself when
+ found along any line. (mrs) */
+
+ char *errstr = 0;
+
+ /* Set this to nonzero if we don't know how to compute
+ accurate error messages for access control. */
+ int index = MEMOIZED_HASH_FN (name);
+
+ /* If we are looking for a constructor in a templated type, use the
+ unspecialized name, as that is how we store it. */
+ if (IDENTIFIER_TEMPLATE (name))
+ name = constructor_name (name);
+
+ if (TREE_CODE (xbasetype) == TREE_VEC)
+ {
+ type = BINFO_TYPE (xbasetype);
+ basetype_path = xbasetype;
+ }
+ else if (IS_AGGR_TYPE_CODE (TREE_CODE (xbasetype)))
+ {
+ type = xbasetype;
+ basetype_path = TYPE_BINFO (xbasetype);
+ BINFO_VIA_PUBLIC (basetype_path) = 1;
+ BINFO_INHERITANCE_CHAIN (basetype_path) = NULL_TREE;
+ }
+ else my_friendly_abort (97);
+
+ if (CLASSTYPE_MTABLE_ENTRY (type))
+ {
+ tree tem = MEMOIZED_FIELDS (CLASSTYPE_MTABLE_ENTRY (type), index);
+
+ while (tem && TREE_PURPOSE (tem) != name)
+ {
+ memoized_fields_searched[0]++;
+ tem = TREE_CHAIN (tem);
+ }
+ if (tem)
+ {
+ if (protect && TREE_TYPE (tem))
+ {
+ error (TREE_STRING_POINTER (TREE_TYPE (tem)),
+ IDENTIFIER_POINTER (name),
+ TYPE_NAME_STRING (DECL_FIELD_CONTEXT (TREE_VALUE (tem))));
+ return error_mark_node;
+ }
+ if (TREE_VALUE (tem) == NULL_TREE)
+ memoized_fast_rejects[0] += 1;
+ else
+ memoized_fast_finds[0] += 1;
+ return TREE_VALUE (tem);
+ }
+ }
+
+#ifdef GATHER_STATISTICS
+ n_calls_lookup_field++;
+#endif
+ if (protect && flag_memoize_lookups && ! global_bindings_p ())
+ entry = make_memoized_table_entry (type, name, 0);
+ else
+ entry = 0;
+
+ rval = lookup_field_1 (type, name);
+
+ if (rval || lookup_fnfields_here (type, name) >= 0)
+ {
+ if (rval)
+ {
+ if (want_type)
+ {
+ if (TREE_CODE (rval) != TYPE_DECL)
+ {
+ rval = purpose_member (name, CLASSTYPE_TAGS (type));
+ if (rval)
+ rval = TYPE_MAIN_DECL (TREE_VALUE (rval));
+ }
+ }
+ else
+ {
+ if (TREE_CODE (rval) == TYPE_DECL
+ && lookup_fnfields_here (type, name) >= 0)
+ rval = NULL_TREE;
+ }
+ }
+
+ if (protect && rval)
+ {
+ if (TREE_PRIVATE (rval) | TREE_PROTECTED (rval))
+ this_v = compute_access (basetype_path, rval);
+ if (TREE_CODE (rval) == CONST_DECL)
+ {
+ if (this_v == access_private)
+ errstr = "enum `%D' is a private value of class `%T'";
+ else if (this_v == access_protected)
+ errstr = "enum `%D' is a protected value of class `%T'";
+ }
+ else
+ {
+ if (this_v == access_private)
+ errstr = "member `%D' is a private member of class `%T'";
+ else if (this_v == access_protected)
+ errstr = "member `%D' is a protected member of class `%T'";
+ }
+ }
+
+ if (entry)
+ {
+ if (errstr)
+ {
+ /* This depends on behavior of lookup_field_1! */
+ tree error_string = my_build_string (errstr);
+ TREE_TYPE (entry) = error_string;
+ }
+ else
+ {
+ /* Let entry know there is no problem with this access. */
+ TREE_TYPE (entry) = NULL_TREE;
+ }
+ TREE_VALUE (entry) = rval;
+ }
+
+ if (errstr && protect)
+ {
+ cp_error (errstr, name, type);
+ return error_mark_node;
+ }
+ return rval;
+ }
+
+ basetype_chain = build_tree_list (NULL_TREE, basetype_path);
+ TREE_VIA_PUBLIC (basetype_chain) = TREE_VIA_PUBLIC (basetype_path);
+ TREE_VIA_PROTECTED (basetype_chain) = TREE_VIA_PROTECTED (basetype_path);
+ TREE_VIA_VIRTUAL (basetype_chain) = TREE_VIA_VIRTUAL (basetype_path);
+
+ /* The ambiguity check relies upon breadth first searching. */
+
+ search_stack = push_search_level (search_stack, &search_obstack);
+ binfo = basetype_path;
+ binfo_h = binfo;
+
+ while (1)
+ {
+ tree binfos = BINFO_BASETYPES (binfo);
+ int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+ tree nval;
+
+ /* Process and/or queue base types. */
+ for (i = 0; i < n_baselinks; i++)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ if (BINFO_FIELDS_MARKED (base_binfo) == 0)
+ {
+ tree btypes;
+
+ SET_BINFO_FIELDS_MARKED (base_binfo);
+ btypes = my_tree_cons (NULL_TREE, base_binfo, basetype_chain);
+ TREE_VIA_PUBLIC (btypes) = TREE_VIA_PUBLIC (base_binfo);
+ TREE_VIA_PROTECTED (btypes) = TREE_VIA_PROTECTED (base_binfo);
+ TREE_VIA_VIRTUAL (btypes) = TREE_VIA_VIRTUAL (base_binfo);
+ if (TREE_VIA_VIRTUAL (base_binfo))
+ btypes = tree_cons (NULL_TREE,
+ TYPE_BINFO (BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (binfo_h), i))),
+ btypes);
+ else
+ btypes = tree_cons (NULL_TREE,
+ TREE_VEC_ELT (BINFO_BASETYPES (binfo_h), i),
+ btypes);
+ obstack_ptr_grow (&search_obstack, btypes);
+ tail += 1;
+ if (tail >= search_stack->limit)
+ my_friendly_abort (98);
+ }
+ }
+
+ /* Process head of queue, if one exists. */
+ if (head >= tail)
+ break;
+
+ basetype_chain = search_stack->first[head++];
+ binfo_h = TREE_VALUE (basetype_chain);
+ basetype_chain = TREE_CHAIN (basetype_chain);
+ basetype_path = TREE_VALUE (basetype_chain);
+ if (TREE_CHAIN (basetype_chain))
+ BINFO_INHERITANCE_CHAIN (basetype_path) = TREE_VALUE (TREE_CHAIN (basetype_chain));
+ else
+ BINFO_INHERITANCE_CHAIN (basetype_path) = NULL_TREE;
+
+ binfo = basetype_path;
+ type = BINFO_TYPE (binfo);
+
+ /* See if we can find NAME in TYPE. If RVAL is nonzero,
+ and we do find NAME in TYPE, verify that such a second
+ sighting is in fact valid. */
+
+ nval = lookup_field_1 (type, name);
+
+ if (nval || lookup_fnfields_here (type, name)>=0)
+ {
+ if (nval && nval == rval && SHARED_MEMBER_P (nval))
+ {
+ /* This is ok, the member found is the same [class.ambig] */
+ }
+ else if (rval_binfo && hides (rval_binfo_h, binfo_h))
+ {
+ /* This is ok, the member found is in rval_binfo, not
+ here (binfo). */
+ }
+ else if (rval_binfo==NULL_TREE || hides (binfo_h, rval_binfo_h))
+ {
+ /* This is ok, the member found is here (binfo), not in
+ rval_binfo. */
+ if (nval)
+ {
+ rval = nval;
+ if (entry || protect)
+ this_v = compute_access (basetype_path, rval);
+ /* These may look ambiguous, but they really are not. */
+ if (vbase_name_p)
+ break;
+ }
+ else
+ {
+ /* Undo finding it before, as something else hides it. */
+ rval = NULL_TREE;
+ }
+ rval_binfo = binfo;
+ rval_binfo_h = binfo_h;
+ }
+ else
+ {
+ /* This is ambiguous. */
+ errstr = "request for member `%D' is ambiguous";
+ protect = 2;
+ break;
+ }
+ }
+ }
+ {
+ tree *tp = search_stack->first;
+ tree *search_tail = tp + tail;
+
+ if (entry)
+ TREE_VALUE (entry) = rval;
+
+ if (rval_binfo)
+ {
+ type = BINFO_TYPE (rval_binfo);
+
+ if (rval)
+ {
+ if (want_type)
+ {
+ if (TREE_CODE (rval) != TYPE_DECL)
+ {
+ rval = purpose_member (name, CLASSTYPE_TAGS (type));
+ if (rval)
+ rval = TYPE_MAIN_DECL (TREE_VALUE (rval));
+ }
+ }
+ else
+ {
+ if (TREE_CODE (rval) == TYPE_DECL
+ && lookup_fnfields_here (type, name) >= 0)
+ rval = NULL_TREE;
+ }
+ }
+ }
+
+ if (rval == NULL_TREE)
+ errstr = 0;
+
+ /* If this FIELD_DECL defines its own access level, deal with that. */
+ if (rval && errstr == 0
+ && ((protect&1) || entry)
+ && DECL_LANG_SPECIFIC (rval)
+ && DECL_ACCESS (rval))
+ {
+ while (tp < search_tail)
+ {
+ /* If is possible for one of the derived types on the path to
+ have defined special access for this field. Look for such
+ declarations and report an error if a conflict is found. */
+ enum access_type new_v;
+
+ if (this_v != access_default)
+ new_v = compute_access (TREE_VALUE (TREE_CHAIN (*tp)), rval);
+ if (this_v != access_default && new_v != this_v)
+ {
+ errstr = "conflicting access to member `%D'";
+ this_v = access_default;
+ }
+ own_access = new_v;
+ CLEAR_BINFO_FIELDS_MARKED (TREE_VALUE (TREE_CHAIN (*tp)));
+ tp += 1;
+ }
+ }
+ else
+ {
+ while (tp < search_tail)
+ {
+ CLEAR_BINFO_FIELDS_MARKED (TREE_VALUE (TREE_CHAIN (*tp)));
+ tp += 1;
+ }
+ }
+ }
+ search_stack = pop_search_level (search_stack);
+
+ if (errstr == 0)
+ {
+ if (own_access == access_private)
+ errstr = "member `%D' declared private";
+ else if (own_access == access_protected)
+ errstr = "member `%D' declared protected";
+ else if (this_v == access_private)
+ errstr = TREE_PRIVATE (rval)
+ ? "member `%D' is private"
+ : "member `%D' is from private base class";
+ else if (this_v == access_protected)
+ errstr = TREE_PROTECTED (rval)
+ ? "member `%D' is protected"
+ : "member `%D' is from protected base class";
+ }
+
+ if (entry)
+ {
+ if (errstr)
+ {
+ tree error_string = my_build_string (errstr);
+ /* Save error message with entry. */
+ TREE_TYPE (entry) = error_string;
+ }
+ else
+ {
+ /* Mark entry as having no error string. */
+ TREE_TYPE (entry) = NULL_TREE;
+ }
+ }
+
+ if (errstr && protect)
+ {
+ cp_error (errstr, name, type);
+ rval = error_mark_node;
+ }
+ return rval;
+}
+
+/* Try to find NAME inside a nested class. */
+tree
+lookup_nested_field (name, complain)
+ tree name;
+ int complain;
+{
+ register tree t;
+
+ tree id = NULL_TREE;
+ if (TREE_CHAIN (current_class_type))
+ {
+ /* Climb our way up the nested ladder, seeing if we're trying to
+ modify a field in an enclosing class. If so, we should only
+ be able to modify if it's static. */
+ for (t = TREE_CHAIN (current_class_type);
+ t && DECL_CONTEXT (t);
+ t = TREE_CHAIN (DECL_CONTEXT (t)))
+ {
+ if (TREE_CODE (DECL_CONTEXT (t)) != RECORD_TYPE)
+ break;
+
+ /* N.B.: lookup_field will do the access checking for us */
+ id = lookup_field (DECL_CONTEXT (t), name, complain, 0);
+ if (id == error_mark_node)
+ {
+ id = NULL_TREE;
+ continue;
+ }
+
+ if (id != NULL_TREE)
+ {
+ if (TREE_CODE (id) == FIELD_DECL
+ && ! TREE_STATIC (id)
+ && TREE_TYPE (id) != error_mark_node)
+ {
+ if (complain)
+ {
+ /* At parse time, we don't want to give this error, since
+ we won't have enough state to make this kind of
+ decision properly. But there are times (e.g., with
+ enums in nested classes) when we do need to call
+ this fn at parse time. So, in those cases, we pass
+ complain as a 0 and just return a NULL_TREE. */
+ error ("assignment to non-static member `%s' of enclosing class `%s'",
+ lang_printable_name (id),
+ IDENTIFIER_POINTER (TYPE_IDENTIFIER
+ (DECL_CONTEXT (t))));
+ /* Mark this for do_identifier(). It would otherwise
+ claim that the variable was undeclared. */
+ TREE_TYPE (id) = error_mark_node;
+ }
+ else
+ {
+ id = NULL_TREE;
+ continue;
+ }
+ }
+ break;
+ }
+ }
+ }
+
+ return id;
+}
+
+/* TYPE is a class type. Return the index of the fields within
+ the method vector with name NAME, or -1 is no such field exists. */
+static int
+lookup_fnfields_1 (type, name)
+ tree type, name;
+{
+ register tree method_vec = CLASSTYPE_METHOD_VEC (type);
+
+ if (method_vec != 0)
+ {
+ register tree *methods = &TREE_VEC_ELT (method_vec, 0);
+ register tree *end = TREE_VEC_END (method_vec);
+
+#ifdef GATHER_STATISTICS
+ n_calls_lookup_fnfields_1++;
+#endif
+ if (*methods && name == constructor_name (type))
+ return 0;
+
+ while (++methods != end)
+ {
+#ifdef GATHER_STATISTICS
+ n_outer_fields_searched++;
+#endif
+ if (DECL_NAME (*methods) == name)
+ break;
+ }
+ if (methods != end)
+ return methods - &TREE_VEC_ELT (method_vec, 0);
+ }
+
+ return -1;
+}
+
+/* Starting from BASETYPE, return a TREE_BASELINK-like object
+ which gives the following information (in a list):
+
+ TREE_TYPE: list of basetypes needed to get to...
+ TREE_VALUE: list of all functions in of given type
+ which have name NAME.
+
+ No access information is computed by this function,
+ other then to adorn the list of basetypes with
+ TREE_VIA_PUBLIC.
+
+ If there are two ways to find a name (two members), if COMPLAIN is
+ non-zero, then error_mark_node is returned, and an error message is
+ printed, otherwise, just an error_mark_node is returned.
+
+ As a special case, is COMPLAIN is -1, we don't complain, and we
+ don't return error_mark_node, but rather the complete list of
+ virtuals. This is used by get_virtuals_named_this. */
+tree
+lookup_fnfields (basetype_path, name, complain)
+ tree basetype_path, name;
+ int complain;
+{
+ int head = 0, tail = 0;
+ tree type, rval, rval_binfo = NULL_TREE, rvals = NULL_TREE, rval_binfo_h;
+ tree entry, binfo, basetype_chain, binfo_h;
+ int find_all = 0;
+
+ /* rval_binfo is the binfo associated with the found member, note,
+ this can be set with useful information, even when rval is not
+ set, because it must deal with ALL members, not just function
+ members. It is used for ambiguity checking and the hidden
+ checks. Whereas rval is only set if a proper (not hidden)
+ function member is found. */
+
+ /* rval_binfo_h and binfo_h are binfo values used when we perform the
+ hiding checks, as virtual base classes may not be shared. The strategy
+ is we always go into the the binfo hierarchy owned by TYPE_BINFO of
+ virtual base classes, as we cross virtual base class lines. This way
+ we know that binfo of a virtual base class will always == itself when
+ found along any line. (mrs) */
+
+ /* For now, don't try this. */
+ int protect = complain;
+
+ char *errstr = 0;
+
+ /* Set this to nonzero if we don't know how to compute
+ accurate error messages for access control. */
+ int index = MEMOIZED_HASH_FN (name);
+
+ if (complain == -1)
+ {
+ find_all = 1;
+ protect = complain = 0;
+ }
+
+ /* If we are looking for a constructor in a templated type, use the
+ unspecialized name, as that is how we store it. */
+ if (IDENTIFIER_TEMPLATE (name))
+ name = constructor_name (name);
+
+ binfo = basetype_path;
+ binfo_h = binfo;
+ type = BINFO_TYPE (basetype_path);
+
+ /* The memoization code is in need of maintenance. */
+ if (!find_all && CLASSTYPE_MTABLE_ENTRY (type))
+ {
+ tree tem = MEMOIZED_FNFIELDS (CLASSTYPE_MTABLE_ENTRY (type), index);
+
+ while (tem && TREE_PURPOSE (tem) != name)
+ {
+ memoized_fields_searched[1]++;
+ tem = TREE_CHAIN (tem);
+ }
+ if (tem)
+ {
+ if (protect && TREE_TYPE (tem))
+ {
+ error (TREE_STRING_POINTER (TREE_TYPE (tem)),
+ IDENTIFIER_POINTER (name),
+ TYPE_NAME_STRING (DECL_CLASS_CONTEXT (TREE_VALUE (TREE_VALUE (tem)))));
+ return error_mark_node;
+ }
+ if (TREE_VALUE (tem) == NULL_TREE)
+ {
+ memoized_fast_rejects[1] += 1;
+ return NULL_TREE;
+ }
+ else
+ {
+ /* Want to return this, but we must make sure
+ that access information is consistent. */
+ tree baselink = TREE_VALUE (tem);
+ tree memoized_basetypes = TREE_PURPOSE (baselink);
+ tree these_basetypes = basetype_path;
+ while (memoized_basetypes && these_basetypes)
+ {
+ memoized_fields_searched[1]++;
+ if (TREE_VALUE (memoized_basetypes) != these_basetypes)
+ break;
+ memoized_basetypes = TREE_CHAIN (memoized_basetypes);
+ these_basetypes = BINFO_INHERITANCE_CHAIN (these_basetypes);
+ }
+ /* The following statement is true only when both are NULL. */
+ if (memoized_basetypes == these_basetypes)
+ {
+ memoized_fast_finds[1] += 1;
+ return TREE_VALUE (tem);
+ }
+ /* else, we must re-find this field by hand. */
+ baselink = tree_cons (basetype_path, TREE_VALUE (baselink), TREE_CHAIN (baselink));
+ return baselink;
+ }
+ }
+ }
+
+#ifdef GATHER_STATISTICS
+ n_calls_lookup_fnfields++;
+#endif
+ if (protect && flag_memoize_lookups && ! global_bindings_p ())
+ entry = make_memoized_table_entry (type, name, 1);
+ else
+ entry = 0;
+
+ index = lookup_fnfields_here (type, name);
+ if (index >= 0 || lookup_field_1 (type, name))
+ {
+ rval_binfo = basetype_path;
+ rval_binfo_h = rval_binfo;
+ }
+
+ if (index >= 0)
+ {
+ rval = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), index);
+ rvals = my_tree_cons (basetype_path, rval, rvals);
+ if (BINFO_BASETYPES (binfo) && CLASSTYPE_BASELINK_VEC (type))
+ TREE_TYPE (rvals) = TREE_VEC_ELT (CLASSTYPE_BASELINK_VEC (type), index);
+
+ if (entry)
+ {
+ TREE_VALUE (entry) = rvals;
+ TREE_TYPE (entry) = NULL_TREE;
+ }
+
+ return rvals;
+ }
+ rval = NULL_TREE;
+
+ if (basetype_path == TYPE_BINFO (type))
+ {
+ basetype_chain = CLASSTYPE_BINFO_AS_LIST (type);
+ TREE_VIA_PUBLIC (basetype_chain) = 1;
+ BINFO_VIA_PUBLIC (basetype_path) = 1;
+ BINFO_INHERITANCE_CHAIN (basetype_path) = NULL_TREE;
+ }
+ else
+ {
+ basetype_chain = build_tree_list (NULL_TREE, basetype_path);
+ TREE_VIA_PUBLIC (basetype_chain) = TREE_VIA_PUBLIC (basetype_path);
+ TREE_VIA_PROTECTED (basetype_chain) = TREE_VIA_PROTECTED (basetype_path);
+ TREE_VIA_VIRTUAL (basetype_chain) = TREE_VIA_VIRTUAL (basetype_path);
+ }
+
+ /* The ambiguity check relies upon breadth first searching. */
+
+ search_stack = push_search_level (search_stack, &search_obstack);
+ binfo = basetype_path;
+ binfo_h = binfo;
+
+ while (1)
+ {
+ tree binfos = BINFO_BASETYPES (binfo);
+ int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+ int index;
+
+ /* Process and/or queue base types. */
+ for (i = 0; i < n_baselinks; i++)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ if (BINFO_FIELDS_MARKED (base_binfo) == 0)
+ {
+ tree btypes;
+
+ SET_BINFO_FIELDS_MARKED (base_binfo);
+ btypes = my_tree_cons (NULL_TREE, base_binfo, basetype_chain);
+ TREE_VIA_PUBLIC (btypes) = TREE_VIA_PUBLIC (base_binfo);
+ TREE_VIA_PROTECTED (btypes) = TREE_VIA_PROTECTED (base_binfo);
+ TREE_VIA_VIRTUAL (btypes) = TREE_VIA_VIRTUAL (base_binfo);
+ if (TREE_VIA_VIRTUAL (base_binfo))
+ btypes = tree_cons (NULL_TREE,
+ TYPE_BINFO (BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (binfo_h), i))),
+ btypes);
+ else
+ btypes = tree_cons (NULL_TREE,
+ TREE_VEC_ELT (BINFO_BASETYPES (binfo_h), i),
+ btypes);
+ obstack_ptr_grow (&search_obstack, btypes);
+ tail += 1;
+ if (tail >= search_stack->limit)
+ my_friendly_abort (99);
+ }
+ }
+
+ /* Process head of queue, if one exists. */
+ if (head >= tail)
+ break;
+
+ basetype_chain = search_stack->first[head++];
+ binfo_h = TREE_VALUE (basetype_chain);
+ basetype_chain = TREE_CHAIN (basetype_chain);
+ basetype_path = TREE_VALUE (basetype_chain);
+ if (TREE_CHAIN (basetype_chain))
+ BINFO_INHERITANCE_CHAIN (basetype_path) = TREE_VALUE (TREE_CHAIN (basetype_chain));
+ else
+ BINFO_INHERITANCE_CHAIN (basetype_path) = NULL_TREE;
+
+ binfo = basetype_path;
+ type = BINFO_TYPE (binfo);
+
+ /* See if we can find NAME in TYPE. If RVAL is nonzero,
+ and we do find NAME in TYPE, verify that such a second
+ sighting is in fact valid. */
+
+ index = lookup_fnfields_here (type, name);
+
+ if (index >= 0 || (lookup_field_1 (type, name)!=NULL_TREE && !find_all))
+ {
+ if (rval_binfo && !find_all && hides (rval_binfo_h, binfo_h))
+ {
+ /* This is ok, the member found is in rval_binfo, not
+ here (binfo). */
+ }
+ else if (rval_binfo==NULL_TREE || find_all || hides (binfo_h, rval_binfo_h))
+ {
+ /* This is ok, the member found is here (binfo), not in
+ rval_binfo. */
+ if (index >= 0)
+ {
+ rval = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), index);
+ /* Note, rvals can only be previously set if find_all is
+ true. */
+ rvals = my_tree_cons (basetype_path, rval, rvals);
+ if (TYPE_BINFO_BASETYPES (type)
+ && CLASSTYPE_BASELINK_VEC (type))
+ TREE_TYPE (rvals) = TREE_VEC_ELT (CLASSTYPE_BASELINK_VEC (type), index);
+ }
+ else
+ {
+ /* Undo finding it before, as something else hides it. */
+ rval = NULL_TREE;
+ rvals = NULL_TREE;
+ }
+ rval_binfo = binfo;
+ rval_binfo_h = binfo_h;
+ }
+ else
+ {
+ /* This is ambiguous. */
+ errstr = "request for method `%D' is ambiguous";
+ rvals = error_mark_node;
+ break;
+ }
+ }
+ }
+ {
+ tree *tp = search_stack->first;
+ tree *search_tail = tp + tail;
+
+ while (tp < search_tail)
+ {
+ CLEAR_BINFO_FIELDS_MARKED (TREE_VALUE (TREE_CHAIN (*tp)));
+ tp += 1;
+ }
+ }
+ search_stack = pop_search_level (search_stack);
+
+ if (entry)
+ {
+ if (errstr)
+ {
+ tree error_string = my_build_string (errstr);
+ /* Save error message with entry. */
+ TREE_TYPE (entry) = error_string;
+ }
+ else
+ {
+ /* Mark entry as having no error string. */
+ TREE_TYPE (entry) = NULL_TREE;
+ TREE_VALUE (entry) = rvals;
+ }
+ }
+
+ if (errstr && protect)
+ {
+ cp_error (errstr, name);
+ rvals = error_mark_node;
+ }
+
+ return rvals;
+}
+
+/* BREADTH-FIRST SEARCH ROUTINES. */
+
+/* Search a multiple inheritance hierarchy by breadth-first search.
+
+ TYPE is an aggregate type, possibly in a multiple-inheritance hierarchy.
+ TESTFN is a function, which, if true, means that our condition has been met,
+ and its return value should be returned.
+ QFN, if non-NULL, is a predicate dictating whether the type should
+ even be queued. */
+
+HOST_WIDE_INT
+breadth_first_search (binfo, testfn, qfn)
+ tree binfo;
+ int (*testfn)();
+ int (*qfn)();
+{
+ int head = 0, tail = 0;
+ int rval = 0;
+
+ search_stack = push_search_level (search_stack, &search_obstack);
+
+ while (1)
+ {
+ tree binfos = BINFO_BASETYPES (binfo);
+ int n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+ int i;
+
+ /* Process and/or queue base types. */
+ for (i = 0; i < n_baselinks; i++)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+
+ if (BINFO_MARKED (base_binfo) == 0
+ && (qfn == 0 || (*qfn) (binfo, i)))
+ {
+ SET_BINFO_MARKED (base_binfo);
+ obstack_ptr_grow (&search_obstack, binfo);
+ obstack_ptr_grow (&search_obstack, (HOST_WIDE_INT) i);
+ tail += 2;
+ if (tail >= search_stack->limit)
+ my_friendly_abort (100);
+ }
+ }
+ /* Process head of queue, if one exists. */
+ if (head >= tail)
+ {
+ rval = 0;
+ break;
+ }
+
+ binfo = search_stack->first[head++];
+ i = (HOST_WIDE_INT) search_stack->first[head++];
+ if (rval = (*testfn) (binfo, i))
+ break;
+ binfo = BINFO_BASETYPE (binfo, i);
+ }
+ {
+ tree *tp = search_stack->first;
+ tree *search_tail = tp + tail;
+ while (tp < search_tail)
+ {
+ tree binfo = *tp++;
+ int i = (HOST_WIDE_INT)(*tp++);
+ CLEAR_BINFO_MARKED (BINFO_BASETYPE (binfo, i));
+ }
+ }
+
+ search_stack = pop_search_level (search_stack);
+ return rval;
+}
+
+/* Functions to use in breadth first searches. */
+typedef tree (*pft)();
+typedef int (*pfi)();
+
+int tree_needs_constructor_p (binfo, i)
+ tree binfo;
+ int i;
+{
+ tree basetype;
+ my_friendly_assert (i != 0, 296);
+ basetype = BINFO_TYPE (BINFO_BASETYPE (binfo, i));
+ return TYPE_NEEDS_CONSTRUCTING (basetype);
+}
+
+static tree declarator;
+
+static tree
+get_virtuals_named_this (binfo)
+ tree binfo;
+{
+ tree fields;
+
+ fields = lookup_fnfields (binfo, declarator, -1);
+ /* fields cannot be error_mark_node */
+
+ if (fields == 0)
+ return 0;
+
+ /* Get to the function decls, and return the first virtual function
+ with this name, if there is one. */
+ while (fields)
+ {
+ tree fndecl;
+
+ for (fndecl = TREE_VALUE (fields); fndecl; fndecl = DECL_CHAIN (fndecl))
+ if (DECL_VINDEX (fndecl))
+ return fields;
+ fields = next_baselink (fields);
+ }
+ return NULL_TREE;
+}
+
+static tree get_virtual_destructor (binfo, i)
+ tree binfo;
+ int i;
+{
+ tree type = BINFO_TYPE (binfo);
+ if (i >= 0)
+ type = BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (binfo), i));
+ if (TYPE_HAS_DESTRUCTOR (type)
+ && DECL_VINDEX (TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), 0)))
+ return TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), 0);
+ return 0;
+}
+
+int tree_has_any_destructor_p (binfo, i)
+ tree binfo;
+ int i;
+{
+ tree type = BINFO_TYPE (binfo);
+ if (i >= 0)
+ type = BINFO_TYPE (TREE_VEC_ELT (BINFO_BASETYPES (binfo), i));
+ return TYPE_NEEDS_DESTRUCTOR (type);
+}
+
+/* Given a class type TYPE, and a function decl FNDECL, look for a
+ virtual function in TYPE's hierarchy which FNDECL could match as a
+ virtual function. It doesn't matter which one we find.
+
+ DTORP is nonzero if we are looking for a destructor. Destructors
+ need special treatment because they do not match by name. */
+tree
+get_matching_virtual (binfo, fndecl, dtorp)
+ tree binfo, fndecl;
+ int dtorp;
+{
+ tree tmp = NULL_TREE;
+
+ /* Breadth first search routines start searching basetypes
+ of TYPE, so we must perform first ply of search here. */
+ if (dtorp)
+ {
+ if (tree_has_any_destructor_p (binfo, -1))
+ tmp = get_virtual_destructor (binfo, -1);
+
+ if (tmp)
+ return tmp;
+
+ tmp = (tree) breadth_first_search (binfo,
+ (pfi) get_virtual_destructor,
+ tree_has_any_destructor_p);
+ return tmp;
+ }
+ else
+ {
+ tree drettype, dtypes, btypes, instptr_type;
+ tree basetype = DECL_CLASS_CONTEXT (fndecl);
+ tree baselink, best = NULL_TREE;
+ tree name = DECL_ASSEMBLER_NAME (fndecl);
+
+ declarator = DECL_NAME (fndecl);
+ if (IDENTIFIER_VIRTUAL_P (declarator) == 0)
+ return NULL_TREE;
+
+ baselink = get_virtuals_named_this (binfo);
+ if (baselink == NULL_TREE)
+ return NULL_TREE;
+
+ drettype = TREE_TYPE (TREE_TYPE (fndecl));
+ dtypes = TYPE_ARG_TYPES (TREE_TYPE (fndecl));
+ if (DECL_STATIC_FUNCTION_P (fndecl))
+ instptr_type = NULL_TREE;
+ else
+ instptr_type = TREE_TYPE (TREE_VALUE (dtypes));
+
+ for (; baselink; baselink = next_baselink (baselink))
+ {
+ for (tmp = TREE_VALUE (baselink); tmp; tmp = DECL_CHAIN (tmp))
+ {
+ if (! DECL_VINDEX (tmp))
+ continue;
+
+ btypes = TYPE_ARG_TYPES (TREE_TYPE (tmp));
+ if (instptr_type == NULL_TREE)
+ {
+ if (compparms (TREE_CHAIN (btypes), dtypes, 3))
+ /* Caller knows to give error in this case. */
+ return tmp;
+ return NULL_TREE;
+ }
+
+ if ((TYPE_READONLY (TREE_TYPE (TREE_VALUE (btypes)))
+ == TYPE_READONLY (instptr_type))
+ && compparms (TREE_CHAIN (btypes), TREE_CHAIN (dtypes), 3))
+ {
+ tree brettype = TREE_TYPE (TREE_TYPE (tmp));
+ if (comptypes (brettype, drettype, 1))
+ /* OK */;
+ else if
+ (TREE_CODE (brettype) == TREE_CODE (drettype)
+ && (TREE_CODE (brettype) == POINTER_TYPE
+ || TREE_CODE (brettype) == REFERENCE_TYPE)
+ && comptypes (TYPE_MAIN_VARIANT (TREE_TYPE (brettype)),
+ TYPE_MAIN_VARIANT (TREE_TYPE (drettype)),
+ 0))
+ /* covariant return type */
+ {
+ tree b = TREE_TYPE (brettype), d = TREE_TYPE (drettype);
+ if (TYPE_MAIN_VARIANT (b) != TYPE_MAIN_VARIANT (d))
+ {
+ tree binfo = get_binfo (b, d, 1);
+ if (binfo != error_mark_node
+ && ! BINFO_OFFSET_ZEROP (binfo))
+ sorry ("adjusting pointers for covariant returns");
+ }
+ if (TYPE_READONLY (d) > TYPE_READONLY (b))
+ {
+ cp_error ("return type of `%#D' adds const", fndecl);
+ cp_error_at (" overriding definition as `%#D'",
+ tmp);
+ }
+ else if (TYPE_VOLATILE (d) > TYPE_VOLATILE (b))
+ {
+ cp_error ("return type of `%#D' adds volatile",
+ fndecl);
+ cp_error_at (" overriding definition as `%#D'",
+ tmp);
+ }
+ }
+ else if (IS_AGGR_TYPE_2 (brettype, drettype)
+ && comptypes (brettype, drettype, 0))
+ {
+ error ("invalid covariant return type (must use pointer or reference)");
+ cp_error_at (" overriding `%#D'", tmp);
+ cp_error (" with `%#D'", fndecl);
+ }
+ else if (IDENTIFIER_ERROR_LOCUS (name) == NULL_TREE)
+ {
+ cp_error ("conflicting return type specified for virtual function `%#D'", fndecl);
+ cp_error_at (" overriding definition as `%#D'", tmp);
+ SET_IDENTIFIER_ERROR_LOCUS (name, basetype);
+ }
+ break;
+ }
+ }
+ if (tmp)
+ {
+ best = tmp;
+ break;
+ }
+ }
+ if (best == NULL_TREE && warn_overloaded_virtual)
+ cp_warning_at ("conflicting specification deriving virtual function `%D'", fndecl);
+
+ return best;
+ }
+}
+
+/* Return the list of virtual functions which are abstract in type
+ TYPE that come from non virtual base classes. See
+ expand_direct_vtbls_init for the style of search we do. */
+static tree
+get_abstract_virtuals_1 (binfo, do_self, abstract_virtuals)
+ tree binfo, abstract_virtuals;
+ int do_self;
+{
+ tree binfos = BINFO_BASETYPES (binfo);
+ int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+
+ for (i = 0; i < n_baselinks; i++)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ int is_not_base_vtable =
+ i != CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (binfo));
+ if (! TREE_VIA_VIRTUAL (base_binfo))
+ abstract_virtuals
+ = get_abstract_virtuals_1 (base_binfo, is_not_base_vtable,
+ abstract_virtuals);
+ }
+ /* Should we use something besides CLASSTYPE_VFIELDS? */
+ if (do_self && CLASSTYPE_VFIELDS (BINFO_TYPE (binfo)))
+ {
+ tree virtuals = BINFO_VIRTUALS (binfo);
+
+ skip_rtti_stuff (&virtuals);
+
+ while (virtuals)
+ {
+ tree base_pfn = FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (virtuals));
+ tree base_fndecl = TREE_OPERAND (base_pfn, 0);
+ if (DECL_ABSTRACT_VIRTUAL_P (base_fndecl))
+ abstract_virtuals = tree_cons (NULL_TREE, base_fndecl, abstract_virtuals);
+ virtuals = TREE_CHAIN (virtuals);
+ }
+ }
+ return abstract_virtuals;
+}
+
+/* Return the list of virtual functions which are abstract in type TYPE.
+ This information is cached, and so must be built on a
+ non-temporary obstack. */
+tree
+get_abstract_virtuals (type)
+ tree type;
+{
+ tree vbases;
+ tree abstract_virtuals = CLASSTYPE_ABSTRACT_VIRTUALS (type);
+
+ /* First get all from non-virtual bases. */
+ abstract_virtuals
+ = get_abstract_virtuals_1 (TYPE_BINFO (type), 1, abstract_virtuals);
+
+ for (vbases = CLASSTYPE_VBASECLASSES (type); vbases; vbases = TREE_CHAIN (vbases))
+ {
+ tree virtuals = BINFO_VIRTUALS (vbases);
+
+ skip_rtti_stuff (&virtuals);
+
+ while (virtuals)
+ {
+ tree base_pfn = FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (virtuals));
+ tree base_fndecl = TREE_OPERAND (base_pfn, 0);
+ if (DECL_ABSTRACT_VIRTUAL_P (base_fndecl))
+ abstract_virtuals = tree_cons (NULL_TREE, base_fndecl, abstract_virtuals);
+ virtuals = TREE_CHAIN (virtuals);
+ }
+ }
+ return nreverse (abstract_virtuals);
+}
+
+/* For the type TYPE, return a list of member functions available from
+ base classes with name NAME. The TREE_VALUE of the list is a chain of
+ member functions with name NAME. The TREE_PURPOSE of the list is a
+ basetype, or a list of base types (in reverse order) which were
+ traversed to reach the chain of member functions. If we reach a base
+ type which provides a member function of name NAME, and which has at
+ most one base type itself, then we can terminate the search. */
+
+tree
+get_baselinks (type_as_binfo_list, type, name)
+ tree type_as_binfo_list;
+ tree type, name;
+{
+ int head = 0, tail = 0, index;
+ tree rval = 0, nval = 0;
+ tree basetypes = type_as_binfo_list;
+ tree binfo = TYPE_BINFO (type);
+
+ search_stack = push_search_level (search_stack, &search_obstack);
+
+ while (1)
+ {
+ tree binfos = BINFO_BASETYPES (binfo);
+ int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+
+ /* Process and/or queue base types. */
+ for (i = 0; i < n_baselinks; i++)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ tree btypes;
+
+ btypes = hash_tree_cons (TREE_VIA_PUBLIC (base_binfo),
+ TREE_VIA_VIRTUAL (base_binfo),
+ TREE_VIA_PROTECTED (base_binfo),
+ NULL_TREE, base_binfo,
+ basetypes);
+ obstack_ptr_grow (&search_obstack, btypes);
+ search_stack->first = (tree *)obstack_base (&search_obstack);
+ tail += 1;
+ }
+
+ dont_queue:
+ /* Process head of queue, if one exists. */
+ if (head >= tail)
+ break;
+
+ basetypes = search_stack->first[head++];
+ binfo = TREE_VALUE (basetypes);
+ type = BINFO_TYPE (binfo);
+ index = lookup_fnfields_1 (type, name);
+ if (index >= 0)
+ {
+ nval = TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (type), index);
+ rval = hash_tree_cons (0, 0, 0, basetypes, nval, rval);
+ if (TYPE_BINFO_BASETYPES (type) == 0)
+ goto dont_queue;
+ else if (TREE_VEC_LENGTH (TYPE_BINFO_BASETYPES (type)) == 1)
+ {
+ if (CLASSTYPE_BASELINK_VEC (type))
+ TREE_TYPE (rval) = TREE_VEC_ELT (CLASSTYPE_BASELINK_VEC (type), index);
+ goto dont_queue;
+ }
+ }
+ nval = NULL_TREE;
+ }
+
+ search_stack = pop_search_level (search_stack);
+ return rval;
+}
+
+tree
+next_baselink (baselink)
+ tree baselink;
+{
+ tree tmp = TREE_TYPE (baselink);
+ baselink = TREE_CHAIN (baselink);
+ while (tmp)
+ {
+ /* @@ does not yet add previous base types. */
+ baselink = tree_cons (TREE_PURPOSE (tmp), TREE_VALUE (tmp),
+ baselink);
+ TREE_TYPE (baselink) = TREE_TYPE (tmp);
+ tmp = TREE_CHAIN (tmp);
+ }
+ return baselink;
+}
+
+/* DEPTH-FIRST SEARCH ROUTINES. */
+
+/* Assign unique numbers to _CLASSTYPE members of the lattice
+ specified by TYPE. The root nodes are marked first; the nodes
+ are marked depth-fisrt, left-right. */
+
+static int cid;
+
+/* Matrix implementing a relation from CLASSTYPE X CLASSTYPE => INT.
+ Relation yields 1 if C1 <= C2, 0 otherwise. */
+typedef char mi_boolean;
+static mi_boolean *mi_matrix;
+
+/* Type for which this matrix is defined. */
+static tree mi_type;
+
+/* Size of the matrix for indexing purposes. */
+static int mi_size;
+
+/* Return nonzero if class C2 derives from class C1. */
+#define BINFO_DERIVES_FROM(C1, C2) \
+ ((mi_matrix+mi_size*(BINFO_CID (C1)-1))[BINFO_CID (C2)-1])
+#define TYPE_DERIVES_FROM(C1, C2) \
+ ((mi_matrix+mi_size*(CLASSTYPE_CID (C1)-1))[CLASSTYPE_CID (C2)-1])
+#define BINFO_DERIVES_FROM_STAR(C) \
+ (mi_matrix+(BINFO_CID (C)-1))
+
+/* This routine converts a pointer to be a pointer of an immediate
+ base class. The normal convert_pointer_to routine would diagnose
+ the conversion as ambiguous, under MI code that has the base class
+ as an ambiguous base class. */
+static tree
+convert_pointer_to_single_level (to_type, expr)
+ tree to_type, expr;
+{
+ tree binfo_of_derived;
+ tree last;
+
+ binfo_of_derived = TYPE_BINFO (TREE_TYPE (TREE_TYPE (expr)));
+ last = get_binfo (to_type, TREE_TYPE (TREE_TYPE (expr)), 0);
+ BINFO_INHERITANCE_CHAIN (last) = binfo_of_derived;
+ BINFO_INHERITANCE_CHAIN (binfo_of_derived) = NULL_TREE;
+ return build_vbase_path (PLUS_EXPR, build_pointer_type (to_type), expr, last, 1);
+}
+
+/* The main function which implements depth first search.
+
+ This routine has to remember the path it walked up, when
+ dfs_init_vbase_pointers is the work function, as otherwise there
+ would be no record. */
+static void
+dfs_walk (binfo, fn, qfn)
+ tree binfo;
+ void (*fn)();
+ int (*qfn)();
+{
+ tree binfos = BINFO_BASETYPES (binfo);
+ int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+
+ for (i = 0; i < n_baselinks; i++)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+
+ if (qfn == 0 || (*qfn)(base_binfo))
+ {
+ if (fn == dfs_init_vbase_pointers)
+ {
+ /* When traversing an arbitrary MI hierarchy, we need to keep
+ a record of the path we took to get down to the final base
+ type, as otherwise there would be no record of it, and just
+ trying to blindly convert at the bottom would be ambiguous.
+
+ The easiest way is to do the conversions one step at a time,
+ as we know we want the immediate base class at each step.
+
+ The only special trick to converting one step at a time,
+ is that when we hit the last virtual base class, we must
+ use the SLOT value for it, and not use the normal convert
+ routine. We use the last virtual base class, as in our
+ implementation, we have pointers to all virtual base
+ classes in the base object. */
+
+ tree saved_vbase_decl_ptr_intermediate
+ = vbase_decl_ptr_intermediate;
+
+ if (TREE_VIA_VIRTUAL (base_binfo))
+ {
+ /* No need for the conversion here, as we know it is the
+ right type. */
+ vbase_decl_ptr_intermediate
+ = (tree)CLASSTYPE_SEARCH_SLOT (BINFO_TYPE (base_binfo));
+ }
+ else
+ {
+ vbase_decl_ptr_intermediate
+ = convert_pointer_to_single_level (BINFO_TYPE (base_binfo),
+ vbase_decl_ptr_intermediate);
+ }
+
+ dfs_walk (base_binfo, fn, qfn);
+
+ vbase_decl_ptr_intermediate = saved_vbase_decl_ptr_intermediate;
+ } else
+ dfs_walk (base_binfo, fn, qfn);
+ }
+ }
+
+ fn (binfo);
+}
+
+/* Predicate functions which serve for dfs_walk. */
+static int numberedp (binfo) tree binfo;
+{ return BINFO_CID (binfo); }
+static int unnumberedp (binfo) tree binfo;
+{ return BINFO_CID (binfo) == 0; }
+
+static int markedp (binfo) tree binfo;
+{ return BINFO_MARKED (binfo); }
+static int bfs_markedp (binfo, i) tree binfo; int i;
+{ return BINFO_MARKED (BINFO_BASETYPE (binfo, i)); }
+static int unmarkedp (binfo) tree binfo;
+{ return BINFO_MARKED (binfo) == 0; }
+static int bfs_unmarkedp (binfo, i) tree binfo; int i;
+{ return BINFO_MARKED (BINFO_BASETYPE (binfo, i)) == 0; }
+static int marked_vtable_pathp (binfo) tree binfo;
+{ return BINFO_VTABLE_PATH_MARKED (binfo); }
+static int bfs_marked_vtable_pathp (binfo, i) tree binfo; int i;
+{ return BINFO_VTABLE_PATH_MARKED (BINFO_BASETYPE (binfo, i)); }
+static int unmarked_vtable_pathp (binfo) tree binfo;
+{ return BINFO_VTABLE_PATH_MARKED (binfo) == 0; }
+static int bfs_unmarked_vtable_pathp (binfo, i) tree binfo; int i;
+{ return BINFO_VTABLE_PATH_MARKED (BINFO_BASETYPE (binfo, i)) == 0; }
+static int marked_new_vtablep (binfo) tree binfo;
+{ return BINFO_NEW_VTABLE_MARKED (binfo); }
+static int bfs_marked_new_vtablep (binfo, i) tree binfo; int i;
+{ return BINFO_NEW_VTABLE_MARKED (BINFO_BASETYPE (binfo, i)); }
+static int unmarked_new_vtablep (binfo) tree binfo;
+{ return BINFO_NEW_VTABLE_MARKED (binfo) == 0; }
+static int bfs_unmarked_new_vtablep (binfo, i) tree binfo; int i;
+{ return BINFO_NEW_VTABLE_MARKED (BINFO_BASETYPE (binfo, i)) == 0; }
+
+static int dfs_search_slot_nonempty_p (binfo) tree binfo;
+{ return CLASSTYPE_SEARCH_SLOT (BINFO_TYPE (binfo)) != 0; }
+
+static int dfs_debug_unmarkedp (binfo) tree binfo;
+{ return CLASSTYPE_DEBUG_REQUESTED (BINFO_TYPE (binfo)) == 0; }
+
+/* The worker functions for `dfs_walk'. These do not need to
+ test anything (vis a vis marking) if they are paired with
+ a predicate function (above). */
+
+/* Assign each type within the lattice a number which is unique
+ in the lattice. The first number assigned is 1. */
+
+static void
+dfs_number (binfo)
+ tree binfo;
+{
+ BINFO_CID (binfo) = ++cid;
+}
+
+static void
+dfs_unnumber (binfo)
+ tree binfo;
+{
+ BINFO_CID (binfo) = 0;
+}
+
+static void
+dfs_mark (binfo) tree binfo;
+{ SET_BINFO_MARKED (binfo); }
+
+static void
+dfs_unmark (binfo) tree binfo;
+{ CLEAR_BINFO_MARKED (binfo); }
+
+static void
+dfs_mark_vtable_path (binfo) tree binfo;
+{ SET_BINFO_VTABLE_PATH_MARKED (binfo); }
+
+static void
+dfs_unmark_vtable_path (binfo) tree binfo;
+{ CLEAR_BINFO_VTABLE_PATH_MARKED (binfo); }
+
+static void
+dfs_mark_new_vtable (binfo) tree binfo;
+{ SET_BINFO_NEW_VTABLE_MARKED (binfo); }
+
+static void
+dfs_unmark_new_vtable (binfo) tree binfo;
+{ CLEAR_BINFO_NEW_VTABLE_MARKED (binfo); }
+
+static void
+dfs_clear_search_slot (binfo) tree binfo;
+{ CLASSTYPE_SEARCH_SLOT (BINFO_TYPE (binfo)) = 0; }
+
+static void
+dfs_debug_mark (binfo)
+ tree binfo;
+{
+ tree t = BINFO_TYPE (binfo);
+
+ /* Use heuristic that if there are virtual functions,
+ ignore until we see a non-inline virtual function. */
+ tree methods = CLASSTYPE_METHOD_VEC (t);
+
+ CLASSTYPE_DEBUG_REQUESTED (t) = 1;
+
+ /* If interface info is known, the value of (?@@?) is correct. */
+ if (methods == 0
+ || CLASSTYPE_INTERFACE_KNOWN (t)
+ || (write_virtuals == 2 && TYPE_VIRTUAL_P (t)))
+ return;
+
+ /* If debug info is requested from this context for this type, supply it.
+ If debug info is requested from another context for this type,
+ see if some third context can supply it. */
+ if (current_function_decl == NULL_TREE
+ || DECL_CLASS_CONTEXT (current_function_decl) != t)
+ {
+ if (TREE_VEC_ELT (methods, 0))
+ methods = TREE_VEC_ELT (methods, 0);
+ else
+ methods = TREE_VEC_ELT (methods, 1);
+ while (methods)
+ {
+ if (DECL_VINDEX (methods)
+ && DECL_THIS_INLINE (methods) == 0
+ && DECL_ABSTRACT_VIRTUAL_P (methods) == 0)
+ {
+ /* Somebody, somewhere is going to have to define this
+ virtual function. When they do, they will provide
+ the debugging info. */
+ return;
+ }
+ methods = TREE_CHAIN (methods);
+ }
+ }
+ /* We cannot rely on some alien method to solve our problems,
+ so we must write out the debug info ourselves. */
+ TYPE_DECL_SUPPRESS_DEBUG (TYPE_NAME (t)) = 0;
+ rest_of_type_compilation (t, global_bindings_p ());
+}
+
+/* Attach to the type of the virtual base class, the pointer to the
+ virtual base class, given the global pointer vbase_decl_ptr.
+
+ We use the global vbase_types. ICK! */
+static void
+dfs_find_vbases (binfo)
+ tree binfo;
+{
+ tree binfos = BINFO_BASETYPES (binfo);
+ int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+
+ for (i = n_baselinks-1; i >= 0; i--)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+
+ if (TREE_VIA_VIRTUAL (base_binfo)
+ && CLASSTYPE_SEARCH_SLOT (BINFO_TYPE (base_binfo)) == 0)
+ {
+ tree vbase = BINFO_TYPE (base_binfo);
+ tree binfo = binfo_member (vbase, vbase_types);
+
+ CLASSTYPE_SEARCH_SLOT (vbase)
+ = (char *) build (PLUS_EXPR, build_pointer_type (vbase),
+ vbase_decl_ptr, BINFO_OFFSET (binfo));
+ }
+ }
+ SET_BINFO_VTABLE_PATH_MARKED (binfo);
+ SET_BINFO_NEW_VTABLE_MARKED (binfo);
+}
+
+static void
+dfs_init_vbase_pointers (binfo)
+ tree binfo;
+{
+ tree type = BINFO_TYPE (binfo);
+ tree fields = TYPE_FIELDS (type);
+ tree this_vbase_ptr;
+
+ CLEAR_BINFO_VTABLE_PATH_MARKED (binfo);
+
+ /* If there is a rtti, it is the first field, though perhaps from
+ the base class. Otherwise, the first fields are virtual base class
+ pointer fields. */
+ if (CLASSTYPE_RTTI (type) && VFIELD_NAME_P (DECL_NAME (fields)))
+ /* Get past vtable for the object. */
+ fields = TREE_CHAIN (fields);
+
+ if (fields == NULL_TREE
+ || DECL_NAME (fields) == NULL_TREE
+ || ! VBASE_NAME_P (DECL_NAME (fields)))
+ return;
+
+ this_vbase_ptr = vbase_decl_ptr_intermediate;
+
+ if (build_pointer_type (type) != TYPE_MAIN_VARIANT (TREE_TYPE (this_vbase_ptr)))
+ my_friendly_abort (125);
+
+ while (fields && DECL_NAME (fields)
+ && VBASE_NAME_P (DECL_NAME (fields)))
+ {
+ tree ref = build (COMPONENT_REF, TREE_TYPE (fields),
+ build_indirect_ref (this_vbase_ptr, NULL_PTR), fields);
+ tree init = (tree)CLASSTYPE_SEARCH_SLOT (TREE_TYPE (TREE_TYPE (fields)));
+ vbase_init_result = tree_cons (binfo_member (TREE_TYPE (TREE_TYPE (fields)),
+ vbase_types),
+ build_modify_expr (ref, NOP_EXPR, init),
+ vbase_init_result);
+ fields = TREE_CHAIN (fields);
+ }
+}
+
+/* Sometimes this needs to clear both VTABLE_PATH and NEW_VTABLE. Other
+ times, just NEW_VTABLE, but optimizer should make both with equal
+ efficiency (though it does not currently). */
+static void
+dfs_clear_vbase_slots (binfo)
+ tree binfo;
+{
+ tree type = BINFO_TYPE (binfo);
+ CLASSTYPE_SEARCH_SLOT (type) = 0;
+ CLEAR_BINFO_VTABLE_PATH_MARKED (binfo);
+ CLEAR_BINFO_NEW_VTABLE_MARKED (binfo);
+}
+
+tree
+init_vbase_pointers (type, decl_ptr)
+ tree type;
+ tree decl_ptr;
+{
+ if (TYPE_USES_VIRTUAL_BASECLASSES (type))
+ {
+ int old_flag = flag_this_is_variable;
+ tree binfo = TYPE_BINFO (type);
+ flag_this_is_variable = -2;
+ vbase_types = CLASSTYPE_VBASECLASSES (type);
+ vbase_decl_ptr = decl_ptr;
+ vbase_decl = build_indirect_ref (decl_ptr, NULL_PTR);
+ vbase_decl_ptr_intermediate = vbase_decl_ptr;
+ vbase_init_result = NULL_TREE;
+ dfs_walk (binfo, dfs_find_vbases, unmarked_vtable_pathp);
+ dfs_walk (binfo, dfs_init_vbase_pointers, marked_vtable_pathp);
+ dfs_walk (binfo, dfs_clear_vbase_slots, marked_new_vtablep);
+ flag_this_is_variable = old_flag;
+ return vbase_init_result;
+ }
+ return 0;
+}
+
+/* get the virtual context (the vbase that directly contains the
+ DECL_CLASS_CONTEXT of the FNDECL) that the given FNDECL is declared in,
+ or NULL_TREE if there is none.
+
+ FNDECL must come from a virtual table from a virtual base to ensure that
+ there is only one possible DECL_CLASS_CONTEXT.
+
+ We know that if there is more than one place (binfo) the fndecl that the
+ declared, they all refer to the same binfo. See get_class_offset_1 for
+ the check that ensures this. */
+static tree
+virtual_context (fndecl, t, vbase)
+ tree fndecl, t, vbase;
+{
+ tree path;
+ if (get_base_distance (DECL_CLASS_CONTEXT (fndecl), t, 0, &path) < 0)
+ {
+ /* DECL_CLASS_CONTEXT can be ambiguous in t. */
+ if (get_base_distance (DECL_CLASS_CONTEXT (fndecl), vbase, 0, &path) >= 0)
+ {
+ while (path)
+ {
+ /* Not sure if checking path == vbase is necessary here, but just in
+ case it is. */
+ if (TREE_VIA_VIRTUAL (path) || path == vbase)
+ return binfo_member (BINFO_TYPE (path), CLASSTYPE_VBASECLASSES (t));
+ path = BINFO_INHERITANCE_CHAIN (path);
+ }
+ }
+ /* This shouldn't happen, I don't want errors! */
+ warning ("recoverable compiler error, fixups for virtual function");
+ return vbase;
+ }
+ while (path)
+ {
+ if (TREE_VIA_VIRTUAL (path))
+ return binfo_member (BINFO_TYPE (path), CLASSTYPE_VBASECLASSES (t));
+ path = BINFO_INHERITANCE_CHAIN (path);
+ }
+ return 0;
+}
+
+/* Fixups upcast offsets for one vtable.
+ Entries may stay within the VBASE given, or
+ they may upcast into a direct base, or
+ they may upcast into a different vbase.
+
+ We only need to do fixups in case 2 and 3.
+
+ This routine mirrors fixup_vtable_deltas in functionality, though
+ this one is runtime based, and the other is compile time based.
+ Conceivably that routine could be removed entirely, and all fixups
+ done at runtime.
+
+ VBASE_OFFSETS is an association list of virtual bases that contains
+ offset information, so the offsets are only calculated once. */
+static void
+expand_upcast_fixups (binfo, addr, orig_addr, vbase, t, vbase_offsets)
+ tree binfo, addr, orig_addr, vbase, t, *vbase_offsets;
+{
+ tree virtuals = BINFO_VIRTUALS (binfo);
+ tree vc;
+ tree delta;
+ unsigned HOST_WIDE_INT n;
+
+ delta = purpose_member (vbase, *vbase_offsets);
+ if (! delta)
+ {
+ delta = (tree)CLASSTYPE_SEARCH_SLOT (BINFO_TYPE (vbase));
+ delta = build (MINUS_EXPR, ptrdiff_type_node, delta, addr);
+ delta = save_expr (delta);
+ delta = tree_cons (vbase, delta, *vbase_offsets);
+ *vbase_offsets = delta;
+ }
+
+ n = skip_rtti_stuff (&virtuals);
+
+ while (virtuals)
+ {
+ tree current_fndecl = TREE_VALUE (virtuals);
+ current_fndecl = FNADDR_FROM_VTABLE_ENTRY (current_fndecl);
+ current_fndecl = TREE_OPERAND (current_fndecl, 0);
+ if (current_fndecl
+ && current_fndecl != abort_fndecl
+ && (vc=virtual_context (current_fndecl, t, vbase)) != vbase)
+ {
+ /* This may in fact need a runtime fixup. */
+ tree idx = DECL_VINDEX (current_fndecl);
+ tree vtbl = BINFO_VTABLE (binfo);
+ tree nvtbl = lookup_name (DECL_NAME (vtbl), 0);
+ tree aref, ref, naref;
+ tree old_delta, new_delta;
+ tree init;
+
+ if (nvtbl == NULL_TREE
+ || nvtbl == IDENTIFIER_GLOBAL_VALUE (DECL_NAME (vtbl)))
+ {
+ /* Dup it if it isn't in local scope yet. */
+ nvtbl = build_decl (VAR_DECL,
+ DECL_NAME (vtbl),
+ TYPE_MAIN_VARIANT (TREE_TYPE (BINFO_VTABLE (binfo))));
+ DECL_ALIGN (nvtbl) = MAX (TYPE_ALIGN (double_type_node),
+ DECL_ALIGN (nvtbl));
+ TREE_READONLY (nvtbl) = 0;
+ nvtbl = pushdecl (nvtbl);
+ init = NULL_TREE;
+ cp_finish_decl (nvtbl, init, NULL_TREE, 0, LOOKUP_ONLYCONVERTING);
+ DECL_VIRTUAL_P (nvtbl) = 1;
+ DECL_CONTEXT (nvtbl) = t;
+ init = build (MODIFY_EXPR, TREE_TYPE (nvtbl),
+ nvtbl, vtbl);
+ TREE_SIDE_EFFECTS (init) = 1;
+ expand_expr_stmt (init);
+ /* Update the vtable pointers as necessary. */
+ ref = build_vfield_ref (build_indirect_ref (addr, NULL_PTR), DECL_CONTEXT (CLASSTYPE_VFIELD (BINFO_TYPE (binfo))));
+ expand_expr_stmt (build_modify_expr (ref, NOP_EXPR,
+ build_unary_op (ADDR_EXPR, nvtbl, 0)));
+ }
+ assemble_external (vtbl);
+ aref = build_array_ref (vtbl, idx);
+ naref = build_array_ref (nvtbl, idx);
+ old_delta = build_component_ref (aref, delta_identifier, 0, 0);
+ new_delta = build_component_ref (naref, delta_identifier, 0, 0);
+ old_delta = build_binary_op (PLUS_EXPR, old_delta,
+ TREE_VALUE (delta), 0);
+ if (vc)
+ {
+ /* If this is set, we need to add in delta adjustments for
+ the other virtual base. */
+ tree vc_delta = purpose_member (vc, *vbase_offsets);
+ if (! vc_delta)
+ {
+ tree vc_addr = convert_pointer_to_real (vc, orig_addr);
+ vc_delta = (tree)CLASSTYPE_SEARCH_SLOT (BINFO_TYPE (vc));
+ vc_delta = build (MINUS_EXPR, ptrdiff_type_node,
+ vc_addr, vc_delta);
+ vc_delta = save_expr (vc_delta);
+ *vbase_offsets = tree_cons (vc, vc_delta, *vbase_offsets);
+ }
+ else
+ vc_delta = TREE_VALUE (vc_delta);
+
+ old_delta = build_binary_op (PLUS_EXPR, old_delta, vc_delta, 0);
+ }
+
+ TREE_READONLY (new_delta) = 0;
+ expand_expr_stmt (build_modify_expr (new_delta, NOP_EXPR,
+ old_delta));
+ }
+ ++n;
+ virtuals = TREE_CHAIN (virtuals);
+ }
+}
+
+/* Fixup upcast offsets for all direct vtables. Patterned after
+ expand_direct_vtbls_init. */
+static void
+fixup_virtual_upcast_offsets (real_binfo, binfo, init_self, can_elide, addr, orig_addr, type, vbase, vbase_offsets)
+ tree real_binfo, binfo, addr, orig_addr, type, vbase, *vbase_offsets;
+ int init_self, can_elide;
+{
+ tree real_binfos = BINFO_BASETYPES (real_binfo);
+ tree binfos = BINFO_BASETYPES (binfo);
+ int i, n_baselinks = real_binfos ? TREE_VEC_LENGTH (real_binfos) : 0;
+
+ for (i = 0; i < n_baselinks; i++)
+ {
+ tree real_base_binfo = TREE_VEC_ELT (real_binfos, i);
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ int is_not_base_vtable =
+ i != CLASSTYPE_VFIELD_PARENT (BINFO_TYPE (real_binfo));
+ if (! TREE_VIA_VIRTUAL (real_base_binfo))
+ fixup_virtual_upcast_offsets (real_base_binfo, base_binfo,
+ is_not_base_vtable, can_elide, addr,
+ orig_addr, type, vbase, vbase_offsets);
+ }
+#if 0
+ /* Before turning this on, make sure it is correct. */
+ if (can_elide && ! BINFO_MODIFIED (binfo))
+ return;
+#endif
+ /* Should we use something besides CLASSTYPE_VFIELDS? */
+ if (init_self && CLASSTYPE_VFIELDS (BINFO_TYPE (real_binfo)))
+ {
+ addr = convert_pointer_to_real (binfo, addr);
+ expand_upcast_fixups (real_binfo, addr, orig_addr, vbase, type, vbase_offsets);
+ }
+}
+
+/* Build a COMPOUND_EXPR which when expanded will generate the code
+ needed to initialize all the virtual function table slots of all
+ the virtual baseclasses. MAIN_BINFO is the binfo which determines
+ the virtual baseclasses to use; TYPE is the type of the object to
+ which the initialization applies. TRUE_EXP is the true object we
+ are initializing, and DECL_PTR is the pointer to the sub-object we
+ are initializing.
+
+ When USE_COMPUTED_OFFSETS is non-zero, we can assume that the
+ object was laid out by a top-level constructor and the computed
+ offsets are valid to store vtables. When zero, we must store new
+ vtables through virtual baseclass pointers.
+
+ We setup and use the globals: vbase_decl, vbase_decl_ptr, vbase_types
+ ICK! */
+
+void
+expand_indirect_vtbls_init (binfo, true_exp, decl_ptr, use_computed_offsets)
+ tree binfo;
+ tree true_exp, decl_ptr;
+ int use_computed_offsets;
+{
+ tree type = BINFO_TYPE (binfo);
+ if (TYPE_USES_VIRTUAL_BASECLASSES (type))
+ {
+ rtx fixup_insns = NULL_RTX;
+ int old_flag = flag_this_is_variable;
+ tree vbases = CLASSTYPE_VBASECLASSES (type);
+ vbase_types = vbases;
+ vbase_decl_ptr = true_exp ? build_unary_op (ADDR_EXPR, true_exp, 0) : decl_ptr;
+ vbase_decl = true_exp ? true_exp : build_indirect_ref (decl_ptr, NULL_PTR);
+
+ if (use_computed_offsets)
+ {
+ /* This is an object of type IN_TYPE, */
+ flag_this_is_variable = -2;
+ }
+
+ dfs_walk (binfo, dfs_find_vbases, unmarked_new_vtablep);
+
+ /* Initialized with vtables of type TYPE. */
+ for (; vbases; vbases = TREE_CHAIN (vbases))
+ {
+ tree addr;
+ if (use_computed_offsets)
+ addr = (tree)CLASSTYPE_SEARCH_SLOT (BINFO_TYPE (vbases));
+ else
+ {
+#if 1
+ addr = convert_pointer_to_vbase (TREE_TYPE (vbases), vbase_decl_ptr);
+#else
+ /* This should should never work better than the above. (mrs) */
+ tree vbinfo = get_binfo (TREE_TYPE (vbases),
+ TREE_TYPE (vbase_decl),
+ 0);
+
+ /* See is we can get lucky. */
+ if (TREE_VIA_VIRTUAL (vbinfo))
+ addr = convert_pointer_to_real (vbinfo, vbase_decl_ptr);
+ else
+ {
+ /* We go through all these contortions to avoid this
+ call, as it will fail when the virtual base type
+ is ambiguous from here. We don't yet have a way
+ to search for and find just an instance of the
+ virtual base class. Searching for the binfo in
+ vbases won't work, as we don't have the vbase
+ pointer field, for all vbases in the main class,
+ only direct vbases. */
+ addr = convert_pointer_to_real (TREE_TYPE (vbases),
+ vbase_decl_ptr);
+ if (addr == error_mark_node)
+ continue;
+ }
+#endif
+ }
+
+ /* Do all vtables from this virtual base. */
+ /* This assumes that virtual bases can never serve as parent
+ binfos. (in the CLASSTPE_VFIELD_PARENT sense) */
+ expand_direct_vtbls_init (vbases, TYPE_BINFO (BINFO_TYPE (vbases)),
+ 1, 0, addr);
+
+ /* If we are using computed offsets we can skip fixups. */
+ if (use_computed_offsets)
+ continue;
+
+ /* Now we adjust the offsets for virtual functions that cross
+ virtual boundaries on an implicit upcast on vf call so that
+ the layout of the most complete type is used, instead of
+ assuming the layout of the virtual bases from our current type. */
+
+ if (flag_vtable_thunks)
+ {
+ /* We don't have dynamic thunks yet! So for now, just fail silently. */
+ }
+ else
+ {
+ tree vbase_offsets = NULL_TREE;
+ push_to_sequence (fixup_insns);
+ fixup_virtual_upcast_offsets (vbases,
+ TYPE_BINFO (BINFO_TYPE (vbases)),
+ 1, 0, addr, vbase_decl_ptr,
+ type, vbases, &vbase_offsets);
+ fixup_insns = get_insns ();
+ end_sequence ();
+ }
+ }
+
+ if (fixup_insns)
+ {
+ extern tree in_charge_identifier;
+ tree in_charge_node = lookup_name (in_charge_identifier, 0);
+ if (! in_charge_node)
+ {
+ warning ("recoverable internal compiler error, nobody's in charge!");
+ in_charge_node = integer_zero_node;
+ }
+ in_charge_node = build_binary_op (EQ_EXPR, in_charge_node, integer_zero_node, 1);
+ expand_start_cond (in_charge_node, 0);
+ emit_insns (fixup_insns);
+ expand_end_cond ();
+ }
+
+ dfs_walk (binfo, dfs_clear_vbase_slots, marked_new_vtablep);
+
+ flag_this_is_variable = old_flag;
+ }
+}
+
+void
+clear_search_slots (type)
+ tree type;
+{
+ dfs_walk (TYPE_BINFO (type),
+ dfs_clear_search_slot, dfs_search_slot_nonempty_p);
+}
+
+/* get virtual base class types.
+ This adds type to the vbase_types list in reverse dfs order.
+ Ordering is very important, so don't change it. */
+
+static void
+dfs_get_vbase_types (binfo)
+ tree binfo;
+{
+ if (TREE_VIA_VIRTUAL (binfo) && ! BINFO_VBASE_MARKED (binfo))
+ {
+ vbase_types = make_binfo (integer_zero_node, binfo,
+ BINFO_VTABLE (binfo),
+ BINFO_VIRTUALS (binfo), vbase_types);
+ TREE_VIA_VIRTUAL (vbase_types) = 1;
+ SET_BINFO_VBASE_MARKED (binfo);
+ }
+ SET_BINFO_MARKED (binfo);
+}
+
+/* get a list of virtual base classes in dfs order. */
+tree
+get_vbase_types (type)
+ tree type;
+{
+ tree vbases;
+ tree binfo;
+
+ if (TREE_CODE (type) == TREE_VEC)
+ binfo = type;
+ else
+ binfo = TYPE_BINFO (type);
+
+ vbase_types = NULL_TREE;
+ dfs_walk (binfo, dfs_get_vbase_types, unmarkedp);
+ dfs_walk (binfo, dfs_unmark, markedp);
+ /* Rely upon the reverse dfs ordering from dfs_get_vbase_types, and now
+ reverse it so that we get normal dfs ordering. */
+ vbase_types = nreverse (vbase_types);
+
+ /* unmark marked vbases */
+ for (vbases = vbase_types; vbases; vbases = TREE_CHAIN (vbases))
+ CLEAR_BINFO_VBASE_MARKED (vbases);
+
+ return vbase_types;
+}
+
+static void
+dfs_record_inheritance (binfo)
+ tree binfo;
+{
+ tree binfos = BINFO_BASETYPES (binfo);
+ int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+ mi_boolean *derived_row = BINFO_DERIVES_FROM_STAR (binfo);
+
+ for (i = n_baselinks-1; i >= 0; i--)
+ {
+ int j;
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ tree baseclass = BINFO_TYPE (base_binfo);
+ mi_boolean *base_row = BINFO_DERIVES_FROM_STAR (base_binfo);
+
+ /* Don't search if there's nothing there! MI_SIZE can be
+ zero as a result of parse errors. */
+ if (TYPE_BINFO_BASETYPES (baseclass) && mi_size > 0)
+ for (j = mi_size*(CLASSTYPE_CID (baseclass)-1); j >= 0; j -= mi_size)
+ derived_row[j] |= base_row[j];
+ TYPE_DERIVES_FROM (baseclass, BINFO_TYPE (binfo)) = 1;
+ }
+
+ SET_BINFO_MARKED (binfo);
+}
+
+/* Given a _CLASSTYPE node in a multiple inheritance lattice,
+ convert the lattice into a simple relation such that,
+ given to CIDs, C1 and C2, one can determine if C1 <= C2
+ or C2 <= C1 or C1 <> C2.
+
+ Once constructed, we walk the lattice depth fisrt,
+ applying various functions to elements as they are encountered.
+
+ We use xmalloc here, in case we want to randomly free these tables. */
+
+#define SAVE_MI_MATRIX
+
+void
+build_mi_matrix (type)
+ tree type;
+{
+ tree binfo = TYPE_BINFO (type);
+ cid = 0;
+
+#ifdef SAVE_MI_MATRIX
+ if (CLASSTYPE_MI_MATRIX (type))
+ {
+ mi_size = CLASSTYPE_N_SUPERCLASSES (type) + CLASSTYPE_N_VBASECLASSES (type);
+ mi_matrix = CLASSTYPE_MI_MATRIX (type);
+ mi_type = type;
+ dfs_walk (binfo, dfs_number, unnumberedp);
+ return;
+ }
+#endif
+
+ mi_size = CLASSTYPE_N_SUPERCLASSES (type) + CLASSTYPE_N_VBASECLASSES (type);
+ mi_matrix = (char *)xmalloc ((mi_size + 1) * (mi_size + 1));
+ mi_type = type;
+ bzero (mi_matrix, (mi_size + 1) * (mi_size + 1));
+ dfs_walk (binfo, dfs_number, unnumberedp);
+ dfs_walk (binfo, dfs_record_inheritance, unmarkedp);
+ dfs_walk (binfo, dfs_unmark, markedp);
+}
+
+void
+free_mi_matrix ()
+{
+ dfs_walk (TYPE_BINFO (mi_type), dfs_unnumber, numberedp);
+
+#ifdef SAVE_MI_MATRIX
+ CLASSTYPE_MI_MATRIX (mi_type) = mi_matrix;
+#else
+ free (mi_matrix);
+ mi_size = 0;
+ cid = 0;
+#endif
+}
+
+/* If we want debug info for a type TYPE, make sure all its base types
+ are also marked as being potentially interesting. This avoids
+ the problem of not writing any debug info for intermediate basetypes
+ that have abstract virtual functions. Also mark member types. */
+
+void
+note_debug_info_needed (type)
+ tree type;
+{
+ tree field;
+ dfs_walk (TYPE_BINFO (type), dfs_debug_mark, dfs_debug_unmarkedp);
+ for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
+ {
+ tree ttype;
+ if (TREE_CODE (field) == FIELD_DECL
+ && IS_AGGR_TYPE (ttype = target_type (TREE_TYPE (field)))
+ && dfs_debug_unmarkedp (TYPE_BINFO (ttype)))
+ note_debug_info_needed (ttype);
+ }
+}
+
+/* Subroutines of push_class_decls (). */
+
+/* Add in a decl to the envelope. */
+static void
+envelope_add_decl (type, decl, values)
+ tree type, decl, *values;
+{
+ tree context, *tmp;
+ tree name = DECL_NAME (decl);
+ int dont_add = 0;
+
+ /* virtual base names are always unique. */
+ if (VBASE_NAME_P (name))
+ *values = NULL_TREE;
+
+ /* Possible ambiguity. If its defining type(s)
+ is (are all) derived from us, no problem. */
+ else if (*values && TREE_CODE (*values) != TREE_LIST)
+ {
+ tree value = *values;
+ /* Only complain if we shadow something we can access. */
+ if (warn_shadow && TREE_CODE (decl) == FUNCTION_DECL
+ && ((DECL_LANG_SPECIFIC (*values)
+ && DECL_CLASS_CONTEXT (value) == current_class_type)
+ || ! TREE_PRIVATE (value)))
+ /* Should figure out access control more accurately. */
+ {
+ cp_warning_at ("member `%#D' is shadowed", value);
+ cp_warning_at ("by member function `%#D'", decl);
+ warning ("in this context");
+ }
+
+ context = (TREE_CODE (value) == FUNCTION_DECL
+ && DECL_VIRTUAL_P (value))
+ ? DECL_CLASS_CONTEXT (value)
+ : DECL_CONTEXT (value);
+
+ if (context == type)
+ {
+ if (TREE_CODE (value) == TYPE_DECL
+ && DECL_ARTIFICIAL (value))
+ *values = NULL_TREE;
+ else
+ dont_add = 1;
+ }
+ else if (context && TYPE_DERIVES_FROM (context, type))
+ {
+ /* Don't add in *values to list */
+ *values = NULL_TREE;
+ }
+ else
+ *values = build_tree_list (NULL_TREE, value);
+ }
+ else
+ for (tmp = values; *tmp;)
+ {
+ tree value = TREE_VALUE (*tmp);
+ my_friendly_assert (TREE_CODE (value) != TREE_LIST, 999);
+ context = (TREE_CODE (value) == FUNCTION_DECL
+ && DECL_VIRTUAL_P (value))
+ ? DECL_CLASS_CONTEXT (value)
+ : DECL_CONTEXT (value);
+
+ if (context && TYPE_DERIVES_FROM (context, type))
+ {
+ /* remove *tmp from list */
+ *tmp = TREE_CHAIN (*tmp);
+ }
+ else
+ tmp = &TREE_CHAIN (*tmp);
+ }
+
+ if (! dont_add)
+ {
+ /* Put the new contents in our envelope. */
+ if (TREE_CODE (decl) == FUNCTION_DECL)
+ {
+ *values = tree_cons (name, decl, *values);
+ TREE_NONLOCAL_FLAG (*values) = 1;
+ TREE_TYPE (*values) = unknown_type_node;
+ }
+ else
+ {
+ if (*values)
+ {
+ *values = tree_cons (NULL_TREE, decl, *values);
+ /* Mark this as a potentially ambiguous member. */
+ /* Leaving TREE_TYPE blank is intentional.
+ We cannot use `error_mark_node' (lookup_name)
+ or `unknown_type_node' (all member functions use this). */
+ TREE_NONLOCAL_FLAG (*values) = 1;
+ }
+ else
+ *values = decl;
+ }
+ }
+}
+
+/* Add the instance variables which this class contributed to the
+ current class binding contour. When a redefinition occurs, if the
+ redefinition is strictly within a single inheritance path, we just
+ overwrite the old declaration with the new. If the fields are not
+ within a single inheritance path, we must cons them.
+
+ In order to know what decls are new (stemming from the current
+ invocation of push_class_decls) we enclose them in an "envelope",
+ which is a TREE_LIST node where the TREE_PURPOSE slot contains the
+ new decl (or possibly a list of competing ones), the TREE_VALUE slot
+ points to the old value and the TREE_CHAIN slot chains together all
+ envelopes which needs to be "opened" in push_class_decls. Opening an
+ envelope means: push the old value onto the class_shadowed list,
+ install the new one and if it's a TYPE_DECL do the same to the
+ IDENTIFIER_TYPE_VALUE. Such an envelope is recognized by seeing that
+ the TREE_PURPOSE slot is non-null, and that it is not an identifier.
+ Because if it is, it could be a set of overloaded methods from an
+ outer scope. */
+
+static void
+dfs_pushdecls (binfo)
+ tree binfo;
+{
+ tree type = BINFO_TYPE (binfo);
+ tree fields, *methods, *end;
+ tree method_vec;
+
+ for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields))
+ {
+ /* Unmark so that if we are in a constructor, and then find that
+ this field was initialized by a base initializer,
+ we can emit an error message. */
+ if (TREE_CODE (fields) == FIELD_DECL)
+ TREE_USED (fields) = 0;
+
+ /* Recurse into anonymous unions. */
+ if (DECL_NAME (fields) == NULL_TREE
+ && TREE_CODE (TREE_TYPE (fields)) == UNION_TYPE)
+ {
+ dfs_pushdecls (TYPE_BINFO (TREE_TYPE (fields)));
+ continue;
+ }
+
+ if (DECL_NAME (fields))
+ {
+ tree name = DECL_NAME (fields);
+ tree class_value = IDENTIFIER_CLASS_VALUE (name);
+
+ /* If the class value is not an envelope of the kind described in
+ the comment above, we create a new envelope. */
+ if (class_value == NULL_TREE || TREE_CODE (class_value) != TREE_LIST
+ || TREE_PURPOSE (class_value) == NULL_TREE
+ || TREE_CODE (TREE_PURPOSE (class_value)) == IDENTIFIER_NODE)
+ {
+ /* See comment above for a description of envelopes. */
+ closed_envelopes = tree_cons (NULL_TREE, class_value,
+ closed_envelopes);
+ IDENTIFIER_CLASS_VALUE (name) = closed_envelopes;
+ class_value = IDENTIFIER_CLASS_VALUE (name);
+ }
+
+ envelope_add_decl (type, fields, &TREE_PURPOSE (class_value));
+ }
+ }
+
+ method_vec = CLASSTYPE_METHOD_VEC (type);
+ if (method_vec != 0)
+ {
+ /* Farm out constructors and destructors. */
+ methods = &TREE_VEC_ELT (method_vec, 1);
+ end = TREE_VEC_END (method_vec);
+
+ while (methods != end)
+ {
+ /* This will cause lookup_name to return a pointer
+ to the tree_list of possible methods of this name. */
+ tree name = DECL_NAME (*methods);
+ tree class_value = IDENTIFIER_CLASS_VALUE (name);
+
+ /* If the class value is not an envelope of the kind described in
+ the comment above, we create a new envelope. */
+ if (class_value == NULL_TREE || TREE_CODE (class_value) != TREE_LIST
+ || TREE_PURPOSE (class_value) == NULL_TREE
+ || TREE_CODE (TREE_PURPOSE (class_value)) == IDENTIFIER_NODE)
+ {
+ /* See comment above for a description of envelopes. */
+ closed_envelopes = tree_cons (NULL_TREE, class_value,
+ closed_envelopes);
+ IDENTIFIER_CLASS_VALUE (name) = closed_envelopes;
+ class_value = IDENTIFIER_CLASS_VALUE (name);
+ }
+
+ /* Here we try to rule out possible ambiguities.
+ If we can't do that, keep a TREE_LIST with possibly ambiguous
+ decls in there. */
+ maybe_push_cache_obstack ();
+ envelope_add_decl (type, *methods, &TREE_PURPOSE (class_value));
+ pop_obstacks ();
+
+ methods++;
+ }
+ }
+ SET_BINFO_MARKED (binfo);
+}
+
+/* Consolidate unique (by name) member functions. */
+static void
+dfs_compress_decls (binfo)
+ tree binfo;
+{
+ tree type = BINFO_TYPE (binfo);
+ tree method_vec = CLASSTYPE_METHOD_VEC (type);
+
+ if (method_vec != 0)
+ {
+ /* Farm out constructors and destructors. */
+ tree *methods = &TREE_VEC_ELT (method_vec, 1);
+ tree *end = TREE_VEC_END (method_vec);
+
+ for (; methods != end; methods++)
+ {
+ /* This is known to be an envelope of the kind described before
+ dfs_pushdecls. */
+ tree class_value = IDENTIFIER_CLASS_VALUE (DECL_NAME (*methods));
+ tree tmp = TREE_PURPOSE (class_value);
+
+ /* This was replaced in scope by somebody else. Just leave it
+ alone. */
+ if (TREE_CODE (tmp) != TREE_LIST)
+ continue;
+
+ if (TREE_CHAIN (tmp) == NULL_TREE
+ && TREE_VALUE (tmp)
+ && DECL_CHAIN (TREE_VALUE (tmp)) == NULL_TREE)
+ {
+ TREE_PURPOSE (class_value) = TREE_VALUE (tmp);
+ }
+ }
+ }
+ CLEAR_BINFO_MARKED (binfo);
+}
+
+/* When entering the scope of a class, we cache all of the
+ fields that that class provides within its inheritance
+ lattice. Where ambiguities result, we mark them
+ with `error_mark_node' so that if they are encountered
+ without explicit qualification, we can emit an error
+ message. */
+void
+push_class_decls (type)
+ tree type;
+{
+ tree id;
+ struct obstack *ambient_obstack = current_obstack;
+
+ search_stack = push_search_level (search_stack, &search_obstack);
+
+ id = TYPE_IDENTIFIER (type);
+#if 0
+ if (IDENTIFIER_TEMPLATE (id) != 0)
+ {
+ tree tmpl = IDENTIFIER_TEMPLATE (id);
+ push_template_decls (DECL_ARGUMENTS (TREE_PURPOSE (tmpl)),
+ TREE_VALUE (tmpl), 1);
+ overload_template_name (id, 1);
+ }
+#endif
+
+ /* Push class fields into CLASS_VALUE scope, and mark. */
+ dfs_walk (TYPE_BINFO (type), dfs_pushdecls, unmarkedp);
+
+ /* Compress fields which have only a single entry
+ by a given name, and unmark. */
+ dfs_walk (TYPE_BINFO (type), dfs_compress_decls, markedp);
+
+ /* Open up all the closed envelopes and push the contained decls into
+ class scope. */
+ while (closed_envelopes)
+ {
+ tree new = TREE_PURPOSE (closed_envelopes);
+ tree id;
+
+ /* This is messy because the class value may be a *_DECL, or a
+ TREE_LIST of overloaded *_DECLs or even a TREE_LIST of ambiguous
+ *_DECLs. The name is stored at different places in these three
+ cases. */
+ if (TREE_CODE (new) == TREE_LIST)
+ {
+ if (TREE_PURPOSE (new) != NULL_TREE)
+ id = TREE_PURPOSE (new);
+ else
+ {
+ tree node = TREE_VALUE (new);
+
+ while (TREE_CODE (node) == TREE_LIST)
+ node = TREE_VALUE (node);
+ id = DECL_NAME (node);
+ }
+ }
+ else
+ id = DECL_NAME (new);
+
+ /* Install the original class value in order to make
+ pushdecl_class_level work correctly. */
+ IDENTIFIER_CLASS_VALUE (id) = TREE_VALUE (closed_envelopes);
+ if (TREE_CODE (new) == TREE_LIST)
+ push_class_level_binding (id, new);
+ else
+ pushdecl_class_level (new);
+ closed_envelopes = TREE_CHAIN (closed_envelopes);
+ }
+ current_obstack = ambient_obstack;
+}
+
+/* Here's a subroutine we need because C lacks lambdas. */
+static void
+dfs_unuse_fields (binfo)
+ tree binfo;
+{
+ tree type = TREE_TYPE (binfo);
+ tree fields;
+
+ for (fields = TYPE_FIELDS (type); fields; fields = TREE_CHAIN (fields))
+ {
+ if (TREE_CODE (fields) != FIELD_DECL)
+ continue;
+
+ TREE_USED (fields) = 0;
+ if (DECL_NAME (fields) == NULL_TREE
+ && TREE_CODE (TREE_TYPE (fields)) == UNION_TYPE)
+ unuse_fields (TREE_TYPE (fields));
+ }
+}
+
+void
+unuse_fields (type)
+ tree type;
+{
+ dfs_walk (TYPE_BINFO (type), dfs_unuse_fields, unmarkedp);
+}
+
+void
+pop_class_decls (type)
+ tree type;
+{
+ /* We haven't pushed a search level when dealing with cached classes,
+ so we'd better not try to pop it. */
+ if (search_stack)
+ search_stack = pop_search_level (search_stack);
+}
+
+void
+print_search_statistics ()
+{
+#ifdef GATHER_STATISTICS
+ if (flag_memoize_lookups)
+ {
+ fprintf (stderr, "%d memoized contexts saved\n",
+ n_contexts_saved);
+ fprintf (stderr, "%d local tree nodes made\n", my_tree_node_counter);
+ fprintf (stderr, "%d local hash nodes made\n", my_memoized_entry_counter);
+ fprintf (stderr, "fields statistics:\n");
+ fprintf (stderr, " memoized finds = %d; rejects = %d; (searches = %d)\n",
+ memoized_fast_finds[0], memoized_fast_rejects[0],
+ memoized_fields_searched[0]);
+ fprintf (stderr, " memoized_adds = %d\n", memoized_adds[0]);
+ fprintf (stderr, "fnfields statistics:\n");
+ fprintf (stderr, " memoized finds = %d; rejects = %d; (searches = %d)\n",
+ memoized_fast_finds[1], memoized_fast_rejects[1],
+ memoized_fields_searched[1]);
+ fprintf (stderr, " memoized_adds = %d\n", memoized_adds[1]);
+ }
+ fprintf (stderr, "%d fields searched in %d[%d] calls to lookup_field[_1]\n",
+ n_fields_searched, n_calls_lookup_field, n_calls_lookup_field_1);
+ fprintf (stderr, "%d fnfields searched in %d calls to lookup_fnfields\n",
+ n_outer_fields_searched, n_calls_lookup_fnfields);
+ fprintf (stderr, "%d calls to get_base_type\n", n_calls_get_base_type);
+#else
+ fprintf (stderr, "no search statistics\n");
+#endif
+}
+
+void
+init_search_processing ()
+{
+ gcc_obstack_init (&search_obstack);
+ gcc_obstack_init (&type_obstack);
+ gcc_obstack_init (&type_obstack_entries);
+
+ /* This gives us room to build our chains of basetypes,
+ whether or not we decide to memoize them. */
+ type_stack = push_type_level (0, &type_obstack);
+ _vptr_name = get_identifier ("_vptr");
+}
+
+void
+reinit_search_statistics ()
+{
+ my_memoized_entry_counter = 0;
+ memoized_fast_finds[0] = 0;
+ memoized_fast_finds[1] = 0;
+ memoized_adds[0] = 0;
+ memoized_adds[1] = 0;
+ memoized_fast_rejects[0] = 0;
+ memoized_fast_rejects[1] = 0;
+ memoized_fields_searched[0] = 0;
+ memoized_fields_searched[1] = 0;
+ n_fields_searched = 0;
+ n_calls_lookup_field = 0, n_calls_lookup_field_1 = 0;
+ n_calls_lookup_fnfields = 0, n_calls_lookup_fnfields_1 = 0;
+ n_calls_get_base_type = 0;
+ n_outer_fields_searched = 0;
+ n_contexts_saved = 0;
+}
+
+static tree conversions;
+static void
+add_conversions (binfo)
+ tree binfo;
+{
+ tree tmp = CLASSTYPE_FIRST_CONVERSION (BINFO_TYPE (binfo));
+ for (; tmp && IDENTIFIER_TYPENAME_P (DECL_NAME (tmp));
+ tmp = TREE_CHAIN (tmp))
+ conversions = tree_cons (DECL_NAME (tmp), TREE_TYPE (TREE_TYPE (tmp)),
+ conversions);
+}
+
+tree
+lookup_conversions (type)
+ tree type;
+{
+ conversions = NULL_TREE;
+ dfs_walk (TYPE_BINFO (type), add_conversions, 0);
+ return conversions;
+}
diff --git a/contrib/gcc/cp/sig.c b/contrib/gcc/cp/sig.c
new file mode 100644
index 0000000..135dc6d
--- /dev/null
+++ b/contrib/gcc/cp/sig.c
@@ -0,0 +1,1049 @@
+/* Functions dealing with signatures and signature pointers/references.
+ Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+ Contributed by Gerald Baumgartner (gb@cs.purdue.edu)
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+#include "config.h"
+#include <stdio.h>
+#include "obstack.h"
+#include "tree.h"
+#include "cp-tree.h"
+#include "flags.h"
+#include "assert.h"
+
+extern struct obstack *current_obstack;
+extern struct obstack permanent_obstack;
+extern struct obstack *saveable_obstack;
+
+extern void error ();
+extern void sorry ();
+extern void compiler_error ();
+extern void make_decl_rtl PROTO((tree, char *, int));
+
+/* Used to help generate globally unique names for signature tables. */
+
+static int global_sigtable_name_counter;
+
+/* Build an identifier for a signature pointer or reference, so we
+ can use it's name in function name mangling. */
+
+static tree
+build_signature_pointer_or_reference_name (to_type, constp, volatilep, refp)
+ tree to_type;
+ int constp, volatilep, refp;
+{
+ char * sig_name = TYPE_NAME_STRING (to_type);
+ int name_len = TYPE_NAME_LENGTH (to_type) + constp + volatilep;
+ char * name;
+
+ if (refp)
+ {
+ name = (char *) alloca (name_len + sizeof (SIGNATURE_REFERENCE_NAME) +2);
+ sprintf (name, SIGNATURE_REFERENCE_NAME_FORMAT,
+ constp ? "C" : "", volatilep ? "V": "", sig_name);
+ }
+ else
+ {
+ name = (char *) alloca (name_len + sizeof (SIGNATURE_POINTER_NAME) + 2);
+ sprintf (name, SIGNATURE_POINTER_NAME_FORMAT,
+ constp ? "C" : "", volatilep ? "V": "", sig_name);
+ }
+ return get_identifier (name);
+}
+
+/* Build a DECL node for a signature pointer or reference, so we can
+ tell the debugger the structure of signature pointers/references.
+ This function is called at most eight times for a given signature,
+ once for each [const] [volatile] signature pointer/reference. */
+
+static void
+build_signature_pointer_or_reference_decl (type, name)
+ tree type, name;
+{
+ tree decl;
+
+ /* We don't enter this declaration in any sort of symbol table. */
+ decl = build_decl (TYPE_DECL, name, type);
+ TYPE_NAME (type) = decl;
+ TREE_CHAIN (type) = decl;
+}
+
+/* Construct, lay out and return the type of pointers or references
+ to signature TO_TYPE. If such a type has already been constructed,
+ reuse it. If CONSTP or VOLATILEP is specified, make the `optr' const
+ or volatile, respectively. If we are constructing a const/volatile
+ type variant and the main type variant doesn't exist yet, it is built
+ as well. If REFP is 1, we construct a signature reference, otherwise
+ a signature pointer is constructed.
+
+ This function is a subroutine of `build_signature_pointer_type' and
+ `build_signature_reference_type'. */
+
+static tree
+build_signature_pointer_or_reference_type (to_type, constp, volatilep, refp)
+ tree to_type;
+ int constp, volatilep, refp;
+{
+ register tree t, m;
+ register struct obstack *ambient_obstack = current_obstack;
+ register struct obstack *ambient_saveable_obstack = saveable_obstack;
+
+ m = refp ? SIGNATURE_REFERENCE_TO (to_type) : SIGNATURE_POINTER_TO (to_type);
+
+ /* If we don't have the main variant yet, construct it. */
+ if (m == NULL_TREE
+ && (constp || volatilep))
+ m = build_signature_pointer_or_reference_type (to_type, 0, 0, refp);
+
+ /* Treat any nonzero argument as 1. */
+ constp = !!constp;
+ volatilep = !!volatilep;
+ refp = !!refp;
+
+ /* If not generating auxiliary info, search the chain of variants to see
+ if there is already one there just like the one we need to have. If so,
+ use that existing one.
+
+ We don't do this in the case where we are generating aux info because
+ in that case we want each typedef names to get it's own distinct type
+ node, even if the type of this new typedef is the same as some other
+ (existing) type. */
+
+ if (m && !flag_gen_aux_info)
+ for (t = m; t; t = TYPE_NEXT_VARIANT (t))
+ if (constp == TYPE_READONLY (TREE_TYPE (TREE_TYPE (TYPE_FIELDS (t))))
+ && volatilep == TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (TYPE_FIELDS (t)))))
+ return t;
+
+ /* We need a new one. If TO_TYPE is permanent, make this permanent too. */
+ if (TREE_PERMANENT (to_type))
+ {
+ current_obstack = &permanent_obstack;
+ saveable_obstack = &permanent_obstack;
+ }
+
+ /* A signature pointer or reference to a signature `s' looks like this:
+
+ struct {
+ void * optr;
+ const s * sptr;
+ };
+
+ A `const' signature pointer/reference is a
+
+ struct {
+ const void * optr;
+ const s * sptr;
+ };
+
+ Similarly, for `volatile' and `const volatile'.
+ */
+
+ t = make_lang_type (RECORD_TYPE);
+ {
+ tree obj_type = build_type_variant (void_type_node, constp, volatilep);
+ tree optr_type = build_pointer_type (obj_type);
+ tree optr, sptr;
+
+ optr = build_lang_field_decl (FIELD_DECL,
+ get_identifier (SIGNATURE_OPTR_NAME),
+ optr_type);
+ DECL_FIELD_CONTEXT (optr) = t;
+ DECL_CLASS_CONTEXT (optr) = t;
+
+ if (m)
+ /* We can share the `sptr' field among type variants. */
+ sptr = TREE_CHAIN (TYPE_FIELDS (m));
+ else
+ {
+ tree sig_tbl_type = cp_build_type_variant (to_type, 1, 0);
+
+ sptr = build_lang_field_decl (FIELD_DECL,
+ get_identifier (SIGNATURE_SPTR_NAME),
+ build_pointer_type (sig_tbl_type));
+ DECL_FIELD_CONTEXT (sptr) = t;
+ DECL_CLASS_CONTEXT (sptr) = t;
+ TREE_CHAIN (sptr) = NULL_TREE;
+ }
+
+ TREE_CHAIN (optr) = sptr;
+ TYPE_FIELDS (t) = optr;
+ TYPE_ALIGN (t) = TYPE_ALIGN (optr_type);
+
+ /* A signature pointer/reference type isn't a `real' class type. */
+ IS_AGGR_TYPE (t) = 0;
+ }
+
+ {
+ tree name = build_signature_pointer_or_reference_name (to_type, constp,
+ volatilep, refp);
+
+ /* Build a DECL node for this type, so the debugger has access to it. */
+ build_signature_pointer_or_reference_decl (t, name);
+ }
+
+ CLASSTYPE_GOT_SEMICOLON (t) = 1;
+ IS_SIGNATURE_POINTER (t) = ! refp;
+ IS_SIGNATURE_REFERENCE (t) = refp;
+ SIGNATURE_TYPE (t) = to_type;
+
+ if (m)
+ {
+ /* Add this type to the chain of variants of TYPE.
+ Every type has to be its own TYPE_MAIN_VARIANT. */
+ TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m);
+ TYPE_NEXT_VARIANT (m) = t;
+ }
+ else if (refp)
+ /* Record this type as the reference to TO_TYPE. */
+ SIGNATURE_REFERENCE_TO (to_type) = t;
+ else
+ /* Record this type as the pointer to TO_TYPE. */
+ SIGNATURE_POINTER_TO (to_type) = t;
+
+ /* Lay out the type. This function has many callers that are concerned
+ with expression-construction, and this simplifies them all.
+ Also, it guarantees the TYPE_SIZE is permanent if the type is. */
+ layout_type (t);
+
+ current_obstack = ambient_obstack;
+ saveable_obstack = ambient_saveable_obstack;
+
+ /* Output debug information for this type. */
+ rest_of_type_compilation (t, 1);
+
+ return t;
+}
+
+/* Construct, lay out and return the type of pointers to signature TO_TYPE. */
+
+tree
+build_signature_pointer_type (to_type, constp, volatilep)
+ tree to_type;
+ int constp, volatilep;
+{
+ return
+ build_signature_pointer_or_reference_type (to_type, constp, volatilep, 0);
+}
+
+/* Construct, lay out and return the type of pointers to signature TO_TYPE. */
+
+tree
+build_signature_reference_type (to_type, constp, volatilep)
+ tree to_type;
+ int constp, volatilep;
+{
+ return
+ build_signature_pointer_or_reference_type (to_type, constp, volatilep, 1);
+}
+
+/* Return the name of the signature table (as an IDENTIFIER_NODE)
+ for the given signature type SIG_TYPE and rhs type RHS_TYPE. */
+
+static tree
+get_sigtable_name (sig_type, rhs_type)
+ tree sig_type, rhs_type;
+{
+ tree sig_type_id = build_typename_overload (sig_type);
+ tree rhs_type_id = build_typename_overload (rhs_type);
+ char *buf = (char *) alloca (sizeof (SIGTABLE_NAME_FORMAT_LONG)
+ + IDENTIFIER_LENGTH (sig_type_id)
+ + IDENTIFIER_LENGTH (rhs_type_id) + 20);
+ char *sig_ptr = IDENTIFIER_POINTER (sig_type_id);
+ char *rhs_ptr = IDENTIFIER_POINTER (rhs_type_id);
+ int i, j;
+
+ for (i = 0; sig_ptr[i] == OPERATOR_TYPENAME_FORMAT[i]; i++)
+ /* do nothing */;
+ while (sig_ptr[i] >= '0' && sig_ptr[i] <= '9')
+ i += 1;
+
+ for (j = 0; rhs_ptr[j] == OPERATOR_TYPENAME_FORMAT[j]; j++)
+ /* do nothing */;
+ while (rhs_ptr[j] >= '0' && rhs_ptr[j] <= '9')
+ j += 1;
+
+ if (IS_SIGNATURE (rhs_type))
+ sprintf (buf, SIGTABLE_NAME_FORMAT_LONG, sig_ptr+i, rhs_ptr+j,
+ global_sigtable_name_counter++);
+ else
+ sprintf (buf, SIGTABLE_NAME_FORMAT, sig_ptr+i, rhs_ptr+j);
+ return get_identifier (buf);
+}
+
+/* Build a field decl that points to a signature member function. */
+
+static tree
+build_member_function_pointer (member)
+ tree member;
+{
+ char *namstr = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (member));
+ int namlen = IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (member));
+ char *name;
+ tree entry;
+
+ name = (char *) alloca (namlen + sizeof (SIGNATURE_FIELD_NAME) + 2);
+ sprintf (name, SIGNATURE_FIELD_NAME_FORMAT, namstr);
+
+ /* @@ Do we really want to xref signature table fields? */
+ GNU_xref_ref (current_function_decl, name);
+
+ entry = build_lang_field_decl (FIELD_DECL, get_identifier (name),
+ TYPE_MAIN_VARIANT (sigtable_entry_type));
+ TREE_CONSTANT (entry) = 1;
+ TREE_READONLY (entry) = 1;
+
+ /* @@ Do we really want to xref signature table fields? */
+ GNU_xref_decl (current_function_decl, entry);
+
+ return entry;
+}
+
+/* For each FUNCTION_DECL in a signature we construct a member function
+ pointer of the appropriate type. We also need two flags to test
+ whether the member function pointer points to a virtual function or
+ to a default implementation. Those flags will be the two lower order
+ bits of the member function pointer (or the two higher order bits,
+ based on the configuration).
+
+ The new FIELD_DECLs are appended at the end of the last (and only)
+ sublist of `list_of_fieldlists.'
+
+ As a side effect, each member function in the signature gets the
+ `decl.ignored' bit turned on, so we don't output debug info for it. */
+
+void
+append_signature_fields (list_of_fieldlists)
+ tree list_of_fieldlists;
+{
+ tree l, x;
+ tree last_x = NULL_TREE;
+ tree mfptr;
+ tree last_mfptr;
+ tree mfptr_list = NULL_TREE;
+
+ /* For signatures it should actually be only a list with one element. */
+ for (l = list_of_fieldlists; l; l = TREE_CHAIN (l))
+ {
+ for (x = TREE_VALUE (l); x; x = TREE_CHAIN (x))
+ {
+ if (TREE_CODE (x) == FUNCTION_DECL)
+ {
+ mfptr = build_member_function_pointer (x);
+ DECL_MEMFUNC_POINTER_TO (x) = mfptr;
+ DECL_MEMFUNC_POINTING_TO (mfptr) = x;
+ DECL_IGNORED_P (x) = 1;
+ DECL_IN_AGGR_P (mfptr) = 1;
+ if (! mfptr_list)
+ mfptr_list = last_mfptr = mfptr;
+ else
+ {
+ TREE_CHAIN (last_mfptr) = mfptr;
+ last_mfptr = mfptr;
+ }
+ }
+ last_x = x;
+ }
+ }
+
+ /* Append the lists. */
+ if (last_x && mfptr_list)
+ {
+ TREE_CHAIN (last_x) = mfptr_list;
+ TREE_CHAIN (last_mfptr) = NULL_TREE;
+ }
+}
+
+/* Compare the types of a signature member function and a class member
+ function. Returns 1 if the types are in the C++ `<=' relationship.
+
+ If we have a signature pointer/reference as argument or return type
+ we don't want to do a recursive conformance check. The conformance
+ check only succeeds if both LHS and RHS refer to the same signature
+ pointer. Otherwise we need to keep information about parameter types
+ around at run time to initialize the signature table correctly. */
+
+static int
+match_method_types (sig_mtype, class_mtype)
+ tree sig_mtype, class_mtype;
+{
+ tree sig_return_type = TREE_TYPE (sig_mtype);
+ tree sig_arg_types = TYPE_ARG_TYPES (sig_mtype);
+ tree class_return_type = TREE_TYPE (class_mtype);
+ tree class_arg_types = TYPE_ARG_TYPES (class_mtype);
+
+ /* The return types have to be the same. */
+ if (! comptypes (sig_return_type, class_return_type, 1))
+ return 0;
+
+ /* Compare the first argument `this.' */
+ {
+ /* Get the type of what the `optr' is pointing to. */
+ tree sig_this =
+ TREE_TYPE (TREE_TYPE (TYPE_FIELDS (TREE_VALUE (sig_arg_types))));
+ tree class_this = TREE_VALUE (class_arg_types);
+
+ if (TREE_CODE (class_this) == RECORD_TYPE) /* Is `this' a sig ptr? */
+ class_this = TREE_TYPE (TREE_TYPE (TYPE_FIELDS (class_this)));
+ else
+ class_this = TREE_TYPE (class_this);
+
+ /* If a signature method's `this' is const or volatile, so has to be
+ the corresponding class method's `this.' */
+ if ((TYPE_READONLY (sig_this) && ! TYPE_READONLY (class_this))
+ || (TYPE_VOLATILE (sig_this) && ! TYPE_VOLATILE (class_this)))
+ return 0;
+ }
+
+ sig_arg_types = TREE_CHAIN (sig_arg_types);
+ class_arg_types = TREE_CHAIN (class_arg_types);
+
+ /* The number of arguments and the argument types have to be the same. */
+ return compparms (sig_arg_types, class_arg_types, 3);
+}
+
+/* Undo casts of opaque type variables to the RHS types. */
+static void
+undo_casts (sig_ty)
+ tree sig_ty;
+{
+ tree field = TYPE_FIELDS (sig_ty);
+
+ /* Since all the FIELD_DECLs for the signature table entries are at the end
+ of the chain (see `append_signature_fields'), we can do it this way. */
+ for (; field && TREE_CODE (field) != FIELD_DECL; field = TREE_CHAIN (field))
+ if (TYPE_MAIN_VARIANT (TREE_TYPE (field)) == opaque_type_node)
+ TREE_TYPE (TREE_TYPE (field)) = TREE_TYPE (ptr_type_node);
+}
+
+/* Do the type checking necessary to see whether the `rhs' conforms to
+ the lhs's `sig_ty'. Depending on the type of `rhs' return a NULL_TREE,
+ an integer_zero_node, a constructor, or an expression offsetting the
+ `rhs' signature table. */
+
+static tree
+build_signature_table_constructor (sig_ty, rhs)
+ tree sig_ty, rhs;
+{
+ tree rhstype = TREE_TYPE (rhs);
+ tree sig_field = TYPE_FIELDS (sig_ty);
+ tree result = NULL_TREE;
+ tree first_rhs_field = NULL_TREE;
+ tree last_rhs_field;
+ int sig_ptr_p = IS_SIGNATURE (rhstype);
+ int offset_p = sig_ptr_p;
+
+ rhstype = sig_ptr_p ? rhstype : TREE_TYPE (rhstype);
+
+ if (CLASSTYPE_TAGS (sig_ty))
+ {
+ sorry ("conformance check with signature containing class declarations");
+ return error_mark_node;
+ }
+
+ for (; sig_field; sig_field = TREE_CHAIN (sig_field))
+ {
+ tree basetype_path, baselink, basetypes;
+ tree sig_method, sig_mname, sig_mtype;
+ tree rhs_method, tbl_entry;
+
+ if (TREE_CODE (sig_field) == TYPE_DECL)
+ {
+ tree sig_field_type = TREE_TYPE (sig_field);
+
+ if (TYPE_MAIN_VARIANT (sig_field_type) == opaque_type_node)
+ {
+ /* We've got an opaque type here. */
+ tree oty_name = DECL_NAME (sig_field);
+ tree oty_type = lookup_field (rhstype, oty_name, 1, 1);
+
+ if (oty_type == NULL_TREE || oty_type == error_mark_node)
+ {
+ cp_error ("class `%T' does not contain type `%T'",
+ rhstype, oty_type);
+ undo_casts (sig_ty);
+ return error_mark_node;
+ }
+ oty_type = TREE_TYPE (oty_type);
+
+ /* Cast `sig_field' to be of type `oty_type'. This will be
+ undone in `undo_casts' by walking over all the TYPE_DECLs. */
+ TREE_TYPE (sig_field_type) = TREE_TYPE (oty_type);
+ }
+ /* If we don't have an opaque type, we can ignore the `typedef'. */
+ continue;
+ }
+
+ /* Find the signature method corresponding to `sig_field'. */
+ sig_method = DECL_MEMFUNC_POINTING_TO (sig_field);
+ sig_mname = DECL_NAME (sig_method);
+ sig_mtype = TREE_TYPE (sig_method);
+
+ basetype_path = TYPE_BINFO (rhstype);
+ baselink = lookup_fnfields (basetype_path, sig_mname, 0);
+ if (baselink == NULL_TREE || baselink == error_mark_node)
+ {
+ if (! IS_DEFAULT_IMPLEMENTATION (sig_method))
+ {
+ cp_error ("class `%T' does not contain method `%D'",
+ rhstype, sig_mname);
+ undo_casts (sig_ty);
+ return error_mark_node;
+ }
+ else
+ {
+ /* We use the signature's default implementation. */
+ rhs_method = sig_method;
+ }
+ }
+ else
+ {
+ /* Find the class method of the correct type. */
+
+ basetypes = TREE_PURPOSE (baselink);
+ if (TREE_CODE (basetypes) == TREE_LIST)
+ basetypes = TREE_VALUE (basetypes);
+
+ rhs_method = TREE_VALUE (baselink);
+ for (; rhs_method; rhs_method = TREE_CHAIN (rhs_method))
+ if (sig_mname == DECL_NAME (rhs_method)
+ && ! DECL_STATIC_FUNCTION_P (rhs_method)
+ && match_method_types (sig_mtype, TREE_TYPE (rhs_method)))
+ break;
+
+ if (rhs_method == NULL_TREE
+ || (compute_access (basetypes, rhs_method)
+ != access_public))
+ {
+ error ("class `%s' does not contain a method conforming to `%s'",
+ TYPE_NAME_STRING (rhstype),
+ fndecl_as_string (NULL, sig_method, 1));
+ undo_casts (sig_ty);
+ return error_mark_node;
+ }
+ }
+
+ if (sig_ptr_p && rhs_method != sig_method)
+ {
+ tree rhs_field = DECL_MEMFUNC_POINTER_TO (rhs_method);
+
+ if (first_rhs_field == NULL_TREE)
+ {
+ first_rhs_field = rhs_field;
+ last_rhs_field = rhs_field;
+ }
+ else if (TREE_CHAIN (last_rhs_field) == rhs_field)
+ last_rhs_field = rhs_field;
+ else
+ offset_p = 0;
+
+ tbl_entry = build_component_ref (rhs, DECL_NAME (rhs_field),
+ NULL_TREE, 1);
+ }
+ else
+ {
+ tree tag, vb_off, delta, index, pfn, vt_off;
+ tree tag_decl, vb_off_decl, delta_decl, index_decl;
+ tree pfn_decl, vt_off_decl;
+
+ if (rhs_method == sig_method)
+ {
+ /* default implementation */
+ tag = build_unary_op (NEGATE_EXPR, integer_one_node, 0);
+ vb_off = build_unary_op (NEGATE_EXPR, integer_one_node, 0);
+ delta = integer_zero_node;
+ index = integer_zero_node;
+ pfn = build_unary_op (ADDR_EXPR, rhs_method, 0);
+ TREE_TYPE (pfn) = ptr_type_node;
+ TREE_ADDRESSABLE (rhs_method) = 1;
+ offset_p = 0; /* we can't offset the rhs sig table */
+ }
+ else if (DECL_VINDEX (rhs_method))
+ {
+ /* virtual member function */
+ tag = integer_one_node;
+ vb_off = build_unary_op (NEGATE_EXPR, integer_one_node, 0);
+ delta = BINFO_OFFSET (get_binfo (DECL_CLASS_CONTEXT (rhs_method),
+ rhstype, 1));
+ index = DECL_VINDEX (rhs_method);
+ vt_off = get_vfield_offset (get_binfo (DECL_CONTEXT (rhs_method),
+ rhstype, 0));
+ }
+ else
+ {
+ /* non-virtual member function */
+ tag = integer_zero_node;
+ vb_off = build_unary_op (NEGATE_EXPR, integer_one_node, 0);
+ delta = BINFO_OFFSET (get_binfo (DECL_CLASS_CONTEXT (rhs_method),
+ rhstype, 1));
+ index = integer_zero_node;
+ pfn = build_unary_op (ADDR_EXPR, rhs_method, 0);
+ TREE_TYPE (pfn) = ptr_type_node;
+ TREE_ADDRESSABLE (rhs_method) = 1;
+ }
+
+ /* Since digest_init doesn't handle initializing selected fields
+ of a struct (i.e., anonymous union), we build the constructor
+ by hand, without calling digest_init. */
+ tag_decl = TYPE_FIELDS (sigtable_entry_type);
+ vb_off_decl = TREE_CHAIN (tag_decl);
+ delta_decl = TREE_CHAIN (vb_off_decl);
+ index_decl = TREE_CHAIN (delta_decl);
+ pfn_decl = TREE_CHAIN (index_decl);
+ vt_off_decl = TREE_CHAIN (pfn_decl);
+
+ tag = convert (TREE_TYPE (tag_decl), tag);
+ vb_off = convert (TREE_TYPE (vb_off_decl), vb_off);
+ delta = convert (TREE_TYPE (delta_decl), delta);
+ index = convert (TREE_TYPE (index_decl), index);
+
+ if (DECL_VINDEX (rhs_method))
+ {
+ vt_off = convert (TREE_TYPE (vt_off_decl), vt_off);
+
+ tbl_entry = build_tree_list (vt_off_decl, vt_off);
+ }
+ else
+ {
+ pfn = convert (TREE_TYPE (pfn_decl), pfn);
+
+ tbl_entry = build_tree_list (pfn_decl, pfn);
+ }
+ tbl_entry = tree_cons (delta_decl, delta,
+ tree_cons (index_decl, index, tbl_entry));
+ tbl_entry = tree_cons (tag_decl, tag,
+ tree_cons (vb_off_decl, vb_off, tbl_entry));
+ tbl_entry = build (CONSTRUCTOR, sigtable_entry_type,
+ NULL_TREE, tbl_entry);
+
+ TREE_CONSTANT (tbl_entry) = 1;
+ }
+
+ /* Chain those function address expressions together. */
+ if (result)
+ result = tree_cons (NULL_TREE, tbl_entry, result);
+ else
+ result = build_tree_list (NULL_TREE, tbl_entry);
+ }
+
+ if (result == NULL_TREE)
+ {
+ /* The signature was empty, we don't need a signature table. */
+ undo_casts (sig_ty);
+ return NULL_TREE;
+ }
+
+ if (offset_p)
+ {
+ if (first_rhs_field == TYPE_FIELDS (rhstype))
+ {
+ /* The sptr field on the lhs can be copied from the rhs. */
+ undo_casts (sig_ty);
+ return integer_zero_node;
+ }
+ else
+ {
+ /* The sptr field on the lhs will point into the rhs sigtable. */
+ undo_casts (sig_ty);
+ return build_component_ref (rhs, DECL_NAME (first_rhs_field),
+ NULL_TREE, 0);
+ }
+ }
+
+ /* We need to construct a new signature table. */
+ result = build_nt (CONSTRUCTOR, NULL_TREE, nreverse (result));
+ TREE_HAS_CONSTRUCTOR (result) = 1;
+ TREE_CONSTANT (result) = !sig_ptr_p;
+
+ undo_casts (sig_ty);
+ return result;
+}
+
+/* Build a signature table declaration and initialize it or return an
+ existing one if we built one already. If we don't get a constructor
+ as initialization expression, we don't need a new signature table
+ variable and just hand back the init expression.
+
+ The declaration processing is done by hand instead of using `cp_finish_decl'
+ so that we can make signature pointers global variables instead of
+ static ones. */
+
+static tree
+build_sigtable (sig_type, rhs_type, init_from)
+ tree sig_type, rhs_type, init_from;
+{
+ tree name = NULL_TREE;
+ tree decl = NULL_TREE;
+ tree init_expr;
+
+ push_obstacks_nochange ();
+ end_temporary_allocation ();
+
+ if (! IS_SIGNATURE (rhs_type))
+ {
+ name = get_sigtable_name (sig_type, rhs_type);
+ decl = IDENTIFIER_GLOBAL_VALUE (name);
+ }
+ if (decl == NULL_TREE)
+ {
+ tree init;
+
+ /* We allow only one signature table to be generated for signatures
+ with opaque types. Otherwise we create a loophole in the type
+ system since we could cast data from one classes implementation
+ of the opaque type to that of another class. */
+ if (SIGNATURE_HAS_OPAQUE_TYPEDECLS (sig_type)
+ && SIGTABLE_HAS_BEEN_GENERATED (sig_type))
+ {
+ error ("signature with opaque type implemented by multiple classes");
+ return error_mark_node;
+ }
+ SIGTABLE_HAS_BEEN_GENERATED (sig_type) = 1;
+
+ init_expr = build_signature_table_constructor (sig_type, init_from);
+ if (init_expr == NULL_TREE || TREE_CODE (init_expr) != CONSTRUCTOR)
+ return init_expr;
+
+ if (name == NULL_TREE)
+ name = get_sigtable_name (sig_type, rhs_type);
+ {
+ tree context = current_function_decl;
+
+ /* Make the signature table global, not just static in whichever
+ function a signature pointer/ref is used for the first time. */
+ current_function_decl = NULL_TREE;
+ decl = pushdecl_top_level (build_decl (VAR_DECL, name, sig_type));
+ current_function_decl = context;
+ }
+ IDENTIFIER_GLOBAL_VALUE (name) = decl;
+ store_init_value (decl, init_expr);
+ if (IS_SIGNATURE (rhs_type))
+ {
+ init = DECL_INITIAL (decl);
+ DECL_INITIAL (decl) = error_mark_node;
+ }
+
+ DECL_ALIGN (decl) = MAX (TYPE_ALIGN (double_type_node),
+ DECL_ALIGN (decl));
+#if 0
+ /* GDB-4.7 doesn't find the initialization value of a signature table
+ when it is constant. */
+ TREE_READONLY (decl) = 1;
+#endif
+ TREE_STATIC (decl) = 1;
+ TREE_USED (decl) = 1;
+
+ make_decl_rtl (decl, NULL, 1);
+ if (IS_SIGNATURE (rhs_type))
+ expand_static_init (decl, init);
+ }
+
+ pop_obstacks ();
+
+ return decl;
+}
+
+/* Create a constructor or modify expression if the LHS of an assignment
+ is a signature pointer or a signature reference. If LHS is a record
+ type node, we build a constructor, otherwise a compound expression. */
+
+tree
+build_signature_pointer_constructor (lhs, rhs)
+ tree lhs, rhs;
+{
+ register struct obstack *ambient_obstack = current_obstack;
+ register struct obstack *ambient_saveable_obstack = saveable_obstack;
+ int initp = (TREE_CODE (lhs) == RECORD_TYPE);
+ tree lhstype = initp ? lhs : TREE_TYPE (lhs);
+ tree rhstype = TREE_TYPE (rhs);
+ tree sig_ty = SIGNATURE_TYPE (lhstype);
+ tree sig_tbl, sptr_expr, optr_expr;
+ tree result;
+
+ if (! ((TREE_CODE (rhstype) == POINTER_TYPE
+ && TREE_CODE (TREE_TYPE (rhstype)) == RECORD_TYPE)
+ || (TYPE_LANG_SPECIFIC (rhstype) &&
+ (IS_SIGNATURE_POINTER (rhstype)
+ || IS_SIGNATURE_REFERENCE (rhstype)))))
+ {
+ error ("invalid assignment to signature pointer or reference");
+ return error_mark_node;
+ }
+
+ if (TYPE_SIZE (sig_ty) == NULL_TREE)
+ {
+ cp_error ("undefined signature `%T' used in signature %s declaration",
+ sig_ty,
+ IS_SIGNATURE_POINTER (lhstype) ? "pointer" : "reference");
+ return error_mark_node;
+ }
+
+ /* If SIG_TY is permanent, make the signature table constructor and
+ the signature pointer/reference constructor permanent too. */
+ if (TREE_PERMANENT (sig_ty))
+ {
+ current_obstack = &permanent_obstack;
+ saveable_obstack = &permanent_obstack;
+ }
+
+ if (TYPE_LANG_SPECIFIC (rhstype) &&
+ (IS_SIGNATURE_POINTER (rhstype) || IS_SIGNATURE_REFERENCE (rhstype)))
+ {
+ if (SIGNATURE_TYPE (rhstype) == sig_ty)
+ {
+ /* LHS and RHS are signature pointers/refs of the same signature. */
+ optr_expr = build_optr_ref (rhs);
+ sptr_expr = build_sptr_ref (rhs);
+ }
+ else
+ {
+ /* We need to create a new signature table and copy
+ elements from the rhs signature table. */
+ tree rhs_sptr_ref = build_sptr_ref (rhs);
+ tree rhs_tbl = build1 (INDIRECT_REF, SIGNATURE_TYPE (rhstype),
+ rhs_sptr_ref);
+
+ sig_tbl = build_sigtable (sig_ty, SIGNATURE_TYPE (rhstype), rhs_tbl);
+ if (sig_tbl == error_mark_node)
+ return error_mark_node;
+
+ optr_expr = build_optr_ref (rhs);
+ if (sig_tbl == NULL_TREE)
+ /* The signature was empty. The signature pointer is
+ pretty useless, but the user has been warned. */
+ sptr_expr = copy_node (null_pointer_node);
+ else if (sig_tbl == integer_zero_node)
+ sptr_expr = rhs_sptr_ref;
+ else
+ sptr_expr = build_unary_op (ADDR_EXPR, sig_tbl, 0);
+ TREE_TYPE (sptr_expr) = build_pointer_type (sig_ty);
+ }
+ }
+ else
+ {
+ sig_tbl = build_sigtable (sig_ty, TREE_TYPE (rhstype), rhs);
+ if (sig_tbl == error_mark_node)
+ return error_mark_node;
+
+ optr_expr = rhs;
+ if (sig_tbl == NULL_TREE)
+ /* The signature was empty. The signature pointer is
+ pretty useless, but the user has been warned. */
+ {
+ sptr_expr = copy_node (null_pointer_node);
+ TREE_TYPE (sptr_expr) = build_pointer_type (sig_ty);
+ }
+ else
+ sptr_expr = build_unary_op (ADDR_EXPR, sig_tbl, 0);
+ }
+
+ if (initp)
+ {
+ result = tree_cons (NULL_TREE, optr_expr,
+ build_tree_list (NULL_TREE, sptr_expr));
+ result = build_nt (CONSTRUCTOR, NULL_TREE, result);
+ TREE_HAS_CONSTRUCTOR (result) = 1;
+ result = digest_init (lhstype, result, 0);
+ }
+ else
+ {
+ if (TREE_READONLY (lhs) || TYPE_READONLY (lhstype))
+ readonly_error (lhs, "assignment", 0);
+
+ optr_expr = build_modify_expr (build_optr_ref (lhs), NOP_EXPR,
+ optr_expr);
+ sptr_expr = build_modify_expr (build_sptr_ref (lhs), NOP_EXPR,
+ sptr_expr);
+
+ result = tree_cons (NULL_TREE, optr_expr,
+ tree_cons (NULL_TREE, sptr_expr,
+ build_tree_list (NULL_TREE, lhs)));
+ result = build_compound_expr (result);
+ }
+
+ current_obstack = ambient_obstack;
+ saveable_obstack = ambient_saveable_obstack;
+ return result;
+}
+
+/* Build a temporary variable declaration for the instance of a signature
+ member function call if it isn't a declaration node already. Simply
+ using a SAVE_EXPR doesn't work since we need `this' in both branches
+ of a conditional expression. */
+
+static tree
+save_this (instance)
+ tree instance;
+{
+ tree decl;
+
+ if (TREE_CODE_CLASS (TREE_CODE (instance)) == 'd')
+ decl = instance;
+ else
+ {
+ decl = build_decl (VAR_DECL, NULL_TREE, TREE_TYPE (instance));
+ DECL_REGISTER (decl) = 1;
+ layout_decl (decl, 0);
+ expand_decl (decl);
+ }
+
+ return decl;
+}
+
+/* Build a signature member function call. Looks up the signature table
+ entry corresponding to FUNCTION. Depending on the value of the CODE
+ field, either call the function in PFN directly, or use OFFSET to
+ index INSTANCE's virtual function table. */
+
+tree
+build_signature_method_call (basetype, instance, function, parms)
+ tree basetype, instance, function, parms;
+{
+ tree saved_instance = save_this (instance); /* Create temp for `this'. */
+ tree object_ptr = build_optr_ref (saved_instance);
+ tree new_object_ptr, new_parms;
+ tree signature_tbl_ptr = build_sptr_ref (saved_instance);
+ tree sig_field_name = DECL_NAME (DECL_MEMFUNC_POINTER_TO (function));
+ tree basetype_path = TYPE_BINFO (basetype);
+ tree tbl_entry = build_component_ref (build1 (INDIRECT_REF, basetype,
+ signature_tbl_ptr),
+ sig_field_name, basetype_path, 1);
+ tree tag, delta, pfn, vt_off, index, vfn;
+ tree deflt_call = NULL_TREE, direct_call, virtual_call, result;
+
+ tbl_entry = save_expr (tbl_entry);
+ tag = build_component_ref (tbl_entry, tag_identifier, NULL_TREE, 1);
+ delta = build_component_ref (tbl_entry, delta_identifier, NULL_TREE, 1);
+ pfn = build_component_ref (tbl_entry, pfn_identifier, NULL_TREE, 1);
+ vt_off = build_component_ref (tbl_entry, vt_off_identifier, NULL_TREE, 1);
+ index = build_component_ref (tbl_entry, index_identifier, NULL_TREE, 1);
+ TREE_TYPE (pfn) = build_pointer_type (TREE_TYPE (function));
+
+ if (IS_DEFAULT_IMPLEMENTATION (function))
+ {
+ pfn = save_expr (pfn);
+ deflt_call = build_function_call (pfn, parms);
+ }
+
+ new_object_ptr = build (PLUS_EXPR, build_pointer_type (basetype),
+ convert (ptrdiff_type_node, object_ptr),
+ convert (ptrdiff_type_node, delta));
+
+ parms = tree_cons (NULL_TREE,
+ convert (build_pointer_type (basetype), object_ptr),
+ TREE_CHAIN (parms));
+ new_parms = tree_cons (NULL_TREE, new_object_ptr, TREE_CHAIN (parms));
+
+ {
+ /* Cast the signature method to have `this' of a normal pointer type. */
+ tree old_this = TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (TREE_TYPE (pfn))));
+
+ TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (TREE_TYPE (pfn)))) =
+ build_type_variant (build_pointer_type (basetype),
+ TYPE_READONLY (old_this),
+ TYPE_VOLATILE (old_this));
+
+ direct_call = build_function_call (pfn, new_parms);
+
+ {
+ tree vfld, vtbl, aref;
+
+ vfld = build (PLUS_EXPR,
+ build_pointer_type (build_pointer_type (vtbl_type_node)),
+ convert (ptrdiff_type_node, object_ptr),
+ convert (ptrdiff_type_node, vt_off));
+ vtbl = build_indirect_ref (build_indirect_ref (vfld, NULL_PTR),
+ NULL_PTR);
+ aref = build_array_ref (vtbl, index);
+
+ if (flag_vtable_thunks)
+ vfn = aref;
+ else
+ vfn = build_component_ref (aref, pfn_identifier, 0, 0);
+
+ TREE_TYPE (vfn) = build_pointer_type (TREE_TYPE (function));
+
+ if (flag_vtable_thunks)
+ virtual_call = build_function_call (vfn, parms);
+ else
+ virtual_call = build_function_call (vfn, new_parms);
+ }
+
+ /* Undo the cast, make `this' a signature pointer again. */
+ TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (TREE_TYPE (pfn)))) = old_this;
+ }
+
+ /* Once the function was found, there should be no reason why we
+ couldn't build the member function pointer call. */
+ if (!direct_call || direct_call == error_mark_node
+ || !virtual_call || virtual_call == error_mark_node
+ || (IS_DEFAULT_IMPLEMENTATION (function)
+ && (!deflt_call || deflt_call == error_mark_node)))
+ {
+ compiler_error ("cannot build call of signature member function `%s'",
+ fndecl_as_string (NULL, function, 1));
+ return error_mark_node;
+ }
+
+ if (IS_DEFAULT_IMPLEMENTATION (function))
+ {
+ tree test = build_binary_op_nodefault (LT_EXPR, tag, integer_zero_node,
+ LT_EXPR);
+ result = build_conditional_expr (tag,
+ build_conditional_expr (test,
+ deflt_call,
+ virtual_call),
+ direct_call);
+ }
+ else
+ result = build_conditional_expr (tag, virtual_call, direct_call);
+
+ /* If we created a temporary variable for `this', initialize it first. */
+ if (instance != saved_instance)
+ result = build (COMPOUND_EXPR, TREE_TYPE (result),
+ build_modify_expr (saved_instance, NOP_EXPR, instance),
+ result);
+
+ return result;
+}
+
+/* Create a COMPONENT_REF expression for referencing the OPTR field
+ of a signature pointer or reference. */
+
+tree
+build_optr_ref (instance)
+ tree instance;
+{
+ tree field = get_identifier (SIGNATURE_OPTR_NAME);
+
+ return build_component_ref (instance, field, NULL_TREE, 1);
+}
+
+/* Create a COMPONENT_REF expression for referencing the SPTR field
+ of a signature pointer or reference. */
+
+tree
+build_sptr_ref (instance)
+ tree instance;
+{
+ tree field = get_identifier (SIGNATURE_SPTR_NAME);
+
+ return build_component_ref (instance, field, NULL_TREE, 1);
+}
diff --git a/contrib/gcc/cp/spew.c b/contrib/gcc/cp/spew.c
new file mode 100644
index 0000000..4b30b95
--- /dev/null
+++ b/contrib/gcc/cp/spew.c
@@ -0,0 +1,455 @@
+/* Type Analyzer for GNU C++.
+ Copyright (C) 1987, 89, 92, 93, 94, 1995 Free Software Foundation, Inc.
+ Hacked... nay, bludgeoned... by Mark Eichin (eichin@cygnus.com)
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+/* This file is the type analyzer for GNU C++. To debug it, define SPEW_DEBUG
+ when compiling parse.c and spew.c. */
+
+#include "config.h"
+#include <stdio.h>
+#include "input.h"
+#include "tree.h"
+#include "lex.h"
+#include "parse.h"
+#include "cp-tree.h"
+#include "flags.h"
+#include "obstack.h"
+
+/* This takes a token stream that hasn't decided much about types and
+ tries to figure out as much as it can, with excessive lookahead and
+ backtracking. */
+
+/* fifo of tokens recognized and available to parser. */
+struct token {
+ /* The values for YYCHAR will fit in a short. */
+ short yychar;
+ short end_of_file;
+ YYSTYPE yylval;
+};
+
+static int do_aggr ();
+
+/* From lex.c: */
+/* the declaration found for the last IDENTIFIER token read in.
+ yylex must look this up to detect typedefs, which get token type TYPENAME,
+ so it is left around in case the identifier is not a typedef but is
+ used in a context which makes it a reference to a variable. */
+extern tree lastiddecl; /* let our brains leak out here too */
+extern int yychar; /* the lookahead symbol */
+extern YYSTYPE yylval; /* the semantic value of the */
+ /* lookahead symbol */
+extern int end_of_file;
+
+struct obstack token_obstack;
+int first_token;
+
+#ifdef SPEW_DEBUG
+int spew_debug = 0;
+static unsigned int yylex_ctr = 0;
+static int debug_yychar ();
+#endif
+
+/* Initialize token_obstack. Called once, from init_lex. */
+void
+init_spew ()
+{
+ gcc_obstack_init(&token_obstack);
+}
+
+#ifdef SPEW_DEBUG
+/* Use functions for debugging... */
+
+/* Return the number of tokens available on the fifo. */
+static int
+num_tokens ()
+{
+ return (obstack_object_size(&token_obstack)/sizeof(struct token))
+ - first_token;
+}
+
+/* Fetch the token N down the line from the head of the fifo. */
+static struct token*
+nth_token (n)
+ int n;
+{
+ /* could just have this do slurp_ implicitly, but this way is easier
+ * to debug... */
+ my_friendly_assert (n < num_tokens(), 298);
+ return ((struct token*)obstack_base(&token_obstack))+n+first_token;
+}
+
+/* Add a token to the token fifo. */
+static void
+add_token (t)
+ struct token* t;
+{
+ obstack_grow(&token_obstack,t,sizeof (struct token));
+}
+
+/* Consume the next token out of the fifo. */
+static void
+consume_token()
+{
+ if (num_tokens() == 1)
+ {
+ obstack_free(&token_obstack, obstack_base (&token_obstack));
+ first_token = 0;
+ }
+ else
+ first_token++;
+}
+
+#else
+/* ...otherwise use macros. */
+
+#define num_tokens() \
+ ((obstack_object_size(&token_obstack)/sizeof(struct token)) - first_token)
+
+#define nth_token(N) \
+ (((struct token*)obstack_base(&token_obstack))+(N)+first_token)
+
+#define add_token(T) obstack_grow(&token_obstack, (T), sizeof (struct token))
+
+#define consume_token() \
+ (num_tokens() == 1 \
+ ? (obstack_free (&token_obstack, obstack_base (&token_obstack)), \
+ (first_token = 0)) \
+ : first_token++)
+#endif
+
+/* Pull in enough tokens from real_yylex that the queue is N long beyond
+ the current token. */
+
+static void
+scan_tokens (n)
+ int n;
+{
+ int i;
+ struct token *tmp;
+
+ /* We cannot read past certain tokens, so make sure we don't. */
+ i = num_tokens ();
+ if (i > n)
+ return;
+ while (i-- > 0)
+ {
+ tmp = nth_token (i);
+ /* Never read past these characters: they might separate
+ the current input stream from one we save away later. */
+ if (tmp->yychar == '{' || tmp->yychar == ':' || tmp->yychar == ';')
+ goto pad_tokens;
+ }
+
+ while (num_tokens() <= n)
+ {
+ obstack_blank(&token_obstack,sizeof (struct token));
+ tmp = ((struct token *)obstack_next_free (&token_obstack))-1;
+ tmp->yychar = real_yylex();
+ tmp->end_of_file = end_of_file;
+ tmp->yylval = yylval;
+ end_of_file = 0;
+ if (tmp->yychar == '{'
+ || tmp->yychar == ':'
+ || tmp->yychar == ';')
+ {
+ pad_tokens:
+ while (num_tokens () <= n)
+ {
+ obstack_blank(&token_obstack,sizeof (struct token));
+ tmp = ((struct token *)obstack_next_free (&token_obstack))-1;
+ tmp->yychar = EMPTY;
+ tmp->end_of_file = 0;
+ }
+ }
+ }
+}
+
+/* Create room for N tokens at the front of the fifo. This is used
+ to insert new tokens into the stream ahead of the current token. */
+
+static void
+shift_tokens (n)
+ int n;
+{
+ if (first_token >= n)
+ first_token -= n;
+ else
+ {
+ int old_token_count = num_tokens ();
+ char *tmp;
+
+ obstack_blank (&token_obstack, (n-first_token) * sizeof (struct token));
+ if (old_token_count)
+ {
+ tmp = (char *)alloca ((num_tokens () + (n-first_token))
+ * sizeof (struct token));
+ /* This move does not rely on the system being able to handle
+ overlapping moves. */
+ bcopy ((char *) nth_token (0), tmp,
+ old_token_count * sizeof (struct token));
+ bcopy (tmp, (char *) nth_token (n),
+ old_token_count * sizeof (struct token));
+ }
+ first_token = 0;
+ }
+}
+
+static int
+probe_obstack (h, obj, nlevels)
+ struct obstack *h;
+ tree obj;
+ unsigned int nlevels;
+{
+ register struct _obstack_chunk* lp; /* below addr of any objects in this chunk */
+ register struct _obstack_chunk* plp; /* point to previous chunk if any */
+
+ lp = (h)->chunk;
+ /* We use >= rather than > since the object cannot be exactly at
+ the beginning of the chunk but might be an empty object exactly
+ at the end of an adjacent chunk. */
+ for (; nlevels != 0 && lp != 0 && ((tree)lp >= obj || (tree)lp->limit < obj);
+ nlevels -= 1)
+ {
+ plp = lp->prev;
+ lp = plp;
+ }
+ return nlevels != 0 && lp != 0;
+}
+
+/* from lex.c: */
+/* Value is 1 (or 2) if we should try to make the next identifier look like
+ a typename (when it may be a local variable or a class variable).
+ Value is 0 if we treat this name in a default fashion. */
+extern int looking_for_typename;
+int looking_for_template;
+
+extern struct obstack *current_obstack, *saveable_obstack;
+tree got_scope;
+tree got_object;
+
+int
+peekyylex()
+{
+ scan_tokens (0);
+ return nth_token (0)->yychar;
+}
+
+int
+yylex()
+{
+ struct token tmp_token;
+ tree trrr;
+
+ retry:
+#ifdef SPEW_DEBUG
+ if (spew_debug)
+ {
+ yylex_ctr ++;
+ fprintf(stderr, "\t\t## %d ##",yylex_ctr);
+ }
+#endif
+
+ /* if we've got tokens, send them */
+ if (num_tokens())
+ {
+ tmp_token= *nth_token(0);
+
+ /* TMP_TOKEN.YYLVAL.TTYPE may have been allocated on the wrong obstack.
+ If we don't find it in CURRENT_OBSTACK's current or immediately
+ previous chunk, assume it was and copy it to the current obstack. */
+ if ((tmp_token.yychar == CONSTANT
+ || tmp_token.yychar == STRING)
+ && ! TREE_PERMANENT (tmp_token.yylval.ttype)
+ && ! probe_obstack (current_obstack, tmp_token.yylval.ttype, 2)
+ && ! probe_obstack (saveable_obstack, tmp_token.yylval.ttype, 2))
+ tmp_token.yylval.ttype = copy_node (tmp_token.yylval.ttype);
+ }
+ else
+ {
+ /* if not, grab the next one and think about it */
+ tmp_token.yychar = real_yylex ();
+ tmp_token.yylval = yylval;
+ tmp_token.end_of_file = end_of_file;
+ add_token(&tmp_token);
+ }
+
+ /* many tokens just need to be returned. At first glance, all we
+ * have to do is send them back up, but some of them are needed to
+ * figure out local context. */
+ switch(tmp_token.yychar)
+ {
+ case EMPTY:
+ /* This is a lexical no-op. */
+ consume_token ();
+#ifdef SPEW_DEBUG
+ if (spew_debug)
+ debug_yychar (tmp_token.yychar);
+#endif
+ goto retry;
+
+ case IDENTIFIER:
+ scan_tokens (1);
+ if (nth_token (1)->yychar == SCOPE)
+ /* Don't interfere with the setting from an 'aggr' prefix. */
+ looking_for_typename++;
+ else if (nth_token (1)->yychar == '<')
+ looking_for_template = 1;
+
+ trrr = lookup_name (tmp_token.yylval.ttype, -2);
+
+ if (trrr)
+ {
+ tmp_token.yychar = identifier_type (trrr);
+ switch (tmp_token.yychar)
+ {
+ case TYPENAME:
+ lastiddecl = identifier_typedecl_value (tmp_token.yylval.ttype);
+ if (lastiddecl != trrr)
+ {
+ lastiddecl = trrr;
+ if (got_scope || got_object)
+ tmp_token.yylval.ttype = DECL_NESTED_TYPENAME (trrr);
+ }
+ break;
+ case IDENTIFIER:
+ lastiddecl = trrr;
+ break;
+ case PTYPENAME:
+ lastiddecl = NULL_TREE;
+ break;
+ case NSNAME:
+ lastiddecl = trrr;
+ if (got_scope || got_object)
+ tmp_token.yylval.ttype = trrr;
+ break;
+ default:
+ my_friendly_abort (101);
+ }
+ }
+ else
+ lastiddecl = trrr;
+ got_scope = NULL_TREE;
+ /* and fall through to... */
+ case IDENTIFIER_DEFN:
+ case TYPENAME:
+ case TYPENAME_DEFN:
+ case PTYPENAME:
+ case PTYPENAME_DEFN:
+ consume_token ();
+ if (looking_for_typename > 0)
+ looking_for_typename--;
+ looking_for_template = 0;
+ break;
+
+ case SCSPEC:
+ /* do_aggr needs to check if the previous token was RID_FRIEND,
+ so just increment first_token instead of calling consume_token. */
+ first_token++;
+ break;
+ case TYPESPEC:
+ consume_token ();
+ break;
+
+ case AGGR:
+ *nth_token(0) = tmp_token;
+ do_aggr ();
+ /* fall through to output... */
+ case ENUM:
+ /* Set this again, in case we are rescanning. */
+ looking_for_typename = 1;
+ /* fall through... */
+ default:
+ consume_token();
+ }
+
+ yylval = tmp_token.yylval;
+ yychar = tmp_token.yychar;
+ end_of_file = tmp_token.end_of_file;
+#ifdef SPEW_DEBUG
+ if (spew_debug)
+ debug_yychar(yychar);
+#endif
+ return yychar;
+}
+
+/* token[0] == AGGR (struct/union/enum)
+ * Thus, token[1] is either a TYPENAME or a TYPENAME_DEFN.
+ * If token[2] == '{' or ':' then it's TYPENAME_DEFN.
+ * It's also a definition if it's a forward declaration (as in 'struct Foo;')
+ * which we can tell lf token[2] == ';' *and* token[-1] != FRIEND.
+ */
+static int
+do_aggr ()
+{
+ int yc1, yc2;
+
+ scan_tokens (2);
+ yc1 = nth_token (1)->yychar;
+ if (yc1 != TYPENAME && yc1 != IDENTIFIER && yc1 != PTYPENAME)
+ return 0;
+ yc2 = nth_token (2)->yychar;
+ if (yc2 == ';')
+ {
+ /* It's a forward declaration iff we were not preceded by 'friend'. */
+ if (first_token > 0 && nth_token (-1)->yychar == SCSPEC
+ && nth_token (-1)->yylval.ttype == ridpointers[(int) RID_FRIEND])
+ return 0;
+ }
+ else if (yc2 != '{' && yc2 != ':')
+ return 0;
+
+ switch (yc1)
+ {
+ case TYPENAME:
+ nth_token (1)->yychar = TYPENAME_DEFN;
+ break;
+ case PTYPENAME:
+ nth_token (1)->yychar = PTYPENAME_DEFN;
+ break;
+ case IDENTIFIER:
+ nth_token (1)->yychar = IDENTIFIER_DEFN;
+ break;
+ default:
+ my_friendly_abort (102);
+ }
+ return 0;
+}
+
+#ifdef SPEW_DEBUG
+/* debug_yychar takes a yychar (token number) value and prints its name. */
+static int
+debug_yychar (yy)
+ int yy;
+{
+ /* In parse.y: */
+ extern char *debug_yytranslate ();
+
+ int i;
+
+ if(yy<256) {
+ fprintf (stderr, "<%d: %c >\n", yy, yy);
+ return 0;
+ }
+ fprintf (stderr, "<%d:%s>\n", yy, debug_yytranslate (yy));
+ return 1;
+}
+
+#endif
diff --git a/contrib/gcc/cp/templates.texi b/contrib/gcc/cp/templates.texi
new file mode 100644
index 0000000..2a6db07
--- /dev/null
+++ b/contrib/gcc/cp/templates.texi
@@ -0,0 +1,235 @@
+@node Templates
+@chapter The Template Implementation
+
+@cindex templates
+@cindex function templates
+@cindex class templates
+@cindex parameterized types
+@cindex types, parameterized
+The C++ template@footnote{Class templates are also known as
+@dfn{parameterized types}.} facility, which effectively allows use of
+variables for types in declarations, is one of the newest features of
+the language.
+
+@sc{gnu} C++ is one of the first compilers to implement many
+of the template facilities currently defined by the @sc{ansi} committee.
+
+Nevertheless, the template implementation is not yet complete. This
+chapter maps the current limitations of the @sc{gnu} C++ template
+implementation.
+
+@menu
+* Template limitations:: Limitations for function and class templates
+* Function templates:: Limitations for function templates
+* Class templates:: Limitations for class templates
+* Template debugging:: Debugging information for templates
+@end menu
+
+@node Template limitations
+@section Limitations for function and class templates
+
+@cindex template limitations
+@cindex template bugs
+@cindex bugs, templates
+These limitations apply to any use of templates (function templates or
+class templates) with @sc{gnu} C++:
+
+@table @emph
+@item Template definitions must be visible
+When you compile code with templates, the template definitions must come
+first (before the compiler needs to expand them), and template
+definitions you use must be visible in the current scope.
+@c FIXME! Is this a defined property of templates, rather than a
+@c temporary limitation?
+@c ANSWER: It's a limitation, but it's hard to say why it's a limitation
+@c to someone. We need an infinite link-cycle, in one camp, to
+@c accomplish things so you don't need the template definitions around.
+
+@cindex static data in template classes
+@cindex template classes, static data in
+@item Individual initializers needed for static data
+Templates for static data in template classes do not work. @xref{Class
+templates,,Limitations for class templates}.
+@end table
+
+@node Function templates
+@section Limitations for function templates
+
+@cindex function template limitations
+Function templates are implemented for the most part. The compiler can
+correctly determine template parameter values, and will delay
+instantiation of a function that uses templates until the requisite type
+information is available.
+
+@noindent
+The following limitations remain:
+
+@itemize @bullet
+@cindex template vs declaration, functions
+@cindex declaration vs template, functions
+@cindex function declaration vs template
+@item
+Narrowed specification: function declarations should not prevent
+template expansion. When you declare a function, @sc{gnu} C++
+interprets the declaration as an indication that you will provide a
+definition for that function. Therefore, @sc{gnu} C++ does not use a
+template expansion if there is also an applicable declaration. @sc{gnu}
+C++ only expands the template when there is no such declaration.
+
+The specification in Bjarne Stroustrup's @cite{The C++ Programming
+Language, Second Edition} is narrower, and the @sc{gnu} C++
+implementation is now clearly incorrect. With this new specification, a
+declaration that corresponds to an instantiation of a function template
+only affects whether conversions are needed to use that version of the
+function. It should no longer prevent expansion of the template
+definition.
+
+For example, this code fragment must be treated differently:
+
+@smallexample
+template <class X> X min (X& x1, X& x2) @{ @dots{} @}
+int min (int, int);
+@dots{}
+int i; short s;
+min (i, s); // @r{should call} min(int,int)
+ // @r{derived from template}
+@dots{}
+@end smallexample
+
+@item
+The compiler does not yet understand function signatures where types are
+nested within template parameters. For example, a function like the
+following produces a syntax error on the closing @samp{)} of the
+definition of the function @code{f}:
+
+@smallexample
+template <class T> class A @{ public: T x; class Y @{@}; @};
+template <class X> int f (A<X>::Y y) @{ @dots{} @}
+@end smallexample
+
+@cindex @code{inline} and function templates
+@cindex function templates and @code{inline}
+@item
+If you declare an @code{inline} function using templates, the compiler
+can only inline the code @emph{after} the first time you use
+that function with whatever particular type signature the template
+was instantiated.
+
+Removing this limitation is akin to supporting nested function
+definitions in @sc{gnu} C++; the limitation will probably remain until the
+more general problem of nested functions is solved.
+
+@item
+All the @emph{method} templates (templates for member functions) for a
+class must be visible to the compiler when the class template is
+instantiated.
+@end itemize
+
+@node Class templates
+@section Limitations for class templates
+
+@cindex class template limitations
+@ignore
+FIXME!! Include a comprehensible version of this if someone can explain it.
+ (Queried Brendan and Raeburn w/full orig context, 26may1993---pesch)
+ - [RHP: I don't understand what the following fragment refers to. If it's
+ the "BIG BUG" section in the original, why does it say "overriding class
+ declarations" here when the more detailed text refers to *function*
+ declarations? Here's the fragment I don't understand:]
+ there are problems with user-supplied overriding class declarations (see
+ below).
+@end ignore
+
+@itemize @bullet
+@ignore
+@cindex static data, not working in templates
+@item
+Templates for static data in template classes do not work.
+Currently, you must initialize each case of such data
+individually.
+@c FIXME!! Brendan to see if still true.
+@c ANSWER: This section presumes that it's incorrect to have to
+@c initialize for each type you instantiate with. It's not, it's the
+@c right way to do it.
+@end ignore
+
+Unfortunately, individual initializations of this sort are likely to be
+considered errors eventually; since they're needed now, you might want to
+flag places where you use them with comments to mark the need for a
+future transition.
+
+@cindex nested type results vs templates
+@item
+Member functions in template classes may not have results of nested
+type; @sc{gnu} C++ signals a syntax error on the attempt. The following
+example illustrates this problem with an @code{enum} type @code{alph}:
+
+@smallexample
+template <class T> class list @{
+ @dots{}
+ enum alph @{a,b,c@};
+ alph bar();
+ @dots{}
+@};
+
+template <class T>
+list<int>::alph list<int>::bar() // @i{Syntax error here}
+@{
+@dots{}
+@}
+@end smallexample
+
+@cindex preprocessor conditionals in templates
+@cindex conditionals (preprocessor) in templates
+@item
+A parsing bug makes it difficult to use preprocessor conditionals within
+templates. For example, in this code:
+
+@smallexample
+template <class T>
+class list @{
+ @dots{}
+#ifdef SYSWRONG
+ T x;
+#endif
+ @dots{}
+@}
+@end smallexample
+
+The preprocessor output leaves sourcefile line number information (lines
+like @samp{# 6 "foo.cc"} when it expands the @code{#ifdef} block. These
+lines confuse the compiler while parsing templates, giving a syntax
+error.
+
+If you cannot avoid preprocessor conditionals in templates, you can
+suppress the line number information using the @samp{-P} preprocessor
+option (but this will make debugging more difficult), by compiling the
+affected modules like this:
+
+@smallexample
+g++ -P foo.cc -o foo
+@end smallexample
+
+@cindex parsing errors, templates
+@item
+Parsing errors are reported when templates are first
+@emph{instantiated}---not on the template definition itself. In
+particular, if you do not instantiate a template definition at all, the
+compiler never reports any parsing errors that may be in the template
+definition.
+@end itemize
+
+@node Template debugging
+@section Debugging information for templates
+
+@cindex templates and debugging information
+@cindex debugging information and templates
+Debugging information for templates works for some object code formats,
+but not others. It works for stabs@footnote{Except that insufficient
+debugging information for methods of template classes is generated in
+stabs.} (used primarily in @sc{a.out} object code, but also in the Solaris 2
+version of @sc{elf}), and the @sc{mips} version of @sc{coff} debugging
+format.
+
+@sc{dwarf} support is currently minimal, and requires further
+development.
diff --git a/contrib/gcc/cp/tree.c b/contrib/gcc/cp/tree.c
new file mode 100644
index 0000000..7fb688e
--- /dev/null
+++ b/contrib/gcc/cp/tree.c
@@ -0,0 +1,1995 @@
+/* Language-dependent node constructors for parse phase of GNU compiler.
+ Copyright (C) 1987, 88, 92, 93, 94, 1995 Free Software Foundation, Inc.
+ Hacked by Michael Tiemann (tiemann@cygnus.com)
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+#include "config.h"
+#include <stdio.h>
+#include "obstack.h"
+#include "tree.h"
+#include "cp-tree.h"
+#include "flags.h"
+#include "rtl.h"
+
+#define CEIL(x,y) (((x) + (y) - 1) / (y))
+
+/* Return nonzero if REF is an lvalue valid for this language.
+ Lvalues can be assigned, unless they have TREE_READONLY.
+ Lvalues can have their address taken, unless they have DECL_REGISTER. */
+
+int
+real_lvalue_p (ref)
+ tree ref;
+{
+ if (! language_lvalue_valid (ref))
+ return 0;
+
+ if (TREE_CODE (TREE_TYPE (ref)) == REFERENCE_TYPE)
+ return 1;
+
+ if (ref == current_class_decl && flag_this_is_variable <= 0)
+ return 0;
+
+ switch (TREE_CODE (ref))
+ {
+ /* preincrements and predecrements are valid lvals, provided
+ what they refer to are valid lvals. */
+ case PREINCREMENT_EXPR:
+ case PREDECREMENT_EXPR:
+ case COMPONENT_REF:
+ case SAVE_EXPR:
+ return real_lvalue_p (TREE_OPERAND (ref, 0));
+
+ case STRING_CST:
+ return 1;
+
+ case VAR_DECL:
+ if (TREE_READONLY (ref) && ! TREE_STATIC (ref)
+ && DECL_LANG_SPECIFIC (ref)
+ && DECL_IN_AGGR_P (ref))
+ return 0;
+ case INDIRECT_REF:
+ case ARRAY_REF:
+ case PARM_DECL:
+ case RESULT_DECL:
+ case ERROR_MARK:
+ if (TREE_CODE (TREE_TYPE (ref)) != FUNCTION_TYPE
+ && TREE_CODE (TREE_TYPE (ref)) != METHOD_TYPE)
+ return 1;
+ break;
+
+ case WITH_CLEANUP_EXPR:
+ return real_lvalue_p (TREE_OPERAND (ref, 0));
+
+ /* A currently unresolved scope ref. */
+ case SCOPE_REF:
+ my_friendly_abort (103);
+ case OFFSET_REF:
+ if (TREE_CODE (TREE_OPERAND (ref, 1)) == FUNCTION_DECL)
+ return 1;
+ return real_lvalue_p (TREE_OPERAND (ref, 0))
+ && real_lvalue_p (TREE_OPERAND (ref, 1));
+ break;
+
+ case COND_EXPR:
+ return (real_lvalue_p (TREE_OPERAND (ref, 1))
+ && real_lvalue_p (TREE_OPERAND (ref, 2)));
+
+ case MODIFY_EXPR:
+ return 1;
+
+ case COMPOUND_EXPR:
+ return real_lvalue_p (TREE_OPERAND (ref, 1));
+
+ case MAX_EXPR:
+ case MIN_EXPR:
+ return (real_lvalue_p (TREE_OPERAND (ref, 0))
+ && real_lvalue_p (TREE_OPERAND (ref, 1)));
+ }
+
+ return 0;
+}
+
+int
+lvalue_p (ref)
+ tree ref;
+{
+ if (! language_lvalue_valid (ref))
+ return 0;
+
+ if (TREE_CODE (TREE_TYPE (ref)) == REFERENCE_TYPE)
+ return 1;
+
+ if (ref == current_class_decl && flag_this_is_variable <= 0)
+ return 0;
+
+ switch (TREE_CODE (ref))
+ {
+ /* preincrements and predecrements are valid lvals, provided
+ what they refer to are valid lvals. */
+ case PREINCREMENT_EXPR:
+ case PREDECREMENT_EXPR:
+ case COMPONENT_REF:
+ case SAVE_EXPR:
+ return lvalue_p (TREE_OPERAND (ref, 0));
+
+ case STRING_CST:
+ return 1;
+
+ case VAR_DECL:
+ if (TREE_READONLY (ref) && ! TREE_STATIC (ref)
+ && DECL_LANG_SPECIFIC (ref)
+ && DECL_IN_AGGR_P (ref))
+ return 0;
+ case INDIRECT_REF:
+ case ARRAY_REF:
+ case PARM_DECL:
+ case RESULT_DECL:
+ case ERROR_MARK:
+ if (TREE_CODE (TREE_TYPE (ref)) != FUNCTION_TYPE
+ && TREE_CODE (TREE_TYPE (ref)) != METHOD_TYPE)
+ return 1;
+ break;
+
+ case WITH_CLEANUP_EXPR:
+ return lvalue_p (TREE_OPERAND (ref, 0));
+
+ case TARGET_EXPR:
+ return 1;
+
+ case CALL_EXPR:
+ if (IS_AGGR_TYPE (TREE_TYPE (ref)))
+ return 1;
+ break;
+
+ /* A currently unresolved scope ref. */
+ case SCOPE_REF:
+ my_friendly_abort (103);
+ case OFFSET_REF:
+ if (TREE_CODE (TREE_OPERAND (ref, 1)) == FUNCTION_DECL)
+ return 1;
+ return lvalue_p (TREE_OPERAND (ref, 0))
+ && lvalue_p (TREE_OPERAND (ref, 1));
+ break;
+
+ case COND_EXPR:
+ return (lvalue_p (TREE_OPERAND (ref, 1))
+ && lvalue_p (TREE_OPERAND (ref, 2)));
+
+ case MODIFY_EXPR:
+ return 1;
+
+ case COMPOUND_EXPR:
+ return lvalue_p (TREE_OPERAND (ref, 1));
+
+ case MAX_EXPR:
+ case MIN_EXPR:
+ return (lvalue_p (TREE_OPERAND (ref, 0))
+ && lvalue_p (TREE_OPERAND (ref, 1)));
+ }
+
+ return 0;
+}
+
+/* Return nonzero if REF is an lvalue valid for this language;
+ otherwise, print an error message and return zero. */
+
+int
+lvalue_or_else (ref, string)
+ tree ref;
+ char *string;
+{
+ int win = lvalue_p (ref);
+ if (! win)
+ error ("non-lvalue in %s", string);
+ return win;
+}
+
+/* INIT is a CALL_EXPR which needs info about its target.
+ TYPE is the type that this initialization should appear to have.
+
+ Build an encapsulation of the initialization to perform
+ and return it so that it can be processed by language-independent
+ and language-specific expression expanders.
+
+ If WITH_CLEANUP_P is nonzero, we build a cleanup for this expression.
+ Otherwise, cleanups are not built here. For example, when building
+ an initialization for a stack slot, since the called function handles
+ the cleanup, we would not want to do it here. */
+tree
+build_cplus_new (type, init, with_cleanup_p)
+ tree type;
+ tree init;
+ int with_cleanup_p;
+{
+ tree slot;
+ tree rval;
+
+ slot = build (VAR_DECL, type);
+ layout_decl (slot, 0);
+ rval = build (NEW_EXPR, type,
+ TREE_OPERAND (init, 0), TREE_OPERAND (init, 1), slot);
+ TREE_SIDE_EFFECTS (rval) = 1;
+ TREE_ADDRESSABLE (rval) = 1;
+ rval = build (TARGET_EXPR, type, slot, rval, 0);
+ TREE_SIDE_EFFECTS (rval) = 1;
+ TREE_ADDRESSABLE (rval) = 1;
+
+#if 0
+ if (with_cleanup_p && TYPE_NEEDS_DESTRUCTOR (type))
+ {
+ TREE_OPERAND (rval, 2) = error_mark_node;
+ rval = build (WITH_CLEANUP_EXPR, type, rval, 0,
+ build_delete (build_pointer_type (type),
+ build_unary_op (ADDR_EXPR, slot, 0),
+ integer_two_node,
+ LOOKUP_NORMAL|LOOKUP_DESTRUCTOR, 0));
+ TREE_SIDE_EFFECTS (rval) = 1;
+ TREE_ADDRESSABLE (rval) = 1;
+ }
+#endif
+ return rval;
+}
+
+/* Recursively search EXP for CALL_EXPRs that need cleanups and replace
+ these CALL_EXPRs with tree nodes that will perform the cleanups. */
+
+tree
+break_out_cleanups (exp)
+ tree exp;
+{
+ tree tmp = exp;
+
+ if (TREE_CODE (tmp) == CALL_EXPR
+ && TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (tmp)))
+ return build_cplus_new (TREE_TYPE (tmp), tmp, 1);
+
+ while (TREE_CODE (tmp) == NOP_EXPR
+ || TREE_CODE (tmp) == CONVERT_EXPR
+ || TREE_CODE (tmp) == NON_LVALUE_EXPR)
+ {
+ if (TREE_CODE (TREE_OPERAND (tmp, 0)) == CALL_EXPR
+ && TYPE_NEEDS_DESTRUCTOR (TREE_TYPE (TREE_OPERAND (tmp, 0))))
+ {
+ TREE_OPERAND (tmp, 0)
+ = build_cplus_new (TREE_TYPE (TREE_OPERAND (tmp, 0)),
+ TREE_OPERAND (tmp, 0), 1);
+ break;
+ }
+ else
+ tmp = TREE_OPERAND (tmp, 0);
+ }
+ return exp;
+}
+
+/* Recursively perform a preorder search EXP for CALL_EXPRs, making
+ copies where they are found. Returns a deep copy all nodes transitively
+ containing CALL_EXPRs. */
+
+tree
+break_out_calls (exp)
+ tree exp;
+{
+ register tree t1, t2;
+ register enum tree_code code;
+ register int changed = 0;
+ register int i;
+
+ if (exp == NULL_TREE)
+ return exp;
+
+ code = TREE_CODE (exp);
+
+ if (code == CALL_EXPR)
+ return copy_node (exp);
+
+ /* Don't try and defeat a save_expr, as it should only be done once. */
+ if (code == SAVE_EXPR)
+ return exp;
+
+ switch (TREE_CODE_CLASS (code))
+ {
+ default:
+ abort ();
+
+ case 'c': /* a constant */
+ case 't': /* a type node */
+ case 'x': /* something random, like an identifier or an ERROR_MARK. */
+ return exp;
+
+ case 'd': /* A decl node */
+#if 0 /* This is bogus. jason 9/21/94 */
+
+ t1 = break_out_calls (DECL_INITIAL (exp));
+ if (t1 != DECL_INITIAL (exp))
+ {
+ exp = copy_node (exp);
+ DECL_INITIAL (exp) = t1;
+ }
+#endif
+ return exp;
+
+ case 'b': /* A block node */
+ {
+ /* Don't know how to handle these correctly yet. Must do a
+ break_out_calls on all DECL_INITIAL values for local variables,
+ and also break_out_calls on all sub-blocks and sub-statements. */
+ abort ();
+ }
+ return exp;
+
+ case 'e': /* an expression */
+ case 'r': /* a reference */
+ case 's': /* an expression with side effects */
+ for (i = tree_code_length[(int) code] - 1; i >= 0; i--)
+ {
+ t1 = break_out_calls (TREE_OPERAND (exp, i));
+ if (t1 != TREE_OPERAND (exp, i))
+ {
+ exp = copy_node (exp);
+ TREE_OPERAND (exp, i) = t1;
+ }
+ }
+ return exp;
+
+ case '<': /* a comparison expression */
+ case '2': /* a binary arithmetic expression */
+ t2 = break_out_calls (TREE_OPERAND (exp, 1));
+ if (t2 != TREE_OPERAND (exp, 1))
+ changed = 1;
+ case '1': /* a unary arithmetic expression */
+ t1 = break_out_calls (TREE_OPERAND (exp, 0));
+ if (t1 != TREE_OPERAND (exp, 0))
+ changed = 1;
+ if (changed)
+ {
+ if (tree_code_length[(int) code] == 1)
+ return build1 (code, TREE_TYPE (exp), t1);
+ else
+ return build (code, TREE_TYPE (exp), t1, t2);
+ }
+ return exp;
+ }
+
+}
+
+extern struct obstack *current_obstack;
+extern struct obstack permanent_obstack, class_obstack;
+extern struct obstack *saveable_obstack;
+
+/* Here is how primitive or already-canonicalized types' hash
+ codes are made. MUST BE CONSISTENT WITH tree.c !!! */
+#define TYPE_HASH(TYPE) ((HOST_WIDE_INT) (TYPE) & 0777777)
+
+/* Construct, lay out and return the type of methods belonging to class
+ BASETYPE and whose arguments are described by ARGTYPES and whose values
+ are described by RETTYPE. If each type exists already, reuse it. */
+tree
+build_cplus_method_type (basetype, rettype, argtypes)
+ tree basetype, rettype, argtypes;
+{
+ register tree t;
+ tree ptype;
+ int hashcode;
+
+ /* Make a node of the sort we want. */
+ t = make_node (METHOD_TYPE);
+
+ TYPE_METHOD_BASETYPE (t) = TYPE_MAIN_VARIANT (basetype);
+ TREE_TYPE (t) = rettype;
+ if (IS_SIGNATURE (basetype))
+ ptype = build_signature_pointer_type (TYPE_MAIN_VARIANT (basetype),
+ TYPE_READONLY (basetype),
+ TYPE_VOLATILE (basetype));
+ else
+ ptype = build_pointer_type (basetype);
+
+ /* The actual arglist for this function includes a "hidden" argument
+ which is "this". Put it into the list of argument types. */
+
+ argtypes = tree_cons (NULL_TREE, ptype, argtypes);
+ TYPE_ARG_TYPES (t) = argtypes;
+ TREE_SIDE_EFFECTS (argtypes) = 1; /* Mark first argtype as "artificial". */
+
+ /* If we already have such a type, use the old one and free this one.
+ Note that it also frees up the above cons cell if found. */
+ hashcode = TYPE_HASH (basetype) + TYPE_HASH (rettype) + type_hash_list (argtypes);
+ t = type_hash_canon (hashcode, t);
+
+ if (TYPE_SIZE (t) == 0)
+ layout_type (t);
+
+ return t;
+}
+
+tree
+build_cplus_staticfn_type (basetype, rettype, argtypes)
+ tree basetype, rettype, argtypes;
+{
+ register tree t;
+ int hashcode;
+
+ /* Make a node of the sort we want. */
+ t = make_node (FUNCTION_TYPE);
+
+ TYPE_METHOD_BASETYPE (t) = TYPE_MAIN_VARIANT (basetype);
+ TREE_TYPE (t) = rettype;
+
+ TYPE_ARG_TYPES (t) = argtypes;
+
+ /* If we already have such a type, use the old one and free this one.
+ Note that it also frees up the above cons cell if found. */
+ hashcode = TYPE_HASH (basetype) + TYPE_HASH (rettype) + type_hash_list (argtypes);
+ t = type_hash_canon (hashcode, t);
+
+ if (TYPE_SIZE (t) == 0)
+ layout_type (t);
+
+ return t;
+}
+
+tree
+build_cplus_array_type (elt_type, index_type)
+ tree elt_type;
+ tree index_type;
+{
+ register struct obstack *ambient_obstack = current_obstack;
+ register struct obstack *ambient_saveable_obstack = saveable_obstack;
+ tree t;
+
+ /* We need a new one. If both ELT_TYPE and INDEX_TYPE are permanent,
+ make this permanent too. */
+ if (TREE_PERMANENT (elt_type)
+ && (index_type == 0 || TREE_PERMANENT (index_type)))
+ {
+ current_obstack = &permanent_obstack;
+ saveable_obstack = &permanent_obstack;
+ }
+
+ t = build_array_type (elt_type, index_type);
+
+ /* Push these needs up so that initialization takes place
+ more easily. */
+ TYPE_NEEDS_CONSTRUCTING (t) = TYPE_NEEDS_CONSTRUCTING (TYPE_MAIN_VARIANT (elt_type));
+ TYPE_NEEDS_DESTRUCTOR (t) = TYPE_NEEDS_DESTRUCTOR (TYPE_MAIN_VARIANT (elt_type));
+ current_obstack = ambient_obstack;
+ saveable_obstack = ambient_saveable_obstack;
+ return t;
+}
+
+/* Make a variant type in the proper way for C/C++, propagating qualifiers
+ down to the element type of an array. */
+
+tree
+cp_build_type_variant (type, constp, volatilep)
+ tree type;
+ int constp, volatilep;
+{
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ {
+ tree real_main_variant = TYPE_MAIN_VARIANT (type);
+
+ push_obstacks (TYPE_OBSTACK (real_main_variant),
+ TYPE_OBSTACK (real_main_variant));
+ type = build_cplus_array_type (cp_build_type_variant (TREE_TYPE (type),
+ constp, volatilep),
+ TYPE_DOMAIN (type));
+
+ /* TYPE must be on same obstack as REAL_MAIN_VARIANT. If not,
+ make a copy. (TYPE might have come from the hash table and
+ REAL_MAIN_VARIANT might be in some function's obstack.) */
+
+ if (TYPE_OBSTACK (type) != TYPE_OBSTACK (real_main_variant))
+ {
+ type = copy_node (type);
+ TYPE_POINTER_TO (type) = TYPE_REFERENCE_TO (type) = 0;
+ }
+
+ TYPE_MAIN_VARIANT (type) = real_main_variant;
+ pop_obstacks ();
+ }
+ return build_type_variant (type, constp, volatilep);
+}
+
+/* Add OFFSET to all base types of T.
+
+ OFFSET, which is a type offset, is number of bytes.
+
+ Note that we don't have to worry about having two paths to the
+ same base type, since this type owns its association list. */
+void
+propagate_binfo_offsets (binfo, offset)
+ tree binfo;
+ tree offset;
+{
+ tree binfos = BINFO_BASETYPES (binfo);
+ int i, n_baselinks = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+
+ for (i = 0; i < n_baselinks; /* note increment is done in the loop. */)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+
+ if (TREE_VIA_VIRTUAL (base_binfo))
+ i += 1;
+ else
+ {
+ int j;
+ tree base_binfos = BINFO_BASETYPES (base_binfo);
+ tree delta;
+
+ for (j = i+1; j < n_baselinks; j++)
+ if (! TREE_VIA_VIRTUAL (TREE_VEC_ELT (binfos, j)))
+ {
+ /* The next basetype offset must take into account the space
+ between the classes, not just the size of each class. */
+ delta = size_binop (MINUS_EXPR,
+ BINFO_OFFSET (TREE_VEC_ELT (binfos, j)),
+ BINFO_OFFSET (base_binfo));
+ break;
+ }
+
+#if 0
+ if (BINFO_OFFSET_ZEROP (base_binfo))
+ BINFO_OFFSET (base_binfo) = offset;
+ else
+ BINFO_OFFSET (base_binfo)
+ = size_binop (PLUS_EXPR, BINFO_OFFSET (base_binfo), offset);
+#else
+ BINFO_OFFSET (base_binfo) = offset;
+#endif
+ if (base_binfos)
+ {
+ int k;
+ tree chain = NULL_TREE;
+
+ /* Now unshare the structure beneath BASE_BINFO. */
+ for (k = TREE_VEC_LENGTH (base_binfos)-1;
+ k >= 0; k--)
+ {
+ tree base_base_binfo = TREE_VEC_ELT (base_binfos, k);
+ if (! TREE_VIA_VIRTUAL (base_base_binfo))
+ TREE_VEC_ELT (base_binfos, k)
+ = make_binfo (BINFO_OFFSET (base_base_binfo),
+ base_base_binfo,
+ BINFO_VTABLE (base_base_binfo),
+ BINFO_VIRTUALS (base_base_binfo),
+ chain);
+ chain = TREE_VEC_ELT (base_binfos, k);
+ TREE_VIA_PUBLIC (chain) = TREE_VIA_PUBLIC (base_base_binfo);
+ TREE_VIA_PROTECTED (chain) = TREE_VIA_PROTECTED (base_base_binfo);
+ BINFO_INHERITANCE_CHAIN (chain) = base_binfo;
+ }
+ /* Now propagate the offset to the base types. */
+ propagate_binfo_offsets (base_binfo, offset);
+ }
+
+ /* Go to our next class that counts for offset propagation. */
+ i = j;
+ if (i < n_baselinks)
+ offset = size_binop (PLUS_EXPR, offset, delta);
+ }
+ }
+}
+
+/* Compute the actual offsets that our virtual base classes
+ will have *for this type*. This must be performed after
+ the fields are laid out, since virtual baseclasses must
+ lay down at the end of the record.
+
+ Returns the maximum number of virtual functions any of the virtual
+ baseclasses provide. */
+int
+layout_vbasetypes (rec, max)
+ tree rec;
+ int max;
+{
+ /* Get all the virtual base types that this type uses.
+ The TREE_VALUE slot holds the virtual baseclass type. */
+ tree vbase_types = get_vbase_types (rec);
+
+#ifdef STRUCTURE_SIZE_BOUNDARY
+ unsigned record_align = MAX (STRUCTURE_SIZE_BOUNDARY, TYPE_ALIGN (rec));
+#else
+ unsigned record_align = MAX (BITS_PER_UNIT, TYPE_ALIGN (rec));
+#endif
+ int desired_align;
+
+ /* Record size so far is CONST_SIZE + VAR_SIZE bits,
+ where CONST_SIZE is an integer
+ and VAR_SIZE is a tree expression.
+ If VAR_SIZE is null, the size is just CONST_SIZE.
+ Naturally we try to avoid using VAR_SIZE. */
+ register unsigned const_size = 0;
+ register tree var_size = 0;
+ int nonvirtual_const_size;
+ tree nonvirtual_var_size;
+
+ CLASSTYPE_VBASECLASSES (rec) = vbase_types;
+
+ if (TREE_CODE (TYPE_SIZE (rec)) == INTEGER_CST)
+ const_size = TREE_INT_CST_LOW (TYPE_SIZE (rec));
+ else
+ var_size = TYPE_SIZE (rec);
+
+ nonvirtual_const_size = const_size;
+ nonvirtual_var_size = var_size;
+
+ while (vbase_types)
+ {
+ tree basetype = BINFO_TYPE (vbase_types);
+ tree offset;
+
+ desired_align = TYPE_ALIGN (basetype);
+ record_align = MAX (record_align, desired_align);
+
+ if (const_size == 0)
+ offset = integer_zero_node;
+ else
+ {
+ /* Give each virtual base type the alignment it wants. */
+ const_size = CEIL (const_size, TYPE_ALIGN (basetype))
+ * TYPE_ALIGN (basetype);
+ offset = size_int (CEIL (const_size, BITS_PER_UNIT));
+ }
+
+ if (CLASSTYPE_VSIZE (basetype) > max)
+ max = CLASSTYPE_VSIZE (basetype);
+ BINFO_OFFSET (vbase_types) = offset;
+
+ if (TREE_CODE (TYPE_SIZE (basetype)) == INTEGER_CST)
+ {
+ /* Every virtual baseclass takes a least a UNIT, so that we can
+ take it's address and get something different for each base. */
+ const_size += MAX (BITS_PER_UNIT,
+ TREE_INT_CST_LOW (TYPE_SIZE (basetype))
+ - TREE_INT_CST_LOW (CLASSTYPE_VBASE_SIZE (basetype)));
+ }
+ else if (var_size == 0)
+ var_size = TYPE_SIZE (basetype);
+ else
+ var_size = size_binop (PLUS_EXPR, var_size, TYPE_SIZE (basetype));
+
+ vbase_types = TREE_CHAIN (vbase_types);
+ }
+
+ if (const_size)
+ {
+ /* Because a virtual base might take a single byte above,
+ we have to re-adjust the total size to make sure it it
+ a multiple of the alignment. */
+ /* Give the whole object the alignment it wants. */
+ const_size = CEIL (const_size, record_align) * record_align;
+ }
+
+ /* Set the alignment in the complete type. We don't set CLASSTYPE_ALIGN
+ here, as that is for this class, without any virtual base classes. */
+ TYPE_ALIGN (rec) = record_align;
+ if (const_size != nonvirtual_const_size)
+ {
+ CLASSTYPE_VBASE_SIZE (rec)
+ = size_int (const_size - nonvirtual_const_size);
+ TYPE_SIZE (rec) = size_int (const_size);
+ }
+
+ /* Now propagate offset information throughout the lattice
+ under the vbase type. */
+ for (vbase_types = CLASSTYPE_VBASECLASSES (rec); vbase_types;
+ vbase_types = TREE_CHAIN (vbase_types))
+ {
+ tree base_binfos = BINFO_BASETYPES (vbase_types);
+
+ BINFO_INHERITANCE_CHAIN (vbase_types) = TYPE_BINFO (rec);
+
+ if (base_binfos)
+ {
+ tree chain = NULL_TREE;
+ int j;
+ /* Now unshare the structure beneath BASE_BINFO. */
+
+ for (j = TREE_VEC_LENGTH (base_binfos)-1;
+ j >= 0; j--)
+ {
+ tree base_base_binfo = TREE_VEC_ELT (base_binfos, j);
+ if (! TREE_VIA_VIRTUAL (base_base_binfo))
+ TREE_VEC_ELT (base_binfos, j)
+ = make_binfo (BINFO_OFFSET (base_base_binfo),
+ base_base_binfo,
+ BINFO_VTABLE (base_base_binfo),
+ BINFO_VIRTUALS (base_base_binfo),
+ chain);
+ chain = TREE_VEC_ELT (base_binfos, j);
+ TREE_VIA_PUBLIC (chain) = TREE_VIA_PUBLIC (base_base_binfo);
+ TREE_VIA_PROTECTED (chain) = TREE_VIA_PROTECTED (base_base_binfo);
+ BINFO_INHERITANCE_CHAIN (chain) = vbase_types;
+ }
+
+ propagate_binfo_offsets (vbase_types, BINFO_OFFSET (vbase_types));
+ }
+ }
+
+ return max;
+}
+
+/* Lay out the base types of a record type, REC.
+ Tentatively set the size and alignment of REC
+ according to the base types alone.
+
+ Offsets for immediate nonvirtual baseclasses are also computed here.
+
+ TYPE_BINFO (REC) should be NULL_TREE on entry, and this routine
+ creates a list of base_binfos in TYPE_BINFO (REC) from BINFOS.
+
+ Returns list of virtual base classes in a FIELD_DECL chain. */
+tree
+layout_basetypes (rec, binfos)
+ tree rec, binfos;
+{
+ /* Chain to hold all the new FIELD_DECLs which point at virtual
+ base classes. */
+ tree vbase_decls = NULL_TREE;
+
+#ifdef STRUCTURE_SIZE_BOUNDARY
+ unsigned record_align = MAX (STRUCTURE_SIZE_BOUNDARY, TYPE_ALIGN (rec));
+#else
+ unsigned record_align = MAX (BITS_PER_UNIT, TYPE_ALIGN (rec));
+#endif
+
+ /* Record size so far is CONST_SIZE + VAR_SIZE bits, where CONST_SIZE is
+ an integer and VAR_SIZE is a tree expression. If VAR_SIZE is null,
+ the size is just CONST_SIZE. Naturally we try to avoid using
+ VAR_SIZE. And so far, we've been successful. */
+#if 0
+ register tree var_size = 0;
+#endif
+
+ register unsigned const_size = 0;
+ int i, n_baseclasses = binfos ? TREE_VEC_LENGTH (binfos) : 0;
+
+ /* Handle basetypes almost like fields, but record their
+ offsets differently. */
+
+ for (i = 0; i < n_baseclasses; i++)
+ {
+ int inc, desired_align, int_vbase_size;
+ register tree base_binfo = TREE_VEC_ELT (binfos, i);
+ register tree basetype = BINFO_TYPE (base_binfo);
+ tree decl, offset;
+
+ if (TYPE_SIZE (basetype) == 0)
+ {
+#if 0
+ /* This error is now reported in xref_tag, thus giving better
+ location information. */
+ error_with_aggr_type (base_binfo,
+ "base class `%s' has incomplete type");
+
+ TREE_VIA_PUBLIC (base_binfo) = 1;
+ TREE_VIA_PROTECTED (base_binfo) = 0;
+ TREE_VIA_VIRTUAL (base_binfo) = 0;
+
+ /* Should handle this better so that
+
+ class A;
+ class B: private A { virtual void F(); };
+
+ does not dump core when compiled. */
+ my_friendly_abort (121);
+#endif
+ continue;
+ }
+
+ /* All basetypes are recorded in the association list of the
+ derived type. */
+
+ if (TREE_VIA_VIRTUAL (base_binfo))
+ {
+ int j;
+ char *name = (char *)alloca (TYPE_NAME_LENGTH (basetype)
+ + sizeof (VBASE_NAME) + 1);
+
+ /* The offset for a virtual base class is only used in computing
+ virtual function tables and for initializing virtual base
+ pointers. It is built once `get_vbase_types' is called. */
+
+ /* If this basetype can come from another vbase pointer
+ without an additional indirection, we will share
+ that pointer. If an indirection is involved, we
+ make our own pointer. */
+ for (j = 0; j < n_baseclasses; j++)
+ {
+ tree other_base_binfo = TREE_VEC_ELT (binfos, j);
+ if (! TREE_VIA_VIRTUAL (other_base_binfo)
+ && binfo_member (basetype,
+ CLASSTYPE_VBASECLASSES (BINFO_TYPE (other_base_binfo))))
+ goto got_it;
+ }
+ sprintf (name, VBASE_NAME_FORMAT, TYPE_NAME_STRING (basetype));
+ decl = build_lang_decl (FIELD_DECL, get_identifier (name),
+ build_pointer_type (basetype));
+ /* If you change any of the below, take a look at all the
+ other VFIELD_BASEs and VTABLE_BASEs in the code, and change
+ them too. */
+ DECL_ASSEMBLER_NAME (decl) = get_identifier (VTABLE_BASE);
+ DECL_VIRTUAL_P (decl) = 1;
+ DECL_FIELD_CONTEXT (decl) = rec;
+ DECL_CLASS_CONTEXT (decl) = rec;
+ DECL_FCONTEXT (decl) = basetype;
+ DECL_SAVED_INSNS (decl) = NULL_RTX;
+ DECL_FIELD_SIZE (decl) = 0;
+ DECL_ALIGN (decl) = TYPE_ALIGN (ptr_type_node);
+ TREE_CHAIN (decl) = vbase_decls;
+ BINFO_VPTR_FIELD (base_binfo) = decl;
+ vbase_decls = decl;
+
+ if (warn_nonvdtor && TYPE_HAS_DESTRUCTOR (basetype)
+ && DECL_VINDEX (TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (basetype), 0)) == NULL_TREE)
+ {
+ warning_with_decl (TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (basetype), 0),
+ "destructor `%s' non-virtual");
+ warning ("in inheritance relationship `%s: virtual %s'",
+ TYPE_NAME_STRING (rec),
+ TYPE_NAME_STRING (basetype));
+ }
+ got_it:
+ /* The space this decl occupies has already been accounted for. */
+ continue;
+ }
+
+ if (const_size == 0)
+ offset = integer_zero_node;
+ else
+ {
+ /* Give each base type the alignment it wants. */
+ const_size = CEIL (const_size, TYPE_ALIGN (basetype))
+ * TYPE_ALIGN (basetype);
+ offset = size_int ((const_size + BITS_PER_UNIT - 1) / BITS_PER_UNIT);
+
+#if 0
+ /* bpk: Disabled this check until someone is willing to
+ claim it as theirs and explain exactly what circumstances
+ warrant the warning. */
+ if (warn_nonvdtor && TYPE_HAS_DESTRUCTOR (basetype)
+ && DECL_VINDEX (TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (basetype), 0)) == NULL_TREE)
+ {
+ warning_with_decl (TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (basetype), 0),
+ "destructor `%s' non-virtual");
+ warning ("in inheritance relationship `%s:%s %s'",
+ TYPE_NAME_STRING (rec),
+ TREE_VIA_VIRTUAL (base_binfo) ? " virtual" : "",
+ TYPE_NAME_STRING (basetype));
+ }
+#endif
+ }
+ BINFO_OFFSET (base_binfo) = offset;
+ if (CLASSTYPE_VSIZE (basetype))
+ {
+ BINFO_VTABLE (base_binfo) = TYPE_BINFO_VTABLE (basetype);
+ BINFO_VIRTUALS (base_binfo) = TYPE_BINFO_VIRTUALS (basetype);
+ }
+ TREE_CHAIN (base_binfo) = TYPE_BINFO (rec);
+ TYPE_BINFO (rec) = base_binfo;
+
+ /* Add only the amount of storage not present in
+ the virtual baseclasses. */
+
+ int_vbase_size = TREE_INT_CST_LOW (CLASSTYPE_VBASE_SIZE (basetype));
+ if (TREE_INT_CST_LOW (TYPE_SIZE (basetype)) > int_vbase_size)
+ {
+ inc = MAX (record_align,
+ (TREE_INT_CST_LOW (TYPE_SIZE (basetype))
+ - int_vbase_size));
+
+ /* Record must have at least as much alignment as any field. */
+ desired_align = TYPE_ALIGN (basetype);
+ record_align = MAX (record_align, desired_align);
+
+ const_size += inc;
+ }
+ }
+
+ if (const_size)
+ CLASSTYPE_SIZE (rec) = size_int (const_size);
+ else
+ CLASSTYPE_SIZE (rec) = integer_zero_node;
+ CLASSTYPE_ALIGN (rec) = record_align;
+
+ return vbase_decls;
+}
+
+/* Hashing of lists so that we don't make duplicates.
+ The entry point is `list_hash_canon'. */
+
+/* Each hash table slot is a bucket containing a chain
+ of these structures. */
+
+struct list_hash
+{
+ struct list_hash *next; /* Next structure in the bucket. */
+ int hashcode; /* Hash code of this list. */
+ tree list; /* The list recorded here. */
+};
+
+/* Now here is the hash table. When recording a list, it is added
+ to the slot whose index is the hash code mod the table size.
+ Note that the hash table is used for several kinds of lists.
+ While all these live in the same table, they are completely independent,
+ and the hash code is computed differently for each of these. */
+
+#define TYPE_HASH_SIZE 59
+struct list_hash *list_hash_table[TYPE_HASH_SIZE];
+
+/* Compute a hash code for a list (chain of TREE_LIST nodes
+ with goodies in the TREE_PURPOSE, TREE_VALUE, and bits of the
+ TREE_COMMON slots), by adding the hash codes of the individual entries. */
+
+int
+list_hash (list)
+ tree list;
+{
+ register int hashcode = 0;
+
+ if (TREE_CHAIN (list))
+ hashcode += TYPE_HASH (TREE_CHAIN (list));
+
+ if (TREE_VALUE (list))
+ hashcode += TYPE_HASH (TREE_VALUE (list));
+ else
+ hashcode += 1007;
+ if (TREE_PURPOSE (list))
+ hashcode += TYPE_HASH (TREE_PURPOSE (list));
+ else
+ hashcode += 1009;
+ return hashcode;
+}
+
+/* Look in the type hash table for a type isomorphic to TYPE.
+ If one is found, return it. Otherwise return 0. */
+
+tree
+list_hash_lookup (hashcode, list)
+ int hashcode;
+ tree list;
+{
+ register struct list_hash *h;
+ for (h = list_hash_table[hashcode % TYPE_HASH_SIZE]; h; h = h->next)
+ if (h->hashcode == hashcode
+ && TREE_VIA_VIRTUAL (h->list) == TREE_VIA_VIRTUAL (list)
+ && TREE_VIA_PUBLIC (h->list) == TREE_VIA_PUBLIC (list)
+ && TREE_VIA_PROTECTED (h->list) == TREE_VIA_PROTECTED (list)
+ && TREE_PURPOSE (h->list) == TREE_PURPOSE (list)
+ && TREE_VALUE (h->list) == TREE_VALUE (list)
+ && TREE_CHAIN (h->list) == TREE_CHAIN (list))
+ {
+ my_friendly_assert (TREE_TYPE (h->list) == TREE_TYPE (list), 299);
+ return h->list;
+ }
+ return 0;
+}
+
+/* Add an entry to the list-hash-table
+ for a list TYPE whose hash code is HASHCODE. */
+
+void
+list_hash_add (hashcode, list)
+ int hashcode;
+ tree list;
+{
+ register struct list_hash *h;
+
+ h = (struct list_hash *) obstack_alloc (&class_obstack, sizeof (struct list_hash));
+ h->hashcode = hashcode;
+ h->list = list;
+ h->next = list_hash_table[hashcode % TYPE_HASH_SIZE];
+ list_hash_table[hashcode % TYPE_HASH_SIZE] = h;
+}
+
+/* Given TYPE, and HASHCODE its hash code, return the canonical
+ object for an identical list if one already exists.
+ Otherwise, return TYPE, and record it as the canonical object
+ if it is a permanent object.
+
+ To use this function, first create a list of the sort you want.
+ Then compute its hash code from the fields of the list that
+ make it different from other similar lists.
+ Then call this function and use the value.
+ This function frees the list you pass in if it is a duplicate. */
+
+/* Set to 1 to debug without canonicalization. Never set by program. */
+static int debug_no_list_hash = 0;
+
+tree
+list_hash_canon (hashcode, list)
+ int hashcode;
+ tree list;
+{
+ tree t1;
+
+ if (debug_no_list_hash)
+ return list;
+
+ t1 = list_hash_lookup (hashcode, list);
+ if (t1 != 0)
+ {
+ obstack_free (&class_obstack, list);
+ return t1;
+ }
+
+ /* If this is a new list, record it for later reuse. */
+ list_hash_add (hashcode, list);
+
+ return list;
+}
+
+tree
+hash_tree_cons (via_public, via_virtual, via_protected, purpose, value, chain)
+ int via_public, via_virtual, via_protected;
+ tree purpose, value, chain;
+{
+ struct obstack *ambient_obstack = current_obstack;
+ tree t;
+ int hashcode;
+
+ current_obstack = &class_obstack;
+ t = tree_cons (purpose, value, chain);
+ TREE_VIA_PUBLIC (t) = via_public;
+ TREE_VIA_PROTECTED (t) = via_protected;
+ TREE_VIA_VIRTUAL (t) = via_virtual;
+ hashcode = list_hash (t);
+ t = list_hash_canon (hashcode, t);
+ current_obstack = ambient_obstack;
+ return t;
+}
+
+/* Constructor for hashed lists. */
+tree
+hash_tree_chain (value, chain)
+ tree value, chain;
+{
+ struct obstack *ambient_obstack = current_obstack;
+ tree t;
+ int hashcode;
+
+ current_obstack = &class_obstack;
+ t = tree_cons (NULL_TREE, value, chain);
+ hashcode = list_hash (t);
+ t = list_hash_canon (hashcode, t);
+ current_obstack = ambient_obstack;
+ return t;
+}
+
+/* Similar, but used for concatenating two lists. */
+tree
+hash_chainon (list1, list2)
+ tree list1, list2;
+{
+ if (list2 == 0)
+ return list1;
+ if (list1 == 0)
+ return list2;
+ if (TREE_CHAIN (list1) == NULL_TREE)
+ return hash_tree_chain (TREE_VALUE (list1), list2);
+ return hash_tree_chain (TREE_VALUE (list1),
+ hash_chainon (TREE_CHAIN (list1), list2));
+}
+
+static tree
+get_identifier_list (value)
+ tree value;
+{
+ tree list = IDENTIFIER_AS_LIST (value);
+ if (list != NULL_TREE
+ && (TREE_CODE (list) != TREE_LIST
+ || TREE_VALUE (list) != value))
+ list = NULL_TREE;
+ else if (IDENTIFIER_HAS_TYPE_VALUE (value)
+ && TREE_CODE (IDENTIFIER_TYPE_VALUE (value)) == RECORD_TYPE
+ && IDENTIFIER_TYPE_VALUE (value)
+ == TYPE_MAIN_VARIANT (IDENTIFIER_TYPE_VALUE (value)))
+ {
+ tree type = IDENTIFIER_TYPE_VALUE (value);
+
+ if (TYPE_PTRMEMFUNC_P (type))
+ list = NULL_TREE;
+ else if (type == current_class_type)
+ /* Don't mess up the constructor name. */
+ list = tree_cons (NULL_TREE, value, NULL_TREE);
+ else
+ {
+ register tree id;
+ /* This will return the correct thing for regular types,
+ nested types, and templates. Yay! */
+ if (TYPE_NESTED_NAME (type))
+ id = TYPE_NESTED_NAME (type);
+ else
+ id = TYPE_IDENTIFIER (type);
+
+ if (CLASSTYPE_ID_AS_LIST (type) == NULL_TREE)
+ CLASSTYPE_ID_AS_LIST (type)
+ = perm_tree_cons (NULL_TREE, id, NULL_TREE);
+ list = CLASSTYPE_ID_AS_LIST (type);
+ }
+ }
+ return list;
+}
+
+tree
+get_decl_list (value)
+ tree value;
+{
+ tree list = NULL_TREE;
+
+ if (TREE_CODE (value) == IDENTIFIER_NODE)
+ list = get_identifier_list (value);
+ else if (TREE_CODE (value) == RECORD_TYPE
+ && TYPE_LANG_SPECIFIC (value))
+ list = CLASSTYPE_AS_LIST (value);
+
+ if (list != NULL_TREE)
+ {
+ my_friendly_assert (TREE_CHAIN (list) == NULL_TREE, 301);
+ return list;
+ }
+
+ return build_decl_list (NULL_TREE, value);
+}
+
+/* Look in the type hash table for a type isomorphic to
+ `build_tree_list (NULL_TREE, VALUE)'.
+ If one is found, return it. Otherwise return 0. */
+
+tree
+list_hash_lookup_or_cons (value)
+ tree value;
+{
+ register int hashcode = TYPE_HASH (value);
+ register struct list_hash *h;
+ struct obstack *ambient_obstack;
+ tree list = NULL_TREE;
+
+ if (TREE_CODE (value) == IDENTIFIER_NODE)
+ list = get_identifier_list (value);
+ else if (TREE_CODE (value) == TYPE_DECL
+ && TREE_CODE (TREE_TYPE (value)) == RECORD_TYPE
+ && TYPE_LANG_SPECIFIC (TREE_TYPE (value)))
+ list = CLASSTYPE_ID_AS_LIST (TREE_TYPE (value));
+ else if (TREE_CODE (value) == RECORD_TYPE
+ && TYPE_LANG_SPECIFIC (value))
+ list = CLASSTYPE_AS_LIST (value);
+
+ if (list != NULL_TREE)
+ {
+ my_friendly_assert (TREE_CHAIN (list) == NULL_TREE, 302);
+ return list;
+ }
+
+ if (debug_no_list_hash)
+ return hash_tree_chain (value, NULL_TREE);
+
+ for (h = list_hash_table[hashcode % TYPE_HASH_SIZE]; h; h = h->next)
+ if (h->hashcode == hashcode
+ && TREE_VIA_VIRTUAL (h->list) == 0
+ && TREE_VIA_PUBLIC (h->list) == 0
+ && TREE_VIA_PROTECTED (h->list) == 0
+ && TREE_PURPOSE (h->list) == 0
+ && TREE_VALUE (h->list) == value)
+ {
+ my_friendly_assert (TREE_TYPE (h->list) == 0, 303);
+ my_friendly_assert (TREE_CHAIN (h->list) == 0, 304);
+ return h->list;
+ }
+
+ ambient_obstack = current_obstack;
+ current_obstack = &class_obstack;
+ list = build_tree_list (NULL_TREE, value);
+ list_hash_add (hashcode, list);
+ current_obstack = ambient_obstack;
+ return list;
+}
+
+/* Build an association between TYPE and some parameters:
+
+ OFFSET is the offset added to `this' to convert it to a pointer
+ of type `TYPE *'
+
+ BINFO is the base binfo to use, if we are deriving from one. This
+ is necessary, as we want specialized parent binfos from base
+ classes, so that the VTABLE_NAMEs of bases are for the most derived
+ type, instead of of the simple type.
+
+ VTABLE is the virtual function table with which to initialize
+ sub-objects of type TYPE.
+
+ VIRTUALS are the virtual functions sitting in VTABLE.
+
+ CHAIN are more associations we must retain. */
+
+tree
+make_binfo (offset, binfo, vtable, virtuals, chain)
+ tree offset, binfo;
+ tree vtable, virtuals;
+ tree chain;
+{
+ tree new_binfo = make_tree_vec (6);
+ tree type;
+
+ if (TREE_CODE (binfo) == TREE_VEC)
+ type = BINFO_TYPE (binfo);
+ else
+ {
+ type = binfo;
+ binfo = TYPE_BINFO (binfo);
+ }
+
+ TREE_CHAIN (new_binfo) = chain;
+ if (chain)
+ TREE_USED (new_binfo) = TREE_USED (chain);
+
+ TREE_TYPE (new_binfo) = TYPE_MAIN_VARIANT (type);
+ BINFO_OFFSET (new_binfo) = offset;
+ BINFO_VTABLE (new_binfo) = vtable;
+ BINFO_VIRTUALS (new_binfo) = virtuals;
+ BINFO_VPTR_FIELD (new_binfo) = NULL_TREE;
+
+ if (binfo && BINFO_BASETYPES (binfo) != NULL_TREE)
+ BINFO_BASETYPES (new_binfo) = copy_node (BINFO_BASETYPES (binfo));
+ return new_binfo;
+}
+
+/* Return the binfo value for ELEM in TYPE. */
+
+tree
+binfo_value (elem, type)
+ tree elem;
+ tree type;
+{
+ if (get_base_distance (elem, type, 0, (tree *)0) == -2)
+ compiler_error ("base class `%s' ambiguous in binfo_value",
+ TYPE_NAME_STRING (elem));
+ if (elem == type)
+ return TYPE_BINFO (type);
+ if (TREE_CODE (elem) == RECORD_TYPE && TYPE_BINFO (elem) == type)
+ return type;
+ return get_binfo (elem, type, 0);
+}
+
+tree
+reverse_path (path)
+ tree path;
+{
+ register tree prev = 0, tmp, next;
+ for (tmp = path; tmp; tmp = next)
+ {
+ next = BINFO_INHERITANCE_CHAIN (tmp);
+ BINFO_INHERITANCE_CHAIN (tmp) = prev;
+ prev = tmp;
+ }
+ return prev;
+}
+
+tree
+virtual_member (elem, list)
+ tree elem;
+ tree list;
+{
+ tree t;
+ tree rval, nval;
+
+ for (t = list; t; t = TREE_CHAIN (t))
+ if (elem == BINFO_TYPE (t))
+ return t;
+ rval = 0;
+ for (t = list; t; t = TREE_CHAIN (t))
+ {
+ tree binfos = BINFO_BASETYPES (t);
+ int i;
+
+ if (binfos != NULL_TREE)
+ for (i = TREE_VEC_LENGTH (binfos)-1; i >= 0; i--)
+ {
+ nval = binfo_value (elem, BINFO_TYPE (TREE_VEC_ELT (binfos, i)));
+ if (nval)
+ {
+ if (rval && BINFO_OFFSET (nval) != BINFO_OFFSET (rval))
+ my_friendly_abort (104);
+ rval = nval;
+ }
+ }
+ }
+ return rval;
+}
+
+void
+debug_binfo (elem)
+ tree elem;
+{
+ unsigned HOST_WIDE_INT n;
+ tree virtuals;
+
+ fprintf (stderr, "type \"%s\"; offset = %d\n",
+ TYPE_NAME_STRING (BINFO_TYPE (elem)),
+ TREE_INT_CST_LOW (BINFO_OFFSET (elem)));
+ fprintf (stderr, "vtable type:\n");
+ debug_tree (BINFO_TYPE (elem));
+ if (BINFO_VTABLE (elem))
+ fprintf (stderr, "vtable decl \"%s\"\n", IDENTIFIER_POINTER (DECL_NAME (BINFO_VTABLE (elem))));
+ else
+ fprintf (stderr, "no vtable decl yet\n");
+ fprintf (stderr, "virtuals:\n");
+ virtuals = BINFO_VIRTUALS (elem);
+
+ n = skip_rtti_stuff (&virtuals);
+
+ while (virtuals)
+ {
+ tree fndecl = TREE_OPERAND (FNADDR_FROM_VTABLE_ENTRY (TREE_VALUE (virtuals)), 0);
+ fprintf (stderr, "%s [%d =? %d]\n",
+ IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl)),
+ n, TREE_INT_CST_LOW (DECL_VINDEX (fndecl)));
+ ++n;
+ virtuals = TREE_CHAIN (virtuals);
+ }
+}
+
+/* Return the length of a chain of nodes chained through DECL_CHAIN.
+ We expect a null pointer to mark the end of the chain.
+ This is the Lisp primitive `length'. */
+
+int
+decl_list_length (t)
+ tree t;
+{
+ register tree tail;
+ register int len = 0;
+
+ my_friendly_assert (TREE_CODE (t) == FUNCTION_DECL
+ || TREE_CODE (t) == TEMPLATE_DECL, 300);
+ for (tail = t; tail; tail = DECL_CHAIN (tail))
+ len++;
+
+ return len;
+}
+
+int
+count_functions (t)
+ tree t;
+{
+ if (TREE_CODE (t) == FUNCTION_DECL)
+ return 1;
+ else if (TREE_CODE (t) == TREE_LIST)
+ return decl_list_length (TREE_VALUE (t));
+
+ my_friendly_abort (359);
+ return 0;
+}
+
+/* Like value_member, but for DECL_CHAINs. */
+tree
+decl_value_member (elem, list)
+ tree elem, list;
+{
+ while (list)
+ {
+ if (elem == list)
+ return list;
+ list = DECL_CHAIN (list);
+ }
+ return NULL_TREE;
+}
+
+int
+is_overloaded_fn (x)
+ tree x;
+{
+ if (TREE_CODE (x) == FUNCTION_DECL)
+ return 1;
+
+ if (TREE_CODE (x) == TREE_LIST
+ && (TREE_CODE (TREE_VALUE (x)) == FUNCTION_DECL
+ || TREE_CODE (TREE_VALUE (x)) == TEMPLATE_DECL))
+ return 1;
+
+ return 0;
+}
+
+int
+really_overloaded_fn (x)
+ tree x;
+{
+ if (TREE_CODE (x) == TREE_LIST
+ && (TREE_CODE (TREE_VALUE (x)) == FUNCTION_DECL
+ || TREE_CODE (TREE_VALUE (x)) == TEMPLATE_DECL))
+ return 1;
+
+ return 0;
+}
+
+tree
+get_first_fn (from)
+ tree from;
+{
+ if (TREE_CODE (from) == FUNCTION_DECL)
+ return from;
+
+ my_friendly_assert (TREE_CODE (from) == TREE_LIST, 9);
+
+ return TREE_VALUE (from);
+}
+
+tree
+fnaddr_from_vtable_entry (entry)
+ tree entry;
+{
+ if (flag_vtable_thunks)
+ {
+ tree func = entry;
+ if (TREE_CODE (func) == ADDR_EXPR)
+ func = TREE_OPERAND (func, 0);
+ if (TREE_CODE (func) == THUNK_DECL)
+ return DECL_INITIAL (func);
+ else
+ return entry;
+ }
+ else
+ return TREE_VALUE (TREE_CHAIN (TREE_CHAIN (CONSTRUCTOR_ELTS (entry))));
+}
+
+void
+set_fnaddr_from_vtable_entry (entry, value)
+ tree entry, value;
+{
+ if (flag_vtable_thunks)
+ abort ();
+ else
+ TREE_VALUE (TREE_CHAIN (TREE_CHAIN (CONSTRUCTOR_ELTS (entry)))) = value;
+}
+
+tree
+function_arg_chain (t)
+ tree t;
+{
+ return TREE_CHAIN (TYPE_ARG_TYPES (TREE_TYPE (t)));
+}
+
+int
+promotes_to_aggr_type (t, code)
+ tree t;
+ enum tree_code code;
+{
+ if (TREE_CODE (t) == code)
+ t = TREE_TYPE (t);
+ return IS_AGGR_TYPE (t);
+}
+
+int
+is_aggr_type_2 (t1, t2)
+ tree t1, t2;
+{
+ if (TREE_CODE (t1) != TREE_CODE (t2))
+ return 0;
+ return IS_AGGR_TYPE (t1) && IS_AGGR_TYPE (t2);
+}
+
+/* Give message using types TYPE1 and TYPE2 as arguments.
+ PFN is the function which will print the message;
+ S is the format string for PFN to use. */
+void
+message_2_types (pfn, s, type1, type2)
+ void (*pfn) ();
+ char *s;
+ tree type1, type2;
+{
+ tree name1 = TYPE_NAME (type1);
+ tree name2 = TYPE_NAME (type2);
+ if (TREE_CODE (name1) == TYPE_DECL)
+ name1 = DECL_NAME (name1);
+ if (TREE_CODE (name2) == TYPE_DECL)
+ name2 = DECL_NAME (name2);
+ (*pfn) (s, IDENTIFIER_POINTER (name1), IDENTIFIER_POINTER (name2));
+}
+
+#define PRINT_RING_SIZE 4
+
+char *
+lang_printable_name (decl)
+ tree decl;
+{
+ static tree decl_ring[PRINT_RING_SIZE];
+ static char *print_ring[PRINT_RING_SIZE];
+ static int ring_counter;
+ int i;
+
+ /* Only cache functions. */
+ if (TREE_CODE (decl) != FUNCTION_DECL
+ || DECL_LANG_SPECIFIC (decl) == 0)
+ return decl_as_string (decl, 1);
+
+ /* See if this print name is lying around. */
+ for (i = 0; i < PRINT_RING_SIZE; i++)
+ if (decl_ring[i] == decl)
+ /* yes, so return it. */
+ return print_ring[i];
+
+ if (++ring_counter == PRINT_RING_SIZE)
+ ring_counter = 0;
+
+ if (current_function_decl != NULL_TREE)
+ {
+ if (decl_ring[ring_counter] == current_function_decl)
+ ring_counter += 1;
+ if (ring_counter == PRINT_RING_SIZE)
+ ring_counter = 0;
+ if (decl_ring[ring_counter] == current_function_decl)
+ my_friendly_abort (106);
+ }
+
+ if (print_ring[ring_counter])
+ free (print_ring[ring_counter]);
+
+ {
+ int print_ret_type_p
+ = (!DECL_CONSTRUCTOR_P (decl)
+ && !DESTRUCTOR_NAME_P (DECL_ASSEMBLER_NAME (decl)));
+
+ char *name = (char *)decl_as_string (decl, print_ret_type_p);
+ print_ring[ring_counter] = (char *)malloc (strlen (name) + 1);
+ strcpy (print_ring[ring_counter], name);
+ decl_ring[ring_counter] = decl;
+ }
+ return print_ring[ring_counter];
+}
+
+/* Comparison function for sorting identifiers in RAISES lists.
+ Note that because IDENTIFIER_NODEs are unique, we can sort
+ them by address, saving an indirection. */
+static int
+id_cmp (p1, p2)
+ tree *p1, *p2;
+{
+ return (HOST_WIDE_INT)TREE_VALUE (*p1) - (HOST_WIDE_INT)TREE_VALUE (*p2);
+}
+
+/* Build the FUNCTION_TYPE or METHOD_TYPE which may throw exceptions
+ listed in RAISES. */
+tree
+build_exception_variant (type, raises)
+ tree type;
+ tree raises;
+{
+ int i;
+ tree v = TYPE_MAIN_VARIANT (type);
+ tree t, t2, cname;
+ tree *a = (tree *)alloca ((list_length (raises)+1) * sizeof (tree));
+ int constp = TYPE_READONLY (type);
+ int volatilep = TYPE_VOLATILE (type);
+
+ for (v = TYPE_NEXT_VARIANT (v); v; v = TYPE_NEXT_VARIANT (v))
+ {
+ if (TYPE_READONLY (v) != constp
+ || TYPE_VOLATILE (v) != volatilep)
+ continue;
+
+ /* @@ This should do set equality, not exact match. */
+ if (simple_cst_list_equal (TYPE_RAISES_EXCEPTIONS (v), raises))
+ /* List of exceptions raised matches previously found list.
+
+ @@ Nice to free up storage used in consing up the
+ @@ list of exceptions raised. */
+ return v;
+ }
+
+ /* Need to build a new variant. */
+ v = copy_node (type);
+ TYPE_NEXT_VARIANT (v) = TYPE_NEXT_VARIANT (type);
+ TYPE_NEXT_VARIANT (type) = v;
+ if (raises && ! TREE_PERMANENT (raises))
+ {
+ push_obstacks_nochange ();
+ end_temporary_allocation ();
+ raises = copy_list (raises);
+ pop_obstacks ();
+ }
+ TYPE_RAISES_EXCEPTIONS (v) = raises;
+ return v;
+}
+
+/* Subroutine of copy_to_permanent
+
+ Assuming T is a node build bottom-up, make it all exist on
+ permanent obstack, if it is not permanent already. */
+
+tree
+mapcar (t, func)
+ tree t;
+ tree (*func)();
+{
+ enum tree_code code;
+ tree tmp;
+
+ if (t == NULL_TREE)
+ return t;
+
+ if (tmp = func (t), tmp != NULL_TREE)
+ return tmp;
+
+ switch (code = TREE_CODE (t))
+ {
+ case ERROR_MARK:
+ return error_mark_node;
+
+ case VAR_DECL:
+ case FUNCTION_DECL:
+ case CONST_DECL:
+ break;
+
+ case PARM_DECL:
+ {
+ tree chain = TREE_CHAIN (t);
+ t = copy_node (t);
+ TREE_CHAIN (t) = mapcar (chain, func);
+ TREE_TYPE (t) = mapcar (TREE_TYPE (t), func);
+ DECL_INITIAL (t) = mapcar (DECL_INITIAL (t), func);
+ DECL_SIZE (t) = mapcar (DECL_SIZE (t), func);
+ return t;
+ }
+
+ case TREE_LIST:
+ {
+ tree chain = TREE_CHAIN (t);
+ t = copy_node (t);
+ TREE_PURPOSE (t) = mapcar (TREE_PURPOSE (t), func);
+ TREE_VALUE (t) = mapcar (TREE_VALUE (t), func);
+ TREE_CHAIN (t) = mapcar (chain, func);
+ return t;
+ }
+
+ case TREE_VEC:
+ {
+ int len = TREE_VEC_LENGTH (t);
+
+ t = copy_node (t);
+ while (len--)
+ TREE_VEC_ELT (t, len) = mapcar (TREE_VEC_ELT (t, len), func);
+ return t;
+ }
+
+ case INTEGER_CST:
+ case REAL_CST:
+ case STRING_CST:
+ return copy_node (t);
+
+ case COND_EXPR:
+ case TARGET_EXPR:
+ case NEW_EXPR:
+ t = copy_node (t);
+ TREE_OPERAND (t, 0) = mapcar (TREE_OPERAND (t, 0), func);
+ TREE_OPERAND (t, 1) = mapcar (TREE_OPERAND (t, 1), func);
+ TREE_OPERAND (t, 2) = mapcar (TREE_OPERAND (t, 2), func);
+ return t;
+
+ case SAVE_EXPR:
+ t = copy_node (t);
+ TREE_OPERAND (t, 0) = mapcar (TREE_OPERAND (t, 0), func);
+ return t;
+
+ case MODIFY_EXPR:
+ case PLUS_EXPR:
+ case MINUS_EXPR:
+ case MULT_EXPR:
+ case TRUNC_DIV_EXPR:
+ case TRUNC_MOD_EXPR:
+ case MIN_EXPR:
+ case MAX_EXPR:
+ case LSHIFT_EXPR:
+ case RSHIFT_EXPR:
+ case BIT_IOR_EXPR:
+ case BIT_XOR_EXPR:
+ case BIT_AND_EXPR:
+ case BIT_ANDTC_EXPR:
+ case TRUTH_ANDIF_EXPR:
+ case TRUTH_ORIF_EXPR:
+ case LT_EXPR:
+ case LE_EXPR:
+ case GT_EXPR:
+ case GE_EXPR:
+ case EQ_EXPR:
+ case NE_EXPR:
+ case CEIL_DIV_EXPR:
+ case FLOOR_DIV_EXPR:
+ case ROUND_DIV_EXPR:
+ case CEIL_MOD_EXPR:
+ case FLOOR_MOD_EXPR:
+ case ROUND_MOD_EXPR:
+ case COMPOUND_EXPR:
+ case PREDECREMENT_EXPR:
+ case PREINCREMENT_EXPR:
+ case POSTDECREMENT_EXPR:
+ case POSTINCREMENT_EXPR:
+ case CALL_EXPR:
+ t = copy_node (t);
+ TREE_OPERAND (t, 0) = mapcar (TREE_OPERAND (t, 0), func);
+ TREE_OPERAND (t, 1) = mapcar (TREE_OPERAND (t, 1), func);
+ return t;
+
+ case CONVERT_EXPR:
+ case ADDR_EXPR:
+ case INDIRECT_REF:
+ case NEGATE_EXPR:
+ case BIT_NOT_EXPR:
+ case TRUTH_NOT_EXPR:
+ case NOP_EXPR:
+ case COMPONENT_REF:
+ t = copy_node (t);
+ TREE_OPERAND (t, 0) = mapcar (TREE_OPERAND (t, 0), func);
+ return t;
+
+ case POINTER_TYPE:
+ return build_pointer_type (mapcar (TREE_TYPE (t), func));
+ case REFERENCE_TYPE:
+ return build_reference_type (mapcar (TREE_TYPE (t), func));
+ case FUNCTION_TYPE:
+ return build_function_type (mapcar (TREE_TYPE (t), func),
+ mapcar (TYPE_ARG_TYPES (t), func));
+ case ARRAY_TYPE:
+ return build_array_type (mapcar (TREE_TYPE (t), func),
+ mapcar (TYPE_DOMAIN (t), func));
+ case INTEGER_TYPE:
+ return build_index_type (mapcar (TYPE_MAX_VALUE (t), func));
+
+ case OFFSET_TYPE:
+ return build_offset_type (mapcar (TYPE_OFFSET_BASETYPE (t), func),
+ mapcar (TREE_TYPE (t), func));
+ case METHOD_TYPE:
+ return build_method_type
+ (mapcar (TYPE_METHOD_BASETYPE (t), func),
+ build_function_type
+ (mapcar (TREE_TYPE (t), func),
+ mapcar (TREE_CHAIN (TYPE_ARG_TYPES (t)), func)));
+
+ case RECORD_TYPE:
+ if (TYPE_PTRMEMFUNC_P (t))
+ return build_ptrmemfunc_type
+ (mapcar (TYPE_PTRMEMFUNC_FN_TYPE (t), func));
+ /* else fall through */
+
+ /* This list is incomplete, but should suffice for now.
+ It is very important that `sorry' does not call
+ `report_error_function'. That could cause an infinite loop. */
+ default:
+ sorry ("initializer contains unrecognized tree code");
+ return error_mark_node;
+
+ }
+ my_friendly_abort (107);
+ /* NOTREACHED */
+ return NULL_TREE;
+}
+
+static tree
+perm_manip (t)
+ tree t;
+{
+ if (TREE_PERMANENT (t))
+ return t;
+ return NULL_TREE;
+}
+
+/* Assuming T is a node built bottom-up, make it all exist on
+ permanent obstack, if it is not permanent already. */
+tree
+copy_to_permanent (t)
+ tree t;
+{
+ register struct obstack *ambient_obstack = current_obstack;
+ register struct obstack *ambient_saveable_obstack = saveable_obstack;
+ int resume;
+
+ if (t == NULL_TREE || TREE_PERMANENT (t))
+ return t;
+
+ saveable_obstack = &permanent_obstack;
+ current_obstack = saveable_obstack;
+ resume = suspend_momentary ();
+
+ t = mapcar (t, perm_manip);
+
+ resume_momentary (resume);
+ current_obstack = ambient_obstack;
+ saveable_obstack = ambient_saveable_obstack;
+
+ return t;
+}
+
+void
+print_lang_statistics ()
+{
+ extern struct obstack maybepermanent_obstack;
+ print_obstack_statistics ("class_obstack", &class_obstack);
+ print_obstack_statistics ("permanent_obstack", &permanent_obstack);
+ print_obstack_statistics ("maybepermanent_obstack", &maybepermanent_obstack);
+ print_search_statistics ();
+ print_class_statistics ();
+}
+
+/* This is used by the `assert' macro. It is provided in libgcc.a,
+ which `cc' doesn't know how to link. Note that the C++ front-end
+ no longer actually uses the `assert' macro (instead, it calls
+ my_friendly_assert). But all of the back-end files still need this. */
+void
+__eprintf (string, expression, line, filename)
+#ifdef __STDC__
+ const char *string;
+ const char *expression;
+ unsigned line;
+ const char *filename;
+#else
+ char *string;
+ char *expression;
+ unsigned line;
+ char *filename;
+#endif
+{
+ fprintf (stderr, string, expression, line, filename);
+ fflush (stderr);
+ abort ();
+}
+
+/* Return, as an INTEGER_CST node, the number of elements for
+ TYPE (which is an ARRAY_TYPE). This counts only elements of the top array. */
+
+tree
+array_type_nelts_top (type)
+ tree type;
+{
+ return fold (build (PLUS_EXPR, sizetype,
+ array_type_nelts (type),
+ integer_one_node));
+}
+
+/* Return, as an INTEGER_CST node, the number of elements for
+ TYPE (which is an ARRAY_TYPE). This one is a recursive count of all
+ ARRAY_TYPEs that are clumped together. */
+
+tree
+array_type_nelts_total (type)
+ tree type;
+{
+ tree sz = array_type_nelts_top (type);
+ type = TREE_TYPE (type);
+ while (TREE_CODE (type) == ARRAY_TYPE)
+ {
+ tree n = array_type_nelts_top (type);
+ sz = fold (build (MULT_EXPR, sizetype, sz, n));
+ type = TREE_TYPE (type);
+ }
+ return sz;
+}
+
+static
+tree
+bot_manip (t)
+ tree t;
+{
+ if (TREE_CODE (t) != TREE_LIST && ! TREE_SIDE_EFFECTS (t))
+ return t;
+ else if (TREE_CODE (t) == TARGET_EXPR)
+ return build_cplus_new (TREE_TYPE (t),
+ break_out_target_exprs (TREE_OPERAND (t, 1)), 0);
+ return NULL_TREE;
+}
+
+/* Actually, we'll just clean out the target exprs for the moment. */
+tree
+break_out_target_exprs (t)
+ tree t;
+{
+ return mapcar (t, bot_manip);
+}
+
+tree
+unsave_expr (expr)
+ tree expr;
+{
+ tree t;
+
+ t = build1 (UNSAVE_EXPR, TREE_TYPE (expr), expr);
+ TREE_SIDE_EFFECTS (t) = TREE_SIDE_EFFECTS (expr);
+ return t;
+}
+
+/* Modify a tree in place so that all the evaluate only once things
+ are cleared out. Return the EXPR given. */
+tree
+unsave_expr_now (expr)
+ tree expr;
+{
+ enum tree_code code;
+ register int i;
+
+ if (expr == NULL_TREE)
+ return expr;
+
+ code = TREE_CODE (expr);
+ switch (code)
+ {
+ case SAVE_EXPR:
+ SAVE_EXPR_RTL (expr) = NULL_RTX;
+ break;
+
+ case TARGET_EXPR:
+ sorry ("TARGET_EXPR reused inside UNSAVE_EXPR");
+ break;
+
+ case RTL_EXPR:
+ warning ("RTL_EXPR reused inside UNSAVE_EXPR");
+ RTL_EXPR_SEQUENCE (expr) = NULL_RTX;
+ break;
+
+ case CALL_EXPR:
+ CALL_EXPR_RTL (expr) = NULL_RTX;
+ if (TREE_OPERAND (expr, 1)
+ && TREE_CODE (TREE_OPERAND (expr, 1)) == TREE_LIST)
+ {
+ tree exp = TREE_OPERAND (expr, 1);
+ while (exp)
+ {
+ unsave_expr_now (TREE_VALUE (exp));
+ exp = TREE_CHAIN (exp);
+ }
+ }
+ break;
+
+ case WITH_CLEANUP_EXPR:
+ warning ("WITH_CLEANUP_EXPR reused inside UNSAVE_EXPR");
+ RTL_EXPR_RTL (expr) = NULL_RTX;
+ break;
+ }
+
+ switch (TREE_CODE_CLASS (code))
+ {
+ case 'c': /* a constant */
+ case 't': /* a type node */
+ case 'x': /* something random, like an identifier or an ERROR_MARK. */
+ case 'd': /* A decl node */
+ case 'b': /* A block node */
+ return expr;
+
+ case 'e': /* an expression */
+ case 'r': /* a reference */
+ case 's': /* an expression with side effects */
+ case '<': /* a comparison expression */
+ case '2': /* a binary arithmetic expression */
+ case '1': /* a unary arithmetic expression */
+ for (i = tree_code_length[(int) code] - 1; i >= 0; i--)
+ unsave_expr_now (TREE_OPERAND (expr, i));
+ return expr;
+
+ default:
+ my_friendly_abort (999);
+ }
+}
+
+/* Since cleanup may have SAVE_EXPRs in it, we protect it with an
+ UNSAVE_EXPR as the backend cannot yet handle SAVE_EXPRs in cleanups
+ by itself. */
+int
+cp_expand_decl_cleanup (decl, cleanup)
+ tree decl, cleanup;
+{
+ return expand_decl_cleanup (decl, unsave_expr (cleanup));
+}
diff --git a/contrib/gcc/cp/tree.def b/contrib/gcc/cp/tree.def
new file mode 100644
index 0000000..82b7954
--- /dev/null
+++ b/contrib/gcc/cp/tree.def
@@ -0,0 +1,116 @@
+/* This file contains the definitions and documentation for the
+ additional tree codes used in the GNU C++ compiler (see tree.def
+ for the standard codes).
+ Copyright (C) 1987, 1988, 1990, 1993 Free Software Foundation, Inc.
+ Hacked by Michael Tiemann (tiemann@cygnus.com)
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+/* Reference to the contents of an offset
+ (a value whose type is an OFFSET_TYPE).
+ Operand 0 is the object within which the offset is taken.
+ Operand 1 is the offset. The language independent OFFSET_REF
+ just won't work for us. */
+DEFTREECODE (CP_OFFSET_REF, "cp_offset_ref", "r", 2)
+
+/* For DELETE_EXPR, operand 0 is the store to be destroyed.
+ Operand 1 is the value to pass to the destroying function
+ saying whether the store should be deallocated as well. */
+DEFTREECODE (DELETE_EXPR, "dl_expr", "e", 2)
+DEFTREECODE (VEC_DELETE_EXPR, "vec_dl_expr", "e", 2)
+
+/* For a UNSAVE_EXPR, operand 0 is the value to unsave. By unsave, we
+ mean that all _EXPRs such as TARGET_EXPRs, SAVE_EXPRs,
+ WITH_CLEANUP_EXPRs, CALL_EXPRs and RTL_EXPRs, that are protected
+ from being evaluated more than once should be reset so that a new
+ expand_expr call of this expr will cause those to be re-evaluated.
+ This is useful when we want to reuse a tree in different places,
+ but where we must re-expand. */
+DEFTREECODE (UNSAVE_EXPR, "unsave_expr", "e", 1)
+
+/* Value is reference to particular overloaded class method.
+ Operand 0 is the class name (an IDENTIFIER_NODE);
+ operand 1 is the field (also an IDENTIFIER_NODE).
+ The COMPLEXITY field holds the class level (usually 0). */
+DEFTREECODE (SCOPE_REF, "scope_ref", "r", 2)
+
+/* When composing an object with a member, this is the result.
+ Operand 0 is the object. Operand 1 is the member (usually
+ a dereferenced pointer to member). */
+DEFTREECODE (MEMBER_REF, "member_ref", "r", 2)
+
+/* Type conversion operator in C++. TREE_TYPE is type that this
+ operator converts to. Operand is expression to be converted. */
+DEFTREECODE (TYPE_EXPR, "type_expr", "e", 1)
+
+/* For CPLUS_NEW_EXPR, operand 0 is function which performs initialization,
+ operand 1 is argument list to initialization function,
+ and operand 2 is the slot which was allocated for this expression. */
+DEFTREECODE (NEW_EXPR, "nw_expr", "e", 3)
+DEFTREECODE (VEC_NEW_EXPR, "vec_nw_expr", "e", 3)
+
+/* A throw expression. operand 0 is the expression, if there was one,
+ else it is NULL_TREE. */
+DEFTREECODE (THROW_EXPR, "throw_expr", "e", 1)
+
+/* Template definition. The following fields have the specified uses,
+ although there are other macros in cp-tree.h that should be used for
+ accessing this data.
+ DECL_ARGUMENTS template parm vector
+ DECL_TEMPLATE_INFO template text &c
+ DECL_VINDEX list of instantiations already produced;
+ only done for functions so far
+ For class template:
+ DECL_INITIAL associated templates (methods &c)
+ DECL_RESULT null
+ For non-class templates:
+ TREE_TYPE type of object to be constructed
+ DECL_RESULT decl for object to be created
+ (e.g., FUNCTION_DECL with tmpl parms used)
+ */
+DEFTREECODE (TEMPLATE_DECL, "template_decl", "d", 0)
+
+/* Index into a template parameter list. This parameter must be a type.
+ Use TYPE_FIELDS to find parmlist and index. */
+DEFTREECODE (TEMPLATE_TYPE_PARM, "template_type_parm", "t", 0)
+
+/* Index into a template parameter list. This parameter must not be a
+ type. */
+DEFTREECODE (TEMPLATE_CONST_PARM, "template_const_parm", "c", 2)
+
+/* For uninstantiated parameterized types.
+ TYPE_VALUES tree list:
+ TREE_PURPOSE template decl
+ TREE_VALUE parm vector
+ TREE_CHAIN null
+ Other useful fields to be defined later. */
+DEFTREECODE (UNINSTANTIATED_P_TYPE, "uninstantiated_p_type", "t", 0)
+
+/* A thunk is a stub function.
+
+ Thunks are used to implement multiple inheritance:
+ At run-time, such a thunk subtracts THUNK_DELTA (an int, not a tree)
+ from the this pointer, and then jumps to DECL_INITIAL
+ (which is an ADDR_EXPR whose operand is a FUNCTION_DECL).
+
+ Other kinds of thunks may be defined later. */
+DEFTREECODE (THUNK_DECL, "thunk_decl", "d", 0)
+
+/* A namespace declaration. */
+DEFTREECODE (NAMESPACE_DECL, "namespace_decl", "d", 0)
diff --git a/contrib/gcc/cp/typeck.c b/contrib/gcc/cp/typeck.c
new file mode 100644
index 0000000..9247bf0
--- /dev/null
+++ b/contrib/gcc/cp/typeck.c
@@ -0,0 +1,7615 @@
+/* Build expressions with type checking for C++ compiler.
+ Copyright (C) 1987, 88, 89, 92, 93, 94, 1995 Free Software Foundation, Inc.
+ Hacked by Michael Tiemann (tiemann@cygnus.com)
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+/* This file is part of the C++ front end.
+ It contains routines to build C++ expressions given their operands,
+ including computing the types of the result, C and C++ specific error
+ checks, and some optimization.
+
+ There are also routines to build RETURN_STMT nodes and CASE_STMT nodes,
+ and to process initializations in declarations (since they work
+ like a strange sort of assignment). */
+
+extern void error ();
+extern void warning ();
+
+#include "config.h"
+#include <stdio.h>
+#include "tree.h"
+#include "rtl.h"
+#include "cp-tree.h"
+#include "flags.h"
+#include "output.h"
+
+int mark_addressable ();
+static tree convert_for_assignment ();
+/* static */ tree convert_for_initialization ();
+extern tree shorten_compare ();
+extern void binary_op_error ();
+static tree pointer_int_sum ();
+static tree pointer_diff ();
+static tree convert_sequence ();
+/* static */ tree unary_complex_lvalue ();
+static tree get_delta_difference PROTO((tree, tree, int));
+
+extern rtx original_result_rtx;
+extern int warn_synth;
+
+/* Return the target type of TYPE, which meas return T for:
+ T*, T&, T[], T (...), and otherwise, just T. */
+
+tree
+target_type (type)
+ tree type;
+{
+ if (TREE_CODE (type) == REFERENCE_TYPE)
+ type = TREE_TYPE (type);
+ while (TREE_CODE (type) == POINTER_TYPE
+ || TREE_CODE (type) == ARRAY_TYPE
+ || TREE_CODE (type) == FUNCTION_TYPE
+ || TREE_CODE (type) == METHOD_TYPE
+ || TREE_CODE (type) == OFFSET_TYPE)
+ type = TREE_TYPE (type);
+ return type;
+}
+
+/* Do `exp = require_complete_type (exp);' to make sure exp
+ does not have an incomplete type. (That includes void types.) */
+
+tree
+require_complete_type (value)
+ tree value;
+{
+ tree type = TREE_TYPE (value);
+
+ /* First, detect a valid value with a complete type. */
+ if (TYPE_SIZE (type) != 0
+ && type != void_type_node
+ && ! (TYPE_LANG_SPECIFIC (type)
+ && (IS_SIGNATURE_POINTER (type) || IS_SIGNATURE_REFERENCE (type))
+ && TYPE_SIZE (SIGNATURE_TYPE (type)) == 0))
+ return value;
+
+ /* If we see X::Y, we build an OFFSET_TYPE which has
+ not been laid out. Try to avoid an error by interpreting
+ it as this->X::Y, if reasonable. */
+ if (TREE_CODE (value) == OFFSET_REF
+ && C_C_D != 0
+ && TREE_OPERAND (value, 0) == C_C_D)
+ {
+ tree base, member = TREE_OPERAND (value, 1);
+ tree basetype = TYPE_OFFSET_BASETYPE (type);
+ my_friendly_assert (TREE_CODE (member) == FIELD_DECL, 305);
+ base = convert_pointer_to (basetype, current_class_decl);
+ value = build (COMPONENT_REF, TREE_TYPE (member),
+ build_indirect_ref (base, NULL_PTR), member);
+ return require_complete_type (value);
+ }
+
+ incomplete_type_error (value, type);
+ return error_mark_node;
+}
+
+/* Return truthvalue of whether type of EXP is instantiated. */
+int
+type_unknown_p (exp)
+ tree exp;
+{
+ return (TREE_CODE (exp) == TREE_LIST
+ || TREE_TYPE (exp) == unknown_type_node
+ || (TREE_CODE (TREE_TYPE (exp)) == OFFSET_TYPE
+ && TREE_TYPE (TREE_TYPE (exp)) == unknown_type_node));
+}
+
+/* Return truthvalue of whether T is function (or pfn) type. */
+int
+fntype_p (t)
+ tree t;
+{
+ return (TREE_CODE (t) == FUNCTION_TYPE || TREE_CODE (t) == METHOD_TYPE
+ || (TREE_CODE (t) == POINTER_TYPE
+ && (TREE_CODE (TREE_TYPE (t)) == FUNCTION_TYPE
+ || TREE_CODE (TREE_TYPE (t)) == METHOD_TYPE)));
+}
+
+/* Do `exp = require_instantiated_type (type, exp);' to make sure EXP
+ does not have an uninstantiated type.
+ TYPE is type to instantiate with, if uninstantiated. */
+tree
+require_instantiated_type (type, exp, errval)
+ tree type, exp, errval;
+{
+ if (TREE_TYPE (exp) == NULL_TREE)
+ {
+ error ("argument list may not have an initializer list");
+ return errval;
+ }
+
+ if (TREE_TYPE (exp) == unknown_type_node
+ || (TREE_CODE (TREE_TYPE (exp)) == OFFSET_TYPE
+ && TREE_TYPE (TREE_TYPE (exp)) == unknown_type_node))
+ {
+ exp = instantiate_type (type, exp, 1);
+ if (TREE_TYPE (exp) == error_mark_node)
+ return errval;
+ }
+ return exp;
+}
+
+/* Return a variant of TYPE which has all the type qualifiers of LIKE
+ as well as those of TYPE. */
+
+static tree
+qualify_type (type, like)
+ tree type, like;
+{
+ int constflag = TYPE_READONLY (type) || TYPE_READONLY (like);
+ int volflag = TYPE_VOLATILE (type) || TYPE_VOLATILE (like);
+ /* @@ Must do member pointers here. */
+ return cp_build_type_variant (type, constflag, volflag);
+}
+
+/* Return the common type of two parameter lists.
+ We assume that comptypes has already been done and returned 1;
+ if that isn't so, this may crash.
+
+ As an optimization, free the space we allocate if the parameter
+ lists are already common. */
+
+tree
+commonparms (p1, p2)
+ tree p1, p2;
+{
+ tree oldargs = p1, newargs, n;
+ int i, len;
+ int any_change = 0;
+ char *first_obj = (char *) oballoc (0);
+
+ len = list_length (p1);
+ newargs = tree_last (p1);
+
+ if (newargs == void_list_node)
+ i = 1;
+ else
+ {
+ i = 0;
+ newargs = 0;
+ }
+
+ for (; i < len; i++)
+ newargs = tree_cons (NULL_TREE, NULL_TREE, newargs);
+
+ n = newargs;
+
+ for (i = 0; p1;
+ p1 = TREE_CHAIN (p1), p2 = TREE_CHAIN (p2), n = TREE_CHAIN (n), i++)
+ {
+ if (TREE_PURPOSE (p1) && !TREE_PURPOSE (p2))
+ {
+ TREE_PURPOSE (n) = TREE_PURPOSE (p1);
+ any_change = 1;
+ }
+ else if (! TREE_PURPOSE (p1))
+ {
+ if (TREE_PURPOSE (p2))
+ {
+ TREE_PURPOSE (n) = TREE_PURPOSE (p2);
+ any_change = 1;
+ }
+ }
+ else
+ {
+ if (1 != simple_cst_equal (TREE_PURPOSE (p1), TREE_PURPOSE (p2)))
+ any_change = 1;
+ TREE_PURPOSE (n) = TREE_PURPOSE (p2);
+ }
+ if (TREE_VALUE (p1) != TREE_VALUE (p2))
+ {
+ any_change = 1;
+ TREE_VALUE (n) = common_type (TREE_VALUE (p1), TREE_VALUE (p2));
+ }
+ else
+ TREE_VALUE (n) = TREE_VALUE (p1);
+ }
+ if (! any_change)
+ {
+ obfree (first_obj);
+ return oldargs;
+ }
+
+ return newargs;
+}
+
+/* Return the common type of two types.
+ We assume that comptypes has already been done and returned 1;
+ if that isn't so, this may crash.
+
+ This is the type for the result of most arithmetic operations
+ if the operands have the given two types.
+
+ We do not deal with enumeral types here because they have already been
+ converted to integer types. */
+
+tree
+common_type (t1, t2)
+ tree t1, t2;
+{
+ register enum tree_code code1;
+ register enum tree_code code2;
+ tree attributes;
+
+ /* Save time if the two types are the same. */
+
+ if (t1 == t2) return t1;
+
+ /* If one type is nonsense, use the other. */
+ if (t1 == error_mark_node)
+ return t2;
+ if (t2 == error_mark_node)
+ return t1;
+
+ /* Merge the attributes */
+
+ { register tree a1, a2;
+ a1 = TYPE_ATTRIBUTES (t1);
+ a2 = TYPE_ATTRIBUTES (t2);
+
+ /* Either one unset? Take the set one. */
+
+ if (!(attributes = a1))
+ attributes = a2;
+
+ /* One that completely contains the other? Take it. */
+
+ else if (a2 && !attribute_list_contained (a1, a2))
+ if (attribute_list_contained (a2, a1))
+ attributes = a2;
+ else
+ {
+ /* Pick the longest list, and hang on the other list. */
+ /* ??? For the moment we punt on the issue of attrs with args. */
+
+ if (list_length (a1) < list_length (a2))
+ attributes = a2, a2 = a1;
+
+ for (; a2; a2 = TREE_CHAIN (a2))
+ if (lookup_attribute (IDENTIFIER_POINTER (TREE_PURPOSE (a2)),
+ attributes) == NULL_TREE)
+ {
+ a1 = copy_node (a2);
+ TREE_CHAIN (a1) = attributes;
+ attributes = a1;
+ }
+ }
+ }
+
+ /* Treat an enum type as the unsigned integer type of the same width. */
+
+ if (TREE_CODE (t1) == ENUMERAL_TYPE)
+ t1 = type_for_size (TYPE_PRECISION (t1), 1);
+ if (TREE_CODE (t2) == ENUMERAL_TYPE)
+ t2 = type_for_size (TYPE_PRECISION (t2), 1);
+
+ code1 = TREE_CODE (t1);
+ code2 = TREE_CODE (t2);
+
+ switch (code1)
+ {
+ case INTEGER_TYPE:
+ case REAL_TYPE:
+ /* If only one is real, use it as the result. */
+
+ if (code1 == REAL_TYPE && code2 != REAL_TYPE)
+ return build_type_attribute_variant (t1, attributes);
+
+ if (code2 == REAL_TYPE && code1 != REAL_TYPE)
+ return build_type_attribute_variant (t2, attributes);
+
+ /* Both real or both integers; use the one with greater precision. */
+
+ if (TYPE_PRECISION (t1) > TYPE_PRECISION (t2))
+ return build_type_attribute_variant (t1, attributes);
+ else if (TYPE_PRECISION (t2) > TYPE_PRECISION (t1))
+ return build_type_attribute_variant (t2, attributes);
+
+ /* Same precision. Prefer longs to ints even when same size. */
+
+ if (TYPE_MAIN_VARIANT (t1) == long_unsigned_type_node
+ || TYPE_MAIN_VARIANT (t2) == long_unsigned_type_node)
+ return build_type_attribute_variant (long_unsigned_type_node,
+ attributes);
+
+ if (TYPE_MAIN_VARIANT (t1) == long_integer_type_node
+ || TYPE_MAIN_VARIANT (t2) == long_integer_type_node)
+ {
+ /* But preserve unsignedness from the other type,
+ since long cannot hold all the values of an unsigned int. */
+ if (TREE_UNSIGNED (t1) || TREE_UNSIGNED (t2))
+ t1 = long_unsigned_type_node;
+ else
+ t1 = long_integer_type_node;
+ return build_type_attribute_variant (t1, attributes);
+ }
+
+ if (TYPE_MAIN_VARIANT (t1) == long_double_type_node
+ || TYPE_MAIN_VARIANT (t2) == long_double_type_node)
+ return build_type_attribute_variant (long_double_type_node,
+ attributes);
+
+ /* Otherwise prefer the unsigned one. */
+
+ if (TREE_UNSIGNED (t1))
+ return build_type_attribute_variant (t1, attributes);
+ else
+ return build_type_attribute_variant (t2, attributes);
+
+ case POINTER_TYPE:
+ case REFERENCE_TYPE:
+ /* For two pointers, do this recursively on the target type,
+ and combine the qualifiers of the two types' targets. */
+ /* This code was turned off; I don't know why.
+ But ANSI C++ specifies doing this with the qualifiers.
+ So I turned it on again. */
+ {
+ tree tt1 = TYPE_MAIN_VARIANT (TREE_TYPE (t1));
+ tree tt2 = TYPE_MAIN_VARIANT (TREE_TYPE (t2));
+ int constp
+ = TYPE_READONLY (TREE_TYPE (t1)) || TYPE_READONLY (TREE_TYPE (t2));
+ int volatilep
+ = TYPE_VOLATILE (TREE_TYPE (t1)) || TYPE_VOLATILE (TREE_TYPE (t2));
+ tree target;
+
+ if (tt1 == tt2)
+ target = tt1;
+ else if (tt1 == void_type_node || tt2 == void_type_node)
+ target = void_type_node;
+ else
+ target = common_type (tt1, tt2);
+
+ target = cp_build_type_variant (target, constp, volatilep);
+ if (code1 == POINTER_TYPE)
+ t1 = build_pointer_type (target);
+ else
+ t1 = build_reference_type (target);
+ t1 = build_type_attribute_variant (t1, attributes);
+
+ if (TREE_CODE (target) == METHOD_TYPE)
+ t1 = build_ptrmemfunc_type (t1);
+
+ return t1;
+ }
+#if 0
+ case POINTER_TYPE:
+ t1 = build_pointer_type (common_type (TREE_TYPE (t1), TREE_TYPE (t2)));
+ return build_type_attribute_variant (t1, attributes);
+
+ case REFERENCE_TYPE:
+ t1 = build_reference_type (common_type (TREE_TYPE (t1), TREE_TYPE (t2)));
+ return build_type_attribute_variant (t1, attributes);
+#endif
+
+ case ARRAY_TYPE:
+ {
+ tree elt = common_type (TREE_TYPE (t1), TREE_TYPE (t2));
+ /* Save space: see if the result is identical to one of the args. */
+ if (elt == TREE_TYPE (t1) && TYPE_DOMAIN (t1))
+ return build_type_attribute_variant (t1, attributes);
+ if (elt == TREE_TYPE (t2) && TYPE_DOMAIN (t2))
+ return build_type_attribute_variant (t2, attributes);
+ /* Merge the element types, and have a size if either arg has one. */
+ t1 = build_cplus_array_type (elt, TYPE_DOMAIN (TYPE_DOMAIN (t1) ? t1 : t2));
+ return build_type_attribute_variant (t1, attributes);
+ }
+
+ case FUNCTION_TYPE:
+ /* Function types: prefer the one that specified arg types.
+ If both do, merge the arg types. Also merge the return types. */
+ {
+ tree valtype = common_type (TREE_TYPE (t1), TREE_TYPE (t2));
+ tree p1 = TYPE_ARG_TYPES (t1);
+ tree p2 = TYPE_ARG_TYPES (t2);
+ tree rval, raises;
+
+ /* Save space: see if the result is identical to one of the args. */
+ if (valtype == TREE_TYPE (t1) && ! p2)
+ return build_type_attribute_variant (t1, attributes);
+ if (valtype == TREE_TYPE (t2) && ! p1)
+ return build_type_attribute_variant (t2, attributes);
+
+ /* Simple way if one arg fails to specify argument types. */
+ if (p1 == NULL_TREE || TREE_VALUE (p1) == void_type_node)
+ {
+ rval = build_function_type (valtype, p2);
+ if ((raises = TYPE_RAISES_EXCEPTIONS (t2)))
+ rval = build_exception_variant (rval, raises);
+ return build_type_attribute_variant (rval, attributes);
+ }
+ raises = TYPE_RAISES_EXCEPTIONS (t1);
+ if (p2 == NULL_TREE || TREE_VALUE (p2) == void_type_node)
+ {
+ rval = build_function_type (valtype, p1);
+ if (raises)
+ rval = build_exception_variant (rval, raises);
+ return build_type_attribute_variant (rval, attributes);
+ }
+
+ rval = build_function_type (valtype, commonparms (p1, p2));
+ rval = build_exception_variant (rval, raises);
+ return build_type_attribute_variant (rval, attributes);
+ }
+
+ case RECORD_TYPE:
+ case UNION_TYPE:
+ my_friendly_assert (TYPE_MAIN_VARIANT (t1) == t1
+ && TYPE_MAIN_VARIANT (t2) == t2, 306);
+
+ if (DERIVED_FROM_P (t1, t2) && binfo_or_else (t1, t2))
+ return build_type_attribute_variant (t1, attributes);
+ else if (binfo_or_else (t2, t1))
+ return build_type_attribute_variant (t2, attributes);
+ else
+ compiler_error ("common_type called with uncommon aggregate types");
+
+ case METHOD_TYPE:
+ if (TREE_CODE (TREE_TYPE (t1)) == TREE_CODE (TREE_TYPE (t2)))
+ {
+ /* Get this value the long way, since TYPE_METHOD_BASETYPE
+ is just the main variant of this. */
+ tree basetype;
+ tree raises, t3;
+
+ tree b1 = TYPE_OFFSET_BASETYPE (t1);
+ tree b2 = TYPE_OFFSET_BASETYPE (t2);
+
+ if (DERIVED_FROM_P (b1, b2) && binfo_or_else (b1, b2))
+ basetype = TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t2)));
+ else
+ {
+ if (binfo_or_else (b2, b1) == NULL_TREE)
+ compiler_error ("common_type called with uncommon method types");
+ basetype = TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (t1)));
+ }
+
+ raises = TYPE_RAISES_EXCEPTIONS (t1);
+
+ /* If this was a member function type, get back to the
+ original type of type member function (i.e., without
+ the class instance variable up front. */
+ t1 = build_function_type (TREE_TYPE (t1), TREE_CHAIN (TYPE_ARG_TYPES (t1)));
+ t2 = build_function_type (TREE_TYPE (t2), TREE_CHAIN (TYPE_ARG_TYPES (t2)));
+ t3 = common_type (t1, t2);
+ t3 = build_cplus_method_type (basetype, TREE_TYPE (t3), TYPE_ARG_TYPES (t3));
+ t1 = build_exception_variant (t3, raises);
+ }
+ else
+ compiler_error ("common_type called with uncommon method types");
+
+ return build_type_attribute_variant (t1, attributes);
+
+ case OFFSET_TYPE:
+ if (TREE_TYPE (t1) == TREE_TYPE (t2))
+ {
+ tree b1 = TYPE_OFFSET_BASETYPE (t1);
+ tree b2 = TYPE_OFFSET_BASETYPE (t2);
+
+ if (DERIVED_FROM_P (b1, b2) && binfo_or_else (b1, b2))
+ return build_type_attribute_variant (t2, attributes);
+ else if (binfo_or_else (b2, b1))
+ return build_type_attribute_variant (t1, attributes);
+ }
+ compiler_error ("common_type called with uncommon member types");
+
+ default:
+ return build_type_attribute_variant (t1, attributes);
+ }
+}
+
+/* Return 1 if TYPE1 and TYPE2 raise the same exceptions. */
+int
+compexcepttypes (t1, t2, strict)
+ tree t1, t2;
+ int strict;
+{
+ return TYPE_RAISES_EXCEPTIONS (t1) == TYPE_RAISES_EXCEPTIONS (t2);
+}
+
+static int
+comp_array_types (cmp, t1, t2, strict)
+ register int (*cmp)();
+ tree t1, t2;
+ int strict;
+{
+ tree d1 = TYPE_DOMAIN (t1);
+ tree d2 = TYPE_DOMAIN (t2);
+
+ /* Target types must match incl. qualifiers. */
+ if (!(TREE_TYPE (t1) == TREE_TYPE (t2)
+ || (*cmp) (TREE_TYPE (t1), TREE_TYPE (t2), strict)))
+ return 0;
+
+ /* Sizes must match unless one is missing or variable. */
+ if (d1 == 0 || d2 == 0 || d1 == d2
+ || TREE_CODE (TYPE_MIN_VALUE (d1)) != INTEGER_CST
+ || TREE_CODE (TYPE_MIN_VALUE (d2)) != INTEGER_CST
+ || TREE_CODE (TYPE_MAX_VALUE (d1)) != INTEGER_CST
+ || TREE_CODE (TYPE_MAX_VALUE (d2)) != INTEGER_CST)
+ return 1;
+
+ return ((TREE_INT_CST_LOW (TYPE_MIN_VALUE (d1))
+ == TREE_INT_CST_LOW (TYPE_MIN_VALUE (d2)))
+ && (TREE_INT_CST_HIGH (TYPE_MIN_VALUE (d1))
+ == TREE_INT_CST_HIGH (TYPE_MIN_VALUE (d2)))
+ && (TREE_INT_CST_LOW (TYPE_MAX_VALUE (d1))
+ == TREE_INT_CST_LOW (TYPE_MAX_VALUE (d2)))
+ && (TREE_INT_CST_HIGH (TYPE_MAX_VALUE (d1))
+ == TREE_INT_CST_HIGH (TYPE_MAX_VALUE (d2))));
+}
+
+/* Return 1 if TYPE1 and TYPE2 are compatible types for assignment
+ or various other operations. This is what ANSI C++ speaks of as
+ "being the same".
+
+ For C++: argument STRICT says we should be strict about this
+ comparison:
+
+ 2 : strict, except that if one type is a reference and
+ the other is not, compare the target type of the
+ reference to the type that's not a reference (ARM, p308).
+ This is used for checking for invalid overloading.
+ 1 : strict (compared according to ANSI C)
+ This is used for checking whether two function decls match.
+ 0 : <= (compared according to C++)
+ -1: <= or >= (relaxed)
+
+ Otherwise, pointers involving base classes and derived classes
+ can be mixed as valid: i.e. a pointer to a base class may be assigned
+ to a pointer to one of its derived classes, as per C++. A pointer to
+ a derived class may be passed as a parameter to a function expecting a
+ pointer to a base classes. These allowances do not commute. In this
+ case, TYPE1 is assumed to be the base class, and TYPE2 is assumed to
+ be the derived class. */
+int
+comptypes (type1, type2, strict)
+ tree type1, type2;
+ int strict;
+{
+ register tree t1 = type1;
+ register tree t2 = type2;
+ int attrval, val;
+
+ /* Suppress errors caused by previously reported errors */
+
+ if (t1 == t2)
+ return 1;
+
+ /* This should never happen. */
+ my_friendly_assert (t1 != error_mark_node, 307);
+
+ if (t2 == error_mark_node)
+ return 0;
+
+ if (strict < 0)
+ {
+ /* Treat an enum type as the unsigned integer type of the same width. */
+
+ if (TREE_CODE (t1) == ENUMERAL_TYPE)
+ t1 = type_for_size (TYPE_PRECISION (t1), 1);
+ if (TREE_CODE (t2) == ENUMERAL_TYPE)
+ t2 = type_for_size (TYPE_PRECISION (t2), 1);
+
+ if (t1 == t2)
+ return 1;
+ }
+
+ /* Different classes of types can't be compatible. */
+
+ if (TREE_CODE (t1) != TREE_CODE (t2))
+ {
+ if (strict == 2
+ && ((TREE_CODE (t1) == REFERENCE_TYPE)
+ ^ (TREE_CODE (t2) == REFERENCE_TYPE)))
+ {
+ if (TREE_CODE (t1) == REFERENCE_TYPE)
+ return comptypes (TREE_TYPE (t1), t2, 1);
+ return comptypes (t1, TREE_TYPE (t2), 1);
+ }
+
+ return 0;
+ }
+ if (strict > 1)
+ strict = 1;
+
+ /* Qualifiers must match. */
+
+ if (TYPE_READONLY (t1) != TYPE_READONLY (t2))
+ return 0;
+ if (TYPE_VOLATILE (t1) != TYPE_VOLATILE (t2))
+ return 0;
+
+ /* Allow for two different type nodes which have essentially the same
+ definition. Note that we already checked for equality of the type
+ type qualifiers (just above). */
+
+ if (TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2))
+ return 1;
+
+#ifdef COMP_TYPE_ATTRIBUTES
+ if (! (attrval = COMP_TYPE_ATTRIBUTES (t1, t2)))
+ return 0;
+#else
+ /* 1 if no need for warning yet, 2 if warning cause has been seen. */
+ attrval = 1;
+#endif
+
+ /* 1 if no need for warning yet, 2 if warning cause has been seen. */
+ val = 0;
+
+ switch (TREE_CODE (t1))
+ {
+ case RECORD_TYPE:
+ case UNION_TYPE:
+ if (strict <= 0)
+ goto look_hard;
+ return 0;
+
+ case OFFSET_TYPE:
+ val = (comptypes (build_pointer_type (TYPE_OFFSET_BASETYPE (t1)),
+ build_pointer_type (TYPE_OFFSET_BASETYPE (t2)), strict)
+ && comptypes (TREE_TYPE (t1), TREE_TYPE (t2), strict));
+ break;
+
+ case METHOD_TYPE:
+ if (! compexcepttypes (t1, t2, strict))
+ return 0;
+
+ /* This case is anti-symmetrical!
+ One can pass a base member (or member function)
+ to something expecting a derived member (or member function),
+ but not vice-versa! */
+
+ val = (comptypes (TREE_TYPE (t1), TREE_TYPE (t2), strict)
+ && compparms (TYPE_ARG_TYPES (t1),
+ TYPE_ARG_TYPES (t2), strict));
+ break;
+
+ case POINTER_TYPE:
+ case REFERENCE_TYPE:
+ t1 = TREE_TYPE (t1);
+ t2 = TREE_TYPE (t2);
+ if (t1 == t2)
+ {
+ val = 1;
+ break;
+ }
+ if (strict <= 0)
+ {
+ if (TREE_CODE (t1) == RECORD_TYPE && TREE_CODE (t2) == RECORD_TYPE)
+ {
+ int rval;
+ look_hard:
+ rval = t1 == t2 || UNIQUELY_DERIVED_FROM_P (t1, t2);
+
+ if (rval)
+ {
+ val = 1;
+ break;
+ }
+ if (strict < 0)
+ {
+ val = UNIQUELY_DERIVED_FROM_P (t2, t1);
+ break;
+ }
+ }
+ return 0;
+ }
+ else
+ val = comptypes (t1, t2, strict);
+ break;
+
+ case FUNCTION_TYPE:
+ if (! compexcepttypes (t1, t2, strict))
+ return 0;
+
+ val = ((TREE_TYPE (t1) == TREE_TYPE (t2)
+ || comptypes (TREE_TYPE (t1), TREE_TYPE (t2), strict))
+ && compparms (TYPE_ARG_TYPES (t1), TYPE_ARG_TYPES (t2), strict));
+ break;
+
+ case ARRAY_TYPE:
+ /* Target types must match incl. qualifiers. */
+ val = comp_array_types (comptypes, t1, t2, strict);
+ break;
+
+ case TEMPLATE_TYPE_PARM:
+ return TEMPLATE_TYPE_IDX (t1) == TEMPLATE_TYPE_IDX (t2);
+
+ case UNINSTANTIATED_P_TYPE:
+ if (UPT_TEMPLATE (t1) != UPT_TEMPLATE (t2))
+ return 0;
+ {
+ int i = TREE_VEC_LENGTH (UPT_PARMS (t1));
+ tree *p1 = &TREE_VEC_ELT (UPT_PARMS (t1), 0);
+ tree *p2 = &TREE_VEC_ELT (UPT_PARMS (t2), 0);
+
+ while (i--)
+ {
+ if (TREE_CODE_CLASS (TREE_CODE (p1[i])) == 't')
+ {
+ if (! comptypes (p1[i], p2[i], 1))
+ return 0;
+ }
+ else
+ {
+ if (simple_cst_equal (p1[i], p2[i]) <= 0)
+ return 0;
+ }
+ }
+ }
+ return 1;
+ }
+ return attrval == 2 && val == 1 ? 2 : val;
+}
+
+/* Return 1 if TTL and TTR are pointers to types that are equivalent,
+ ignoring their qualifiers.
+
+ NPTRS is the number of pointers we can strip off and keep cool.
+ This is used to permit (for aggr A, aggr B) A, B* to convert to A*,
+ but to not permit B** to convert to A**. */
+
+int
+comp_target_types (ttl, ttr, nptrs)
+ tree ttl, ttr;
+ int nptrs;
+{
+ ttl = TYPE_MAIN_VARIANT (ttl);
+ ttr = TYPE_MAIN_VARIANT (ttr);
+ if (ttl == ttr)
+ return 1;
+
+ if (TREE_CODE (ttr) != TREE_CODE (ttl))
+ return 0;
+
+ if (TREE_CODE (ttr) == POINTER_TYPE)
+ {
+ ttl = TREE_TYPE (ttl);
+ ttr = TREE_TYPE (ttr);
+
+ if (nptrs > 0)
+ {
+ if (TREE_CODE (ttl) == VOID_TYPE
+ && TREE_CODE (ttr) != FUNCTION_TYPE
+ && TREE_CODE (ttr) != METHOD_TYPE
+ && TREE_CODE (ttr) != OFFSET_TYPE)
+ return 1;
+ else if (TREE_CODE (ttr) == VOID_TYPE
+ && TREE_CODE (ttl) != FUNCTION_TYPE
+ && TREE_CODE (ttl) != METHOD_TYPE
+ && TREE_CODE (ttl) != OFFSET_TYPE)
+ return -1;
+ else if (TREE_CODE (ttl) == POINTER_TYPE
+ || TREE_CODE (ttl) == ARRAY_TYPE)
+ {
+ if (comp_ptr_ttypes (ttl, ttr))
+ return 1;
+ else if (comp_ptr_ttypes (ttr, ttl))
+ return -1;
+ return 0;
+ }
+ }
+
+ /* Const and volatile mean something different for function types,
+ so the usual checks are not appropriate. */
+ if (TREE_CODE (ttl) == FUNCTION_TYPE || TREE_CODE (ttl) == METHOD_TYPE)
+ return comp_target_types (ttl, ttr, nptrs - 1);
+
+ /* Make sure that the cv-quals change only in the same direction as
+ the target type. */
+ {
+ int t;
+ int c = TYPE_READONLY (ttl) - TYPE_READONLY (ttr);
+ int v = TYPE_VOLATILE (ttl) - TYPE_VOLATILE (ttr);
+
+ if ((c > 0 && v < 0) || (c < 0 && v > 0))
+ return 0;
+
+ if (TYPE_MAIN_VARIANT (ttl) == TYPE_MAIN_VARIANT (ttr))
+ return (c + v < 0) ? -1 : 1;
+
+ t = comp_target_types (ttl, ttr, nptrs - 1);
+ if ((t == 1 && c + v >= 0) || (t == -1 && c + v <= 0))
+ return t;
+
+ return 0;
+ }
+ }
+
+ if (TREE_CODE (ttr) == REFERENCE_TYPE)
+ return comp_target_types (TREE_TYPE (ttl), TREE_TYPE (ttr), nptrs);
+ if (TREE_CODE (ttr) == ARRAY_TYPE)
+ return comp_array_types (comp_target_types, ttl, ttr, 0);
+ else if (TREE_CODE (ttr) == FUNCTION_TYPE || TREE_CODE (ttr) == METHOD_TYPE)
+ if (comp_target_types (TREE_TYPE (ttl), TREE_TYPE (ttr), nptrs))
+ switch (comp_target_parms (TYPE_ARG_TYPES (ttl), TYPE_ARG_TYPES (ttr), 1))
+ {
+ case 0:
+ return 0;
+ case 1:
+ return 1;
+ case 2:
+ return -1;
+ default:
+ my_friendly_abort (112);
+ }
+ else
+ return 0;
+
+ /* for C++ */
+ else if (TREE_CODE (ttr) == OFFSET_TYPE)
+ {
+ /* Contravariance: we can assign a pointer to base member to a pointer
+ to derived member. Note difference from simple pointer case, where
+ we can pass a pointer to derived to a pointer to base. */
+ if (comptypes (TYPE_OFFSET_BASETYPE (ttr), TYPE_OFFSET_BASETYPE (ttl), 0))
+ return comp_target_types (TREE_TYPE (ttl), TREE_TYPE (ttr), nptrs);
+ else if (comptypes (TYPE_OFFSET_BASETYPE (ttl), TYPE_OFFSET_BASETYPE (ttr), 0)
+ && comp_target_types (TREE_TYPE (ttl), TREE_TYPE (ttr), nptrs))
+ return -1;
+ }
+ else if (IS_AGGR_TYPE (ttl))
+ {
+ if (nptrs < 0)
+ return 0;
+ if (comptypes (build_pointer_type (ttl), build_pointer_type (ttr), 0))
+ return 1;
+ if (comptypes (build_pointer_type (ttr), build_pointer_type (ttl), 0))
+ return -1;
+ return 0;
+ }
+
+ return 0;
+}
+
+/* If two types share a common base type, return that basetype.
+ If there is not a unique most-derived base type, this function
+ returns ERROR_MARK_NODE. */
+tree
+common_base_type (tt1, tt2)
+ tree tt1, tt2;
+{
+ tree best = NULL_TREE, tmp;
+ int i;
+
+ /* If one is a baseclass of another, that's good enough. */
+ if (UNIQUELY_DERIVED_FROM_P (tt1, tt2))
+ return tt1;
+ if (UNIQUELY_DERIVED_FROM_P (tt2, tt1))
+ return tt2;
+
+#if 0
+ /* If they share a virtual baseclass, that's good enough. */
+ for (tmp = CLASSTYPE_VBASECLASSES (tt1); tmp; tmp = TREE_CHAIN (tmp))
+ {
+ if (binfo_member (BINFO_TYPE (tmp), CLASSTYPE_VBASECLASSES (tt2)))
+ return BINFO_TYPE (tmp);
+ }
+#endif
+
+ /* Otherwise, try to find a unique baseclass of TT1
+ that is shared by TT2, and follow that down. */
+ for (i = CLASSTYPE_N_BASECLASSES (tt1)-1; i >= 0; i--)
+ {
+ tree basetype = TYPE_BINFO_BASETYPE (tt1, i);
+ tree trial = common_base_type (basetype, tt2);
+ if (trial)
+ {
+ if (trial == error_mark_node)
+ return trial;
+ if (best == NULL_TREE)
+ best = trial;
+ else if (best != trial)
+ return error_mark_node;
+ }
+ }
+
+ /* Same for TT2. */
+ for (i = CLASSTYPE_N_BASECLASSES (tt2)-1; i >= 0; i--)
+ {
+ tree basetype = TYPE_BINFO_BASETYPE (tt2, i);
+ tree trial = common_base_type (tt1, basetype);
+ if (trial)
+ {
+ if (trial == error_mark_node)
+ return trial;
+ if (best == NULL_TREE)
+ best = trial;
+ else if (best != trial)
+ return error_mark_node;
+ }
+ }
+ return best;
+}
+
+/* Subroutines of `comptypes'. */
+
+/* Return 1 if two parameter type lists PARMS1 and PARMS2
+ are equivalent in the sense that functions with those parameter types
+ can have equivalent types.
+ If either list is empty, we win.
+ Otherwise, the two lists must be equivalent, element by element.
+
+ C++: See comment above about TYPE1, TYPE2, STRICT.
+ If STRICT == 3, it means checking is strict, but do not compare
+ default parameter values. */
+int
+compparms (parms1, parms2, strict)
+ tree parms1, parms2;
+ int strict;
+{
+ register tree t1 = parms1, t2 = parms2;
+
+ /* An unspecified parmlist matches any specified parmlist
+ whose argument types don't need default promotions. */
+
+ if (strict <= 0 && t1 == 0)
+ return self_promoting_args_p (t2);
+ if (strict < 0 && t2 == 0)
+ return self_promoting_args_p (t1);
+
+ while (1)
+ {
+ if (t1 == 0 && t2 == 0)
+ return 1;
+ /* If one parmlist is shorter than the other,
+ they fail to match, unless STRICT is <= 0. */
+ if (t1 == 0 || t2 == 0)
+ {
+ if (strict > 0)
+ return 0;
+ if (strict < 0)
+ return 1;
+ if (strict == 0)
+ return t1 && TREE_PURPOSE (t1);
+ }
+ if (! comptypes (TREE_VALUE (t2), TREE_VALUE (t1), strict))
+ {
+ if (strict > 0)
+ return 0;
+ if (strict == 0)
+ return t2 == void_list_node && TREE_PURPOSE (t1);
+ return TREE_PURPOSE (t1) || TREE_PURPOSE (t2);
+ }
+#if 0
+ /* Default parms are not part of the type of a function. */
+ if (strict != 3 && TREE_PURPOSE (t1) && TREE_PURPOSE (t2))
+ {
+ int cmp = simple_cst_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2));
+ if (cmp < 0)
+ my_friendly_abort (113);
+ if (cmp == 0)
+ return 0;
+ }
+#endif
+
+ t1 = TREE_CHAIN (t1);
+ t2 = TREE_CHAIN (t2);
+ }
+}
+
+/* This really wants return whether or not parameter type lists
+ would make their owning functions assignment compatible or not. */
+int
+comp_target_parms (parms1, parms2, strict)
+ tree parms1, parms2;
+ int strict;
+{
+ register tree t1 = parms1, t2 = parms2;
+ int warn_contravariance = 0;
+
+ /* An unspecified parmlist matches any specified parmlist
+ whose argument types don't need default promotions.
+ @@@ see 13.3.3 for a counterexample... */
+
+ if (t1 == 0 && t2 != 0)
+ {
+ cp_pedwarn ("ANSI C++ prohibits conversion from `(%#T)' to `(...)'",
+ parms2);
+ return self_promoting_args_p (t2);
+ }
+ if (t2 == 0)
+ return self_promoting_args_p (t1);
+
+ for (; t1 || t2; t1 = TREE_CHAIN (t1), t2 = TREE_CHAIN (t2))
+ {
+ tree p1, p2;
+
+ /* If one parmlist is shorter than the other,
+ they fail to match, unless STRICT is <= 0. */
+ if (t1 == 0 || t2 == 0)
+ {
+ if (strict > 0)
+ return 0;
+ if (strict < 0)
+ return 1 + warn_contravariance;
+ return ((t1 && TREE_PURPOSE (t1)) + warn_contravariance);
+ }
+ p1 = TREE_VALUE (t1);
+ p2 = TREE_VALUE (t2);
+ if (p1 == p2)
+ continue;
+
+ if ((TREE_CODE (p1) == POINTER_TYPE && TREE_CODE (p2) == POINTER_TYPE)
+ || (TREE_CODE (p1) == REFERENCE_TYPE && TREE_CODE (p2) == REFERENCE_TYPE))
+ {
+ if (strict <= 0
+ && (TYPE_MAIN_VARIANT (TREE_TYPE (p1))
+ == TYPE_MAIN_VARIANT (TREE_TYPE (p2))))
+ continue;
+
+ /* The following is wrong for contravariance,
+ but many programs depend on it. */
+ if (TREE_TYPE (p1) == void_type_node)
+ continue;
+ if (TREE_TYPE (p2) == void_type_node)
+ {
+ warn_contravariance = 1;
+ continue;
+ }
+ if (IS_AGGR_TYPE (TREE_TYPE (p1)))
+ {
+ if (comptypes (p2, p1, 0) == 0)
+ {
+ if (comptypes (p1, p2, 0) != 0)
+ warn_contravariance = 1;
+ else
+ return 0;
+ }
+ continue;
+ }
+ }
+ /* Note backwards order due to contravariance. */
+ if (comp_target_types (p2, p1, 1) == 0)
+ {
+ if (comp_target_types (p1, p2, 1))
+ {
+ warn_contravariance = 1;
+ continue;
+ }
+ if (strict != 0)
+ return 0;
+#if 0
+ /* What good do these cases do? */
+ if (strict == 0)
+ return p2 == void_type_node && TREE_PURPOSE (t1);
+ return TREE_PURPOSE (t1) || TREE_PURPOSE (t2);
+#endif
+ }
+ /* Target types are compatible--just make sure that if
+ we use parameter lists, that they are ok as well. */
+ if (TREE_CODE (p1) == FUNCTION_TYPE || TREE_CODE (p1) == METHOD_TYPE)
+ switch (comp_target_parms (TYPE_ARG_TYPES (p1),
+ TYPE_ARG_TYPES (p2),
+ strict))
+ {
+ case 0:
+ return 0;
+ case 1:
+ break;
+ case 2:
+ warn_contravariance = 1;
+ }
+
+ if (TREE_PURPOSE (t1) && TREE_PURPOSE (t2))
+ {
+ int cmp = simple_cst_equal (TREE_PURPOSE (t1), TREE_PURPOSE (t2));
+ if (cmp < 0)
+ my_friendly_abort (114);
+ if (cmp == 0)
+ return 0;
+ }
+ }
+ return 1 + warn_contravariance;
+}
+
+/* Return 1 if PARMS specifies a fixed number of parameters
+ and none of their types is affected by default promotions. */
+
+int
+self_promoting_args_p (parms)
+ tree parms;
+{
+ register tree t;
+ for (t = parms; t; t = TREE_CHAIN (t))
+ {
+ register tree type = TREE_VALUE (t);
+
+ if (TREE_CHAIN (t) == 0 && type != void_type_node)
+ return 0;
+
+ if (TYPE_MAIN_VARIANT (type) == float_type_node)
+ return 0;
+
+ if (type == 0)
+ return 0;
+
+ if (C_PROMOTING_INTEGER_TYPE_P (type))
+ return 0;
+ }
+ return 1;
+}
+
+/* Return an unsigned type the same as TYPE in other respects.
+
+ C++: must make these work for type variants as well. */
+
+tree
+unsigned_type (type)
+ tree type;
+{
+ tree type1 = TYPE_MAIN_VARIANT (type);
+ if (type1 == signed_char_type_node || type1 == char_type_node)
+ return unsigned_char_type_node;
+ if (type1 == integer_type_node)
+ return unsigned_type_node;
+ if (type1 == short_integer_type_node)
+ return short_unsigned_type_node;
+ if (type1 == long_integer_type_node)
+ return long_unsigned_type_node;
+ if (type1 == long_long_integer_type_node)
+ return long_long_unsigned_type_node;
+ return type;
+}
+
+/* Return a signed type the same as TYPE in other respects. */
+
+tree
+signed_type (type)
+ tree type;
+{
+ tree type1 = TYPE_MAIN_VARIANT (type);
+ if (type1 == unsigned_char_type_node || type1 == char_type_node)
+ return signed_char_type_node;
+ if (type1 == unsigned_type_node)
+ return integer_type_node;
+ if (type1 == short_unsigned_type_node)
+ return short_integer_type_node;
+ if (type1 == long_unsigned_type_node)
+ return long_integer_type_node;
+ if (type1 == long_long_unsigned_type_node)
+ return long_long_integer_type_node;
+ return type;
+}
+
+/* Return a type the same as TYPE except unsigned or
+ signed according to UNSIGNEDP. */
+
+tree
+signed_or_unsigned_type (unsignedp, type)
+ int unsignedp;
+ tree type;
+{
+ if (! INTEGRAL_TYPE_P (type))
+ return type;
+ if (TYPE_PRECISION (type) == TYPE_PRECISION (signed_char_type_node))
+ return unsignedp ? unsigned_char_type_node : signed_char_type_node;
+ if (TYPE_PRECISION (type) == TYPE_PRECISION (integer_type_node))
+ return unsignedp ? unsigned_type_node : integer_type_node;
+ if (TYPE_PRECISION (type) == TYPE_PRECISION (short_integer_type_node))
+ return unsignedp ? short_unsigned_type_node : short_integer_type_node;
+ if (TYPE_PRECISION (type) == TYPE_PRECISION (long_integer_type_node))
+ return unsignedp ? long_unsigned_type_node : long_integer_type_node;
+ if (TYPE_PRECISION (type) == TYPE_PRECISION (long_long_integer_type_node))
+ return (unsignedp ? long_long_unsigned_type_node
+ : long_long_integer_type_node);
+ return type;
+}
+
+tree
+c_sizeof (type)
+ tree type;
+{
+ enum tree_code code = TREE_CODE (type);
+ tree t;
+
+ if (code == FUNCTION_TYPE)
+ {
+ if (pedantic || warn_pointer_arith)
+ pedwarn ("ANSI C++ forbids taking the sizeof a function type");
+ return size_int (1);
+ }
+ if (code == METHOD_TYPE)
+ {
+ if (pedantic || warn_pointer_arith)
+ pedwarn ("ANSI C++ forbids taking the sizeof a method type");
+ return size_int (1);
+ }
+ if (code == VOID_TYPE)
+ {
+ if (pedantic || warn_pointer_arith)
+ pedwarn ("ANSI C++ forbids taking the sizeof a void type");
+ return size_int (1);
+ }
+ if (code == ERROR_MARK)
+ return size_int (1);
+
+ /* ARM $5.3.2: ``When applied to a reference, the result is the size of the
+ referenced object.'' */
+ if (code == REFERENCE_TYPE)
+ type = TREE_TYPE (type);
+
+ /* We couldn't find anything in the ARM or the draft standard that says,
+ one way or the other, if doing sizeof on something that doesn't have
+ an object associated with it is correct or incorrect. For example, if
+ you declare `struct S { char str[16]; };', and in your program do
+ a `sizeof (S::str)', should we flag that as an error or should we give
+ the size of it? Since it seems like a reasonable thing to do, we'll go
+ with giving the value. */
+ if (code == OFFSET_TYPE)
+ type = TREE_TYPE (type);
+
+ /* @@ This also produces an error for a signature ref.
+ In that case we should be able to do better. */
+ if (IS_SIGNATURE (type))
+ {
+ error ("`sizeof' applied to a signature type");
+ return size_int (0);
+ }
+
+ if (TYPE_SIZE (type) == 0)
+ {
+ error ("`sizeof' applied to an incomplete type");
+ return size_int (0);
+ }
+
+ /* Convert in case a char is more than one unit. */
+ t = size_binop (CEIL_DIV_EXPR, TYPE_SIZE (type),
+ size_int (TYPE_PRECISION (char_type_node)));
+ /* size_binop does not put the constant in range, so do it now. */
+ if (TREE_CODE (t) == INTEGER_CST && force_fit_type (t, 0))
+ TREE_CONSTANT_OVERFLOW (t) = TREE_OVERFLOW (t) = 1;
+ return t;
+}
+
+tree
+c_sizeof_nowarn (type)
+ tree type;
+{
+ enum tree_code code = TREE_CODE (type);
+ tree t;
+
+ if (code == FUNCTION_TYPE
+ || code == METHOD_TYPE
+ || code == VOID_TYPE
+ || code == ERROR_MARK)
+ return size_int (1);
+ if (code == REFERENCE_TYPE)
+ type = TREE_TYPE (type);
+
+ if (TYPE_SIZE (type) == 0)
+ {
+#if 0
+ /* ??? Tiemann, why have any diagnostic here?
+ There is none in the corresponding function for C. */
+ warning ("sizeof applied to an incomplete type");
+#endif
+ return size_int (0);
+ }
+
+ /* Convert in case a char is more than one unit. */
+ t = size_binop (CEIL_DIV_EXPR, TYPE_SIZE (type),
+ size_int (TYPE_PRECISION (char_type_node)));
+ force_fit_type (t, 0);
+ return t;
+}
+
+/* Implement the __alignof keyword: Return the minimum required
+ alignment of TYPE, measured in bytes. */
+
+tree
+c_alignof (type)
+ tree type;
+{
+ enum tree_code code = TREE_CODE (type);
+ tree t;
+
+ if (code == FUNCTION_TYPE || code == METHOD_TYPE)
+ return size_int (FUNCTION_BOUNDARY / BITS_PER_UNIT);
+
+ if (code == VOID_TYPE || code == ERROR_MARK)
+ return size_int (1);
+
+ /* C++: this is really correct! */
+ if (code == REFERENCE_TYPE)
+ type = TREE_TYPE (type);
+
+ /* @@ This also produces an error for a signature ref.
+ In that case we should be able to do better. */
+ if (IS_SIGNATURE (type))
+ {
+ error ("`__alignof' applied to a signature type");
+ return size_int (1);
+ }
+
+ t = size_int (TYPE_ALIGN (type) / BITS_PER_UNIT);
+ force_fit_type (t, 0);
+ return t;
+}
+
+/* Perform default promotions for C data used in expressions.
+ Arrays and functions are converted to pointers;
+ enumeral types or short or char, to int.
+ In addition, manifest constants symbols are replaced by their values.
+
+ C++: this will automatically bash references to their target type. */
+
+tree
+decay_conversion (exp)
+ tree exp;
+{
+ register tree type = TREE_TYPE (exp);
+ register enum tree_code code = TREE_CODE (type);
+
+ if (code == OFFSET_TYPE /* || TREE_CODE (exp) == OFFSET_REF */ )
+ {
+ if (TREE_CODE (exp) == OFFSET_REF)
+ return decay_conversion (resolve_offset_ref (exp));
+
+ type = TREE_TYPE (type);
+ code = TREE_CODE (type);
+ }
+
+ if (code == REFERENCE_TYPE)
+ {
+ exp = convert_from_reference (exp);
+ type = TREE_TYPE (exp);
+ code = TREE_CODE (type);
+ }
+
+ /* Constants can be used directly unless they're not loadable. */
+ if (TREE_CODE (exp) == CONST_DECL)
+ exp = DECL_INITIAL (exp);
+ /* Replace a nonvolatile const static variable with its value. */
+ else if (TREE_READONLY_DECL_P (exp))
+ {
+ exp = decl_constant_value (exp);
+ type = TREE_TYPE (exp);
+ }
+
+ /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
+ Leave such NOP_EXPRs, since RHS is being used in non-lvalue context. */
+
+ if (code == VOID_TYPE)
+ {
+ error ("void value not ignored as it ought to be");
+ return error_mark_node;
+ }
+ if (code == FUNCTION_TYPE)
+ {
+ return build_unary_op (ADDR_EXPR, exp, 0);
+ }
+ if (code == METHOD_TYPE)
+ {
+ if (TREE_CODE (exp) == OFFSET_REF)
+ {
+ my_friendly_assert (TREE_CODE (TREE_OPERAND (exp, 1)) == FUNCTION_DECL,
+ 308);
+ return build_unary_op (ADDR_EXPR, TREE_OPERAND (exp, 1), 0);
+ }
+ return build_unary_op (ADDR_EXPR, exp, 0);
+ }
+ if (code == ARRAY_TYPE)
+ {
+ register tree adr;
+ tree restype;
+ tree ptrtype;
+ int constp, volatilep;
+
+ if (TREE_CODE (exp) == INDIRECT_REF)
+ {
+ /* Stripping away the INDIRECT_REF is not the right
+ thing to do for references... */
+ tree inner = TREE_OPERAND (exp, 0);
+ if (TREE_CODE (TREE_TYPE (inner)) == REFERENCE_TYPE)
+ {
+ inner = build1 (CONVERT_EXPR,
+ build_pointer_type (TREE_TYPE (TREE_TYPE (inner))),
+ inner);
+ TREE_REFERENCE_EXPR (inner) = 1;
+ }
+ return convert (build_pointer_type (TREE_TYPE (type)), inner);
+ }
+
+ if (TREE_CODE (exp) == COMPOUND_EXPR)
+ {
+ tree op1 = decay_conversion (TREE_OPERAND (exp, 1));
+ return build (COMPOUND_EXPR, TREE_TYPE (op1),
+ TREE_OPERAND (exp, 0), op1);
+ }
+
+ if (!lvalue_p (exp)
+ && ! (TREE_CODE (exp) == CONSTRUCTOR && TREE_STATIC (exp)))
+ {
+ error ("invalid use of non-lvalue array");
+ return error_mark_node;
+ }
+
+ constp = volatilep = 0;
+ if (TREE_CODE_CLASS (TREE_CODE (exp)) == 'r'
+ || TREE_CODE_CLASS (TREE_CODE (exp)) == 'd')
+ {
+ constp = TREE_READONLY (exp);
+ volatilep = TREE_THIS_VOLATILE (exp);
+ }
+
+ restype = TREE_TYPE (type);
+ if (TYPE_READONLY (type) || TYPE_VOLATILE (type)
+ || constp || volatilep)
+ restype = cp_build_type_variant (restype,
+ TYPE_READONLY (type) || constp,
+ TYPE_VOLATILE (type) || volatilep);
+ ptrtype = build_pointer_type (restype);
+
+ if (TREE_CODE (exp) == VAR_DECL)
+ {
+ /* ??? This is not really quite correct
+ in that the type of the operand of ADDR_EXPR
+ is not the target type of the type of the ADDR_EXPR itself.
+ Question is, can this lossage be avoided? */
+ adr = build1 (ADDR_EXPR, ptrtype, exp);
+ if (mark_addressable (exp) == 0)
+ return error_mark_node;
+ TREE_CONSTANT (adr) = staticp (exp);
+ TREE_SIDE_EFFECTS (adr) = 0; /* Default would be, same as EXP. */
+ return adr;
+ }
+ /* This way is better for a COMPONENT_REF since it can
+ simplify the offset for a component. */
+ adr = build_unary_op (ADDR_EXPR, exp, 1);
+ return convert (ptrtype, adr);
+ }
+
+ return exp;
+}
+
+tree
+default_conversion (exp)
+ tree exp;
+{
+ tree type;
+ enum tree_code code;
+
+ exp = decay_conversion (exp);
+
+ type = TREE_TYPE (exp);
+ code = TREE_CODE (type);
+
+ if (INTEGRAL_CODE_P (code))
+ {
+ tree t = type_promotes_to (type);
+ if (t != type)
+ return convert (t, exp);
+ }
+ if (flag_traditional
+ && TYPE_MAIN_VARIANT (type) == float_type_node)
+ return convert (double_type_node, exp);
+
+ return exp;
+}
+
+tree
+build_object_ref (datum, basetype, field)
+ tree datum, basetype, field;
+{
+ tree dtype;
+ if (datum == error_mark_node)
+ return error_mark_node;
+
+ dtype = TREE_TYPE (datum);
+ if (TREE_CODE (dtype) == REFERENCE_TYPE)
+ dtype = TREE_TYPE (dtype);
+ if (! IS_AGGR_TYPE_CODE (TREE_CODE (dtype)))
+ {
+ cp_error ("request for member `%T::%D' in expression of non-aggregate type `%T'",
+ basetype, field, dtype);
+ return error_mark_node;
+ }
+ else if (IS_SIGNATURE (IDENTIFIER_TYPE_VALUE (basetype)))
+ {
+ warning ("signature name in scope resolution ignored");
+ return build_component_ref (datum, field, NULL_TREE, 1);
+ }
+ else if (is_aggr_typedef (basetype, 1))
+ {
+ tree real_basetype = IDENTIFIER_TYPE_VALUE (basetype);
+ tree binfo = binfo_or_else (real_basetype, TREE_TYPE (datum));
+ if (binfo)
+ return build_component_ref (build_scoped_ref (datum, basetype),
+ field, binfo, 1);
+ }
+ return error_mark_node;
+}
+
+/* Like `build_component_ref, but uses an already found field.
+ Must compute access for C_C_D. Otherwise, ok. */
+tree
+build_component_ref_1 (datum, field, protect)
+ tree datum, field;
+ int protect;
+{
+ register tree basetype = TREE_TYPE (datum);
+ register enum tree_code code = TREE_CODE (basetype);
+ register tree ref;
+
+ if (code == REFERENCE_TYPE)
+ {
+ datum = convert_from_reference (datum);
+ basetype = TREE_TYPE (datum);
+ code = TREE_CODE (basetype);
+ }
+
+ if (! IS_AGGR_TYPE_CODE (code))
+ {
+ if (code != ERROR_MARK)
+ cp_error ("request for member `%D' in `%E', which is of non-aggregate type `%T'",
+ field, datum, basetype);
+ return error_mark_node;
+ }
+
+ if (TYPE_SIZE (basetype) == 0)
+ {
+ incomplete_type_error (0, basetype);
+ return error_mark_node;
+ }
+
+ /* Look up component name in the structure type definition. */
+
+ if (field == error_mark_node)
+ my_friendly_abort (115);
+
+ if (TREE_STATIC (field))
+ return field;
+
+ if (datum == C_C_D)
+ {
+ enum access_type access
+ = compute_access (TYPE_BINFO (current_class_type), field);
+
+ if (access == access_private)
+ {
+ cp_error ("field `%D' is private", field);
+ return error_mark_node;
+ }
+ else if (access == access_protected)
+ {
+ cp_error ("field `%D' is protected", field);
+ return error_mark_node;
+ }
+ }
+
+ ref = build (COMPONENT_REF, TREE_TYPE (field), datum, field);
+
+ if (TREE_READONLY (datum) || TREE_READONLY (field))
+ TREE_READONLY (ref) = 1;
+ if (TREE_THIS_VOLATILE (datum) || TREE_THIS_VOLATILE (field))
+ TREE_THIS_VOLATILE (ref) = 1;
+ if (DECL_MUTABLE_P (field))
+ TREE_READONLY (ref) = 0;
+
+ return ref;
+}
+
+/* Given a COND_EXPR in T, return it in a form that we can, for
+ example, use as an lvalue. This code used to be in unary_complex_lvalue,
+ but we needed it to deal with `a = (d == c) ? b : c' expressions, where
+ we're dealing with aggregates. So, we now call this in unary_complex_lvalue,
+ and in build_modify_expr. The case (in particular) that led to this was
+ with CODE == ADDR_EXPR, since it's not an lvalue when we'd get it there. */
+static tree
+rationalize_conditional_expr (code, t)
+ enum tree_code code;
+ tree t;
+{
+ return
+ build_conditional_expr (TREE_OPERAND (t, 0),
+ build_unary_op (code, TREE_OPERAND (t, 1), 0),
+ build_unary_op (code, TREE_OPERAND (t, 2), 0));
+}
+
+tree
+build_component_ref (datum, component, basetype_path, protect)
+ tree datum, component, basetype_path;
+ int protect;
+{
+ register tree basetype = TREE_TYPE (datum);
+ register enum tree_code code = TREE_CODE (basetype);
+ register tree field = NULL;
+ register tree ref;
+
+ /* If DATUM is a COMPOUND_EXPR or COND_EXPR, move our reference inside it. */
+ switch (TREE_CODE (datum))
+ {
+ case COMPOUND_EXPR:
+ {
+ tree value = build_component_ref (TREE_OPERAND (datum, 1), component,
+ basetype_path, protect);
+ return build (COMPOUND_EXPR, TREE_TYPE (value),
+ TREE_OPERAND (datum, 0), value);
+ }
+ case COND_EXPR:
+ return build_conditional_expr
+ (TREE_OPERAND (datum, 0),
+ build_component_ref (TREE_OPERAND (datum, 1), component,
+ basetype_path, protect),
+ build_component_ref (TREE_OPERAND (datum, 2), component,
+ basetype_path, protect));
+ }
+
+ if (code == REFERENCE_TYPE)
+ {
+#if 0
+ /* TREE_REFERENCE_EXPRs are not converted by `convert_from_reference'.
+ @@ Maybe that is not right. */
+ if (TREE_REFERENCE_EXPR (datum))
+ datum = build1 (INDIRECT_REF, TREE_TYPE (basetype), datum);
+ else
+#endif
+ datum = convert_from_reference (datum);
+ basetype = TREE_TYPE (datum);
+ code = TREE_CODE (basetype);
+ }
+
+ /* First, see if there is a field or component with name COMPONENT. */
+ if (TREE_CODE (component) == TREE_LIST)
+ {
+ my_friendly_assert (!(TREE_CHAIN (component) == NULL_TREE
+ && DECL_CHAIN (TREE_VALUE (component)) == NULL_TREE), 309);
+ return build (COMPONENT_REF, TREE_TYPE (component), datum, component);
+ }
+#if 0
+ if (TREE_CODE (component) == TYPE_EXPR)
+ return build_component_type_expr (datum, component, NULL_TREE, protect);
+#endif
+
+ if (! IS_AGGR_TYPE_CODE (code))
+ {
+ if (code != ERROR_MARK)
+ cp_error ("request for member `%D' in `%E', which is of non-aggregate type `%T'",
+ component, datum, basetype);
+ return error_mark_node;
+ }
+
+ if (TYPE_SIZE (basetype) == 0)
+ {
+ incomplete_type_error (0, basetype);
+ return error_mark_node;
+ }
+
+ if (TREE_CODE (component) == BIT_NOT_EXPR)
+ {
+ if (TYPE_IDENTIFIER (basetype) != TREE_OPERAND (component, 0))
+ {
+ cp_error ("destructor specifier `%T::~%T' must have matching names",
+ basetype, TREE_OPERAND (component, 0));
+ return error_mark_node;
+ }
+ if (! TYPE_HAS_DESTRUCTOR (basetype))
+ {
+ cp_error ("type `%T' has no destructor", basetype);
+ return error_mark_node;
+ }
+ return TREE_VEC_ELT (CLASSTYPE_METHOD_VEC (basetype), 0);
+ }
+
+ /* Look up component name in the structure type definition. */
+ if (CLASSTYPE_VFIELD (basetype)
+ && DECL_NAME (CLASSTYPE_VFIELD (basetype)) == component)
+ /* Special-case this because if we use normal lookups in an ambiguous
+ hierarchy, the compiler will abort (because vptr lookups are
+ not supposed to be ambiguous. */
+ field = CLASSTYPE_VFIELD (basetype);
+ else
+ {
+ if (basetype_path == NULL_TREE)
+ basetype_path = TYPE_BINFO (basetype);
+ field = lookup_field (basetype_path, component,
+ protect && ! VFIELD_NAME_P (component), 0);
+ if (field == error_mark_node)
+ return error_mark_node;
+
+ if (field == NULL_TREE)
+ {
+ /* Not found as a data field, look for it as a method. If found,
+ then if this is the only possible one, return it, else
+ report ambiguity error. */
+ tree fndecls = lookup_fnfields (basetype_path, component, 1);
+ if (fndecls == error_mark_node)
+ return error_mark_node;
+ if (fndecls)
+ {
+ if (TREE_CHAIN (fndecls) == NULL_TREE
+ && DECL_CHAIN (TREE_VALUE (fndecls)) == NULL_TREE)
+ {
+ enum access_type access;
+ tree fndecl;
+
+ /* Unique, so use this one now. */
+ basetype = TREE_PURPOSE (fndecls);
+ fndecl = TREE_VALUE (fndecls);
+ access = compute_access (TREE_PURPOSE (fndecls), fndecl);
+ if (access == access_public)
+ {
+ if (DECL_VINDEX (fndecl)
+ && ! resolves_to_fixed_type_p (datum, 0))
+ {
+ tree addr = build_unary_op (ADDR_EXPR, datum, 0);
+ addr = convert_pointer_to (DECL_CONTEXT (fndecl), addr);
+ datum = build_indirect_ref (addr, NULL_PTR);
+ my_friendly_assert (datum != error_mark_node, 310);
+ fndecl = build_vfn_ref (&addr, datum, DECL_VINDEX (fndecl));
+ }
+ assemble_external (fndecl);
+ return fndecl;
+ }
+ if (access == access_protected)
+ cp_error ("member function `%D' is protected", fndecl);
+ else
+ cp_error ("member function `%D' is private", fndecl);
+ return error_mark_node;
+ }
+ else
+ {
+ /* Just act like build_offset_ref, since the object does
+ not matter unless we're actually calling the function. */
+ tree t;
+
+ for (t = TREE_VALUE (fndecls); t; t = DECL_CHAIN (t))
+ assemble_external (t);
+
+ t = build_tree_list (error_mark_node, fndecls);
+ TREE_TYPE (t) = build_offset_type (basetype,
+ unknown_type_node);
+ return t;
+ }
+ }
+
+#if 0
+ if (component == ansi_opname[(int) TYPE_EXPR])
+ cp_error ("`%#T' has no such type conversion operator", basetype);
+ else
+#endif
+ cp_error ("`%#T' has no member named `%D'", basetype, component);
+ return error_mark_node;
+ }
+ else if (TREE_TYPE (field) == error_mark_node)
+ return error_mark_node;
+
+ if (TREE_CODE (field) != FIELD_DECL)
+ {
+ if (TREE_CODE (field) == TYPE_DECL)
+ {
+ cp_error ("invalid use of type decl `%#D' as expression", field);
+ return error_mark_node;
+ }
+ if (DECL_RTL (field) != 0)
+ assemble_external (field);
+ TREE_USED (field) = 1;
+ return field;
+ }
+ }
+
+ if (DECL_FIELD_CONTEXT (field) != basetype
+ && TYPE_USES_COMPLEX_INHERITANCE (basetype))
+ {
+ tree addr = build_unary_op (ADDR_EXPR, datum, 0);
+ if (integer_zerop (addr))
+ {
+ error ("invalid reference to NULL ptr, use ptr-to-member instead");
+ return error_mark_node;
+ }
+ addr = convert_pointer_to (DECL_FIELD_CONTEXT (field), addr);
+ datum = build_indirect_ref (addr, NULL_PTR);
+ my_friendly_assert (datum != error_mark_node, 311);
+ }
+ ref = fold (build (COMPONENT_REF, TREE_TYPE (field),
+ break_out_cleanups (datum), field));
+
+ if (TREE_READONLY (datum) || TREE_READONLY (field))
+ TREE_READONLY (ref) = 1;
+ if (TREE_THIS_VOLATILE (datum) || TREE_THIS_VOLATILE (field))
+ TREE_THIS_VOLATILE (ref) = 1;
+ if (DECL_MUTABLE_P (field))
+ TREE_READONLY (ref) = 0;
+
+ return ref;
+}
+
+/* Given an expression PTR for a pointer, return an expression
+ for the value pointed to.
+ ERRORSTRING is the name of the operator to appear in error messages.
+
+ This function may need to overload OPERATOR_FNNAME.
+ Must also handle REFERENCE_TYPEs for C++. */
+
+tree
+build_x_indirect_ref (ptr, errorstring)
+ tree ptr;
+ char *errorstring;
+{
+ tree rval = build_opfncall (INDIRECT_REF, LOOKUP_NORMAL, ptr, NULL_TREE, NULL_TREE);
+ if (rval)
+ return rval;
+ return build_indirect_ref (ptr, errorstring);
+}
+
+tree
+build_indirect_ref (ptr, errorstring)
+ tree ptr;
+ char *errorstring;
+{
+ register tree pointer = (TREE_CODE (TREE_TYPE (ptr)) == REFERENCE_TYPE ?
+ ptr : default_conversion (ptr));
+ register tree type = TREE_TYPE (pointer);
+
+ if (ptr == current_class_decl)
+ return C_C_D;
+
+ if (IS_AGGR_TYPE (type))
+ {
+ ptr = build_expr_type_conversion (WANT_POINTER, pointer, 1);
+
+ if (ptr)
+ {
+ pointer = ptr;
+ type = TREE_TYPE (pointer);
+ }
+ }
+
+ if (TREE_CODE (type) == POINTER_TYPE || TREE_CODE (type) == REFERENCE_TYPE)
+ {
+ if (TREE_CODE (pointer) == ADDR_EXPR
+ && (TYPE_MAIN_VARIANT (TREE_TYPE (TREE_OPERAND (pointer, 0)))
+ == TYPE_MAIN_VARIANT (TREE_TYPE (type)))
+ && (TREE_READONLY (TREE_OPERAND (pointer, 0))
+ == TYPE_READONLY (TREE_TYPE (type)))
+ && (TREE_THIS_VOLATILE (TREE_OPERAND (pointer, 0))
+ == TYPE_VOLATILE (TREE_TYPE (type))))
+ return TREE_OPERAND (pointer, 0);
+ else
+ {
+ tree t = TREE_TYPE (type);
+ register tree ref = build1 (INDIRECT_REF,
+ TYPE_MAIN_VARIANT (t), pointer);
+
+ TREE_READONLY (ref) = TYPE_READONLY (t);
+ TREE_THIS_VOLATILE (ref) = TYPE_VOLATILE (t);
+ TREE_SIDE_EFFECTS (ref)
+ = TYPE_VOLATILE (t) || TREE_SIDE_EFFECTS (pointer);
+ return ref;
+ }
+ }
+ /* `pointer' won't be an error_mark_node if we were given a
+ pointer to member, so it's cool to check for this here. */
+ else if (TYPE_PTRMEMFUNC_P (type))
+ error ("invalid use of `%s' on pointer to member function", errorstring);
+ else if (TREE_CODE (type) == RECORD_TYPE
+ && (IS_SIGNATURE_POINTER (type) || IS_SIGNATURE_REFERENCE (type)))
+ error ("cannot dereference signature pointer/reference");
+ else if (pointer != error_mark_node)
+ {
+ if (errorstring)
+ error ("invalid type argument of `%s'", errorstring);
+ else
+ error ("invalid type argument");
+ }
+ return error_mark_node;
+}
+
+/* This handles expressions of the form "a[i]", which denotes
+ an array reference.
+
+ This is logically equivalent in C to *(a+i), but we may do it differently.
+ If A is a variable or a member, we generate a primitive ARRAY_REF.
+ This avoids forcing the array out of registers, and can work on
+ arrays that are not lvalues (for example, members of structures returned
+ by functions).
+
+ If INDEX is of some user-defined type, it must be converted to
+ integer type. Otherwise, to make a compatible PLUS_EXPR, it
+ will inherit the type of the array, which will be some pointer type. */
+
+tree
+build_x_array_ref (array, index)
+ tree array, index;
+{
+ tree rval = build_opfncall (ARRAY_REF, LOOKUP_NORMAL, array, index, NULL_TREE);
+ if (rval)
+ return rval;
+ return build_array_ref (array, index);
+}
+
+tree
+build_array_ref (array, idx)
+ tree array, idx;
+{
+ tree itype;
+
+ if (idx == 0)
+ {
+ error ("subscript missing in array reference");
+ return error_mark_node;
+ }
+
+ if (TREE_TYPE (array) == error_mark_node
+ || TREE_TYPE (idx) == error_mark_node)
+ return error_mark_node;
+
+ itype = TREE_TYPE (idx);
+
+ if (TREE_CODE (TREE_TYPE (array)) == ARRAY_TYPE
+ && TREE_CODE (array) != INDIRECT_REF)
+ {
+ tree rval, type;
+
+ /* Subscripting with type char is likely to lose
+ on a machine where chars are signed.
+ So warn on any machine, but optionally.
+ Don't warn for unsigned char since that type is safe.
+ Don't warn for signed char because anyone who uses that
+ must have done so deliberately. */
+ if (warn_char_subscripts
+ && TYPE_MAIN_VARIANT (TREE_TYPE (idx)) == char_type_node)
+ warning ("array subscript has type `char'");
+
+ /* Apply default promotions *after* noticing character types. */
+ idx = default_conversion (idx);
+
+ if (TREE_CODE (TREE_TYPE (idx)) != INTEGER_TYPE)
+ {
+ error ("array subscript is not an integer");
+ return error_mark_node;
+ }
+
+ /* An array that is indexed by a non-constant
+ cannot be stored in a register; we must be able to do
+ address arithmetic on its address.
+ Likewise an array of elements of variable size. */
+ if (TREE_CODE (idx) != INTEGER_CST
+ || (TYPE_SIZE (TREE_TYPE (TREE_TYPE (array))) != 0
+ && TREE_CODE (TYPE_SIZE (TREE_TYPE (TREE_TYPE (array)))) != INTEGER_CST))
+ {
+ if (mark_addressable (array) == 0)
+ return error_mark_node;
+ }
+ /* An array that is indexed by a constant value which is not within
+ the array bounds cannot be stored in a register either; because we
+ would get a crash in store_bit_field/extract_bit_field when trying
+ to access a non-existent part of the register. */
+ if (TREE_CODE (idx) == INTEGER_CST
+ && TYPE_VALUES (TREE_TYPE (array))
+ && ! int_fits_type_p (idx, TYPE_VALUES (TREE_TYPE (array))))
+ {
+ if (mark_addressable (array) == 0)
+ return error_mark_node;
+ }
+
+ if (pedantic && !lvalue_p (array))
+ pedwarn ("ANSI C++ forbids subscripting non-lvalue array");
+
+ /* Note in C++ it is valid to subscript a `register' array, since
+ it is valid to take the address of something with that
+ storage specification. */
+ if (extra_warnings)
+ {
+ tree foo = array;
+ while (TREE_CODE (foo) == COMPONENT_REF)
+ foo = TREE_OPERAND (foo, 0);
+ if (TREE_CODE (foo) == VAR_DECL && DECL_REGISTER (foo))
+ warning ("subscripting array declared `register'");
+ }
+
+ type = TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (array)));
+ rval = build (ARRAY_REF, type, array, idx);
+ /* Array ref is const/volatile if the array elements are
+ or if the array is.. */
+ TREE_READONLY (rval)
+ |= (TYPE_READONLY (TREE_TYPE (TREE_TYPE (array)))
+ | TREE_READONLY (array));
+ TREE_SIDE_EFFECTS (rval)
+ |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
+ | TREE_SIDE_EFFECTS (array));
+ TREE_THIS_VOLATILE (rval)
+ |= (TYPE_VOLATILE (TREE_TYPE (TREE_TYPE (array)))
+ /* This was added by rms on 16 Nov 91.
+ It fixes vol struct foo *a; a->elts[1]
+ in an inline function.
+ Hope it doesn't break something else. */
+ | TREE_THIS_VOLATILE (array));
+ return require_complete_type (fold (rval));
+ }
+
+ {
+ tree ar = default_conversion (array);
+ tree ind = default_conversion (idx);
+
+ /* Put the integer in IND to simplify error checking. */
+ if (TREE_CODE (TREE_TYPE (ar)) == INTEGER_TYPE)
+ {
+ tree temp = ar;
+ ar = ind;
+ ind = temp;
+ }
+
+ if (ar == error_mark_node)
+ return ar;
+
+ if (TREE_CODE (TREE_TYPE (ar)) != POINTER_TYPE)
+ {
+ error ("subscripted value is neither array nor pointer");
+ return error_mark_node;
+ }
+ if (TREE_CODE (TREE_TYPE (ind)) != INTEGER_TYPE)
+ {
+ error ("array subscript is not an integer");
+ return error_mark_node;
+ }
+
+ return build_indirect_ref (build_binary_op_nodefault (PLUS_EXPR, ar, ind, PLUS_EXPR),
+ "array indexing");
+ }
+}
+
+/* Build a function call to function FUNCTION with parameters PARAMS.
+ PARAMS is a list--a chain of TREE_LIST nodes--in which the
+ TREE_VALUE of each node is a parameter-expression.
+ FUNCTION's data type may be a function type or a pointer-to-function.
+
+ For C++: If FUNCTION's data type is a TREE_LIST, then the tree list
+ is the list of possible methods that FUNCTION could conceivably
+ be. If the list of methods comes from a class, then it will be
+ a list of lists (where each element is associated with the class
+ that produced it), otherwise it will be a simple list (for
+ functions overloaded in global scope).
+
+ In the first case, TREE_VALUE (function) is the head of one of those
+ lists, and TREE_PURPOSE is the name of the function.
+
+ In the second case, TREE_PURPOSE (function) is the function's
+ name directly.
+
+ DECL is the class instance variable, usually CURRENT_CLASS_DECL. */
+
+/*
+ * [eichin:19911015.1726EST] actually return a possibly incomplete
+ * type
+ */
+tree
+build_x_function_call (function, params, decl)
+ tree function, params, decl;
+{
+ tree type;
+ int is_method;
+
+ if (function == error_mark_node)
+ return error_mark_node;
+
+ type = TREE_TYPE (function);
+ is_method = ((TREE_CODE (function) == TREE_LIST
+ && current_class_type != NULL_TREE
+ && IDENTIFIER_CLASS_VALUE (TREE_PURPOSE (function)) == function)
+ || TREE_CODE (function) == IDENTIFIER_NODE
+ || TREE_CODE (type) == METHOD_TYPE
+ || TYPE_PTRMEMFUNC_P (type));
+
+ /* Handle methods, friends, and overloaded functions, respectively. */
+ if (is_method)
+ {
+ if (TREE_CODE (function) == FUNCTION_DECL)
+ {
+ if (DECL_NAME (function))
+ function = DECL_NAME (function);
+ else
+ function = TYPE_IDENTIFIER (DECL_CLASS_CONTEXT (function));
+ }
+ else if (TREE_CODE (function) == TREE_LIST)
+ {
+#if 0
+ if (TREE_CODE (TREE_VALUE (function)) == TREE_LIST)
+ function = TREE_PURPOSE (TREE_VALUE (function));
+ else
+ function = TREE_PURPOSE (function);
+#else
+ my_friendly_assert (TREE_CODE (TREE_VALUE (function)) == FUNCTION_DECL, 312);
+ function = TREE_PURPOSE (function);
+#endif
+ }
+ else if (TREE_CODE (function) != IDENTIFIER_NODE)
+ {
+ if (TREE_CODE (function) == OFFSET_REF)
+ {
+ if (TREE_OPERAND (function, 0))
+ decl = TREE_OPERAND (function, 0);
+ }
+ /* Call via a pointer to member function. */
+ if (decl == NULL_TREE)
+ {
+ error ("pointer to member function called, but not in class scope");
+ return error_mark_node;
+ }
+ /* What other type of POINTER_TYPE could this be? */
+ if (TREE_CODE (TREE_TYPE (function)) != POINTER_TYPE
+ && ! TYPE_PTRMEMFUNC_P (TREE_TYPE (function))
+ && TREE_CODE (function) != OFFSET_REF)
+ function = build (OFFSET_REF, TREE_TYPE (type), NULL_TREE, function);
+ goto do_x_function;
+ }
+
+ /* this is an abbreviated method call.
+ must go through here in case it is a virtual function.
+ @@ Perhaps this could be optimized. */
+
+ if (decl == NULL_TREE)
+ {
+ if (current_class_type == NULL_TREE)
+ {
+ error ("object missing in call to method `%s'",
+ IDENTIFIER_POINTER (function));
+ return error_mark_node;
+ }
+ /* Yow: call from a static member function. */
+ decl = build1 (NOP_EXPR, build_pointer_type (current_class_type),
+ error_mark_node);
+ decl = build_indirect_ref (decl, NULL_PTR);
+ }
+
+ return build_method_call (decl, function, params,
+ NULL_TREE, LOOKUP_NORMAL);
+ }
+ else if (TREE_CODE (function) == COMPONENT_REF
+ && type == unknown_type_node)
+ {
+ /* Should we undo what was done in build_component_ref? */
+ if (TREE_CODE (TREE_PURPOSE (TREE_OPERAND (function, 1))) == TREE_VEC)
+ /* Get the name that build_component_ref hid. */
+ function = DECL_NAME (TREE_VALUE (TREE_OPERAND (function, 1)));
+ else
+ function = TREE_PURPOSE (TREE_OPERAND (function, 1));
+ return build_method_call (decl, function, params,
+ NULL_TREE, LOOKUP_NORMAL);
+ }
+ else if (TREE_CODE (function) == TREE_LIST)
+ {
+ if (TREE_VALUE (function) == NULL_TREE)
+ {
+ cp_error ("function `%D' declared overloaded, but no definitions appear with which to resolve it?!?",
+ TREE_PURPOSE (function));
+ return error_mark_node;
+ }
+ else
+ {
+ tree val = TREE_VALUE (function);
+
+ if (TREE_CODE (val) == TEMPLATE_DECL)
+ return build_overload_call_maybe
+ (function, params, LOOKUP_COMPLAIN, (struct candidate *)0);
+ else if (DECL_CHAIN (val) != NULL_TREE)
+ return build_overload_call
+ (function, params, LOOKUP_COMPLAIN, (struct candidate *)0);
+ else
+ my_friendly_abort (360);
+ }
+ }
+
+ do_x_function:
+ if (TREE_CODE (function) == OFFSET_REF)
+ {
+ /* If the component is a data element (or a virtual function), we play
+ games here to make things work. */
+ tree decl_addr;
+
+ if (TREE_OPERAND (function, 0))
+ decl = TREE_OPERAND (function, 0);
+ else
+ decl = C_C_D;
+
+ decl_addr = build_unary_op (ADDR_EXPR, decl, 0);
+ function = get_member_function_from_ptrfunc (&decl_addr,
+ TREE_OPERAND (function, 1));
+ params = tree_cons (NULL_TREE, decl_addr, params);
+ return build_function_call (function, params);
+ }
+
+ type = TREE_TYPE (function);
+ if (type != error_mark_node)
+ {
+ if (TREE_CODE (type) == REFERENCE_TYPE)
+ type = TREE_TYPE (type);
+
+ if (TYPE_LANG_SPECIFIC (type) && TYPE_OVERLOADS_CALL_EXPR (type))
+ return build_opfncall (CALL_EXPR, LOOKUP_NORMAL, function, params, NULL_TREE);
+ }
+
+ if (is_method)
+ {
+ tree fntype = TREE_TYPE (function);
+ tree ctypeptr;
+
+ /* Explicitly named method? */
+ if (TREE_CODE (function) == FUNCTION_DECL)
+ ctypeptr = build_pointer_type (DECL_CLASS_CONTEXT (function));
+ /* Expression with ptr-to-method type? It could either be a plain
+ usage, or it might be a case where the ptr-to-method is being
+ passed in as an argument. */
+ else if (TYPE_PTRMEMFUNC_P (fntype))
+ {
+ tree rec = TYPE_METHOD_BASETYPE (TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (fntype)));
+ ctypeptr = build_pointer_type (rec);
+ }
+ /* Unexpected node type? */
+ else
+ my_friendly_abort (116);
+ if (decl == NULL_TREE)
+ {
+ if (current_function_decl
+ && DECL_STATIC_FUNCTION_P (current_function_decl))
+ error ("invalid call to member function needing `this' in static member function scope");
+ else
+ error ("pointer to member function called, but not in class scope");
+ return error_mark_node;
+ }
+ if (TREE_CODE (TREE_TYPE (decl)) != POINTER_TYPE
+ && ! TYPE_PTRMEMFUNC_P (TREE_TYPE (decl)))
+ {
+ decl = build_unary_op (ADDR_EXPR, decl, 0);
+ decl = convert_pointer_to (TREE_TYPE (ctypeptr), decl);
+ }
+ else
+ decl = build_c_cast (ctypeptr, decl, 0);
+ params = tree_cons (NULL_TREE, decl, params);
+ }
+
+ return build_function_call (function, params);
+}
+
+/* Resolve a pointer to member function. INSTANCE is the object
+ instance to use, if the member points to a virtual member. */
+
+tree
+get_member_function_from_ptrfunc (instance_ptrptr, function)
+ tree *instance_ptrptr;
+ tree function;
+{
+ if (TREE_CODE (function) == OFFSET_REF)
+ {
+ function = TREE_OPERAND (function, 1);
+ }
+
+ if (TYPE_PTRMEMFUNC_P (TREE_TYPE (function)))
+ {
+ tree fntype, index, e1, delta, delta2, e2, e3, aref, vtbl;
+ tree instance;
+
+ tree instance_ptr = *instance_ptrptr;
+
+ if (TREE_SIDE_EFFECTS (instance_ptr))
+ instance_ptr = save_expr (instance_ptr);
+
+ if (TREE_SIDE_EFFECTS (function))
+ function = save_expr (function);
+
+ fntype = TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (function));
+ index = save_expr (build_component_ref (function,
+ index_identifier,
+ 0, 0));
+ e1 = build (GT_EXPR, boolean_type_node, index,
+ convert (delta_type_node, integer_zero_node));
+ delta = convert (ptrdiff_type_node,
+ build_component_ref (function, delta_identifier, 0, 0));
+ delta2 = DELTA2_FROM_PTRMEMFUNC (function);
+
+ /* convert down to the right base, before using the instance. */
+ instance
+ = convert_pointer_to_real (TYPE_METHOD_BASETYPE (TREE_TYPE (fntype)),
+ instance_ptr);
+ if (instance == error_mark_node)
+ return instance;
+
+ vtbl = convert_pointer_to (ptr_type_node, instance);
+ vtbl
+ = build (PLUS_EXPR,
+ build_pointer_type (build_pointer_type (vtable_entry_type)),
+ vtbl, convert (ptrdiff_type_node, delta2));
+ vtbl = build_indirect_ref (vtbl, NULL_PTR);
+ aref = build_array_ref (vtbl, build_binary_op (MINUS_EXPR,
+ index,
+ integer_one_node, 1));
+ if (! flag_vtable_thunks)
+ {
+ aref = save_expr (aref);
+
+ /* Save the intermediate result in a SAVE_EXPR so we don't have to
+ compute each component of the virtual function pointer twice. */
+ if (/* !building_cleanup && */ TREE_CODE (aref) == INDIRECT_REF)
+ TREE_OPERAND (aref, 0) = save_expr (TREE_OPERAND (aref, 0));
+
+ delta = build_binary_op (PLUS_EXPR,
+ build_conditional_expr (e1, build_component_ref (aref, delta_identifier, 0, 0), integer_zero_node),
+ delta, 1);
+ }
+
+ *instance_ptrptr = build (PLUS_EXPR, TREE_TYPE (instance_ptr),
+ instance_ptr, delta);
+ if (flag_vtable_thunks)
+ e2 = aref;
+ else
+ e2 = build_component_ref (aref, pfn_identifier, 0, 0);
+
+ e3 = PFN_FROM_PTRMEMFUNC (function);
+ TREE_TYPE (e2) = TREE_TYPE (e3);
+ function = build_conditional_expr (e1, e2, e3);
+
+ /* Make sure this doesn't get evaluated first inside one of the
+ branches of the COND_EXPR. */
+ if (TREE_CODE (instance_ptr) == SAVE_EXPR)
+ function = build (COMPOUND_EXPR, TREE_TYPE (function),
+ instance_ptr, function);
+ }
+ return function;
+}
+
+tree
+build_function_call_real (function, params, require_complete, flags)
+ tree function, params;
+ int require_complete, flags;
+{
+ register tree fntype, fndecl;
+ register tree value_type;
+ register tree coerced_params;
+ tree name = NULL_TREE, assembler_name = NULL_TREE;
+ int is_method;
+
+ /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
+ Strip such NOP_EXPRs, since FUNCTION is used in non-lvalue context. */
+ if (TREE_CODE (function) == NOP_EXPR
+ && TREE_TYPE (function) == TREE_TYPE (TREE_OPERAND (function, 0)))
+ function = TREE_OPERAND (function, 0);
+
+ if (TREE_CODE (function) == FUNCTION_DECL)
+ {
+ name = DECL_NAME (function);
+ assembler_name = DECL_ASSEMBLER_NAME (function);
+
+ GNU_xref_call (current_function_decl,
+ IDENTIFIER_POINTER (name ? name
+ : TYPE_IDENTIFIER (DECL_CLASS_CONTEXT (function))));
+ assemble_external (function);
+ fndecl = function;
+
+ /* Convert anything with function type to a pointer-to-function. */
+ if (pedantic
+ && name
+ && IDENTIFIER_LENGTH (name) == 4
+ && ! strcmp (IDENTIFIER_POINTER (name), "main")
+ && DECL_CONTEXT (function) == NULL_TREE)
+ {
+ pedwarn ("ANSI C++ forbids calling `main' from within program");
+ }
+
+ if (pedantic && DECL_THIS_INLINE (function) && ! DECL_INITIAL (function)
+ && ! DECL_ARTIFICIAL (function)
+ && ! DECL_PENDING_INLINE_INFO (function))
+ cp_pedwarn ("inline function `%#D' called before definition",
+ function);
+
+ /* Differs from default_conversion by not setting TREE_ADDRESSABLE
+ (because calling an inline function does not mean the function
+ needs to be separately compiled). */
+
+ if (DECL_INLINE (function))
+ {
+ /* Is it a synthesized method that needs to be synthesized? */
+ if (DECL_ARTIFICIAL (function) && ! flag_no_inline
+ && ! DECL_INITIAL (function)
+ /* Kludge: don't synthesize for default args. */
+ && current_function_decl)
+ synthesize_method (function);
+
+ fntype = build_type_variant (TREE_TYPE (function),
+ TREE_READONLY (function),
+ TREE_THIS_VOLATILE (function));
+ function = build1 (ADDR_EXPR, build_pointer_type (fntype), function);
+ }
+ else
+ {
+ assemble_external (function);
+ TREE_USED (function) = 1;
+ function = default_conversion (function);
+ }
+ }
+ else
+ {
+ fndecl = NULL_TREE;
+
+ /* Convert anything with function type to a pointer-to-function. */
+ if (function == error_mark_node)
+ return error_mark_node;
+ function = default_conversion (function);
+ }
+
+ fntype = TREE_TYPE (function);
+
+ if (TYPE_PTRMEMFUNC_P (fntype))
+ {
+ tree instance_ptr = build_unary_op (ADDR_EXPR, C_C_D, 0);
+ fntype = TYPE_PTRMEMFUNC_FN_TYPE (fntype);
+ function = get_member_function_from_ptrfunc (&instance_ptr, function);
+ }
+
+ is_method = (TREE_CODE (fntype) == POINTER_TYPE
+ && TREE_CODE (TREE_TYPE (fntype)) == METHOD_TYPE);
+
+ if (!((TREE_CODE (fntype) == POINTER_TYPE
+ && TREE_CODE (TREE_TYPE (fntype)) == FUNCTION_TYPE)
+ || is_method))
+ {
+ cp_error ("`%E' cannot be used as a function", function);
+ return error_mark_node;
+ }
+
+ /* fntype now gets the type of function pointed to. */
+ fntype = TREE_TYPE (fntype);
+
+ /* Convert the parameters to the types declared in the
+ function prototype, or apply default promotions. */
+
+ if (flags & LOOKUP_COMPLAIN)
+ coerced_params = convert_arguments (NULL_TREE, TYPE_ARG_TYPES (fntype),
+ params, fndecl, LOOKUP_NORMAL);
+ else
+ coerced_params = convert_arguments (NULL_TREE, TYPE_ARG_TYPES (fntype),
+ params, fndecl, 0);
+
+ if (coerced_params == error_mark_node)
+ if (flags & LOOKUP_SPECULATIVELY)
+ return NULL_TREE;
+ else
+ return error_mark_node;
+
+ /* Check for errors in format strings. */
+
+ if (warn_format && (name || assembler_name))
+ check_function_format (name, assembler_name, coerced_params);
+
+ /* Recognize certain built-in functions so we can make tree-codes
+ other than CALL_EXPR. We do this when it enables fold-const.c
+ to do something useful. */
+
+ if (TREE_CODE (function) == ADDR_EXPR
+ && TREE_CODE (TREE_OPERAND (function, 0)) == FUNCTION_DECL
+ && DECL_BUILT_IN (TREE_OPERAND (function, 0)))
+ switch (DECL_FUNCTION_CODE (TREE_OPERAND (function, 0)))
+ {
+ case BUILT_IN_ABS:
+ case BUILT_IN_LABS:
+ case BUILT_IN_FABS:
+ if (coerced_params == 0)
+ return integer_zero_node;
+ return build_unary_op (ABS_EXPR, TREE_VALUE (coerced_params), 0);
+ }
+
+ /* C++ */
+ value_type = TREE_TYPE (fntype) ? TREE_TYPE (fntype) : void_type_node;
+ {
+ register tree result =
+ build (CALL_EXPR, value_type,
+ function, coerced_params, NULL_TREE);
+
+ TREE_SIDE_EFFECTS (result) = 1;
+
+ if (! require_complete)
+ return convert_from_reference (result);
+ if (value_type == void_type_node)
+ return result;
+ result = require_complete_type (result);
+ return convert_from_reference (result);
+ }
+}
+
+tree
+build_function_call (function, params)
+ tree function, params;
+{
+ return build_function_call_real (function, params, 1, LOOKUP_NORMAL);
+}
+
+tree
+build_function_call_maybe (function, params)
+ tree function, params;
+{
+ return build_function_call_real (function, params, 0, 0);
+}
+
+
+/* Convert the actual parameter expressions in the list VALUES
+ to the types in the list TYPELIST.
+ If parmdecls is exhausted, or when an element has NULL as its type,
+ perform the default conversions.
+
+ RETURN_LOC is the location of the return value, if known, NULL_TREE
+ otherwise. This is useful in the case where we can avoid creating
+ a temporary variable in the case where we can initialize the return
+ value directly. If we are not eliding constructors, then we set this
+ to NULL_TREE to avoid this avoidance.
+
+ NAME is an IDENTIFIER_NODE or 0. It is used only for error messages.
+
+ This is also where warnings about wrong number of args are generated.
+
+ Return a list of expressions for the parameters as converted.
+
+ Both VALUES and the returned value are chains of TREE_LIST nodes
+ with the elements of the list in the TREE_VALUE slots of those nodes.
+
+ In C++, unspecified trailing parameters can be filled in with their
+ default arguments, if such were specified. Do so here. */
+
+tree
+convert_arguments (return_loc, typelist, values, fndecl, flags)
+ tree return_loc, typelist, values, fndecl;
+ int flags;
+{
+ extern tree gc_protect_fndecl;
+ register tree typetail, valtail;
+ register tree result = NULL_TREE;
+ char *called_thing;
+ int i = 0;
+
+ if (! flag_elide_constructors)
+ return_loc = 0;
+
+ if (fndecl)
+ {
+ if (TREE_CODE (TREE_TYPE (fndecl)) == METHOD_TYPE)
+ {
+ if (DECL_NAME (fndecl) == NULL_TREE
+ || IDENTIFIER_HAS_TYPE_VALUE (DECL_NAME (fndecl)))
+ called_thing = "constructor";
+ else
+ called_thing = "member function";
+ }
+ else
+ called_thing = "function";
+ }
+
+ for (valtail = values, typetail = typelist;
+ valtail;
+ valtail = TREE_CHAIN (valtail), i++)
+ {
+ register tree type = typetail ? TREE_VALUE (typetail) : 0;
+ register tree val = TREE_VALUE (valtail);
+
+ if (val == error_mark_node)
+ return error_mark_node;
+
+ if (type == void_type_node)
+ {
+ if (fndecl)
+ {
+ char *buf = (char *)alloca (40 + strlen (called_thing));
+ sprintf (buf, "too many arguments to %s `%%s'", called_thing);
+ error_with_decl (fndecl, buf);
+ error ("at this point in file");
+ }
+ else
+ error ("too many arguments to function");
+ /* In case anybody wants to know if this argument
+ list is valid. */
+ if (result)
+ TREE_TYPE (tree_last (result)) = error_mark_node;
+ break;
+ }
+
+ /* The tree type of the parameter being passed may not yet be
+ known. In this case, its type is TYPE_UNKNOWN, and will
+ be instantiated by the type given by TYPE. If TYPE
+ is also NULL, the tree type of VAL is ERROR_MARK_NODE. */
+ if (type && type_unknown_p (val))
+ val = require_instantiated_type (type, val, integer_zero_node);
+ else if (type_unknown_p (val))
+ {
+ /* Strip the `&' from an overloaded FUNCTION_DECL. */
+ if (TREE_CODE (val) == ADDR_EXPR)
+ val = TREE_OPERAND (val, 0);
+ if (TREE_CODE (val) == TREE_LIST
+ && TREE_CHAIN (val) == NULL_TREE
+ && TREE_TYPE (TREE_VALUE (val)) != NULL_TREE
+ && (TREE_TYPE (val) == unknown_type_node
+ || DECL_CHAIN (TREE_VALUE (val)) == NULL_TREE))
+ /* Instantiates automatically. */
+ val = TREE_VALUE (val);
+ else
+ {
+ error ("insufficient type information in parameter list");
+ val = integer_zero_node;
+ }
+ }
+ else if (TREE_CODE (val) == OFFSET_REF
+ && TREE_CODE (TREE_TYPE (val)) == METHOD_TYPE)
+ {
+ /* This is unclean. Should be handled elsewhere. */
+ val = build_unary_op (ADDR_EXPR, val, 0);
+ }
+ else if (TREE_CODE (val) == OFFSET_REF)
+ val = resolve_offset_ref (val);
+
+ {
+#if 0
+ /* This code forces the assumption that if we have a ptr-to-func
+ type in an arglist, that every routine that wants to check
+ its validity has done so, and thus we need not do any
+ more conversion. I don't remember why this is necessary. */
+ else if (TREE_CODE (ttype) == FUNCTION_TYPE
+ && (type == NULL
+ || TREE_CODE (TREE_TYPE (type)) == FUNCTION_TYPE
+ || TREE_CODE (TREE_TYPE (type)) == VOID_TYPE))
+ {
+ type = build_pointer_type (ttype);
+ }
+#endif
+ }
+
+ /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
+ Strip such NOP_EXPRs, since VAL is used in non-lvalue context. */
+ if (TREE_CODE (val) == NOP_EXPR
+ && TREE_TYPE (val) == TREE_TYPE (TREE_OPERAND (val, 0))
+ && (type == 0 || TREE_CODE (type) != REFERENCE_TYPE))
+ val = TREE_OPERAND (val, 0);
+
+ if (type == 0 || TREE_CODE (type) != REFERENCE_TYPE)
+ {
+ if (TREE_CODE (TREE_TYPE (val)) == ARRAY_TYPE
+ || TREE_CODE (TREE_TYPE (val)) == FUNCTION_TYPE
+ || TREE_CODE (TREE_TYPE (val)) == METHOD_TYPE)
+ val = default_conversion (val);
+
+ val = require_complete_type (val);
+ }
+
+ if (val == error_mark_node)
+ return error_mark_node;
+
+ if (type != 0)
+ {
+ /* Formal parm type is specified by a function prototype. */
+ tree parmval;
+
+ if (TYPE_SIZE (type) == 0)
+ {
+ error ("parameter type of called function is incomplete");
+ parmval = val;
+ }
+ else
+ {
+#if 0 && defined (PROMOTE_PROTOTYPES)
+ /* This breaks user-defined conversions. */
+ /* Rather than truncating and then reextending,
+ convert directly to int, if that's the type we will want. */
+ if (! flag_traditional
+ && (TREE_CODE (type) == INTEGER_TYPE
+ || TREE_CODE (type) == ENUMERAL_TYPE)
+ && (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)))
+ type = integer_type_node;
+#endif
+ parmval = convert_for_initialization (return_loc, type, val, flags,
+ "argument passing", fndecl, i);
+#ifdef PROMOTE_PROTOTYPES
+ if ((TREE_CODE (type) == INTEGER_TYPE
+ || TREE_CODE (type) == ENUMERAL_TYPE)
+ && (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)))
+ parmval = default_conversion (parmval);
+#endif
+ }
+
+ if (parmval == error_mark_node)
+ return error_mark_node;
+
+ result = tree_cons (NULL_TREE, parmval, result);
+ }
+ else
+ {
+ if (TREE_CODE (TREE_TYPE (val)) == REFERENCE_TYPE)
+ val = convert_from_reference (val);
+
+ if (TREE_CODE (TREE_TYPE (val)) == REAL_TYPE
+ && (TYPE_PRECISION (TREE_TYPE (val))
+ < TYPE_PRECISION (double_type_node)))
+ /* Convert `float' to `double'. */
+ result = tree_cons (NULL_TREE, convert (double_type_node, val), result);
+ else if (TYPE_LANG_SPECIFIC (TREE_TYPE (val))
+ && ! TYPE_HAS_TRIVIAL_INIT_REF (TREE_TYPE (val)))
+ {
+ cp_warning ("cannot pass objects of type `%T' through `...'",
+ TREE_TYPE (val));
+ result = tree_cons (NULL_TREE, val, result);
+ }
+ else
+ /* Convert `short' and `char' to full-size `int'. */
+ result = tree_cons (NULL_TREE, default_conversion (val), result);
+ }
+
+ if (flag_gc
+ /* There are certain functions for which we don't need
+ to protect our arguments. GC_PROTECT_FNDECL is one. */
+ && fndecl != gc_protect_fndecl
+ && type_needs_gc_entry (TREE_TYPE (TREE_VALUE (result)))
+ && ! value_safe_from_gc (NULL_TREE, TREE_VALUE (result)))
+ /* This will build a temporary variable whose cleanup is
+ to clear the obstack entry. */
+ TREE_VALUE (result) = protect_value_from_gc (NULL_TREE,
+ TREE_VALUE (result));
+
+ if (typetail)
+ typetail = TREE_CHAIN (typetail);
+ }
+
+ if (typetail != 0 && typetail != void_list_node)
+ {
+ /* See if there are default arguments that can be used */
+ if (TREE_PURPOSE (typetail))
+ {
+ for (; typetail != void_list_node; ++i)
+ {
+ tree type = TREE_VALUE (typetail);
+ tree val = break_out_target_exprs (TREE_PURPOSE (typetail));
+ tree parmval;
+
+ if (val == NULL_TREE)
+ parmval = error_mark_node;
+ else if (TREE_CODE (val) == CONSTRUCTOR)
+ {
+ parmval = digest_init (type, val, (tree *)0);
+ parmval = convert_for_initialization (return_loc, type, parmval, flags,
+ "default constructor", fndecl, i);
+ }
+ else
+ {
+ /* This could get clobbered by the following call. */
+ if (TREE_HAS_CONSTRUCTOR (val))
+ val = copy_node (val);
+
+ parmval = convert_for_initialization (return_loc, type, val, flags,
+ "default argument", fndecl, i);
+#ifdef PROMOTE_PROTOTYPES
+ if ((TREE_CODE (type) == INTEGER_TYPE
+ || TREE_CODE (type) == ENUMERAL_TYPE)
+ && (TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node)))
+ parmval = default_conversion (parmval);
+#endif
+ }
+
+ if (parmval == error_mark_node)
+ return error_mark_node;
+
+ if (flag_gc
+ && type_needs_gc_entry (TREE_TYPE (parmval))
+ && ! value_safe_from_gc (NULL_TREE, parmval))
+ parmval = protect_value_from_gc (NULL_TREE, parmval);
+
+ result = tree_cons (0, parmval, result);
+ typetail = TREE_CHAIN (typetail);
+ /* ends with `...'. */
+ if (typetail == NULL_TREE)
+ break;
+ }
+ }
+ else
+ {
+ if (fndecl)
+ {
+ char *buf = (char *)alloca (32 + strlen (called_thing));
+ sprintf (buf, "too few arguments to %s `%%#D'", called_thing);
+ cp_error_at (buf, fndecl);
+ error ("at this point in file");
+ }
+ else
+ error ("too few arguments to function");
+ return error_mark_list;
+ }
+ }
+
+ return nreverse (result);
+}
+
+/* Build a binary-operation expression, after performing default
+ conversions on the operands. CODE is the kind of expression to build. */
+
+tree
+build_x_binary_op (code, arg1, arg2)
+ enum tree_code code;
+ tree arg1, arg2;
+{
+ tree rval = build_opfncall (code, LOOKUP_SPECULATIVELY,
+ arg1, arg2, NULL_TREE);
+ if (rval)
+ return build_opfncall (code, LOOKUP_NORMAL, arg1, arg2, NULL_TREE);
+ if (code == MEMBER_REF)
+ return build_m_component_ref (build_indirect_ref (arg1, NULL_PTR),
+ arg2);
+ return build_binary_op (code, arg1, arg2, 1);
+}
+
+tree
+build_binary_op (code, arg1, arg2, convert_p)
+ enum tree_code code;
+ tree arg1, arg2;
+ int convert_p;
+{
+ tree args[2];
+
+ args[0] = arg1;
+ args[1] = arg2;
+
+ if (convert_p)
+ {
+ tree args_save [2];
+ tree type0, type1;
+ args[0] = decay_conversion (args[0]);
+ args[1] = decay_conversion (args[1]);
+
+ if (args[0] == error_mark_node || args[1] == error_mark_node)
+ return error_mark_node;
+
+ type0 = TREE_TYPE (args[0]);
+ type1 = TREE_TYPE (args[1]);
+
+ if (type_unknown_p (args[0]))
+ {
+ args[0] = instantiate_type (type1, args[0], 1);
+ args[0] = decay_conversion (args[0]);
+ }
+ else if (type_unknown_p (args[1]))
+ {
+ args[1] = require_instantiated_type (type0, args[1],
+ error_mark_node);
+ args[1] = decay_conversion (args[1]);
+ }
+
+ if (IS_AGGR_TYPE (type0) || IS_AGGR_TYPE (type1))
+ {
+ /* Try to convert this to something reasonable. */
+ if (! build_default_binary_type_conversion(code, &args[0], &args[1]))
+ {
+ cp_error ("no match for `%O(%#T, %#T)'", code,
+ TREE_TYPE (arg1), TREE_TYPE (arg2));
+ return error_mark_node;
+ }
+ }
+ }
+ return build_binary_op_nodefault (code, args[0], args[1], code);
+}
+
+/* Build a binary-operation expression without default conversions.
+ CODE is the kind of expression to build.
+ This function differs from `build' in several ways:
+ the data type of the result is computed and recorded in it,
+ warnings are generated if arg data types are invalid,
+ special handling for addition and subtraction of pointers is known,
+ and some optimization is done (operations on narrow ints
+ are done in the narrower type when that gives the same result).
+ Constant folding is also done before the result is returned.
+
+ ERROR_CODE is the code that determines what to say in error messages.
+ It is usually, but not always, the same as CODE.
+
+ Note that the operands will never have enumeral types
+ because either they have just had the default conversions performed
+ or they have both just been converted to some other type in which
+ the arithmetic is to be done.
+
+ C++: must do special pointer arithmetic when implementing
+ multiple inheritance, and deal with pointer to member functions. */
+
+tree
+build_binary_op_nodefault (code, orig_op0, orig_op1, error_code)
+ enum tree_code code;
+ tree orig_op0, orig_op1;
+ enum tree_code error_code;
+{
+ tree op0, op1;
+ register enum tree_code code0, code1;
+ tree type0, type1;
+
+ /* Expression code to give to the expression when it is built.
+ Normally this is CODE, which is what the caller asked for,
+ but in some special cases we change it. */
+ register enum tree_code resultcode = code;
+
+ /* Data type in which the computation is to be performed.
+ In the simplest cases this is the common type of the arguments. */
+ register tree result_type = NULL;
+
+ /* Nonzero means operands have already been type-converted
+ in whatever way is necessary.
+ Zero means they need to be converted to RESULT_TYPE. */
+ int converted = 0;
+
+ /* Nonzero means create the expression with this type, rather than
+ RESULT_TYPE. */
+ tree build_type = 0;
+
+ /* Nonzero means after finally constructing the expression
+ convert it to this type. */
+ tree final_type = 0;
+
+ /* Nonzero if this is an operation like MIN or MAX which can
+ safely be computed in short if both args are promoted shorts.
+ Also implies COMMON.
+ -1 indicates a bitwise operation; this makes a difference
+ in the exact conditions for when it is safe to do the operation
+ in a narrower mode. */
+ int shorten = 0;
+
+ /* Nonzero if this is a comparison operation;
+ if both args are promoted shorts, compare the original shorts.
+ Also implies COMMON. */
+ int short_compare = 0;
+
+ /* Nonzero if this is a right-shift operation, which can be computed on the
+ original short and then promoted if the operand is a promoted short. */
+ int short_shift = 0;
+
+ /* Nonzero means set RESULT_TYPE to the common type of the args. */
+ int common = 0;
+
+ /* Apply default conversions. */
+ if (code == TRUTH_AND_EXPR || code == TRUTH_ANDIF_EXPR
+ || code == TRUTH_OR_EXPR || code == TRUTH_ORIF_EXPR
+ || code == TRUTH_XOR_EXPR)
+ {
+ op0 = decay_conversion (orig_op0);
+ op1 = decay_conversion (orig_op1);
+ }
+ else
+ {
+ op0 = default_conversion (orig_op0);
+ op1 = default_conversion (orig_op1);
+ }
+
+ type0 = TREE_TYPE (op0);
+ type1 = TREE_TYPE (op1);
+
+ /* The expression codes of the data types of the arguments tell us
+ whether the arguments are integers, floating, pointers, etc. */
+ code0 = TREE_CODE (type0);
+ code1 = TREE_CODE (type1);
+
+ /* Strip NON_LVALUE_EXPRs, etc., since we aren't using as an lvalue. */
+ STRIP_TYPE_NOPS (op0);
+ STRIP_TYPE_NOPS (op1);
+
+ /* If an error was already reported for one of the arguments,
+ avoid reporting another error. */
+
+ if (code0 == ERROR_MARK || code1 == ERROR_MARK)
+ return error_mark_node;
+
+ switch (code)
+ {
+ case PLUS_EXPR:
+ /* Handle the pointer + int case. */
+ if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
+ return pointer_int_sum (PLUS_EXPR, op0, op1);
+ else if (code1 == POINTER_TYPE && code0 == INTEGER_TYPE)
+ return pointer_int_sum (PLUS_EXPR, op1, op0);
+ else
+ common = 1;
+ break;
+
+ case MINUS_EXPR:
+ /* Subtraction of two similar pointers.
+ We must subtract them as integers, then divide by object size. */
+ if (code0 == POINTER_TYPE && code1 == POINTER_TYPE
+ && comp_target_types (type0, type1, 1))
+ return pointer_diff (op0, op1);
+ /* Handle pointer minus int. Just like pointer plus int. */
+ else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
+ return pointer_int_sum (MINUS_EXPR, op0, op1);
+ else
+ common = 1;
+ break;
+
+ case MULT_EXPR:
+ common = 1;
+ break;
+
+ case TRUNC_DIV_EXPR:
+ case CEIL_DIV_EXPR:
+ case FLOOR_DIV_EXPR:
+ case ROUND_DIV_EXPR:
+ case EXACT_DIV_EXPR:
+ if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE)
+ && (code1 == INTEGER_TYPE || code1 == REAL_TYPE))
+ {
+ if (TREE_CODE (op1) == INTEGER_CST && integer_zerop (op1))
+ cp_warning ("division by zero in `%E / 0'", op0);
+ else if (TREE_CODE (op1) == REAL_CST && real_zerop (op1))
+ cp_warning ("division by zero in `%E / 0.'", op0);
+
+ if (!(code0 == INTEGER_TYPE && code1 == INTEGER_TYPE))
+ resultcode = RDIV_EXPR;
+ else
+ /* When dividing two signed integers, we have to promote to int.
+ unless we divide by a constant != -1. Note that default
+ conversion will have been performed on the operands at this
+ point, so we have to dig out the original type to find out if
+ it was unsigned. */
+ shorten = ((TREE_CODE (op0) == NOP_EXPR
+ && TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op0, 0))))
+ || (TREE_CODE (op1) == INTEGER_CST
+ && (TREE_INT_CST_LOW (op1) != -1
+ || TREE_INT_CST_HIGH (op1) != -1)));
+ common = 1;
+ }
+ break;
+
+ case BIT_AND_EXPR:
+ case BIT_ANDTC_EXPR:
+ case BIT_IOR_EXPR:
+ case BIT_XOR_EXPR:
+ if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
+ shorten = -1;
+ /* If one operand is a constant, and the other is a short type
+ that has been converted to an int,
+ really do the work in the short type and then convert the
+ result to int. If we are lucky, the constant will be 0 or 1
+ in the short type, making the entire operation go away. */
+ if (TREE_CODE (op0) == INTEGER_CST
+ && TREE_CODE (op1) == NOP_EXPR
+ && TYPE_PRECISION (type1) > TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op1, 0)))
+ && TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op1, 0))))
+ {
+ final_type = result_type;
+ op1 = TREE_OPERAND (op1, 0);
+ result_type = TREE_TYPE (op1);
+ }
+ if (TREE_CODE (op1) == INTEGER_CST
+ && TREE_CODE (op0) == NOP_EXPR
+ && TYPE_PRECISION (type0) > TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (op0, 0)))
+ && TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op0, 0))))
+ {
+ final_type = result_type;
+ op0 = TREE_OPERAND (op0, 0);
+ result_type = TREE_TYPE (op0);
+ }
+ break;
+
+ case TRUNC_MOD_EXPR:
+ case FLOOR_MOD_EXPR:
+ if (code1 == INTEGER_TYPE && integer_zerop (op1))
+ cp_warning ("division by zero in `%E % 0'", op0);
+ else if (code1 == REAL_TYPE && real_zerop (op1))
+ cp_warning ("division by zero in `%E % 0.'", op0);
+
+ if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
+ {
+ /* Although it would be tempting to shorten always here, that loses
+ on some targets, since the modulo instruction is undefined if the
+ quotient can't be represented in the computation mode. We shorten
+ only if unsigned or if dividing by something we know != -1. */
+ shorten = ((TREE_CODE (op0) == NOP_EXPR
+ && TREE_UNSIGNED (TREE_TYPE (TREE_OPERAND (op0, 0))))
+ || (TREE_CODE (op1) == INTEGER_CST
+ && (TREE_INT_CST_LOW (op1) != -1
+ || TREE_INT_CST_HIGH (op1) != -1)));
+ common = 1;
+ }
+ break;
+
+ case TRUTH_ANDIF_EXPR:
+ case TRUTH_ORIF_EXPR:
+ case TRUTH_AND_EXPR:
+ case TRUTH_OR_EXPR:
+ result_type = boolean_type_node;
+ break;
+
+ /* Shift operations: result has same type as first operand;
+ always convert second operand to int.
+ Also set SHORT_SHIFT if shifting rightward. */
+
+ case RSHIFT_EXPR:
+ if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
+ {
+ result_type = type0;
+ if (TREE_CODE (op1) == INTEGER_CST)
+ {
+ if (tree_int_cst_lt (op1, integer_zero_node))
+ warning ("right shift count is negative");
+ else
+ {
+ if (TREE_INT_CST_LOW (op1) | TREE_INT_CST_HIGH (op1))
+ short_shift = 1;
+ if (TREE_INT_CST_HIGH (op1) != 0
+ || ((unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (op1)
+ >= TYPE_PRECISION (type0)))
+ warning ("right shift count >= width of type");
+ }
+ }
+ /* Convert the shift-count to an integer, regardless of
+ size of value being shifted. */
+ if (TYPE_MAIN_VARIANT (TREE_TYPE (op1)) != integer_type_node)
+ op1 = convert (integer_type_node, op1);
+ /* Avoid converting op1 to result_type later. */
+ converted = 1;
+ }
+ break;
+
+ case LSHIFT_EXPR:
+ if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
+ {
+ result_type = type0;
+ if (TREE_CODE (op1) == INTEGER_CST)
+ {
+ if (tree_int_cst_lt (op1, integer_zero_node))
+ warning ("left shift count is negative");
+ else if (TREE_INT_CST_HIGH (op1) != 0
+ || ((unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (op1)
+ >= TYPE_PRECISION (type0)))
+ warning ("left shift count >= width of type");
+ }
+ /* Convert the shift-count to an integer, regardless of
+ size of value being shifted. */
+ if (TYPE_MAIN_VARIANT (TREE_TYPE (op1)) != integer_type_node)
+ op1 = convert (integer_type_node, op1);
+ /* Avoid converting op1 to result_type later. */
+ converted = 1;
+ }
+ break;
+
+ case RROTATE_EXPR:
+ case LROTATE_EXPR:
+ if (code0 == INTEGER_TYPE && code1 == INTEGER_TYPE)
+ {
+ result_type = type0;
+ if (TREE_CODE (op1) == INTEGER_CST)
+ {
+ if (tree_int_cst_lt (op1, integer_zero_node))
+ warning ("%s rotate count is negative",
+ (code == LROTATE_EXPR) ? "left" : "right");
+ else if (TREE_INT_CST_HIGH (op1) != 0
+ || ((unsigned HOST_WIDE_INT) TREE_INT_CST_LOW (op1)
+ >= TYPE_PRECISION (type0)))
+ warning ("%s rotate count >= width of type",
+ (code == LROTATE_EXPR) ? "left" : "right");
+ }
+ /* Convert the shift-count to an integer, regardless of
+ size of value being shifted. */
+ if (TYPE_MAIN_VARIANT (TREE_TYPE (op1)) != integer_type_node)
+ op1 = convert (integer_type_node, op1);
+ }
+ break;
+
+ case EQ_EXPR:
+ case NE_EXPR:
+ build_type = boolean_type_node;
+ if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE)
+ && (code1 == INTEGER_TYPE || code1 == REAL_TYPE))
+ short_compare = 1;
+ else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
+ {
+ register tree tt0 = TYPE_MAIN_VARIANT (TREE_TYPE (type0));
+ register tree tt1 = TYPE_MAIN_VARIANT (TREE_TYPE (type1));
+
+ if (comp_target_types (type0, type1, 1))
+ result_type = common_type (type0, type1);
+ else if (tt0 == void_type_node)
+ {
+ if (pedantic && TREE_CODE (tt1) == FUNCTION_TYPE
+ && tree_int_cst_lt (TYPE_SIZE (type0), TYPE_SIZE (type1)))
+ pedwarn ("ANSI C++ forbids comparison of `void *' with function pointer");
+ else if (TREE_CODE (tt1) == OFFSET_TYPE)
+ pedwarn ("ANSI C++ forbids conversion of a pointer to member to `void *'");
+ }
+ else if (tt1 == void_type_node)
+ {
+ if (pedantic && TREE_CODE (tt0) == FUNCTION_TYPE
+ && tree_int_cst_lt (TYPE_SIZE (type1), TYPE_SIZE (type0)))
+ pedwarn ("ANSI C++ forbids comparison of `void *' with function pointer");
+ }
+ else
+ cp_pedwarn ("comparison of distinct pointer types `%T' and `%T' lacks a cast",
+ type0, type1);
+
+ if (result_type == NULL_TREE)
+ result_type = ptr_type_node;
+ }
+ else if (code0 == POINTER_TYPE && TREE_CODE (op1) == INTEGER_CST
+ && integer_zerop (op1))
+ result_type = type0;
+ else if (code1 == POINTER_TYPE && TREE_CODE (op0) == INTEGER_CST
+ && integer_zerop (op0))
+ result_type = type1;
+ else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
+ {
+ result_type = type0;
+ error ("ANSI C++ forbids comparison between pointer and integer");
+ }
+ else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE)
+ {
+ result_type = type1;
+ error ("ANSI C++ forbids comparison between pointer and integer");
+ }
+ else if (TYPE_PTRMEMFUNC_P (type0) && TREE_CODE (op1) == INTEGER_CST
+ && integer_zerop (op1))
+ {
+ op0 = build_component_ref (op0, index_identifier, 0, 0);
+ op1 = integer_zero_node;
+ result_type = TREE_TYPE (op0);
+ }
+ else if (TYPE_PTRMEMFUNC_P (type1) && TREE_CODE (op0) == INTEGER_CST
+ && integer_zerop (op0))
+ {
+ op0 = build_component_ref (op1, index_identifier, 0, 0);
+ op1 = integer_zero_node;
+ result_type = TREE_TYPE (op0);
+ }
+ else if (TYPE_PTRMEMFUNC_P (type0) && TYPE_PTRMEMFUNC_P (type1)
+ && (TYPE_PTRMEMFUNC_FN_TYPE (type0)
+ == TYPE_PTRMEMFUNC_FN_TYPE (type1)))
+ {
+ /* The code we generate for the test is:
+
+ (op0.index == op1.index
+ && ((op1.index != -1 && op0.delta2 == op1.delta2)
+ || op0.pfn == op1.pfn)) */
+
+ tree index0 = build_component_ref (op0, index_identifier, 0, 0);
+ tree index1 = save_expr (build_component_ref (op1, index_identifier, 0, 0));
+ tree pfn0 = PFN_FROM_PTRMEMFUNC (op0);
+ tree pfn1 = PFN_FROM_PTRMEMFUNC (op1);
+ tree delta20 = DELTA2_FROM_PTRMEMFUNC (op0);
+ tree delta21 = DELTA2_FROM_PTRMEMFUNC (op1);
+ tree e1, e2, e3;
+ tree integer_neg_one_node
+ = build_binary_op (MINUS_EXPR, integer_zero_node, integer_one_node, 1);
+ e1 = build_binary_op (EQ_EXPR, index0, index1, 1);
+ e2 = build_binary_op (NE_EXPR, index1, integer_neg_one_node, 1);
+ e2 = build_binary_op (TRUTH_ANDIF_EXPR, e2, build_binary_op (EQ_EXPR, delta20, delta21, 1), 1);
+ e3 = build_binary_op (EQ_EXPR, pfn0, pfn1, 1);
+ e2 = build_binary_op (TRUTH_ORIF_EXPR, e2, e3, 1);
+ e2 = build_binary_op (TRUTH_ANDIF_EXPR, e1, e2, 1);
+ if (code == EQ_EXPR)
+ return e2;
+ return build_binary_op (EQ_EXPR, e2, integer_zero_node, 1);
+ }
+ else if (TYPE_PTRMEMFUNC_P (type0)
+ && TYPE_PTRMEMFUNC_FN_TYPE (type0) == type1)
+ {
+ tree index0 = build_component_ref (op0, index_identifier, 0, 0);
+ tree index1;
+ tree pfn0 = PFN_FROM_PTRMEMFUNC (op0);
+ tree delta20 = DELTA2_FROM_PTRMEMFUNC (op0);
+ tree delta21 = integer_zero_node;
+ tree e1, e2, e3;
+ tree integer_neg_one_node
+ = build_binary_op (MINUS_EXPR, integer_zero_node, integer_one_node, 1);
+ if (TREE_CODE (TREE_OPERAND (op1, 0)) == FUNCTION_DECL
+ && DECL_VINDEX (TREE_OPERAND (op1, 0)))
+ {
+ /* Map everything down one to make room for the null pointer to member. */
+ index1 = size_binop (PLUS_EXPR,
+ DECL_VINDEX (TREE_OPERAND (op1, 0)),
+ integer_one_node);
+ op1 = integer_zero_node;
+ delta21 = CLASSTYPE_VFIELD (TYPE_METHOD_BASETYPE (TREE_TYPE (type1)));
+ delta21 = DECL_FIELD_BITPOS (delta21);
+ delta21 = size_binop (FLOOR_DIV_EXPR, delta21, size_int (BITS_PER_UNIT));
+ }
+ else
+ index1 = integer_neg_one_node;
+ {
+ tree nop1 = build1 (NOP_EXPR, TYPE_PTRMEMFUNC_FN_TYPE (type0), op1);
+ TREE_CONSTANT (nop1) = TREE_CONSTANT (op1);
+ op1 = nop1;
+ }
+ e1 = build_binary_op (EQ_EXPR, index0, index1, 1);
+ e2 = build_binary_op (NE_EXPR, index1, integer_neg_one_node, 1);
+ e2 = build_binary_op (TRUTH_ANDIF_EXPR, e2, build_binary_op (EQ_EXPR, delta20, delta21, 1), 1);
+ e3 = build_binary_op (EQ_EXPR, pfn0, op1, 1);
+ e2 = build_binary_op (TRUTH_ORIF_EXPR, e2, e3, 1);
+ e2 = build_binary_op (TRUTH_ANDIF_EXPR, e1, e2, 1);
+ if (code == EQ_EXPR)
+ return e2;
+ return build_binary_op (EQ_EXPR, e2, integer_zero_node, 1);
+ }
+ else if (TYPE_PTRMEMFUNC_P (type1)
+ && TYPE_PTRMEMFUNC_FN_TYPE (type1) == type0)
+ {
+ return build_binary_op (code, op1, op0, 1);
+ }
+ break;
+
+ case MAX_EXPR:
+ case MIN_EXPR:
+ if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE)
+ && (code1 == INTEGER_TYPE || code1 == REAL_TYPE))
+ shorten = 1;
+ else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
+ {
+ if (comp_target_types (type0, type1, 1))
+ result_type = common_type (type0, type1);
+ else
+ {
+ cp_pedwarn ("comparison of distinct pointer types `%T' and `%T' lacks a cast",
+ type0, type1);
+ result_type = ptr_type_node;
+ }
+ }
+ break;
+
+ case LE_EXPR:
+ case GE_EXPR:
+ case LT_EXPR:
+ case GT_EXPR:
+ build_type = boolean_type_node;
+ if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE)
+ && (code1 == INTEGER_TYPE || code1 == REAL_TYPE))
+ short_compare = 1;
+ else if (code0 == POINTER_TYPE && code1 == POINTER_TYPE)
+ {
+ if (comp_target_types (type0, type1, 1))
+ result_type = common_type (type0, type1);
+ else
+ {
+ cp_pedwarn ("comparison of distinct pointer types `%T' and `%T' lacks a cast",
+ type0, type1);
+ result_type = ptr_type_node;
+ }
+ }
+ else if (code0 == POINTER_TYPE && TREE_CODE (op1) == INTEGER_CST
+ && integer_zerop (op1))
+ result_type = type0;
+ else if (code1 == POINTER_TYPE && TREE_CODE (op0) == INTEGER_CST
+ && integer_zerop (op0))
+ result_type = type1;
+ else if (code0 == POINTER_TYPE && code1 == INTEGER_TYPE)
+ {
+ result_type = type0;
+ if (pedantic)
+ pedwarn ("ANSI C++ forbids comparison between pointer and integer");
+ else if (! flag_traditional)
+ warning ("comparison between pointer and integer");
+ }
+ else if (code0 == INTEGER_TYPE && code1 == POINTER_TYPE)
+ {
+ result_type = type1;
+ if (pedantic)
+ pedwarn ("ANSI C++ forbids comparison between pointer and integer");
+ else if (! flag_traditional)
+ warning ("comparison between pointer and integer");
+ }
+ break;
+ }
+
+ if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE)
+ && (code1 == INTEGER_TYPE || code1 == REAL_TYPE))
+ {
+ if (shorten || common || short_compare)
+ result_type = common_type (type0, type1);
+
+ /* For certain operations (which identify themselves by shorten != 0)
+ if both args were extended from the same smaller type,
+ do the arithmetic in that type and then extend.
+
+ shorten !=0 and !=1 indicates a bitwise operation.
+ For them, this optimization is safe only if
+ both args are zero-extended or both are sign-extended.
+ Otherwise, we might change the result.
+ Eg, (short)-1 | (unsigned short)-1 is (int)-1
+ but calculated in (unsigned short) it would be (unsigned short)-1. */
+
+ if (shorten)
+ {
+ int unsigned0, unsigned1;
+ tree arg0 = get_narrower (op0, &unsigned0);
+ tree arg1 = get_narrower (op1, &unsigned1);
+ /* UNS is 1 if the operation to be done is an unsigned one. */
+ int uns = TREE_UNSIGNED (result_type);
+ tree type;
+
+ final_type = result_type;
+
+ /* Handle the case that OP0 does not *contain* a conversion
+ but it *requires* conversion to FINAL_TYPE. */
+
+ if (op0 == arg0 && TREE_TYPE (op0) != final_type)
+ unsigned0 = TREE_UNSIGNED (TREE_TYPE (op0));
+ if (op1 == arg1 && TREE_TYPE (op1) != final_type)
+ unsigned1 = TREE_UNSIGNED (TREE_TYPE (op1));
+
+ /* Now UNSIGNED0 is 1 if ARG0 zero-extends to FINAL_TYPE. */
+
+ /* For bitwise operations, signedness of nominal type
+ does not matter. Consider only how operands were extended. */
+ if (shorten == -1)
+ uns = unsigned0;
+
+ /* Note that in all three cases below we refrain from optimizing
+ an unsigned operation on sign-extended args.
+ That would not be valid. */
+
+ /* Both args variable: if both extended in same way
+ from same width, do it in that width.
+ Do it unsigned if args were zero-extended. */
+ if ((TYPE_PRECISION (TREE_TYPE (arg0))
+ < TYPE_PRECISION (result_type))
+ && (TYPE_PRECISION (TREE_TYPE (arg1))
+ == TYPE_PRECISION (TREE_TYPE (arg0)))
+ && unsigned0 == unsigned1
+ && (unsigned0 || !uns))
+ result_type
+ = signed_or_unsigned_type (unsigned0,
+ common_type (TREE_TYPE (arg0), TREE_TYPE (arg1)));
+ else if (TREE_CODE (arg0) == INTEGER_CST
+ && (unsigned1 || !uns)
+ && (TYPE_PRECISION (TREE_TYPE (arg1))
+ < TYPE_PRECISION (result_type))
+ && (type = signed_or_unsigned_type (unsigned1,
+ TREE_TYPE (arg1)),
+ int_fits_type_p (arg0, type)))
+ result_type = type;
+ else if (TREE_CODE (arg1) == INTEGER_CST
+ && (unsigned0 || !uns)
+ && (TYPE_PRECISION (TREE_TYPE (arg0))
+ < TYPE_PRECISION (result_type))
+ && (type = signed_or_unsigned_type (unsigned0,
+ TREE_TYPE (arg0)),
+ int_fits_type_p (arg1, type)))
+ result_type = type;
+ }
+
+ /* Shifts can be shortened if shifting right. */
+
+ if (short_shift)
+ {
+ int unsigned_arg;
+ tree arg0 = get_narrower (op0, &unsigned_arg);
+
+ final_type = result_type;
+
+ if (arg0 == op0 && final_type == TREE_TYPE (op0))
+ unsigned_arg = TREE_UNSIGNED (TREE_TYPE (op0));
+
+ if (TYPE_PRECISION (TREE_TYPE (arg0)) < TYPE_PRECISION (result_type)
+ /* We can shorten only if the shift count is less than the
+ number of bits in the smaller type size. */
+ && TREE_INT_CST_HIGH (op1) == 0
+ && TYPE_PRECISION (TREE_TYPE (arg0)) > TREE_INT_CST_LOW (op1)
+ /* If arg is sign-extended and then unsigned-shifted,
+ we can simulate this with a signed shift in arg's type
+ only if the extended result is at least twice as wide
+ as the arg. Otherwise, the shift could use up all the
+ ones made by sign-extension and bring in zeros.
+ We can't optimize that case at all, but in most machines
+ it never happens because available widths are 2**N. */
+ && (!TREE_UNSIGNED (final_type)
+ || unsigned_arg
+ || ((unsigned) 2 * TYPE_PRECISION (TREE_TYPE (arg0))
+ <= TYPE_PRECISION (result_type))))
+ {
+ /* Do an unsigned shift if the operand was zero-extended. */
+ result_type
+ = signed_or_unsigned_type (unsigned_arg,
+ TREE_TYPE (arg0));
+ /* Convert value-to-be-shifted to that type. */
+ if (TREE_TYPE (op0) != result_type)
+ op0 = convert (result_type, op0);
+ converted = 1;
+ }
+ }
+
+ /* Comparison operations are shortened too but differently.
+ They identify themselves by setting short_compare = 1. */
+
+ if (short_compare)
+ {
+ /* Don't write &op0, etc., because that would prevent op0
+ from being kept in a register.
+ Instead, make copies of the our local variables and
+ pass the copies by reference, then copy them back afterward. */
+ tree xop0 = op0, xop1 = op1, xresult_type = result_type;
+ enum tree_code xresultcode = resultcode;
+ tree val
+ = shorten_compare (&xop0, &xop1, &xresult_type, &xresultcode);
+ if (val != 0)
+ return convert (boolean_type_node, val);
+ op0 = xop0, op1 = xop1;
+ converted = 1;
+ resultcode = xresultcode;
+ }
+
+ if (short_compare && extra_warnings)
+ {
+ int op0_signed = ! TREE_UNSIGNED (TREE_TYPE (orig_op0));
+ int op1_signed = ! TREE_UNSIGNED (TREE_TYPE (orig_op1));
+
+ int unsignedp0, unsignedp1;
+ tree primop0 = get_narrower (op0, &unsignedp0);
+ tree primop1 = get_narrower (op1, &unsignedp1);
+
+ /* Give warnings for comparisons between signed and unsigned
+ quantities that may fail. */
+ /* Do the checking based on the original operand trees, so that
+ casts will be considered, but default promotions won't be. */
+
+ /* Do not warn if the comparison is being done in a signed type,
+ since the signed type will only be chosen if it can represent
+ all the values of the unsigned type. */
+ if (! TREE_UNSIGNED (result_type))
+ /* OK */;
+ /* Do not warn if both operands are unsigned. */
+ else if (op0_signed == op1_signed)
+ /* OK */;
+ /* Do not warn if the signed quantity is an unsuffixed
+ integer literal (or some static constant expression
+ involving such literals) and it is non-negative. */
+ else if ((op0_signed && TREE_CODE (orig_op0) == INTEGER_CST
+ && tree_int_cst_sgn (orig_op0) >= 0)
+ || (op1_signed && TREE_CODE (orig_op1) == INTEGER_CST
+ && tree_int_cst_sgn (orig_op1) >= 0))
+ /* OK */;
+ /* Do not warn if the comparison is an equality operation,
+ the unsigned quantity is an integral constant and it does
+ not use the most significant bit of result_type. */
+ else if ((resultcode == EQ_EXPR || resultcode == NE_EXPR)
+ && ((op0_signed && TREE_CODE (orig_op1) == INTEGER_CST
+ && int_fits_type_p (orig_op1, signed_type (result_type))
+ || (op1_signed && TREE_CODE (orig_op0) == INTEGER_CST
+ && int_fits_type_p (orig_op0, signed_type (result_type))))))
+ /* OK */;
+ else
+ warning ("comparison between signed and unsigned");
+
+ /* Warn if two unsigned values are being compared in a size
+ larger than their original size, and one (and only one) is the
+ result of a `~' operator. This comparison will always fail.
+
+ Also warn if one operand is a constant, and the constant does not
+ have all bits set that are set in the ~ operand when it is
+ extended. */
+
+ if (TREE_CODE (primop0) == BIT_NOT_EXPR
+ ^ TREE_CODE (primop1) == BIT_NOT_EXPR)
+ {
+ if (TREE_CODE (primop0) == BIT_NOT_EXPR)
+ primop0 = get_narrower (TREE_OPERAND (op0, 0), &unsignedp0);
+ if (TREE_CODE (primop1) == BIT_NOT_EXPR)
+ primop1 = get_narrower (TREE_OPERAND (op1, 0), &unsignedp1);
+
+ if (TREE_CODE (primop0) == INTEGER_CST
+ || TREE_CODE (primop1) == INTEGER_CST)
+ {
+ tree primop;
+ HOST_WIDE_INT constant, mask;
+ int unsignedp;
+ unsigned bits;
+
+ if (TREE_CODE (primop0) == INTEGER_CST)
+ {
+ primop = primop1;
+ unsignedp = unsignedp1;
+ constant = TREE_INT_CST_LOW (primop0);
+ }
+ else
+ {
+ primop = primop0;
+ unsignedp = unsignedp0;
+ constant = TREE_INT_CST_LOW (primop1);
+ }
+
+ bits = TYPE_PRECISION (TREE_TYPE (primop));
+ if (bits < TYPE_PRECISION (result_type)
+ && bits < HOST_BITS_PER_LONG && unsignedp)
+ {
+ mask = (~ (HOST_WIDE_INT) 0) << bits;
+ if ((mask & constant) != mask)
+ warning ("comparison of promoted ~unsigned with constant");
+ }
+ }
+ else if (unsignedp0 && unsignedp1
+ && (TYPE_PRECISION (TREE_TYPE (primop0))
+ < TYPE_PRECISION (result_type))
+ && (TYPE_PRECISION (TREE_TYPE (primop1))
+ < TYPE_PRECISION (result_type)))
+ warning ("comparison of promoted ~unsigned with unsigned");
+ }
+ }
+ }
+
+ /* At this point, RESULT_TYPE must be nonzero to avoid an error message.
+ If CONVERTED is zero, both args will be converted to type RESULT_TYPE.
+ Then the expression will be built.
+ It will be given type FINAL_TYPE if that is nonzero;
+ otherwise, it will be given type RESULT_TYPE. */
+
+ if (!result_type)
+ {
+ cp_error ("invalid operands `%T' and `%T' to binary `%O'",
+ TREE_TYPE (orig_op0), TREE_TYPE (orig_op1), error_code);
+ return error_mark_node;
+ }
+
+ if (! converted)
+ {
+ if (TREE_TYPE (op0) != result_type)
+ op0 = convert (result_type, op0);
+ if (TREE_TYPE (op1) != result_type)
+ op1 = convert (result_type, op1);
+ }
+
+ if (build_type == NULL_TREE)
+ build_type = result_type;
+
+ {
+ register tree result = build (resultcode, build_type, op0, op1);
+ register tree folded;
+
+ folded = fold (result);
+ if (folded == result)
+ TREE_CONSTANT (folded) = TREE_CONSTANT (op0) & TREE_CONSTANT (op1);
+ if (final_type != 0)
+ return convert (final_type, folded);
+ return folded;
+ }
+}
+
+/* Return a tree for the sum or difference (RESULTCODE says which)
+ of pointer PTROP and integer INTOP. */
+
+static tree
+pointer_int_sum (resultcode, ptrop, intop)
+ enum tree_code resultcode;
+ register tree ptrop, intop;
+{
+ tree size_exp;
+
+ register tree result;
+ register tree folded = fold (intop);
+
+ /* The result is a pointer of the same type that is being added. */
+
+ register tree result_type = TREE_TYPE (ptrop);
+
+ if (TREE_CODE (TREE_TYPE (result_type)) == VOID_TYPE)
+ {
+ if (pedantic || warn_pointer_arith)
+ pedwarn ("ANSI C++ forbids using pointer of type `void *' in arithmetic");
+ size_exp = integer_one_node;
+ }
+ else if (TREE_CODE (TREE_TYPE (result_type)) == FUNCTION_TYPE)
+ {
+ if (pedantic || warn_pointer_arith)
+ pedwarn ("ANSI C++ forbids using pointer to a function in arithmetic");
+ size_exp = integer_one_node;
+ }
+ else if (TREE_CODE (TREE_TYPE (result_type)) == METHOD_TYPE)
+ {
+ if (pedantic || warn_pointer_arith)
+ pedwarn ("ANSI C++ forbids using pointer to a method in arithmetic");
+ size_exp = integer_one_node;
+ }
+ else if (TREE_CODE (TREE_TYPE (result_type)) == OFFSET_TYPE)
+ {
+ if (pedantic)
+ pedwarn ("ANSI C++ forbids using pointer to a member in arithmetic");
+ size_exp = integer_one_node;
+ }
+ else
+ size_exp = size_in_bytes (TREE_TYPE (result_type));
+
+ /* Needed to make OOPS V2R3 work. */
+ intop = folded;
+ if (TREE_CODE (intop) == INTEGER_CST
+ && TREE_INT_CST_LOW (intop) == 0
+ && TREE_INT_CST_HIGH (intop) == 0)
+ return ptrop;
+
+ /* If what we are about to multiply by the size of the elements
+ contains a constant term, apply distributive law
+ and multiply that constant term separately.
+ This helps produce common subexpressions. */
+
+ if ((TREE_CODE (intop) == PLUS_EXPR || TREE_CODE (intop) == MINUS_EXPR)
+ && ! TREE_CONSTANT (intop)
+ && TREE_CONSTANT (TREE_OPERAND (intop, 1))
+ && TREE_CONSTANT (size_exp))
+ {
+ enum tree_code subcode = resultcode;
+ if (TREE_CODE (intop) == MINUS_EXPR)
+ subcode = (subcode == PLUS_EXPR ? MINUS_EXPR : PLUS_EXPR);
+ ptrop = build_binary_op (subcode, ptrop, TREE_OPERAND (intop, 1), 1);
+ intop = TREE_OPERAND (intop, 0);
+ }
+
+ /* Convert the integer argument to a type the same size as a pointer
+ so the multiply won't overflow spuriously. */
+
+ if (TYPE_PRECISION (TREE_TYPE (intop)) != POINTER_SIZE)
+ intop = convert (type_for_size (POINTER_SIZE, 0), intop);
+
+ /* Replace the integer argument with a suitable product by the object size.
+ Do this multiplication as signed, then convert to the appropriate
+ pointer type (actually unsigned integral). */
+
+ intop = convert (result_type,
+ build_binary_op (MULT_EXPR, intop,
+ convert (TREE_TYPE (intop), size_exp), 1));
+
+ /* Create the sum or difference. */
+
+ result = build (resultcode, result_type, ptrop, intop);
+
+ folded = fold (result);
+ if (folded == result)
+ TREE_CONSTANT (folded) = TREE_CONSTANT (ptrop) & TREE_CONSTANT (intop);
+ return folded;
+}
+
+/* Return a tree for the difference of pointers OP0 and OP1.
+ The resulting tree has type int. */
+
+static tree
+pointer_diff (op0, op1)
+ register tree op0, op1;
+{
+ register tree result, folded;
+ tree restype = ptrdiff_type_node;
+ tree target_type = TREE_TYPE (TREE_TYPE (op0));
+
+ if (pedantic)
+ {
+ if (TREE_CODE (target_type) == VOID_TYPE)
+ pedwarn ("ANSI C++ forbids using pointer of type `void *' in subtraction");
+ if (TREE_CODE (target_type) == FUNCTION_TYPE)
+ pedwarn ("ANSI C++ forbids using pointer to a function in subtraction");
+ if (TREE_CODE (target_type) == METHOD_TYPE)
+ pedwarn ("ANSI C++ forbids using pointer to a method in subtraction");
+ if (TREE_CODE (target_type) == OFFSET_TYPE)
+ pedwarn ("ANSI C++ forbids using pointer to a member in subtraction");
+ }
+
+ /* First do the subtraction as integers;
+ then drop through to build the divide operator. */
+
+ op0 = build_binary_op (MINUS_EXPR,
+ convert (restype, op0), convert (restype, op1), 1);
+
+ /* This generates an error if op1 is a pointer to an incomplete type. */
+ if (TYPE_SIZE (TREE_TYPE (TREE_TYPE (op1))) == 0)
+ error ("arithmetic on pointer to an incomplete type");
+
+ op1 = ((TREE_CODE (target_type) == VOID_TYPE
+ || TREE_CODE (target_type) == FUNCTION_TYPE
+ || TREE_CODE (target_type) == METHOD_TYPE
+ || TREE_CODE (target_type) == OFFSET_TYPE)
+ ? integer_one_node
+ : size_in_bytes (target_type));
+
+ /* Do the division. */
+
+ result = build (EXACT_DIV_EXPR, restype, op0, convert (restype, op1));
+
+ folded = fold (result);
+ if (folded == result)
+ TREE_CONSTANT (folded) = TREE_CONSTANT (op0) & TREE_CONSTANT (op1);
+ return folded;
+}
+
+/* Handle the case of taking the address of a COMPONENT_REF.
+ Called by `build_unary_op' and `build_up_reference'.
+
+ ARG is the COMPONENT_REF whose address we want.
+ ARGTYPE is the pointer type that this address should have.
+ MSG is an error message to print if this COMPONENT_REF is not
+ addressable (such as a bitfield). */
+
+tree
+build_component_addr (arg, argtype, msg)
+ tree arg, argtype;
+ char *msg;
+{
+ tree field = TREE_OPERAND (arg, 1);
+ tree basetype = decl_type_context (field);
+ tree rval = build_unary_op (ADDR_EXPR, TREE_OPERAND (arg, 0), 0);
+
+ if (DECL_BIT_FIELD (field))
+ {
+ error (msg, IDENTIFIER_POINTER (DECL_NAME (field)));
+ return error_mark_node;
+ }
+
+ if (flag_gc)
+ cp_warning ("address of `%T::%D' taken", basetype, field);
+
+ if (TREE_CODE (field) == FIELD_DECL
+ && TYPE_USES_COMPLEX_INHERITANCE (basetype))
+ {
+ /* Can't convert directly to ARGTYPE, since that
+ may have the same pointer type as one of our
+ baseclasses. */
+ rval = build1 (NOP_EXPR, argtype,
+ convert_pointer_to (basetype, rval));
+ TREE_CONSTANT (rval) = TREE_CONSTANT (TREE_OPERAND (rval, 0));
+ }
+ else
+ /* This conversion is harmless. */
+ rval = convert_force (argtype, rval, 0);
+
+ if (! integer_zerop (DECL_FIELD_BITPOS (field)))
+ {
+ tree offset = size_binop (EASY_DIV_EXPR, DECL_FIELD_BITPOS (field),
+ size_int (BITS_PER_UNIT));
+ int flag = TREE_CONSTANT (rval);
+ rval = fold (build (PLUS_EXPR, argtype,
+ rval, convert (argtype, offset)));
+ TREE_CONSTANT (rval) = flag;
+ }
+ return rval;
+}
+
+/* Construct and perhaps optimize a tree representation
+ for a unary operation. CODE, a tree_code, specifies the operation
+ and XARG is the operand. */
+
+tree
+build_x_unary_op (code, xarg)
+ enum tree_code code;
+ tree xarg;
+{
+ /* & rec, on incomplete RECORD_TYPEs is the simple opr &, not an
+ error message. */
+ if (code == ADDR_EXPR
+ && ((IS_AGGR_TYPE_CODE (TREE_CODE (TREE_TYPE (xarg)))
+ && TYPE_SIZE (TREE_TYPE (xarg)) == NULL_TREE)
+ || (TREE_CODE (xarg) == OFFSET_REF)))
+ /* don't look for a function */;
+ else
+ {
+ tree rval = build_opfncall (code, LOOKUP_SPECULATIVELY, xarg,
+ NULL_TREE, NULL_TREE);
+ if (rval)
+ return build_opfncall (code, LOOKUP_NORMAL, xarg,
+ NULL_TREE, NULL_TREE);
+ }
+ return build_unary_op (code, xarg, 0);
+}
+
+/* Just like truthvalue_conversion, but we want a CLEANUP_POINT_EXPR. */
+
+tree
+condition_conversion (expr)
+ tree expr;
+{
+ tree t = convert (boolean_type_node, expr);
+ t = fold (build1 (CLEANUP_POINT_EXPR, boolean_type_node, t));
+ return t;
+}
+
+/* C++: Must handle pointers to members.
+
+ Perhaps type instantiation should be extended to handle conversion
+ from aggregates to types we don't yet know we want? (Or are those
+ cases typically errors which should be reported?)
+
+ NOCONVERT nonzero suppresses the default promotions
+ (such as from short to int). */
+tree
+build_unary_op (code, xarg, noconvert)
+ enum tree_code code;
+ tree xarg;
+ int noconvert;
+{
+ /* No default_conversion here. It causes trouble for ADDR_EXPR. */
+ register tree arg = xarg;
+ register tree argtype = 0;
+ char *errstring = NULL;
+ tree val;
+
+ if (arg == error_mark_node)
+ return error_mark_node;
+
+ switch (code)
+ {
+ case CONVERT_EXPR:
+ /* This is used for unary plus, because a CONVERT_EXPR
+ is enough to prevent anybody from looking inside for
+ associativity, but won't generate any code. */
+ if (!(arg = build_expr_type_conversion
+ (WANT_ARITH | WANT_ENUM | WANT_POINTER, arg, 1)))
+ errstring = "wrong type argument to unary plus";
+ else
+ {
+ if (!noconvert)
+ arg = default_conversion (arg);
+ arg = build1 (NON_LVALUE_EXPR, TREE_TYPE (arg), arg);
+ }
+ break;
+
+ case NEGATE_EXPR:
+ if (!(arg = build_expr_type_conversion (WANT_ARITH | WANT_ENUM, arg, 1)))
+ errstring = "wrong type argument to unary minus";
+ else if (!noconvert)
+ arg = default_conversion (arg);
+ break;
+
+ case BIT_NOT_EXPR:
+ if (!(arg = build_expr_type_conversion (WANT_INT | WANT_ENUM, arg, 1)))
+ errstring = "wrong type argument to bit-complement";
+ else if (!noconvert)
+ arg = default_conversion (arg);
+ break;
+
+ case ABS_EXPR:
+ if (!(arg = build_expr_type_conversion (WANT_ARITH | WANT_ENUM, arg, 1)))
+ errstring = "wrong type argument to abs";
+ else if (!noconvert)
+ arg = default_conversion (arg);
+ break;
+
+ case TRUTH_NOT_EXPR:
+ arg = convert (boolean_type_node, arg);
+ val = invert_truthvalue (arg);
+ if (arg != error_mark_node)
+ return val;
+ errstring = "in argument to unary !";
+ break;
+
+ case NOP_EXPR:
+ break;
+
+ case PREINCREMENT_EXPR:
+ case POSTINCREMENT_EXPR:
+ case PREDECREMENT_EXPR:
+ case POSTDECREMENT_EXPR:
+ /* Handle complex lvalues (when permitted)
+ by reduction to simpler cases. */
+
+ val = unary_complex_lvalue (code, arg);
+ if (val != 0)
+ return val;
+
+ /* Report invalid types. */
+
+ if (!(arg = build_expr_type_conversion (WANT_ARITH | WANT_POINTER,
+ arg, 1)))
+ {
+ if (code == PREINCREMENT_EXPR)
+ errstring ="no pre-increment operator for type";
+ else if (code == POSTINCREMENT_EXPR)
+ errstring ="no post-increment operator for type";
+ else if (code == PREDECREMENT_EXPR)
+ errstring ="no pre-decrement operator for type";
+ else
+ errstring ="no post-decrement operator for type";
+ break;
+ }
+
+ /* Report something read-only. */
+
+ if (TYPE_READONLY (TREE_TYPE (arg))
+ || TREE_READONLY (arg))
+ readonly_error (arg, ((code == PREINCREMENT_EXPR
+ || code == POSTINCREMENT_EXPR)
+ ? "increment" : "decrement"),
+ 0);
+
+ {
+ register tree inc;
+ tree result_type = TREE_TYPE (arg);
+
+ arg = get_unwidened (arg, 0);
+ argtype = TREE_TYPE (arg);
+
+ /* ARM $5.2.5 last annotation says this should be forbidden. */
+ if (TREE_CODE (argtype) == ENUMERAL_TYPE)
+ pedwarn ("ANSI C++ forbids %sing an enum",
+ (code == PREINCREMENT_EXPR || code == POSTINCREMENT_EXPR)
+ ? "increment" : "decrement");
+
+ /* Compute the increment. */
+
+ if (TREE_CODE (argtype) == POINTER_TYPE)
+ {
+ enum tree_code tmp = TREE_CODE (TREE_TYPE (argtype));
+ if (TYPE_SIZE (TREE_TYPE (argtype)) == 0)
+ cp_error ("cannot %s a pointer to incomplete type `%T'",
+ ((code == PREINCREMENT_EXPR
+ || code == POSTINCREMENT_EXPR)
+ ? "increment" : "decrement"), TREE_TYPE (argtype));
+ else if (tmp == FUNCTION_TYPE || tmp == METHOD_TYPE
+ || tmp == VOID_TYPE || tmp == OFFSET_TYPE)
+ cp_pedwarn ("ANSI C++ forbids %sing a pointer of type `%T'",
+ ((code == PREINCREMENT_EXPR
+ || code == POSTINCREMENT_EXPR)
+ ? "increment" : "decrement"), argtype);
+ inc = c_sizeof_nowarn (TREE_TYPE (argtype));
+ }
+ else
+ inc = integer_one_node;
+
+ inc = convert (argtype, inc);
+
+ /* Handle incrementing a cast-expression. */
+
+ switch (TREE_CODE (arg))
+ {
+ case NOP_EXPR:
+ case CONVERT_EXPR:
+ case FLOAT_EXPR:
+ case FIX_TRUNC_EXPR:
+ case FIX_FLOOR_EXPR:
+ case FIX_ROUND_EXPR:
+ case FIX_CEIL_EXPR:
+ {
+ tree incremented, modify, value;
+ if (! lvalue_p (arg) && pedantic)
+ pedwarn ("cast to non-reference type used as lvalue");
+ arg = stabilize_reference (arg);
+ if (code == PREINCREMENT_EXPR || code == PREDECREMENT_EXPR)
+ value = arg;
+ else
+ value = save_expr (arg);
+ incremented = build (((code == PREINCREMENT_EXPR
+ || code == POSTINCREMENT_EXPR)
+ ? PLUS_EXPR : MINUS_EXPR),
+ argtype, value, inc);
+ TREE_SIDE_EFFECTS (incremented) = 1;
+ modify = build_modify_expr (arg, NOP_EXPR, incremented);
+ return build (COMPOUND_EXPR, TREE_TYPE (arg), modify, value);
+ }
+ }
+
+ /* Complain about anything else that is not a true lvalue. */
+ if (!lvalue_or_else (arg, ((code == PREINCREMENT_EXPR
+ || code == POSTINCREMENT_EXPR)
+ ? "increment" : "decrement")))
+ return error_mark_node;
+
+ /* Forbid using -- on `bool'. */
+ if (TREE_TYPE (arg) == boolean_type_node)
+ {
+ if (code == POSTDECREMENT_EXPR || code == PREDECREMENT_EXPR)
+ {
+ cp_error ("invalid use of `--' on bool variable `%D'", arg);
+ return error_mark_node;
+ }
+#if 0
+ /* This will only work if someone can convince Kenner to accept
+ my patch to expand_increment. (jason) */
+ val = build (code, TREE_TYPE (arg), arg, inc);
+#else
+ if (code == POSTINCREMENT_EXPR)
+ {
+ arg = stabilize_reference (arg);
+ val = build (MODIFY_EXPR, TREE_TYPE (arg), arg,
+ boolean_true_node);
+ TREE_SIDE_EFFECTS (val) = 1;
+ arg = save_expr (arg);
+ val = build (COMPOUND_EXPR, TREE_TYPE (arg), val, arg);
+ val = build (COMPOUND_EXPR, TREE_TYPE (arg), arg, val);
+ }
+ else
+ val = build (MODIFY_EXPR, TREE_TYPE (arg), arg,
+ boolean_true_node);
+#endif
+ }
+ else
+ val = build (code, TREE_TYPE (arg), arg, inc);
+
+ TREE_SIDE_EFFECTS (val) = 1;
+ return convert (result_type, val);
+ }
+
+ case ADDR_EXPR:
+ /* Note that this operation never does default_conversion
+ regardless of NOCONVERT. */
+
+ argtype = TREE_TYPE (arg);
+ if (TREE_CODE (argtype) == REFERENCE_TYPE)
+ {
+ arg = build1 (CONVERT_EXPR, build_pointer_type (TREE_TYPE (TREE_TYPE (arg))), arg);
+ TREE_REFERENCE_EXPR (arg) = 1;
+ return arg;
+ }
+ else if (pedantic
+ && TREE_CODE (arg) == FUNCTION_DECL
+ && DECL_NAME (arg)
+ && DECL_CONTEXT (arg) == NULL_TREE
+ && IDENTIFIER_LENGTH (DECL_NAME (arg)) == 4
+ && IDENTIFIER_POINTER (DECL_NAME (arg))[0] == 'm'
+ && ! strcmp (IDENTIFIER_POINTER (DECL_NAME (arg)), "main"))
+ /* ARM $3.4 */
+ pedwarn ("taking address of function `main'");
+
+ /* Let &* cancel out to simplify resulting code. */
+ if (TREE_CODE (arg) == INDIRECT_REF)
+ {
+ /* We don't need to have `current_class_decl' wrapped in a
+ NON_LVALUE_EXPR node. */
+ if (arg == C_C_D)
+ return current_class_decl;
+
+ /* Keep `default_conversion' from converting if
+ ARG is of REFERENCE_TYPE. */
+ arg = TREE_OPERAND (arg, 0);
+ if (TREE_CODE (TREE_TYPE (arg)) == REFERENCE_TYPE)
+ {
+ if (TREE_CODE (arg) == VAR_DECL && DECL_INITIAL (arg)
+ && !TREE_SIDE_EFFECTS (DECL_INITIAL (arg)))
+ arg = DECL_INITIAL (arg);
+ arg = build1 (CONVERT_EXPR, build_pointer_type (TREE_TYPE (TREE_TYPE (arg))), arg);
+ TREE_REFERENCE_EXPR (arg) = 1;
+ TREE_CONSTANT (arg) = TREE_CONSTANT (TREE_OPERAND (arg, 0));
+ }
+ else if (lvalue_p (arg))
+ /* Don't let this be an lvalue. */
+ return non_lvalue (arg);
+ return arg;
+ }
+
+ /* For &x[y], return x+y */
+ if (TREE_CODE (arg) == ARRAY_REF)
+ {
+ if (mark_addressable (TREE_OPERAND (arg, 0)) == 0)
+ return error_mark_node;
+ return build_binary_op (PLUS_EXPR, TREE_OPERAND (arg, 0),
+ TREE_OPERAND (arg, 1), 1);
+ }
+
+ /* Uninstantiated types are all functions. Taking the
+ address of a function is a no-op, so just return the
+ argument. */
+
+ if (TREE_CODE (arg) == IDENTIFIER_NODE
+ && IDENTIFIER_OPNAME_P (arg))
+ {
+ my_friendly_abort (117);
+ /* We don't know the type yet, so just work around the problem.
+ We know that this will resolve to an lvalue. */
+ return build1 (ADDR_EXPR, unknown_type_node, arg);
+ }
+
+ if (TREE_CODE (arg) == TREE_LIST)
+ {
+ if (TREE_CODE (TREE_VALUE (arg)) == FUNCTION_DECL
+ && DECL_CHAIN (TREE_VALUE (arg)) == NULL_TREE)
+ /* Unique overloaded non-member function. */
+ return build_unary_op (ADDR_EXPR, TREE_VALUE (arg), 0);
+ if (TREE_CHAIN (arg) == NULL_TREE
+ && TREE_CODE (TREE_VALUE (arg)) == TREE_LIST
+ && DECL_CHAIN (TREE_VALUE (TREE_VALUE (arg))) == NULL_TREE)
+ /* Unique overloaded member function. */
+ return build_unary_op (ADDR_EXPR, TREE_VALUE (TREE_VALUE (arg)),
+ 0);
+ return build1 (ADDR_EXPR, unknown_type_node, arg);
+ }
+
+ /* Handle complex lvalues (when permitted)
+ by reduction to simpler cases. */
+ val = unary_complex_lvalue (code, arg);
+ if (val != 0)
+ return val;
+
+ switch (TREE_CODE (arg))
+ {
+ case NOP_EXPR:
+ case CONVERT_EXPR:
+ case FLOAT_EXPR:
+ case FIX_TRUNC_EXPR:
+ case FIX_FLOOR_EXPR:
+ case FIX_ROUND_EXPR:
+ case FIX_CEIL_EXPR:
+ if (! lvalue_p (arg) && pedantic)
+ pedwarn ("taking the address of a cast to non-reference type");
+ }
+
+ /* Allow the address of a constructor if all the elements
+ are constant. */
+ if (TREE_CODE (arg) == CONSTRUCTOR && TREE_CONSTANT (arg))
+ ;
+ /* Anything not already handled and not a true memory reference
+ is an error. */
+ else if (TREE_CODE (argtype) != FUNCTION_TYPE
+ && TREE_CODE (argtype) != METHOD_TYPE
+ && !lvalue_or_else (arg, "unary `&'"))
+ return error_mark_node;
+
+ /* Ordinary case; arg is a COMPONENT_REF or a decl. */
+ /* If the lvalue is const or volatile,
+ merge that into the type that the address will point to. */
+ if (TREE_CODE_CLASS (TREE_CODE (arg)) == 'd'
+ || TREE_CODE_CLASS (TREE_CODE (arg)) == 'r')
+ {
+ if (TREE_READONLY (arg) || TREE_THIS_VOLATILE (arg))
+ argtype = cp_build_type_variant (argtype,
+ TREE_READONLY (arg),
+ TREE_THIS_VOLATILE (arg));
+ }
+
+ argtype = build_pointer_type (argtype);
+
+ if (mark_addressable (arg) == 0)
+ return error_mark_node;
+
+ {
+ tree addr;
+
+ if (TREE_CODE (arg) == COMPONENT_REF)
+ addr = build_component_addr (arg, argtype,
+ "attempt to take address of bit-field structure member `%s'");
+ else
+ addr = build1 (code, argtype, arg);
+
+ /* Address of a static or external variable or
+ function counts as a constant */
+ if (staticp (arg))
+ TREE_CONSTANT (addr) = 1;
+ return addr;
+ }
+ }
+
+ if (!errstring)
+ {
+ if (argtype == 0)
+ argtype = TREE_TYPE (arg);
+ return fold (build1 (code, argtype, arg));
+ }
+
+ error (errstring);
+ return error_mark_node;
+}
+
+/* If CONVERSIONS is a conversion expression or a nested sequence of such,
+ convert ARG with the same conversions in the same order
+ and return the result. */
+
+static tree
+convert_sequence (conversions, arg)
+ tree conversions;
+ tree arg;
+{
+ switch (TREE_CODE (conversions))
+ {
+ case NOP_EXPR:
+ case CONVERT_EXPR:
+ case FLOAT_EXPR:
+ case FIX_TRUNC_EXPR:
+ case FIX_FLOOR_EXPR:
+ case FIX_ROUND_EXPR:
+ case FIX_CEIL_EXPR:
+ return convert (TREE_TYPE (conversions),
+ convert_sequence (TREE_OPERAND (conversions, 0),
+ arg));
+
+ default:
+ return arg;
+ }
+}
+
+/* Apply unary lvalue-demanding operator CODE to the expression ARG
+ for certain kinds of expressions which are not really lvalues
+ but which we can accept as lvalues.
+
+ If ARG is not a kind of expression we can handle, return zero. */
+
+tree
+unary_complex_lvalue (code, arg)
+ enum tree_code code;
+ tree arg;
+{
+ /* Handle (a, b) used as an "lvalue". */
+ if (TREE_CODE (arg) == COMPOUND_EXPR)
+ {
+ tree real_result = build_unary_op (code, TREE_OPERAND (arg, 1), 0);
+ return build (COMPOUND_EXPR, TREE_TYPE (real_result),
+ TREE_OPERAND (arg, 0), real_result);
+ }
+
+ /* Handle (a ? b : c) used as an "lvalue". */
+ if (TREE_CODE (arg) == COND_EXPR)
+ return rationalize_conditional_expr (code, arg);
+
+ if (TREE_CODE (arg) == MODIFY_EXPR
+ || TREE_CODE (arg) == PREINCREMENT_EXPR
+ || TREE_CODE (arg) == PREDECREMENT_EXPR)
+ return unary_complex_lvalue
+ (code, build (COMPOUND_EXPR, TREE_TYPE (TREE_OPERAND (arg, 0)),
+ arg, TREE_OPERAND (arg, 0)));
+
+ if (code != ADDR_EXPR)
+ return 0;
+
+ /* Handle (a = b) used as an "lvalue" for `&'. */
+ if (TREE_CODE (arg) == MODIFY_EXPR
+ || TREE_CODE (arg) == INIT_EXPR)
+ {
+ tree real_result = build_unary_op (code, TREE_OPERAND (arg, 0), 0);
+ return build (COMPOUND_EXPR, TREE_TYPE (real_result), arg, real_result);
+ }
+
+ if (TREE_CODE (arg) == WITH_CLEANUP_EXPR)
+ {
+ tree real_result = build_unary_op (code, TREE_OPERAND (arg, 0), 0);
+ real_result = build (WITH_CLEANUP_EXPR, TREE_TYPE (real_result),
+ real_result, 0, TREE_OPERAND (arg, 2));
+ return real_result;
+ }
+
+ if (TREE_CODE (TREE_TYPE (arg)) == FUNCTION_TYPE
+ || TREE_CODE (TREE_TYPE (arg)) == METHOD_TYPE
+ || TREE_CODE (TREE_TYPE (arg)) == OFFSET_TYPE)
+ {
+ /* The representation of something of type OFFSET_TYPE
+ is really the representation of a pointer to it.
+ Here give the representation its true type. */
+ tree t;
+ tree offset;
+
+ my_friendly_assert (TREE_CODE (arg) != SCOPE_REF, 313);
+
+ if (TREE_CODE (arg) != OFFSET_REF)
+ return 0;
+
+ t = TREE_OPERAND (arg, 1);
+
+ if (TREE_CODE (t) == FUNCTION_DECL) /* Check all this code for right semantics. */
+ return build_unary_op (ADDR_EXPR, t, 0);
+ if (TREE_CODE (t) == VAR_DECL)
+ return build_unary_op (ADDR_EXPR, t, 0);
+ else
+ {
+ if (TREE_OPERAND (arg, 0)
+ && (TREE_CODE (TREE_OPERAND (arg, 0)) != NOP_EXPR
+ || TREE_OPERAND (TREE_OPERAND (arg, 0), 0) != error_mark_node))
+ if (TREE_CODE (t) != FIELD_DECL)
+ {
+ /* Don't know if this should return address to just
+ _DECL, or actual address resolved in this expression. */
+ sorry ("address of bound pointer-to-member expression");
+ return error_mark_node;
+ }
+
+ offset = get_delta_difference (DECL_FIELD_CONTEXT (t),
+ TREE_TYPE (TREE_OPERAND (arg, 0)),
+ 0);
+ offset = size_binop (PLUS_EXPR, offset,
+ size_binop (EASY_DIV_EXPR,
+ DECL_FIELD_BITPOS (t),
+ size_int (BITS_PER_UNIT)));
+ return convert (build_pointer_type (TREE_TYPE (arg)), offset);
+ }
+ }
+
+ if (TREE_CODE (arg) == OFFSET_REF)
+ {
+ tree left = TREE_OPERAND (arg, 0), left_addr;
+ tree right_addr = build_unary_op (ADDR_EXPR, TREE_OPERAND (arg, 1), 0);
+
+ if (left == 0)
+ if (current_class_decl)
+ left_addr = current_class_decl;
+ else
+ {
+ error ("no `this' for pointer to member");
+ return error_mark_node;
+ }
+ else
+ left_addr = build_unary_op (ADDR_EXPR, left, 0);
+
+ return build (PLUS_EXPR, build_pointer_type (TREE_TYPE (arg)),
+ build1 (NOP_EXPR, integer_type_node, left_addr),
+ build1 (NOP_EXPR, integer_type_node, right_addr));
+ }
+
+ /* We permit compiler to make function calls returning
+ objects of aggregate type look like lvalues. */
+ {
+ tree targ = arg;
+
+ if (TREE_CODE (targ) == SAVE_EXPR)
+ targ = TREE_OPERAND (targ, 0);
+
+ if (TREE_CODE (targ) == CALL_EXPR && IS_AGGR_TYPE (TREE_TYPE (targ)))
+ {
+ if (TREE_CODE (arg) == SAVE_EXPR)
+ targ = arg;
+ else
+ targ = build_cplus_new (TREE_TYPE (arg), arg, 1);
+ return build1 (ADDR_EXPR, build_pointer_type (TREE_TYPE (arg)), targ);
+ }
+
+ if (TREE_CODE (arg) == SAVE_EXPR && TREE_CODE (targ) == INDIRECT_REF)
+ return build (SAVE_EXPR, build_pointer_type (TREE_TYPE (arg)),
+ TREE_OPERAND (targ, 0), current_function_decl, NULL);
+
+ /* We shouldn't wrap WITH_CLEANUP_EXPRs inside of SAVE_EXPRs, but in case
+ we do, here's how to handle it. */
+ if (TREE_CODE (arg) == SAVE_EXPR && TREE_CODE (targ) == WITH_CLEANUP_EXPR)
+ {
+#if 0
+ /* Not really a bug, but something to turn on when testing. */
+ compiler_error ("WITH_CLEANUP_EXPR wrapped in SAVE_EXPR");
+#endif
+ return unary_complex_lvalue (ADDR_EXPR, targ);
+ }
+ }
+
+ /* Don't let anything else be handled specially. */
+ return 0;
+}
+
+/* Mark EXP saying that we need to be able to take the
+ address of it; it should not be allocated in a register.
+ Value is 1 if successful.
+
+ C++: we do not allow `current_class_decl' to be addressable. */
+
+int
+mark_addressable (exp)
+ tree exp;
+{
+ register tree x = exp;
+
+ if (TREE_ADDRESSABLE (x) == 1)
+ return 1;
+
+ while (1)
+ switch (TREE_CODE (x))
+ {
+ case ADDR_EXPR:
+ case COMPONENT_REF:
+ case ARRAY_REF:
+ x = TREE_OPERAND (x, 0);
+ break;
+
+ case PARM_DECL:
+ if (x == current_class_decl)
+ {
+ error ("address of `this' not available");
+ TREE_ADDRESSABLE (x) = 1; /* so compiler doesn't die later */
+ put_var_into_stack (x);
+ return 1;
+ }
+ case VAR_DECL:
+ if (TREE_STATIC (x)
+ && TREE_READONLY (x)
+ && DECL_RTL (x) != 0
+ && ! decl_in_memory_p (x))
+ {
+ /* We thought this would make a good constant variable,
+ but we were wrong. */
+ push_obstacks_nochange ();
+ end_temporary_allocation ();
+
+ TREE_ASM_WRITTEN (x) = 0;
+ DECL_RTL (x) = 0;
+ rest_of_decl_compilation (x, 0, IDENTIFIER_LOCAL_VALUE (x) == 0, 0);
+ TREE_ADDRESSABLE (x) = 1;
+
+ pop_obstacks ();
+
+ return 1;
+ }
+ /* Caller should not be trying to mark initialized
+ constant fields addressable. */
+ my_friendly_assert (DECL_LANG_SPECIFIC (x) == 0
+ || DECL_IN_AGGR_P (x) == 0
+ || TREE_STATIC (x)
+ || DECL_EXTERNAL (x), 314);
+
+ case CONST_DECL:
+ case RESULT_DECL:
+ /* For C++, we don't warn about taking the address of a register
+ variable for CONST_DECLs; ARM p97 explicitly says it's okay. */
+ put_var_into_stack (x);
+ TREE_ADDRESSABLE (x) = 1;
+ return 1;
+
+ case FUNCTION_DECL:
+ /* We have to test both conditions here. The first may
+ be non-zero in the case of processing a default function.
+ The second may be non-zero in the case of a template function. */
+ x = DECL_MAIN_VARIANT (x);
+ if ((DECL_THIS_INLINE (x) || DECL_PENDING_INLINE_INFO (x))
+ && (DECL_CONTEXT (x) == NULL_TREE
+ || TREE_CODE_CLASS (TREE_CODE (DECL_CONTEXT (x))) != 't'
+ || ! CLASSTYPE_INTERFACE_ONLY (DECL_CONTEXT (x))))
+ {
+ mark_inline_for_output (x);
+ if (x == current_function_decl)
+ DECL_EXTERNAL (x) = 0;
+ }
+ TREE_ADDRESSABLE (x) = 1;
+ TREE_USED (x) = 1;
+ TREE_ADDRESSABLE (DECL_ASSEMBLER_NAME (x)) = 1;
+ if (asm_out_file)
+ assemble_external (x);
+ return 1;
+
+ default:
+ return 1;
+ }
+}
+
+/* Build and return a conditional expression IFEXP ? OP1 : OP2. */
+
+tree
+build_x_conditional_expr (ifexp, op1, op2)
+ tree ifexp, op1, op2;
+{
+ tree rval = NULL_TREE;
+
+ /* See comments in `build_x_binary_op'. */
+ if (op1 != 0)
+ rval = build_opfncall (COND_EXPR, LOOKUP_SPECULATIVELY, ifexp, op1, op2);
+ if (rval)
+ return build_opfncall (COND_EXPR, LOOKUP_NORMAL, ifexp, op1, op2);
+
+ return build_conditional_expr (ifexp, op1, op2);
+}
+
+tree
+build_conditional_expr (ifexp, op1, op2)
+ tree ifexp, op1, op2;
+{
+ register tree type1;
+ register tree type2;
+ register enum tree_code code1;
+ register enum tree_code code2;
+ register tree result_type = NULL_TREE;
+ tree orig_op1 = op1, orig_op2 = op2;
+
+ /* If second operand is omitted, it is the same as the first one;
+ make sure it is calculated only once. */
+ if (op1 == 0)
+ {
+ if (pedantic)
+ pedwarn ("ANSI C++ forbids omitting the middle term of a ?: expression");
+ ifexp = op1 = save_expr (ifexp);
+ }
+
+ ifexp = convert (boolean_type_node, ifexp);
+
+ if (TREE_CODE (ifexp) == ERROR_MARK)
+ return error_mark_node;
+
+ op1 = require_instantiated_type (TREE_TYPE (op2), op1, error_mark_node);
+ if (op1 == error_mark_node)
+ return error_mark_node;
+ op2 = require_instantiated_type (TREE_TYPE (op1), op2, error_mark_node);
+ if (op2 == error_mark_node)
+ return error_mark_node;
+
+ /* C++: REFERENCE_TYPES must be dereferenced. */
+ type1 = TREE_TYPE (op1);
+ code1 = TREE_CODE (type1);
+ type2 = TREE_TYPE (op2);
+ code2 = TREE_CODE (type2);
+
+ if (code1 == REFERENCE_TYPE)
+ {
+ op1 = convert_from_reference (op1);
+ type1 = TREE_TYPE (op1);
+ code1 = TREE_CODE (type1);
+ }
+ if (code2 == REFERENCE_TYPE)
+ {
+ op2 = convert_from_reference (op2);
+ type2 = TREE_TYPE (op2);
+ code2 = TREE_CODE (type2);
+ }
+
+#if 1 /* Produces wrong result if within sizeof. Sorry. */
+ /* Don't promote the operands separately if they promote
+ the same way. Return the unpromoted type and let the combined
+ value get promoted if necessary. */
+
+ if (TYPE_MAIN_VARIANT (type1) == TYPE_MAIN_VARIANT (type2)
+ && code2 != ARRAY_TYPE
+#if 0
+ /* For C++, let the enumeral type come through. */
+ && code2 != ENUMERAL_TYPE
+#endif
+ && code2 != FUNCTION_TYPE
+ && code2 != METHOD_TYPE)
+ {
+ tree result;
+
+ if (TREE_CONSTANT (ifexp)
+ && (TREE_CODE (ifexp) == INTEGER_CST
+ || TREE_CODE (ifexp) == ADDR_EXPR))
+ return (integer_zerop (ifexp) ? op2 : op1);
+
+ if (TREE_CODE (op1) == CONST_DECL)
+ op1 = DECL_INITIAL (op1);
+ else if (TREE_READONLY_DECL_P (op1))
+ op1 = decl_constant_value (op1);
+ if (TREE_CODE (op2) == CONST_DECL)
+ op2 = DECL_INITIAL (op2);
+ else if (TREE_READONLY_DECL_P (op2))
+ op2 = decl_constant_value (op2);
+ if (type1 != type2)
+ type1 = cp_build_type_variant
+ (type1,
+ TREE_READONLY (op1) || TREE_READONLY (op2),
+ TREE_THIS_VOLATILE (op1) || TREE_THIS_VOLATILE (op2));
+ /* ??? This is a kludge to deal with the fact that
+ we don't sort out integers and enums properly, yet. */
+ result = fold (build (COND_EXPR, type1, ifexp, op1, op2));
+ if (TREE_TYPE (result) != type1)
+ result = build1 (NOP_EXPR, type1, result);
+ return result;
+ }
+#endif
+
+ /* They don't match; promote them both and then try to reconcile them.
+ But don't permit mismatching enum types. */
+ if (code1 == ENUMERAL_TYPE)
+ {
+ if (code2 == ENUMERAL_TYPE)
+ {
+ cp_error ("enumeral mismatch in conditional expression: `%T' vs `%T'", type1, type2);
+ return error_mark_node;
+ }
+ else if (extra_warnings && ! IS_AGGR_TYPE_CODE (code2)
+ && type2 != type_promotes_to (type1))
+ warning ("enumeral and non-enumeral type in conditional expression");
+ }
+ else if (extra_warnings
+ && code2 == ENUMERAL_TYPE && ! IS_AGGR_TYPE_CODE (code1)
+ && type1 != type_promotes_to (type2))
+ warning ("enumeral and non-enumeral type in conditional expression");
+
+ if (code1 != VOID_TYPE)
+ {
+ op1 = default_conversion (op1);
+ type1 = TREE_TYPE (op1);
+ if (TYPE_PTRMEMFUNC_P (type1))
+ type1 = TYPE_PTRMEMFUNC_FN_TYPE (type1);
+ code1 = TREE_CODE (type1);
+ }
+ if (code2 != VOID_TYPE)
+ {
+ op2 = default_conversion (op2);
+ type2 = TREE_TYPE (op2);
+ if (TYPE_PTRMEMFUNC_P (type2))
+ type2 = TYPE_PTRMEMFUNC_FN_TYPE (type2);
+ code2 = TREE_CODE (type2);
+ }
+
+ if (code1 == RECORD_TYPE && code2 == RECORD_TYPE
+ && real_lvalue_p (op1) && real_lvalue_p (op2)
+ && comptypes (type1, type2, -1))
+ {
+ type1 = build_reference_type (type1);
+ type2 = build_reference_type (type2);
+ result_type = common_type (type1, type2);
+ op1 = convert_to_reference (result_type, op1, CONV_IMPLICIT,
+ LOOKUP_NORMAL, NULL_TREE);
+ op2 = convert_to_reference (result_type, op2, CONV_IMPLICIT,
+ LOOKUP_NORMAL, NULL_TREE);
+ }
+ /* Quickly detect the usual case where op1 and op2 have the same type
+ after promotion. */
+ else if (TYPE_MAIN_VARIANT (type1) == TYPE_MAIN_VARIANT (type2))
+ {
+ if (type1 == type2)
+ result_type = type1;
+ else
+ result_type = cp_build_type_variant
+ (type1,
+ TREE_READONLY (op1) || TREE_READONLY (op2),
+ TREE_THIS_VOLATILE (op1) || TREE_THIS_VOLATILE (op2));
+ }
+ else if ((code1 == INTEGER_TYPE || code1 == REAL_TYPE)
+ && (code2 == INTEGER_TYPE || code2 == REAL_TYPE))
+ {
+ result_type = common_type (type1, type2);
+ }
+ else if (code1 == VOID_TYPE || code2 == VOID_TYPE)
+ {
+ if (pedantic && (code1 != VOID_TYPE || code2 != VOID_TYPE))
+ pedwarn ("ANSI C++ forbids conditional expr with only one void side");
+ result_type = void_type_node;
+ }
+ else if (code1 == POINTER_TYPE && code2 == POINTER_TYPE)
+ {
+ if (comp_target_types (type1, type2, 1))
+ result_type = common_type (type1, type2);
+ else if (integer_zerop (op1) && TREE_TYPE (type1) == void_type_node
+ && TREE_CODE (orig_op1) != NOP_EXPR)
+ result_type = qualify_type (type2, type1);
+ else if (integer_zerop (op2) && TREE_TYPE (type2) == void_type_node
+ && TREE_CODE (orig_op2) != NOP_EXPR)
+ result_type = qualify_type (type1, type2);
+ else if (TYPE_MAIN_VARIANT (TREE_TYPE (type1)) == void_type_node)
+ {
+ if (pedantic && TREE_CODE (type2) == FUNCTION_TYPE)
+ pedwarn ("ANSI C++ forbids conditional expr between `void *' and function pointer");
+ result_type = qualify_type (type1, type2);
+ }
+ else if (TYPE_MAIN_VARIANT (TREE_TYPE (type2)) == void_type_node)
+ {
+ if (pedantic && TREE_CODE (type1) == FUNCTION_TYPE)
+ pedwarn ("ANSI C++ forbids conditional expr between `void *' and function pointer");
+ result_type = qualify_type (type2, type1);
+ }
+ /* C++ */
+ else if (comptypes (type2, type1, 0))
+ result_type = type2;
+ else if (IS_AGGR_TYPE (TREE_TYPE (type1))
+ && IS_AGGR_TYPE (TREE_TYPE (type2))
+ && (result_type = common_base_type (TREE_TYPE (type1), TREE_TYPE (type2))))
+ {
+ if (result_type == error_mark_node)
+ {
+ cp_error ("common base type of types `%T' and `%T' is ambiguous",
+ TREE_TYPE (type1), TREE_TYPE (type2));
+ result_type = ptr_type_node;
+ }
+ else
+ {
+ if (pedantic
+ && result_type != TREE_TYPE (type1)
+ && result_type != TREE_TYPE (type2))
+ cp_pedwarn ("`%T' and `%T' converted to `%T *' in conditional expression",
+ type1, type2, result_type);
+
+ result_type = build_pointer_type (result_type);
+ }
+ }
+ else
+ {
+ pedwarn ("pointer type mismatch in conditional expression");
+ result_type = ptr_type_node;
+ }
+ }
+ else if (code1 == POINTER_TYPE && code2 == INTEGER_TYPE)
+ {
+ if (!integer_zerop (op2))
+ pedwarn ("pointer/integer type mismatch in conditional expression");
+ else
+ {
+ op2 = null_pointer_node;
+#if 0 /* Sez who? */
+ if (pedantic && TREE_CODE (type1) == FUNCTION_TYPE)
+ pedwarn ("ANSI C++ forbids conditional expr between 0 and function pointer");
+#endif
+ }
+ result_type = type1;
+ }
+ else if (code2 == POINTER_TYPE && code1 == INTEGER_TYPE)
+ {
+ if (!integer_zerop (op1))
+ pedwarn ("pointer/integer type mismatch in conditional expression");
+ else
+ {
+ op1 = null_pointer_node;
+#if 0 /* Sez who? */
+ if (pedantic && TREE_CODE (type2) == FUNCTION_TYPE)
+ pedwarn ("ANSI C++ forbids conditional expr between 0 and function pointer");
+#endif
+ }
+ result_type = type2;
+ }
+
+ if (!result_type)
+ {
+ /* The match does not look good. If either is
+ an aggregate value, try converting to a scalar type. */
+ if (code1 == RECORD_TYPE && code2 == RECORD_TYPE)
+ {
+ cp_error ("aggregate mismatch in conditional expression: `%T' vs `%T'", type1, type2);
+ return error_mark_node;
+ }
+ if (code1 == RECORD_TYPE && TYPE_HAS_CONVERSION (type1))
+ {
+ tree tmp = build_type_conversion (CONVERT_EXPR, type2, op1, 0);
+ if (tmp == NULL_TREE)
+ {
+ cp_error ("aggregate type `%T' could not convert on lhs of `:'", type1);
+ return error_mark_node;
+ }
+ if (tmp == error_mark_node)
+ error ("ambiguous pointer conversion");
+ result_type = type2;
+ op1 = tmp;
+ }
+ else if (code2 == RECORD_TYPE && TYPE_HAS_CONVERSION (type2))
+ {
+ tree tmp = build_type_conversion (CONVERT_EXPR, type1, op2, 0);
+ if (tmp == NULL_TREE)
+ {
+ cp_error ("aggregate type `%T' could not convert on rhs of `:'", type2);
+ return error_mark_node;
+ }
+ if (tmp == error_mark_node)
+ error ("ambiguous pointer conversion");
+ result_type = type1;
+ op2 = tmp;
+ }
+ else if (flag_cond_mismatch)
+ result_type = void_type_node;
+ else
+ {
+ error ("type mismatch in conditional expression");
+ return error_mark_node;
+ }
+ }
+
+ if (TREE_CODE (result_type) == POINTER_TYPE
+ && TREE_CODE (TREE_TYPE (result_type)) == METHOD_TYPE)
+ result_type = build_ptrmemfunc_type (result_type);
+
+ if (result_type != TREE_TYPE (op1))
+ op1 = convert_and_check (result_type, op1);
+ if (result_type != TREE_TYPE (op2))
+ op2 = convert_and_check (result_type, op2);
+
+#if 0
+ /* XXX delete me, I've been here for years. */
+ if (IS_AGGR_TYPE_CODE (code1))
+ {
+ result_type = TREE_TYPE (op1);
+ if (TREE_CONSTANT (ifexp))
+ return (integer_zerop (ifexp) ? op2 : op1);
+
+ if (TYPE_MODE (result_type) == BLKmode)
+ {
+ register tree tempvar
+ = build_decl (VAR_DECL, NULL_TREE, result_type);
+ register tree xop1 = build_modify_expr (tempvar, NOP_EXPR, op1);
+ register tree xop2 = build_modify_expr (tempvar, NOP_EXPR, op2);
+ register tree result = fold (build (COND_EXPR, result_type,
+ ifexp, xop1, xop2));
+
+ layout_decl (tempvar, 0);
+ /* No way to handle variable-sized objects here.
+ I fear that the entire handling of BLKmode conditional exprs
+ needs to be redone. */
+ my_friendly_assert (TREE_CONSTANT (DECL_SIZE (tempvar)), 315);
+ DECL_RTL (tempvar)
+ = assign_stack_local (DECL_MODE (tempvar),
+ (TREE_INT_CST_LOW (DECL_SIZE (tempvar))
+ + BITS_PER_UNIT - 1)
+ / BITS_PER_UNIT,
+ 0);
+
+ TREE_SIDE_EFFECTS (result)
+ = TREE_SIDE_EFFECTS (ifexp) | TREE_SIDE_EFFECTS (op1)
+ | TREE_SIDE_EFFECTS (op2);
+ return build (COMPOUND_EXPR, result_type, result, tempvar);
+ }
+ }
+#endif /* 0 */
+
+ if (TREE_CONSTANT (ifexp))
+ return integer_zerop (ifexp) ? op2 : op1;
+
+ return convert_from_reference
+ (fold (build (COND_EXPR, result_type, ifexp, op1, op2)));
+}
+
+/* Handle overloading of the ',' operator when needed. Otherwise,
+ this function just builds an expression list. */
+tree
+build_x_compound_expr (list)
+ tree list;
+{
+ tree rest = TREE_CHAIN (list);
+ tree result;
+
+ if (rest == NULL_TREE)
+ return build_compound_expr (list);
+
+ result = build_opfncall (COMPOUND_EXPR, LOOKUP_NORMAL,
+ TREE_VALUE (list), TREE_VALUE (rest), NULL_TREE);
+ if (result)
+ return build_x_compound_expr (tree_cons (NULL_TREE, result, TREE_CHAIN (rest)));
+
+ if (! TREE_SIDE_EFFECTS (TREE_VALUE (list)))
+ {
+ /* the left-hand operand of a comma expression is like an expression
+ statement: we should warn if it doesn't have any side-effects,
+ unless it was explicitly cast to (void). */
+ if ((extra_warnings || warn_unused)
+ && !(TREE_CODE (TREE_VALUE(list)) == CONVERT_EXPR
+ && TREE_TYPE (TREE_VALUE(list)) == void_type_node))
+ warning("left-hand operand of comma expression has no effect");
+ }
+#if 0 /* this requires a gcc backend patch to export warn_if_unused_value */
+ else if (warn_unused)
+ warn_if_unused_value (TREE_VALUE(list));
+#endif
+
+ return build_compound_expr (tree_cons (NULL_TREE, TREE_VALUE (list),
+ build_tree_list (NULL_TREE, build_x_compound_expr (rest))));
+}
+
+/* Given a list of expressions, return a compound expression
+ that performs them all and returns the value of the last of them. */
+
+tree
+build_compound_expr (list)
+ tree list;
+{
+ register tree rest;
+
+ if (TREE_READONLY_DECL_P (TREE_VALUE (list)))
+ TREE_VALUE (list) = decl_constant_value (TREE_VALUE (list));
+
+ if (TREE_CHAIN (list) == 0)
+ {
+ /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
+ Strip such NOP_EXPRs, since LIST is used in non-lvalue context. */
+ if (TREE_CODE (list) == NOP_EXPR
+ && TREE_TYPE (list) == TREE_TYPE (TREE_OPERAND (list, 0)))
+ list = TREE_OPERAND (list, 0);
+
+ /* Convert arrays to pointers. */
+ if (TREE_CODE (TREE_TYPE (TREE_VALUE (list))) == ARRAY_TYPE)
+ return default_conversion (TREE_VALUE (list));
+ else
+ return TREE_VALUE (list);
+ }
+
+ rest = build_compound_expr (TREE_CHAIN (list));
+
+ /* When pedantic, a compound expression cannot be a constant expression. */
+ if (! TREE_SIDE_EFFECTS (TREE_VALUE (list)) && ! pedantic)
+ return rest;
+
+ return build (COMPOUND_EXPR, TREE_TYPE (rest),
+ break_out_cleanups (TREE_VALUE (list)), rest);
+}
+
+#ifdef __GNUC__
+__inline
+#endif
+int
+null_ptr_cst_p (t)
+ tree t;
+{
+ return (TREE_CODE (t) == INTEGER_CST && integer_zerop (t));
+}
+
+tree build_static_cast (type, expr)
+ tree type, expr;
+{
+ return build_c_cast (type, expr, 0);
+}
+
+tree build_reinterpret_cast (type, expr)
+ tree type, expr;
+{
+ tree intype = TREE_TYPE (expr);
+
+ if (TYPE_PTRMEMFUNC_P (type))
+ type = TYPE_PTRMEMFUNC_FN_TYPE (type);
+ if (TYPE_PTRMEMFUNC_P (intype))
+ intype = TYPE_PTRMEMFUNC_FN_TYPE (intype);
+
+ if (! POINTER_TYPE_P (type) && ! TREE_CODE (type) == INTEGER_TYPE)
+ {
+ cp_error ("reinterpret_cast cannot convert to type `%T'", type);
+ return error_mark_node;
+ }
+ if (! POINTER_TYPE_P (intype) && ! TREE_CODE (intype) == INTEGER_TYPE)
+ {
+ cp_error ("reinterpret_cast cannot convert from type `%T'", type);
+ return error_mark_node;
+ }
+ if (TREE_CODE (type) == INTEGER_TYPE && TREE_CODE (intype) != POINTER_TYPE)
+ {
+ cp_error ("reinterpret_cast cannot convert non-pointer type `%T' to `%T'",
+ intype, type);
+ return error_mark_node;
+ }
+ if (TREE_CODE (intype) == INTEGER_TYPE && TREE_CODE (type) != POINTER_TYPE)
+ {
+ cp_error ("reinterpret_cast cannot convert `%T' to non-pointer type `%T'",
+ intype, type);
+ return error_mark_node;
+ }
+
+ if (TREE_CODE (type) == POINTER_TYPE && TREE_CODE (intype) == POINTER_TYPE)
+ expr = convert (ptr_type_node, expr);
+
+ return build_c_cast (type, expr, 0);
+}
+
+tree build_const_cast (type, expr)
+ tree type, expr;
+{
+ tree intype = TREE_TYPE (expr);
+ tree t1, t2;
+
+ if (type == error_mark_node || expr == error_mark_node)
+ return error_mark_node;
+
+ if (TYPE_PTRMEMFUNC_P (type))
+ type = TYPE_PTRMEMFUNC_FN_TYPE (type);
+ if (TYPE_PTRMEMFUNC_P (intype))
+ intype = TYPE_PTRMEMFUNC_FN_TYPE (intype);
+
+ if (! POINTER_TYPE_P (type))
+ {
+ cp_error ("const_cast cannot convert to non-pointer type `%T'", type);
+ return error_mark_node;
+ }
+ if (TREE_CODE (type) == REFERENCE_TYPE && ! real_lvalue_p (expr))
+ {
+ cp_error ("const_cast cannot convert rvalue to type `%T'", type);
+ return error_mark_node;
+ }
+ if (TREE_CODE (type) == POINTER_TYPE && TREE_CODE (intype) != POINTER_TYPE)
+ {
+ cp_error ("const_cast cannot convert non-pointer type `%T' to type `%T'",
+ intype, type);
+ return error_mark_node;
+ }
+
+ if (TREE_CODE (type) == REFERENCE_TYPE)
+ {
+ t1 = TREE_TYPE (type);
+ t2 = intype;
+ }
+ else
+ {
+ t1 = TREE_TYPE (type);
+ t2 = TREE_TYPE (intype);
+
+ for (; TREE_CODE (t1) == POINTER_TYPE && TREE_CODE (t2) == POINTER_TYPE;
+ t1 = TREE_TYPE (t1), t2 = TREE_TYPE (t2))
+ ;
+ }
+
+ if (TREE_CODE (t1) == OFFSET_TYPE && TREE_CODE (t2) == OFFSET_TYPE)
+ {
+ if (TYPE_OFFSET_BASETYPE (t1) != TYPE_OFFSET_BASETYPE (t2))
+ {
+ cp_error ("const_cast cannot convert between pointers to members of different types `%T' and `%T'",
+ TYPE_OFFSET_BASETYPE (t2), TYPE_OFFSET_BASETYPE (t1));
+ return error_mark_node;
+ }
+ t1 = TREE_TYPE (t1);
+ t2 = TREE_TYPE (t2);
+ }
+
+ if (TYPE_MAIN_VARIANT (t1) != TYPE_MAIN_VARIANT (t2))
+ {
+ cp_error ("const_cast cannot convert unrelated type `%T' to `%T'",
+ t2, t1);
+ return error_mark_node;
+ }
+
+ return build_c_cast (type, expr, 0);
+}
+
+/* Build an expression representing a cast to type TYPE of expression EXPR.
+
+ ALLOW_NONCONVERTING is true if we should allow non-converting constructors
+ when doing the cast. */
+
+tree
+build_c_cast (type, expr, allow_nonconverting)
+ register tree type;
+ tree expr;
+ int allow_nonconverting;
+{
+ register tree value = expr;
+
+ if (type == error_mark_node || expr == error_mark_node)
+ return error_mark_node;
+
+ /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
+ Strip such NOP_EXPRs if VALUE is being used in non-lvalue context. */
+ if (TREE_CODE (type) != REFERENCE_TYPE
+ && TREE_CODE (value) == NOP_EXPR
+ && TREE_TYPE (value) == TREE_TYPE (TREE_OPERAND (value, 0)))
+ value = TREE_OPERAND (value, 0);
+
+ if (TREE_TYPE (expr)
+ && TREE_CODE (TREE_TYPE (expr)) == OFFSET_TYPE
+ && TREE_CODE (type) != OFFSET_TYPE)
+ value = resolve_offset_ref (value);
+
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ {
+ /* Allow casting from T1* to T2[] because Cfront allows it.
+ NIHCL uses it. It is not valid ANSI C however, and hence, not
+ valid ANSI C++. */
+ if (TREE_CODE (TREE_TYPE (expr)) == POINTER_TYPE)
+ {
+ if (pedantic)
+ pedwarn ("ANSI C++ forbids casting to an array type");
+ type = build_pointer_type (TREE_TYPE (type));
+ }
+ else
+ {
+ error ("ANSI C++ forbids casting to an array type");
+ return error_mark_node;
+ }
+ }
+
+ if (TREE_CODE (type) == FUNCTION_TYPE
+ || TREE_CODE (type) == METHOD_TYPE)
+ {
+ cp_error ("casting to function type `%T'", type);
+ return error_mark_node;
+ }
+
+ if (IS_SIGNATURE (type))
+ {
+ error ("cast specifies signature type");
+ return error_mark_node;
+ }
+
+ /* If there's only one function in the overloaded space,
+ just take it. */
+ if (TREE_CODE (value) == TREE_LIST
+ && TREE_CHAIN (value) == NULL_TREE)
+ value = TREE_VALUE (value);
+
+ if (TREE_CODE (type) == VOID_TYPE)
+ value = build1 (CONVERT_EXPR, type, value);
+ else if (TREE_TYPE (value) == NULL_TREE
+ || type_unknown_p (value))
+ {
+ value = instantiate_type (type, value, 1);
+ /* Did we lose? */
+ if (value == error_mark_node)
+ return error_mark_node;
+ }
+ else
+ {
+ tree otype;
+ int flag;
+
+ /* Convert functions and arrays to pointers and
+ convert references to their expanded types,
+ but don't convert any other types. */
+ if (TREE_CODE (TREE_TYPE (value)) == FUNCTION_TYPE
+ || TREE_CODE (TREE_TYPE (value)) == METHOD_TYPE
+ || TREE_CODE (TREE_TYPE (value)) == ARRAY_TYPE
+ || TREE_CODE (TREE_TYPE (value)) == REFERENCE_TYPE)
+ value = default_conversion (value);
+ otype = TREE_TYPE (value);
+
+ /* Optionally warn about potentially worrisome casts. */
+
+ if (warn_cast_qual
+ && TREE_CODE (type) == POINTER_TYPE
+ && TREE_CODE (otype) == POINTER_TYPE)
+ {
+ /* For C++ we make these regular warnings, rather than
+ softening them into pedwarns. */
+ if (TYPE_VOLATILE (TREE_TYPE (otype))
+ && ! TYPE_VOLATILE (TREE_TYPE (type)))
+ warning ("cast discards `volatile' from pointer target type");
+ if (TYPE_READONLY (TREE_TYPE (otype))
+ && ! TYPE_READONLY (TREE_TYPE (type)))
+ warning ("cast discards `const' from pointer target type");
+ }
+
+ /* Warn about possible alignment problems. */
+ if (STRICT_ALIGNMENT && warn_cast_align
+ && TREE_CODE (type) == POINTER_TYPE
+ && TREE_CODE (otype) == POINTER_TYPE
+ && TREE_CODE (TREE_TYPE (otype)) != VOID_TYPE
+ && TREE_CODE (TREE_TYPE (otype)) != FUNCTION_TYPE
+ && TYPE_ALIGN (TREE_TYPE (type)) > TYPE_ALIGN (TREE_TYPE (otype)))
+ warning ("cast increases required alignment of target type");
+
+#if 0
+ if (TREE_CODE (type) == INTEGER_TYPE
+ && TREE_CODE (otype) == POINTER_TYPE
+ && TYPE_PRECISION (type) != TYPE_PRECISION (otype))
+ warning ("cast from pointer to integer of different size");
+
+ if (TREE_CODE (type) == POINTER_TYPE
+ && TREE_CODE (otype) == INTEGER_TYPE
+ && TYPE_PRECISION (type) != TYPE_PRECISION (otype)
+ /* Don't warn about converting 0 to pointer,
+ provided the 0 was explicit--not cast or made by folding. */
+ && !(TREE_CODE (value) == INTEGER_CST && integer_zerop (value)))
+ warning ("cast to pointer from integer of different size");
+#endif
+
+ flag = allow_nonconverting ? CONV_NONCONVERTING : 0;
+
+ if (TREE_CODE (type) == REFERENCE_TYPE)
+ value = (convert_from_reference
+ (convert_to_reference (type, value, CONV_OLD_CONVERT|flag,
+ LOOKUP_COMPLAIN, NULL_TREE)));
+ else
+ {
+ tree ovalue;
+
+ if (TREE_READONLY_DECL_P (value))
+ value = decl_constant_value (value);
+
+ ovalue = value;
+ value = convert_force (type, value, flag);
+
+ /* Ignore any integer overflow caused by the cast. */
+ if (TREE_CODE (value) == INTEGER_CST)
+ {
+ TREE_OVERFLOW (value) = TREE_OVERFLOW (ovalue);
+ TREE_CONSTANT_OVERFLOW (value) = TREE_CONSTANT_OVERFLOW (ovalue);
+ }
+ }
+ }
+
+ /* Always produce some operator for an explicit cast,
+ so we can tell (for -pedantic) that the cast is no lvalue.
+ Also, pedantically, don't let (void *) (FOO *) 0 be a null
+ pointer constant. */
+ if (TREE_CODE (type) != REFERENCE_TYPE
+ && (value == expr
+ || (pedantic
+ && TREE_CODE (value) == INTEGER_CST
+ && TREE_CODE (expr) == INTEGER_CST
+ && TREE_CODE (TREE_TYPE (expr)) != INTEGER_TYPE)))
+ value = non_lvalue (value);
+
+ return value;
+}
+
+#if 0
+/* Build an assignment expression of lvalue LHS from value RHS.
+
+ In C++, if the left hand side of the assignment is a REFERENCE_TYPE,
+ that reference becomes deferenced down to it base type. */
+
+/* Return a reference to the BASE_INDEX part of EXPR. TYPE is
+ the type to which BASE_INDEX applies. */
+static tree
+get_base_ref (type, base_index, expr)
+ tree type;
+ int base_index;
+ tree expr;
+{
+ tree binfos = TYPE_BINFO_BASETYPES (type);
+ tree base_binfo = TREE_VEC_ELT (binfos, base_index);
+ tree ref;
+
+ if (TREE_CODE (expr) == ARRAY_REF
+ || ! BINFO_OFFSET_ZEROP (base_binfo)
+ || TREE_VIA_VIRTUAL (base_binfo)
+ || TYPE_MODE (type) != TYPE_MODE (BINFO_TYPE (base_binfo)))
+ {
+ tree addr = build_unary_op (ADDR_EXPR, expr, 0);
+ ref = build_indirect_ref (convert_pointer_to (base_binfo, addr),
+ NULL_PTR);
+ }
+ else
+ {
+ ref = copy_node (expr);
+ TREE_TYPE (ref) = BINFO_TYPE (base_binfo);
+ }
+ return ref;
+}
+
+/* Build an assignment expression of lvalue LHS from value RHS.
+ MODIFYCODE is the code for a binary operator that we use
+ to combine the old value of LHS with RHS to get the new value.
+ Or else MODIFYCODE is NOP_EXPR meaning do a simple assignment.
+
+ C++: If MODIFYCODE is INIT_EXPR, then leave references unbashed.
+
+ `build_modify_expr_1' implements recursive part of memberwise
+ assignment operation. */
+static tree
+build_modify_expr_1 (lhs, modifycode, rhs, basetype_path)
+ tree lhs, rhs;
+ enum tree_code modifycode;
+ tree basetype_path;
+{
+ register tree result;
+ tree newrhs = rhs;
+ tree lhstype = TREE_TYPE (lhs);
+ tree olhstype = lhstype;
+
+ /* Avoid duplicate error messages from operands that had errors. */
+ if (TREE_CODE (lhs) == ERROR_MARK || TREE_CODE (rhs) == ERROR_MARK)
+ return error_mark_node;
+
+ /* If a binary op has been requested, combine the old LHS value with the RHS
+ producing the value we should actually store into the LHS. */
+
+ if (modifycode == INIT_EXPR)
+ ;
+ else if (modifycode == NOP_EXPR)
+ {
+ /* must deal with overloading of `operator=' here. */
+ if (TREE_CODE (lhstype) == REFERENCE_TYPE)
+ lhstype = TREE_TYPE (lhstype);
+ else
+ lhstype = olhstype;
+ }
+ else
+ {
+ lhs = stabilize_reference (lhs);
+ newrhs = build_binary_op (modifycode, lhs, rhs, 1);
+ modifycode = NOP_EXPR;
+ }
+
+ /* If storing into a structure or union member,
+ it has probably been given type `int'.
+ Compute the type that would go with
+ the actual amount of storage the member occupies. */
+
+ if (TREE_CODE (lhs) == COMPONENT_REF
+ && (TREE_CODE (lhstype) == INTEGER_TYPE
+ || TREE_CODE (lhstype) == REAL_TYPE
+ || TREE_CODE (lhstype) == ENUMERAL_TYPE))
+ lhstype = TREE_TYPE (get_unwidened (lhs, 0));
+
+ /* C++: The semantics of C++ differ from those of C when an
+ assignment of an aggregate is desired. Assignment in C++ is
+ now defined as memberwise assignment of non-static members
+ and base class objects. This rule applies recursively
+ until a member of a built-in type is found.
+
+ Also, we cannot do a bit-wise copy of aggregates which
+ contain virtual function table pointers. Those
+ pointer values must be preserved through the copy.
+ However, this is handled in expand_expr, and not here.
+ This is because much better code can be generated at
+ that stage than this one. */
+ if (TREE_CODE (lhstype) == RECORD_TYPE
+ && TYPE_LANG_SPECIFIC (lhstype)
+ && TYPE_MAIN_VARIANT (lhstype) == TYPE_MAIN_VARIANT (TREE_TYPE (newrhs)))
+ {
+ register tree elt;
+ int i;
+
+ /* Perform operation on object. */
+ if (modifycode == INIT_EXPR && TYPE_HAS_INIT_REF (lhstype))
+ {
+ result = build_method_call (lhs, constructor_name_full (lhstype),
+ build_tree_list (NULL_TREE, rhs),
+ basetype_path, LOOKUP_NORMAL);
+ return build_indirect_ref (result, NULL_PTR);
+ }
+ else if (modifycode == NOP_EXPR)
+ {
+ /* `operator=' is not an inheritable operator; see 13.4.3. */
+ if (TYPE_LANG_SPECIFIC (lhstype) && TYPE_HAS_ASSIGNMENT (lhstype))
+ {
+ result = build_opfncall (MODIFY_EXPR, LOOKUP_NORMAL,
+ lhs, rhs, make_node (NOP_EXPR));
+ if (result == NULL_TREE)
+ return error_mark_node;
+ return result;
+ }
+ }
+
+ if (TYPE_USES_VIRTUAL_BASECLASSES (lhstype)
+ || (modifycode == NOP_EXPR && TYPE_GETS_ASSIGNMENT (lhstype))
+ || (modifycode == INIT_EXPR && TYPE_GETS_INIT_REF (lhstype)))
+ {
+ tree binfos = BINFO_BASETYPES (TYPE_BINFO (lhstype));
+ result = NULL_TREE;
+
+ if (binfos != NULL_TREE)
+ /* Perform operation on each member, depth-first, left-right. */
+ for (i = 0; i <= TREE_VEC_LENGTH (binfos)-1; i++)
+ {
+ tree base_binfo = TREE_VEC_ELT (binfos, i);
+ tree base_lhs, base_rhs;
+ tree new_result;
+
+ /* Assignments from virtual baseclasses handled elsewhere. */
+ if (TREE_VIA_VIRTUAL (base_binfo))
+ continue;
+
+ base_lhs = get_base_ref (lhstype, i, lhs);
+ base_rhs = get_base_ref (lhstype, i, newrhs);
+
+ BINFO_INHERITANCE_CHAIN (base_binfo) = basetype_path;
+ new_result
+ = build_modify_expr_1 (base_lhs, modifycode, base_rhs,
+ base_binfo);
+
+ /* We either get back a compound stmt, or a simple one. */
+ if (new_result && TREE_CODE (new_result) == TREE_LIST)
+ new_result = build_compound_expr (new_result);
+ result = tree_cons (NULL_TREE, new_result, result);
+ }
+
+ for (elt = TYPE_FIELDS (lhstype); elt; elt = TREE_CHAIN (elt))
+ {
+ tree vbases = NULL_TREE;
+ tree elt_lhs, elt_rhs;
+
+ if (TREE_CODE (elt) != FIELD_DECL)
+ continue;
+ if (DECL_NAME (elt)
+ && (VFIELD_NAME_P (DECL_NAME (elt))
+ || VBASE_NAME_P (DECL_NAME (elt))))
+ continue;
+
+ if (TREE_READONLY (elt)
+ || TREE_CODE (TREE_TYPE (elt)) == REFERENCE_TYPE)
+ {
+ cp_error ("cannot generate default `%T::operator ='",
+ lhstype);
+ if (TREE_CODE (TREE_TYPE (elt)) == REFERENCE_TYPE)
+ cp_error_at ("because member `%#D' is a reference", elt);
+ else
+ cp_error_at ("because member `%#D' is const", elt);
+
+ return error_mark_node;
+ }
+
+ if (IS_AGGR_TYPE (TREE_TYPE (elt))
+ && TYPE_LANG_SPECIFIC (TREE_TYPE (elt)))
+ vbases = CLASSTYPE_VBASECLASSES (TREE_TYPE (elt));
+
+ elt_lhs = build (COMPONENT_REF, TREE_TYPE (elt), lhs, elt);
+ elt_rhs = build (COMPONENT_REF, TREE_TYPE (elt), newrhs, elt);
+ /* It is not always safe to go through `build_modify_expr_1'
+ when performing element-wise copying. This is because
+ an element may be of ARRAY_TYPE, which will not
+ be properly copied as a naked element. */
+ if (TREE_CODE (TREE_TYPE (elt)) == RECORD_TYPE
+ && TYPE_LANG_SPECIFIC (TREE_TYPE (elt)))
+ basetype_path = TYPE_BINFO (TREE_TYPE (elt));
+
+ while (vbases)
+ {
+ tree elt_lhs_addr = build_unary_op (ADDR_EXPR, elt_lhs, 0);
+ tree elt_rhs_addr = build_unary_op (ADDR_EXPR, elt_rhs, 0);
+
+ elt_lhs_addr = convert_pointer_to (vbases, elt_lhs_addr);
+ elt_rhs_addr = convert_pointer_to (vbases, elt_rhs_addr);
+ result
+ = tree_cons (NULL_TREE,
+ build_modify_expr_1
+ (build_indirect_ref (elt_lhs_addr, NULL_PTR),
+ modifycode,
+ build_indirect_ref (elt_rhs_addr, NULL_PTR),
+ basetype_path),
+ result);
+ if (TREE_VALUE (result) == error_mark_node)
+ return error_mark_node;
+ vbases = TREE_CHAIN (vbases);
+ }
+ elt_lhs = build_modify_expr_1 (elt_lhs, modifycode, elt_rhs,
+ basetype_path);
+ result = tree_cons (NULL_TREE, elt_lhs, result);
+ }
+
+ if (result)
+ return build_compound_expr (result);
+ /* No fields to move. */
+ return integer_zero_node;
+ }
+ else
+ {
+ result = build (modifycode == NOP_EXPR ? MODIFY_EXPR : INIT_EXPR,
+ void_type_node, lhs, rhs);
+ TREE_SIDE_EFFECTS (result) = 1;
+ return result;
+ }
+ }
+
+ result = build_modify_expr (lhs, modifycode, newrhs);
+ /* ARRAY_TYPEs cannot be converted to anything meaningful,
+ and leaving it there screws up `build_compound_expr' when
+ it tries to defaultly convert everything. */
+ if (TREE_CODE (TREE_TYPE (result)) == ARRAY_TYPE)
+ TREE_TYPE (result) = void_type_node;
+ return result;
+}
+#endif
+
+/* Taken from expr.c:
+ Subroutine of expand_expr:
+ record the non-copied parts (LIST) of an expr (LHS), and return a list
+ which specifies the initial values of these parts. */
+
+static tree
+init_noncopied_parts (lhs, list)
+ tree lhs;
+ tree list;
+{
+ tree tail;
+ tree parts = 0;
+
+ for (tail = list; tail; tail = TREE_CHAIN (tail))
+ if (TREE_CODE (TREE_VALUE (tail)) == TREE_LIST)
+ parts = chainon (parts, init_noncopied_parts (lhs, TREE_VALUE (tail)));
+ else
+ {
+ tree part = TREE_VALUE (tail);
+ tree part_type = TREE_TYPE (part);
+ tree to_be_initialized = build (COMPONENT_REF, part_type, lhs, part);
+ parts = tree_cons (TREE_PURPOSE (tail), to_be_initialized, parts);
+ }
+ return parts;
+}
+
+tree
+expand_target_expr (t)
+ tree t;
+{
+ tree xval = make_node (RTL_EXPR);
+ rtx rtxval;
+
+ do_pending_stack_adjust ();
+ start_sequence_for_rtl_expr (xval);
+ emit_note (0, -1);
+ rtxval = expand_expr (t, NULL, VOIDmode, 0);
+ do_pending_stack_adjust ();
+ TREE_SIDE_EFFECTS (xval) = 1;
+ RTL_EXPR_SEQUENCE (xval) = get_insns ();
+ end_sequence ();
+ RTL_EXPR_RTL (xval) = rtxval;
+ TREE_TYPE (xval) = TREE_TYPE (t);
+ return xval;
+}
+
+/* Build an assignment expression of lvalue LHS from value RHS.
+ MODIFYCODE is the code for a binary operator that we use
+ to combine the old value of LHS with RHS to get the new value.
+ Or else MODIFYCODE is NOP_EXPR meaning do a simple assignment.
+
+ C++: If MODIFYCODE is INIT_EXPR, then leave references unbashed.
+*/
+tree
+build_modify_expr (lhs, modifycode, rhs)
+ tree lhs;
+ enum tree_code modifycode;
+ tree rhs;
+{
+ register tree result;
+ tree newrhs = rhs;
+ tree lhstype = TREE_TYPE (lhs);
+ tree olhstype = lhstype;
+ tree olhs = lhs;
+
+ /* Avoid duplicate error messages from operands that had errors. */
+ if (TREE_CODE (lhs) == ERROR_MARK || TREE_CODE (rhs) == ERROR_MARK)
+ return error_mark_node;
+
+ /* Types that aren't fully specified cannot be used in assignments. */
+ lhs = require_complete_type (lhs);
+
+ /* Decide early if we are going to protect RHS from GC
+ before assigning it to LHS. */
+ if (type_needs_gc_entry (TREE_TYPE (rhs))
+ && ! value_safe_from_gc (lhs, rhs))
+ rhs = protect_value_from_gc (lhs, rhs);
+
+ newrhs = rhs;
+
+ /* Handle assignment to signature pointers/refs. */
+
+ if (TYPE_LANG_SPECIFIC (lhstype) &&
+ (IS_SIGNATURE_POINTER (lhstype) || IS_SIGNATURE_REFERENCE (lhstype)))
+ {
+ return build_signature_pointer_constructor (lhs, rhs);
+ }
+
+ /* Handle control structure constructs used as "lvalues". */
+
+ switch (TREE_CODE (lhs))
+ {
+ /* Handle --foo = 5; as these are valid constructs in C++ */
+ case PREDECREMENT_EXPR:
+ case PREINCREMENT_EXPR:
+ if (TREE_SIDE_EFFECTS (TREE_OPERAND (lhs, 0)))
+ lhs = build (TREE_CODE (lhs), TREE_TYPE (lhs),
+ stabilize_reference (TREE_OPERAND (lhs, 0)));
+ return build (COMPOUND_EXPR, lhstype,
+ lhs,
+ build_modify_expr (TREE_OPERAND (lhs, 0),
+ modifycode, rhs));
+
+ /* Handle (a, b) used as an "lvalue". */
+ case COMPOUND_EXPR:
+ newrhs = build_modify_expr (TREE_OPERAND (lhs, 1),
+ modifycode, rhs);
+ if (TREE_CODE (newrhs) == ERROR_MARK)
+ return error_mark_node;
+ return build (COMPOUND_EXPR, lhstype,
+ TREE_OPERAND (lhs, 0), newrhs);
+
+ case MODIFY_EXPR:
+ newrhs = build_modify_expr (TREE_OPERAND (lhs, 0), modifycode, rhs);
+ if (TREE_CODE (newrhs) == ERROR_MARK)
+ return error_mark_node;
+ return build (COMPOUND_EXPR, lhstype, lhs, newrhs);
+
+ /* Handle (a ? b : c) used as an "lvalue". */
+ case COND_EXPR:
+ rhs = save_expr (rhs);
+ {
+ /* Produce (a ? (b = rhs) : (c = rhs))
+ except that the RHS goes through a save-expr
+ so the code to compute it is only emitted once. */
+ tree cond
+ = build_conditional_expr (TREE_OPERAND (lhs, 0),
+ build_modify_expr (convert (TREE_TYPE (lhs), TREE_OPERAND (lhs, 1)),
+ modifycode, rhs),
+ build_modify_expr (convert (TREE_TYPE (lhs), TREE_OPERAND (lhs, 2)),
+ modifycode, rhs));
+ if (TREE_CODE (cond) == ERROR_MARK)
+ return cond;
+ /* Make sure the code to compute the rhs comes out
+ before the split. */
+ return build (COMPOUND_EXPR, TREE_TYPE (lhs),
+ /* Case to void to suppress warning
+ from warn_if_unused_value. */
+ convert (void_type_node, rhs), cond);
+ }
+ }
+
+ if (TREE_CODE (lhs) == OFFSET_REF)
+ {
+ if (TREE_OPERAND (lhs, 0) == NULL_TREE)
+ {
+ /* Static class member? */
+ tree member = TREE_OPERAND (lhs, 1);
+ if (TREE_CODE (member) == VAR_DECL)
+ lhs = member;
+ else
+ {
+ compiler_error ("invalid static class member");
+ return error_mark_node;
+ }
+ }
+ else
+ lhs = resolve_offset_ref (lhs);
+
+ olhstype = lhstype = TREE_TYPE (lhs);
+ }
+
+ if (TREE_CODE (lhstype) == REFERENCE_TYPE
+ && modifycode != INIT_EXPR)
+ {
+ lhs = convert_from_reference (lhs);
+ olhstype = lhstype = TREE_TYPE (lhs);
+ }
+
+ /* If a binary op has been requested, combine the old LHS value with the RHS
+ producing the value we should actually store into the LHS. */
+
+ if (modifycode == INIT_EXPR)
+ {
+ if (! IS_AGGR_TYPE (lhstype))
+ /* Do the default thing */;
+ else if (! TYPE_HAS_CONSTRUCTOR (lhstype))
+ {
+ cp_error ("`%T' has no constructors", lhstype);
+ return error_mark_node;
+ }
+ else if (TYPE_HAS_TRIVIAL_INIT_REF (lhstype)
+ && TYPE_MAIN_VARIANT (lhstype) == TYPE_MAIN_VARIANT (TREE_TYPE (newrhs)))
+ /* Do the default thing */;
+ else
+ {
+ result = build_method_call (lhs, constructor_name_full (lhstype),
+ build_tree_list (NULL_TREE, rhs),
+ NULL_TREE, LOOKUP_NORMAL);
+ if (result == NULL_TREE)
+ return error_mark_node;
+ return result;
+ }
+ }
+ else if (modifycode == NOP_EXPR)
+ {
+#if 1
+ /* `operator=' is not an inheritable operator. */
+ if (! IS_AGGR_TYPE (lhstype))
+ /* Do the default thing */;
+ else if (! TYPE_HAS_ASSIGNMENT (lhstype))
+ {
+ cp_error ("`%T' does not define operator=", lhstype);
+ return error_mark_node;
+ }
+ else if (TYPE_HAS_TRIVIAL_ASSIGN_REF (lhstype)
+ && TYPE_MAIN_VARIANT (lhstype) == TYPE_MAIN_VARIANT (TREE_TYPE (newrhs)))
+ {
+ if (warn_synth)
+ /* If we care about this, do overload resolution. */
+ build_opfncall (MODIFY_EXPR, LOOKUP_NORMAL,
+ lhs, rhs, make_node (NOP_EXPR));
+
+ /* Do the default thing */;
+ }
+ else
+ {
+ result = build_opfncall (MODIFY_EXPR, LOOKUP_NORMAL,
+ lhs, rhs, make_node (NOP_EXPR));
+ if (result == NULL_TREE)
+ return error_mark_node;
+ return result;
+ }
+#else
+ /* Treat `operator=' as an inheritable operator. */
+ if (TYPE_LANG_SPECIFIC (lhstype) && TYPE_GETS_ASSIGNMENT (lhstype))
+ {
+ tree orig_lhstype = lhstype;
+ while (! TYPE_HAS_ASSIGNMENT (lhstype))
+ {
+ int i, n_baseclasses = CLASSTYPE_N_BASECLASSES (lhstype);
+ tree basetype = NULL_TREE;
+ for (i = 0; i < n_baseclasses; i++)
+ if (TYPE_GETS_ASSIGNMENT (TYPE_BINFO_BASETYPE (lhstype, i)))
+ {
+ if (basetype != NULL_TREE)
+ {
+ message_2_types (error, "base classes `%s' and `%s' both have operator ='",
+ basetype,
+ TYPE_BINFO_BASETYPE (lhstype, i));
+ return error_mark_node;
+ }
+ basetype = TYPE_BINFO_BASETYPE (lhstype, i);
+ }
+ lhstype = basetype;
+ }
+ if (orig_lhstype != lhstype)
+ {
+ lhs = build_indirect_ref (convert_pointer_to (lhstype,
+ build_unary_op (ADDR_EXPR, lhs, 0)), NULL_PTR);
+ if (lhs == error_mark_node)
+ {
+ cp_error ("conversion to private basetype `%T'", lhstype);
+ return error_mark_node;
+ }
+ }
+ result = build_opfncall (MODIFY_EXPR, LOOKUP_NORMAL,
+ lhs, rhs, make_node (NOP_EXPR));
+ if (result == NULL_TREE)
+ return error_mark_node;
+ return result;
+ }
+#endif
+ lhstype = olhstype;
+ }
+ else if (PROMOTES_TO_AGGR_TYPE (lhstype, REFERENCE_TYPE))
+ {
+ /* This case must convert to some sort of lvalue that
+ can participate in an op= operation. */
+ tree lhs_tmp = lhs;
+ tree rhs_tmp = rhs;
+ if (build_default_binary_type_conversion (modifycode, &lhs_tmp, &rhs_tmp))
+ {
+ lhs = stabilize_reference (lhs_tmp);
+ /* Forget is was ever anything else. */
+ olhstype = lhstype = TREE_TYPE (lhs);
+ newrhs = build_binary_op (modifycode, lhs, rhs_tmp, 1);
+ }
+ else
+ {
+ cp_error ("no match for `%O(%#T, %#T)'", modifycode,
+ TREE_TYPE (lhs), TREE_TYPE (rhs));
+ return error_mark_node;
+ }
+ }
+ else
+ {
+ lhs = stabilize_reference (lhs);
+ newrhs = build_binary_op (modifycode, lhs, rhs, 1);
+ }
+
+ /* Handle a cast used as an "lvalue".
+ We have already performed any binary operator using the value as cast.
+ Now convert the result to the cast type of the lhs,
+ and then true type of the lhs and store it there;
+ then convert result back to the cast type to be the value
+ of the assignment. */
+
+ switch (TREE_CODE (lhs))
+ {
+ case NOP_EXPR:
+ case CONVERT_EXPR:
+ case FLOAT_EXPR:
+ case FIX_TRUNC_EXPR:
+ case FIX_FLOOR_EXPR:
+ case FIX_ROUND_EXPR:
+ case FIX_CEIL_EXPR:
+ if (TREE_CODE (TREE_TYPE (newrhs)) == ARRAY_TYPE
+ || TREE_CODE (TREE_TYPE (newrhs)) == FUNCTION_TYPE
+ || TREE_CODE (TREE_TYPE (newrhs)) == METHOD_TYPE
+ || TREE_CODE (TREE_TYPE (newrhs)) == OFFSET_TYPE)
+ newrhs = default_conversion (newrhs);
+ {
+ tree inner_lhs = TREE_OPERAND (lhs, 0);
+ tree result;
+ if (! lvalue_p (lhs) && pedantic)
+ pedwarn ("cast to non-reference type used as lvalue");
+
+ result = build_modify_expr (inner_lhs, NOP_EXPR,
+ convert (TREE_TYPE (inner_lhs),
+ convert (lhstype, newrhs)));
+ if (TREE_CODE (result) == ERROR_MARK)
+ return result;
+ return convert (TREE_TYPE (lhs), result);
+ }
+ }
+
+ /* Now we have handled acceptable kinds of LHS that are not truly lvalues.
+ Reject anything strange now. */
+
+ if (!lvalue_or_else (lhs, "assignment"))
+ return error_mark_node;
+
+ GNU_xref_assign (lhs);
+
+ /* Warn about storing in something that is `const'. */
+ /* For C++, don't warn if this is initialization. */
+ if (modifycode != INIT_EXPR
+ /* For assignment to `const' signature pointer/reference fields,
+ don't warn either, we already printed a better message before. */
+ && ! (TREE_CODE (lhs) == COMPONENT_REF
+ && (IS_SIGNATURE_POINTER (TREE_TYPE (TREE_OPERAND (lhs, 0)))
+ || IS_SIGNATURE_REFERENCE (TREE_TYPE (TREE_OPERAND (lhs, 0)))))
+ && (TREE_READONLY (lhs) || TYPE_READONLY (lhstype)
+ || ((TREE_CODE (lhstype) == RECORD_TYPE
+ || TREE_CODE (lhstype) == UNION_TYPE)
+ && C_TYPE_FIELDS_READONLY (lhstype))
+ || (TREE_CODE (lhstype) == REFERENCE_TYPE
+ && TYPE_READONLY (TREE_TYPE (lhstype)))))
+ readonly_error (lhs, "assignment", 0);
+
+ /* If storing into a structure or union member,
+ it has probably been given type `int'.
+ Compute the type that would go with
+ the actual amount of storage the member occupies. */
+
+ if (TREE_CODE (lhs) == COMPONENT_REF
+ && (TREE_CODE (lhstype) == INTEGER_TYPE
+ || TREE_CODE (lhstype) == REAL_TYPE
+ || TREE_CODE (lhstype) == ENUMERAL_TYPE))
+ {
+ lhstype = TREE_TYPE (get_unwidened (lhs, 0));
+
+ /* If storing in a field that is in actuality a short or narrower
+ than one, we must store in the field in its actual type. */
+
+ if (lhstype != TREE_TYPE (lhs))
+ {
+ lhs = copy_node (lhs);
+ TREE_TYPE (lhs) = lhstype;
+ }
+ }
+
+ /* check to see if there is an assignment to `this' */
+ if (lhs == current_class_decl)
+ {
+ if (flag_this_is_variable > 0
+ && DECL_NAME (current_function_decl) != NULL_TREE
+ && (DECL_NAME (current_function_decl)
+ != constructor_name (current_class_type)))
+ warning ("assignment to `this' not in constructor or destructor");
+ current_function_just_assigned_this = 1;
+ }
+
+ /* The TREE_TYPE of RHS may be TYPE_UNKNOWN. This can happen
+ when the type of RHS is not yet known, i.e. its type
+ is inherited from LHS. */
+ rhs = require_instantiated_type (lhstype, newrhs, error_mark_node);
+ if (rhs == error_mark_node)
+ return error_mark_node;
+ newrhs = rhs;
+
+ if (modifycode != INIT_EXPR)
+ {
+ /* Make modifycode now either a NOP_EXPR or an INIT_EXPR. */
+ modifycode = NOP_EXPR;
+ /* Reference-bashing */
+ if (TREE_CODE (lhstype) == REFERENCE_TYPE)
+ {
+ tree tmp = convert_from_reference (lhs);
+ lhstype = TREE_TYPE (tmp);
+ if (TYPE_SIZE (lhstype) == 0)
+ {
+ incomplete_type_error (lhs, lhstype);
+ return error_mark_node;
+ }
+ lhs = tmp;
+ olhstype = lhstype;
+ }
+ if (TREE_CODE (TREE_TYPE (newrhs)) == REFERENCE_TYPE)
+ {
+ tree tmp = convert_from_reference (newrhs);
+ if (TYPE_SIZE (TREE_TYPE (tmp)) == 0)
+ {
+ incomplete_type_error (newrhs, TREE_TYPE (tmp));
+ return error_mark_node;
+ }
+ newrhs = tmp;
+ }
+ }
+
+ if (TREE_SIDE_EFFECTS (lhs))
+ lhs = stabilize_reference (lhs);
+ if (TREE_SIDE_EFFECTS (newrhs))
+ newrhs = stabilize_reference (newrhs);
+
+#if 0
+ /* This is now done by generating X(X&) and operator=(X&). */
+ /* C++: The semantics of C++ differ from those of C when an
+ assignment of an aggregate is desired. Assignment in C++ is
+ now defined as memberwise assignment of non-static members
+ and base class objects. This rule applies recursively
+ until a member of a built-in type is found.
+
+ Also, we cannot do a bit-wise copy of aggregates which
+ contain virtual function table pointers. Those
+ pointer values must be preserved through the copy.
+ However, this is handled in expand_expr, and not here.
+ This is because much better code can be generated at
+ that stage than this one. */
+ if (TREE_CODE (lhstype) == RECORD_TYPE
+ && ! TYPE_PTRMEMFUNC_P (lhstype)
+ && (TYPE_MAIN_VARIANT (lhstype) == TYPE_MAIN_VARIANT (TREE_TYPE (newrhs))
+ || (TREE_CODE (TREE_TYPE (newrhs)) == RECORD_TYPE
+ && UNIQUELY_DERIVED_FROM_P (lhstype, TREE_TYPE (newrhs)))))
+ {
+ tree vbases = CLASSTYPE_VBASECLASSES (lhstype);
+ tree lhs_addr = build_unary_op (ADDR_EXPR, lhs, 0);
+ tree rhs_addr;
+
+ /* Memberwise assignment would cause NEWRHS to be
+ evaluated for every member that gets assigned.
+ By wrapping side-effecting exprs in a SAVE_EXPR,
+ NEWRHS will only be evaluated once. */
+ if (IS_AGGR_TYPE (TREE_TYPE (newrhs))
+ && TREE_SIDE_EFFECTS (newrhs)
+ /* This are things we don't have to save. */
+ && TREE_CODE (newrhs) != COND_EXPR
+ && TREE_CODE (newrhs) != TARGET_EXPR
+ && TREE_CODE (newrhs) != WITH_CLEANUP_EXPR)
+ /* Call `break_out_cleanups' on NEWRHS in case there are cleanups.
+ If NEWRHS is a CALL_EXPR that needs a cleanup, failure to do so
+ will result in expand_expr expanding the call without knowing
+ that it should run the cleanup. */
+ newrhs = save_expr (break_out_cleanups (newrhs));
+
+ if (TREE_CODE (newrhs) == COND_EXPR)
+ rhs_addr = rationalize_conditional_expr (ADDR_EXPR, newrhs);
+ else
+ rhs_addr = build_unary_op (ADDR_EXPR, newrhs, 0);
+
+ result = tree_cons (NULL_TREE,
+ convert (build_reference_type (lhstype), lhs),
+ NULL_TREE);
+
+ if (! comptypes (TREE_TYPE (lhs_addr), TREE_TYPE (rhs_addr), 1))
+ rhs_addr = convert_pointer_to (TREE_TYPE (TREE_TYPE (lhs_addr)), rhs_addr);
+ {
+ tree noncopied_parts = NULL_TREE;
+
+ if (TYPE_NONCOPIED_PARTS (lhstype) != 0)
+ noncopied_parts = init_noncopied_parts (lhs,
+ TYPE_NONCOPIED_PARTS (lhstype));
+ while (noncopied_parts != 0)
+ {
+ result = tree_cons (NULL_TREE,
+ build_modify_expr (convert (ptr_type_node, TREE_VALUE (noncopied_parts)),
+ NOP_EXPR,
+ TREE_PURPOSE (noncopied_parts)),
+ result);
+ noncopied_parts = TREE_CHAIN (noncopied_parts);
+ }
+ }
+ /* Once we have our hands on an address, we must change NEWRHS
+ to work from there. Otherwise we can get multiple evaluations
+ of NEWRHS. */
+ if (TREE_CODE (newrhs) != SAVE_EXPR)
+ newrhs = build_indirect_ref (rhs_addr, NULL_PTR);
+
+ while (vbases)
+ {
+ tree elt_lhs = convert_pointer_to (vbases, lhs_addr);
+ tree elt_rhs = convert_pointer_to (vbases, rhs_addr);
+ result
+ = tree_cons (NULL_TREE,
+ build_modify_expr_1 (build_indirect_ref (elt_lhs, NULL_PTR),
+ modifycode,
+ build_indirect_ref (elt_rhs, NULL_PTR),
+ TYPE_BINFO (lhstype)),
+ result);
+ if (TREE_VALUE (result) == error_mark_node)
+ return error_mark_node;
+ vbases = TREE_CHAIN (vbases);
+ }
+ result = tree_cons (NULL_TREE,
+ build_modify_expr_1 (lhs,
+ modifycode,
+ newrhs,
+ TYPE_BINFO (lhstype)),
+ result);
+ return build_compound_expr (result);
+ }
+#endif
+
+ /* Convert new value to destination type. */
+
+ if (TREE_CODE (lhstype) == ARRAY_TYPE)
+ {
+ int from_array;
+
+ if (! comptypes (lhstype, TREE_TYPE (rhs), 0))
+ {
+ cp_error ("incompatible types in assignment of `%T' to `%T'",
+ TREE_TYPE (rhs), lhstype);
+ return error_mark_node;
+ }
+
+ /* Allow array assignment in compiler-generated code. */
+ if (pedantic && ! DECL_ARTIFICIAL (current_function_decl))
+ pedwarn ("ANSI C++ forbids assignment of arrays");
+
+ /* Have to wrap this in RTL_EXPR for two cases:
+ in base or member initialization and if we
+ are a branch of a ?: operator. Since we
+ can't easily know the latter, just do it always. */
+
+ result = make_node (RTL_EXPR);
+
+ TREE_TYPE (result) = void_type_node;
+ do_pending_stack_adjust ();
+ start_sequence_for_rtl_expr (result);
+
+ /* As a matter of principle, `start_sequence' should do this. */
+ emit_note (0, -1);
+
+ from_array = TREE_CODE (TREE_TYPE (newrhs)) == ARRAY_TYPE
+ ? 1 + (modifycode != INIT_EXPR): 0;
+ expand_vec_init (lhs, lhs, array_type_nelts (lhstype), newrhs,
+ from_array);
+
+ do_pending_stack_adjust ();
+
+ TREE_SIDE_EFFECTS (result) = 1;
+ RTL_EXPR_SEQUENCE (result) = get_insns ();
+ RTL_EXPR_RTL (result) = const0_rtx;
+ end_sequence ();
+ return result;
+ }
+
+ if (modifycode == INIT_EXPR)
+ {
+ newrhs = convert_for_initialization (lhs, lhstype, newrhs, LOOKUP_NORMAL,
+ "assignment", NULL_TREE, 0);
+ if (lhs == DECL_RESULT (current_function_decl))
+ {
+ if (DECL_INITIAL (lhs))
+ warning ("return value from function receives multiple initializations");
+ DECL_INITIAL (lhs) = newrhs;
+ }
+ }
+ else
+ {
+#if 0
+ if (IS_AGGR_TYPE (lhstype))
+ {
+ if (result = build_opfncall (MODIFY_EXPR,
+ LOOKUP_NORMAL, lhs, newrhs,
+ make_node (NOP_EXPR)))
+ return result;
+ }
+#endif
+ /* Avoid warnings on enum bit fields. */
+ if (TREE_CODE (olhstype) == ENUMERAL_TYPE
+ && TREE_CODE (lhstype) == INTEGER_TYPE)
+ {
+ newrhs = convert_for_assignment (olhstype, newrhs, "assignment",
+ NULL_TREE, 0);
+ newrhs = convert_force (lhstype, newrhs, 0);
+ }
+ else
+ newrhs = convert_for_assignment (lhstype, newrhs, "assignment",
+ NULL_TREE, 0);
+ if (TREE_CODE (newrhs) == CALL_EXPR
+ && TYPE_NEEDS_CONSTRUCTING (lhstype))
+ newrhs = build_cplus_new (lhstype, newrhs, 0);
+
+ /* Can't initialize directly from a TARGET_EXPR, since that would
+ cause the lhs to be constructed twice, and possibly result in
+ accidental self-initialization. So we force the TARGET_EXPR to be
+ expanded. expand_expr should really do this by itself. */
+ if (TREE_CODE (newrhs) == TARGET_EXPR)
+ newrhs = expand_target_expr (newrhs);
+ }
+
+ if (TREE_CODE (newrhs) == ERROR_MARK)
+ return error_mark_node;
+
+ if (TREE_CODE (newrhs) == COND_EXPR)
+ {
+ tree lhs1;
+ tree cond = TREE_OPERAND (newrhs, 0);
+
+ if (TREE_SIDE_EFFECTS (lhs))
+ cond = build_compound_expr (tree_cons
+ (NULL_TREE, lhs,
+ build_tree_list (NULL_TREE, cond)));
+
+ /* Cannot have two identical lhs on this one tree (result) as preexpand
+ calls will rip them out and fill in RTL for them, but when the
+ rtl is generated, the calls will only be in the first side of the
+ condition, not on both, or before the conditional jump! (mrs) */
+ lhs1 = break_out_calls (lhs);
+
+ if (lhs == lhs1)
+ /* If there's no change, the COND_EXPR behaves like any other rhs. */
+ result = build (modifycode == NOP_EXPR ? MODIFY_EXPR : INIT_EXPR,
+ lhstype, lhs, newrhs);
+ else
+ {
+ tree result_type = TREE_TYPE (newrhs);
+ /* We have to convert each arm to the proper type because the
+ types may have been munged by constant folding. */
+ result
+ = build (COND_EXPR, result_type, cond,
+ build_modify_expr (lhs, modifycode,
+ convert (result_type,
+ TREE_OPERAND (newrhs, 1))),
+ build_modify_expr (lhs1, modifycode,
+ convert (result_type,
+ TREE_OPERAND (newrhs, 2))));
+ }
+ }
+ else if (modifycode != INIT_EXPR && TREE_CODE (newrhs) == WITH_CLEANUP_EXPR)
+ {
+ tree cleanup = TREE_OPERAND (newrhs, 2);
+ tree slot;
+
+ /* Finish up by running cleanups and having the "value" of the lhs. */
+ tree exprlist = tree_cons (NULL_TREE, cleanup,
+ build_tree_list (NULL_TREE, lhs));
+ newrhs = TREE_OPERAND (newrhs, 0);
+ if (TREE_CODE (newrhs) == TARGET_EXPR)
+ slot = TREE_OPERAND (newrhs, 0);
+ else if (TREE_CODE (newrhs) == ADDR_EXPR)
+ {
+ /* Bad but valid. */
+ slot = newrhs;
+ warning ("address taken of temporary object");
+ }
+ else
+ my_friendly_abort (118);
+
+ /* Copy the value computed in SLOT into LHS. */
+ exprlist = tree_cons (NULL_TREE,
+ build_modify_expr (lhs, modifycode, slot),
+ exprlist);
+ /* Evaluate the expression that needs CLEANUP. This will
+ compute the value into SLOT. */
+ exprlist = tree_cons (NULL_TREE, newrhs, exprlist);
+ result = convert (lhstype, build_compound_expr (exprlist));
+ }
+ else
+ result = build (modifycode == NOP_EXPR ? MODIFY_EXPR : INIT_EXPR,
+ lhstype, lhs, newrhs);
+ TREE_SIDE_EFFECTS (result) = 1;
+
+ /* If we got the LHS in a different type for storing in,
+ convert the result back to the nominal type of LHS
+ so that the value we return always has the same type
+ as the LHS argument. */
+
+ if (olhstype == TREE_TYPE (result))
+ return result;
+ /* Avoid warnings converting integral types back into enums
+ for enum bit fields. */
+ if (TREE_CODE (TREE_TYPE (result)) == INTEGER_TYPE
+ && TREE_CODE (olhstype) == ENUMERAL_TYPE)
+ {
+ result = build (COMPOUND_EXPR, olhstype, result, olhs);
+ TREE_NO_UNUSED_WARNING (result) = 1;
+ return result;
+ }
+ return convert_for_assignment (olhstype, result, "assignment",
+ NULL_TREE, 0);
+}
+
+
+/* Return 0 if EXP is not a valid lvalue in this language
+ even though `lvalue_or_else' would accept it. */
+
+int
+language_lvalue_valid (exp)
+ tree exp;
+{
+ return 1;
+}
+
+/* Get difference in deltas for different pointer to member function
+ types. Return integer_zero_node, if FROM cannot be converted to a
+ TO type. If FORCE is true, then allow reverse conversions as well. */
+static tree
+get_delta_difference (from, to, force)
+ tree from, to;
+ int force;
+{
+ tree delta = integer_zero_node;
+ tree binfo;
+
+ if (to == from)
+ return delta;
+
+ /* Should get_base_distance here, so we can check if any thing along the
+ path is virtual, and we need to make sure we stay
+ inside the real binfos when going through virtual bases.
+ Maybe we should replace virtual bases with
+ binfo_member (...CLASSTYPE_VBASECLASSES...)... (mrs) */
+ binfo = get_binfo (from, to, 1);
+ if (binfo == error_mark_node)
+ {
+ error (" in pointer to member function conversion");
+ return delta;
+ }
+ if (binfo == 0)
+ {
+ if (!force)
+ {
+ error_not_base_type (from, to);
+ error (" in pointer to member function conversion");
+ return delta;
+ }
+ binfo = get_binfo (to, from, 1);
+ if (binfo == error_mark_node)
+ {
+ error (" in pointer to member function conversion");
+ return delta;
+ }
+ if (binfo == 0)
+ {
+ error ("cannot convert pointer to member of type %T to unrelated pointer to member of type %T", from, to);
+ return delta;
+ }
+ if (TREE_VIA_VIRTUAL (binfo))
+ {
+ warning ("pointer to member conversion to virtual base class will only work if you are very careful");
+ }
+ return build_binary_op (MINUS_EXPR,
+ integer_zero_node,
+ BINFO_OFFSET (binfo), 1);
+ }
+ if (TREE_VIA_VIRTUAL (binfo))
+ {
+ warning ("pointer to member conversion from virtual base class will only work if you are very careful");
+ }
+ return BINFO_OFFSET (binfo);
+}
+
+/* Build a constructor for a pointer to member function. It can be
+ used to initialize global variables, local variable, or used
+ as a value in expressions. TYPE is the POINTER to METHOD_TYPE we
+ want to be.
+
+ If FORCE is non-zero, then force this conversion, even if
+ we would rather not do it. Usually set when using an explicit
+ cast.
+
+ Return error_mark_node, if something goes wrong. */
+
+tree
+build_ptrmemfunc (type, pfn, force)
+ tree type, pfn;
+ int force;
+{
+ tree index = integer_zero_node;
+ tree delta = integer_zero_node;
+ tree delta2 = integer_zero_node;
+ tree vfield_offset;
+ tree npfn;
+ tree u;
+
+ /* Handle multiple conversions of pointer to member functions. */
+ if (TYPE_PTRMEMFUNC_P (TREE_TYPE (pfn)))
+ {
+ tree ndelta, ndelta2, nindex;
+ /* Is is already the right type? */
+#if 0
+ /* Sorry, can't do this, the backend is too stupid. */
+ if (TYPE_METHOD_BASETYPE (TREE_TYPE (type))
+ == TYPE_METHOD_BASETYPE (TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (pfn)))))
+ {
+ if (type != TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (pfn)))
+ {
+ npfn = build1 (NOP_EXPR, TYPE_GET_PTRMEMFUNC_TYPE (type), pfn);
+ TREE_CONSTANT (npfn) = TREE_CONSTANT (pfn);
+ }
+ return pfn;
+ }
+#else
+ if (type == TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (pfn)))
+ return pfn;
+#endif
+
+ if (TREE_CODE (pfn) != CONSTRUCTOR)
+ {
+ tree e1, e2, e3;
+ ndelta = convert (ptrdiff_type_node, build_component_ref (pfn, delta_identifier, 0, 0));
+ ndelta2 = convert (ptrdiff_type_node, DELTA2_FROM_PTRMEMFUNC (pfn));
+ index = build_component_ref (pfn, index_identifier, 0, 0);
+ delta = get_delta_difference (TYPE_METHOD_BASETYPE (TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (pfn)))),
+ TYPE_METHOD_BASETYPE (TREE_TYPE (type)),
+ force);
+ delta = build_binary_op (PLUS_EXPR, delta, ndelta, 1);
+ delta2 = build_binary_op (PLUS_EXPR, ndelta2, delta2, 1);
+ e1 = fold (build (GT_EXPR, boolean_type_node, index, integer_zero_node));
+
+ u = build_nt (CONSTRUCTOR, 0, tree_cons (delta2_identifier, delta2, NULL_TREE));
+ u = build_nt (CONSTRUCTOR, 0, tree_cons (NULL_TREE, delta,
+ tree_cons (NULL_TREE, index,
+ tree_cons (NULL_TREE, u, NULL_TREE))));
+ e2 = digest_init (TYPE_GET_PTRMEMFUNC_TYPE (type), u, (tree*)0);
+
+ pfn = PFN_FROM_PTRMEMFUNC (pfn);
+ npfn = build1 (NOP_EXPR, type, pfn);
+ TREE_CONSTANT (npfn) = TREE_CONSTANT (pfn);
+
+ u = build_nt (CONSTRUCTOR, 0, tree_cons (pfn_identifier, npfn, NULL_TREE));
+ u = build_nt (CONSTRUCTOR, 0, tree_cons (NULL_TREE, delta,
+ tree_cons (NULL_TREE, index,
+ tree_cons (NULL_TREE, u, NULL_TREE))));
+ e3 = digest_init (TYPE_GET_PTRMEMFUNC_TYPE (type), u, (tree*)0);
+ return build_conditional_expr (e1, e2, e3);
+ }
+
+ ndelta = TREE_VALUE (CONSTRUCTOR_ELTS (pfn));
+ nindex = TREE_VALUE (TREE_CHAIN (CONSTRUCTOR_ELTS (pfn)));
+ npfn = TREE_VALUE (TREE_CHAIN (TREE_CHAIN (CONSTRUCTOR_ELTS (pfn))));
+ npfn = TREE_VALUE (CONSTRUCTOR_ELTS (npfn));
+ if (integer_zerop (nindex))
+ pfn = integer_zero_node;
+ else if (integer_zerop (fold (size_binop (PLUS_EXPR, nindex, integer_one_node))))
+ {
+ tree e3;
+ delta = get_delta_difference (TYPE_METHOD_BASETYPE (TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (pfn)))),
+ TYPE_METHOD_BASETYPE (TREE_TYPE (type)),
+ force);
+ delta = build_binary_op (PLUS_EXPR, delta, ndelta, 1);
+ pfn = build1 (NOP_EXPR, type, npfn);
+ TREE_CONSTANT (pfn) = TREE_CONSTANT (npfn);
+
+ u = build_nt (CONSTRUCTOR, 0, tree_cons (pfn_identifier, pfn, NULL_TREE));
+ u = build_nt (CONSTRUCTOR, 0, tree_cons (NULL_TREE, delta,
+ tree_cons (NULL_TREE, nindex,
+ tree_cons (NULL_TREE, u, NULL_TREE))));
+ e3 = digest_init (TYPE_GET_PTRMEMFUNC_TYPE (type), u, (tree*)0);
+ return e3;
+ }
+ else
+ {
+ sorry ("value casting of variable nonnull pointer to member functions not supported");
+ return error_mark_node;
+ }
+ }
+
+ /* Handle null pointer to member function conversions. */
+ if (integer_zerop (pfn))
+ {
+ pfn = build_c_cast (type, integer_zero_node, 0);
+ u = build_nt (CONSTRUCTOR, 0, tree_cons (pfn_identifier, pfn, NULL_TREE));
+ u = build_nt (CONSTRUCTOR, 0, tree_cons (NULL_TREE, integer_zero_node,
+ tree_cons (NULL_TREE, integer_zero_node,
+ tree_cons (NULL_TREE, u, NULL_TREE))));
+ return digest_init (TYPE_GET_PTRMEMFUNC_TYPE (type), u, (tree*)0);
+ }
+
+ if (TREE_CODE (pfn) == TREE_LIST
+ || (TREE_CODE (pfn) == ADDR_EXPR
+ && TREE_CODE (TREE_OPERAND (pfn, 0)) == TREE_LIST))
+ {
+ pfn = instantiate_type (type, pfn, 1);
+ if (pfn == error_mark_node)
+ return error_mark_node;
+ if (TREE_CODE (pfn) != ADDR_EXPR)
+ pfn = build_unary_op (ADDR_EXPR, pfn, 0);
+ }
+
+ /* Allow pointer to member conversions here. */
+ delta = get_delta_difference (TYPE_METHOD_BASETYPE (TREE_TYPE (TREE_TYPE (pfn))),
+ TYPE_METHOD_BASETYPE (TREE_TYPE (type)),
+ force);
+ delta2 = build_binary_op (PLUS_EXPR, delta2, delta, 1);
+
+ if (TREE_CODE (TREE_OPERAND (pfn, 0)) != FUNCTION_DECL)
+ warning ("assuming pointer to member function is non-virtual");
+
+ if (TREE_CODE (TREE_OPERAND (pfn, 0)) == FUNCTION_DECL
+ && DECL_VINDEX (TREE_OPERAND (pfn, 0)))
+ {
+ /* Find the offset to the vfield pointer in the object. */
+ vfield_offset = get_binfo (DECL_CONTEXT (TREE_OPERAND (pfn, 0)),
+ DECL_CLASS_CONTEXT (TREE_OPERAND (pfn, 0)),
+ 0);
+ vfield_offset = get_vfield_offset (vfield_offset);
+ delta2 = size_binop (PLUS_EXPR, vfield_offset, delta2);
+
+ /* Map everything down one to make room for the null pointer to member. */
+ index = size_binop (PLUS_EXPR,
+ DECL_VINDEX (TREE_OPERAND (pfn, 0)),
+ integer_one_node);
+ u = build_nt (CONSTRUCTOR, 0, tree_cons (delta2_identifier, delta2, NULL_TREE));
+ }
+ else
+ {
+ index = size_binop (MINUS_EXPR, integer_zero_node, integer_one_node);
+
+ npfn = build1 (NOP_EXPR, type, pfn);
+ TREE_CONSTANT (npfn) = TREE_CONSTANT (pfn);
+
+ u = build_nt (CONSTRUCTOR, 0, tree_cons (pfn_identifier, npfn, NULL_TREE));
+ }
+
+ u = build_nt (CONSTRUCTOR, 0, tree_cons (NULL_TREE, delta,
+ tree_cons (NULL_TREE, index,
+ tree_cons (NULL_TREE, u, NULL_TREE))));
+ return digest_init (TYPE_GET_PTRMEMFUNC_TYPE (type), u, (tree*)0);
+}
+
+/* Convert value RHS to type TYPE as preparation for an assignment
+ to an lvalue of type TYPE.
+ The real work of conversion is done by `convert'.
+ The purpose of this function is to generate error messages
+ for assignments that are not allowed in C.
+ ERRTYPE is a string to use in error messages:
+ "assignment", "return", etc.
+
+ C++: attempts to allow `convert' to find conversions involving
+ implicit type conversion between aggregate and scalar types
+ as per 8.5.6 of C++ manual. Does not randomly dereference
+ pointers to aggregates! */
+
+static tree
+convert_for_assignment (type, rhs, errtype, fndecl, parmnum)
+ tree type, rhs;
+ char *errtype;
+ tree fndecl;
+ int parmnum;
+{
+ register enum tree_code codel = TREE_CODE (type);
+ register tree rhstype;
+ register enum tree_code coder = TREE_CODE (TREE_TYPE (rhs));
+
+ if (coder == UNKNOWN_TYPE)
+ rhs = instantiate_type (type, rhs, 1);
+
+ if (coder == ERROR_MARK)
+ return error_mark_node;
+
+ if (codel == OFFSET_TYPE)
+ {
+ type = TREE_TYPE (type);
+ codel = TREE_CODE (type);
+ }
+
+ /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */
+ if (TREE_CODE (rhs) == NON_LVALUE_EXPR)
+ rhs = TREE_OPERAND (rhs, 0);
+
+ if (rhs == error_mark_node)
+ return error_mark_node;
+
+ if (TREE_VALUE (rhs) == error_mark_node)
+ return error_mark_node;
+
+ if (TREE_CODE (TREE_TYPE (rhs)) == OFFSET_TYPE)
+ {
+ rhs = resolve_offset_ref (rhs);
+ if (rhs == error_mark_node)
+ return error_mark_node;
+ rhstype = TREE_TYPE (rhs);
+ coder = TREE_CODE (rhstype);
+ }
+
+ if (TREE_CODE (TREE_TYPE (rhs)) == ARRAY_TYPE
+ || TREE_CODE (TREE_TYPE (rhs)) == FUNCTION_TYPE
+ || TREE_CODE (TREE_TYPE (rhs)) == METHOD_TYPE)
+ rhs = default_conversion (rhs);
+ else if (TREE_CODE (TREE_TYPE (rhs)) == REFERENCE_TYPE)
+ rhs = convert_from_reference (rhs);
+
+ rhstype = TREE_TYPE (rhs);
+ coder = TREE_CODE (rhstype);
+
+ /* This should no longer change types on us. */
+ if (TREE_CODE (rhs) == CONST_DECL)
+ rhs = DECL_INITIAL (rhs);
+ else if (TREE_READONLY_DECL_P (rhs))
+ rhs = decl_constant_value (rhs);
+
+ if (type == rhstype)
+ {
+ overflow_warning (rhs);
+ return rhs;
+ }
+
+ if (coder == VOID_TYPE)
+ {
+ error ("void value not ignored as it ought to be");
+ return error_mark_node;
+ }
+ /* Arithmetic types all interconvert. */
+ if ((codel == INTEGER_TYPE || codel == REAL_TYPE || codel == BOOLEAN_TYPE)
+ && (coder == INTEGER_TYPE || coder == REAL_TYPE || coder == BOOLEAN_TYPE))
+ {
+ /* But we should warn if assigning REAL_TYPE to INTEGER_TYPE. */
+ if (coder == REAL_TYPE && codel == INTEGER_TYPE)
+ {
+ if (fndecl)
+ cp_warning ("`%T' used for argument %P of `%D'",
+ rhstype, parmnum, fndecl);
+ else
+ cp_warning ("%s to `%T' from `%T'", errtype, type, rhstype);
+ }
+ /* And we should warn if assigning a negative value to
+ an unsigned variable. */
+ else if (TREE_UNSIGNED (type) && codel != BOOLEAN_TYPE)
+ {
+ if (TREE_CODE (rhs) == INTEGER_CST
+ && TREE_NEGATED_INT (rhs))
+ {
+ if (fndecl)
+ cp_warning ("negative value `%E' passed as argument %P of `%D'",
+ rhs, parmnum, fndecl);
+ else
+ cp_warning ("%s of negative value `%E' to `%T'",
+ errtype, rhs, type);
+ }
+ overflow_warning (rhs);
+ if (TREE_CONSTANT (rhs))
+ rhs = fold (rhs);
+ }
+
+ return convert_and_check (type, rhs);
+ }
+ /* Conversions involving enums. */
+ else if ((codel == ENUMERAL_TYPE
+ && (INTEGRAL_CODE_P (coder) || coder == REAL_TYPE))
+ || (coder == ENUMERAL_TYPE
+ && (INTEGRAL_CODE_P (codel) || codel == REAL_TYPE)))
+ {
+ return cp_convert (type, rhs, CONV_IMPLICIT, LOOKUP_NORMAL);
+ }
+ /* Conversions among pointers */
+ else if (codel == POINTER_TYPE
+ && (coder == POINTER_TYPE
+ || (coder == RECORD_TYPE
+ && (IS_SIGNATURE_POINTER (rhstype)
+ || IS_SIGNATURE_REFERENCE (rhstype)))))
+ {
+ register tree ttl = TREE_TYPE (type);
+ register tree ttr;
+ int ctt = 0;
+
+ if (coder == RECORD_TYPE)
+ {
+ rhs = build_optr_ref (rhs);
+ rhstype = TREE_TYPE (rhs);
+ }
+ ttr = TREE_TYPE (rhstype);
+
+ /* If both pointers are of aggregate type, then we
+ can give better error messages, and save some work
+ as well. */
+ if (TREE_CODE (ttl) == RECORD_TYPE && TREE_CODE (ttr) == RECORD_TYPE)
+ {
+ tree binfo;
+
+ if (TYPE_MAIN_VARIANT (ttl) == TYPE_MAIN_VARIANT (ttr)
+ || type == class_star_type_node
+ || rhstype == class_star_type_node)
+ binfo = TYPE_BINFO (ttl);
+ else
+ binfo = get_binfo (ttl, ttr, 1);
+
+ if (binfo == error_mark_node)
+ return error_mark_node;
+ if (binfo == 0)
+ return error_not_base_type (ttl, ttr);
+
+ if (! TYPE_READONLY (ttl) && TYPE_READONLY (ttr))
+ {
+ if (fndecl)
+ cp_pedwarn ("passing `%T' as argument %P of `%D' discards const",
+ rhstype, parmnum, fndecl);
+ else
+ cp_pedwarn ("%s to `%T' from `%T' discards const",
+ errtype, type, rhstype);
+ }
+ if (! TYPE_VOLATILE (ttl) && TYPE_VOLATILE (ttr))
+ {
+ if (fndecl)
+ cp_pedwarn ("passing `%T' as argument %P of `%D' discards volatile",
+ rhstype, parmnum, fndecl);
+ else
+ cp_pedwarn ("%s to `%T' from `%T' discards volatile",
+ errtype, type, rhstype);
+ }
+ }
+
+ /* Any non-function converts to a [const][volatile] void *
+ and vice versa; otherwise, targets must be the same.
+ Meanwhile, the lhs target must have all the qualifiers of the rhs. */
+ else if (TYPE_MAIN_VARIANT (ttl) == void_type_node
+ || TYPE_MAIN_VARIANT (ttr) == void_type_node
+ || (ctt = comp_target_types (type, rhstype, 1))
+ || (unsigned_type (TYPE_MAIN_VARIANT (ttl))
+ == unsigned_type (TYPE_MAIN_VARIANT (ttr))))
+ {
+ /* ARM $4.8, commentary on p39. */
+ if (TYPE_MAIN_VARIANT (ttl) == void_type_node
+ && TREE_CODE (ttr) == OFFSET_TYPE)
+ {
+ cp_error ("no standard conversion from `%T' to `void *'", ttr);
+ return error_mark_node;
+ }
+
+ if (ctt < 0)
+ cp_pedwarn ("converting `%T' to `%T' is a contravariance violation",
+ rhstype, type);
+
+ if (TYPE_MAIN_VARIANT (ttl) != void_type_node
+ && TYPE_MAIN_VARIANT (ttr) == void_type_node
+ && rhs != null_pointer_node)
+ {
+ if (coder == RECORD_TYPE)
+ cp_pedwarn ("implicit conversion of signature pointer to type `%T'",
+ type);
+ else
+ pedwarn ("ANSI C++ forbids implicit conversion from `void *' in %s",
+ errtype);
+ }
+ /* Const and volatile mean something different for function types,
+ so the usual warnings are not appropriate. */
+ else if ((TREE_CODE (ttr) != FUNCTION_TYPE && TREE_CODE (ttr) != METHOD_TYPE)
+ || (TREE_CODE (ttl) != FUNCTION_TYPE && TREE_CODE (ttl) != METHOD_TYPE))
+ {
+ if (TREE_CODE (ttl) == OFFSET_TYPE
+ && binfo_member (TYPE_OFFSET_BASETYPE (ttr),
+ CLASSTYPE_VBASECLASSES (TYPE_OFFSET_BASETYPE (ttl))))
+ {
+ sorry ("%s between pointer to members converting across virtual baseclasses", errtype);
+ return error_mark_node;
+ }
+ else if (! TYPE_READONLY (ttl) && TYPE_READONLY (ttr))
+ {
+ if (fndecl)
+ cp_pedwarn ("passing `%T' as argument %P of `%D' discards const",
+ rhstype, parmnum, fndecl);
+ else
+ cp_pedwarn ("%s to `%T' from `%T' discards const",
+ errtype, type, rhstype);
+ }
+ else if (! TYPE_VOLATILE (ttl) && TYPE_VOLATILE (ttr))
+ {
+ if (fndecl)
+ cp_pedwarn ("passing `%T' as argument %P of `%D' discards volatile",
+ rhstype, parmnum, fndecl);
+ else
+ cp_pedwarn ("%s to `%T' from `%T' discards volatile",
+ errtype, type, rhstype);
+ }
+ else if (TREE_CODE (ttl) == TREE_CODE (ttr)
+ && ! comp_target_types (type, rhstype, 1))
+ {
+ if (fndecl)
+ cp_pedwarn ("passing `%T' as argument %P of `%D' changes signedness",
+ rhstype, parmnum, fndecl);
+ else
+ cp_pedwarn ("%s to `%T' from `%T' changes signedness",
+ errtype, type, rhstype);
+ }
+ }
+ }
+ else if (TREE_CODE (ttr) == OFFSET_TYPE
+ && TREE_CODE (ttl) != OFFSET_TYPE)
+ {
+ /* Normally, pointers to different type codes (other
+ than void) are not compatible, but we perform
+ some type instantiation if that resolves the
+ ambiguity of (X Y::*) and (X *). */
+
+ if (current_class_decl)
+ {
+ if (TREE_CODE (rhs) == INTEGER_CST)
+ {
+ rhs = build (PLUS_EXPR, build_pointer_type (TREE_TYPE (ttr)),
+ current_class_decl, rhs);
+ return convert_for_assignment (type, rhs,
+ errtype, fndecl, parmnum);
+ }
+ }
+ if (TREE_CODE (ttl) == METHOD_TYPE)
+ error ("%s between pointer-to-method and pointer-to-member types",
+ errtype);
+ else
+ error ("%s between pointer and pointer-to-member types", errtype);
+ return error_mark_node;
+ }
+ else
+ {
+ int add_quals = 0, const_parity = 0, volatile_parity = 0;
+ int left_const = 1;
+ int unsigned_parity;
+ int nptrs = 0;
+
+ /* This code is basically a duplicate of comp_ptr_ttypes_real. */
+ for (; ; ttl = TREE_TYPE (ttl), ttr = TREE_TYPE (ttr))
+ {
+ nptrs -= 1;
+ const_parity |= TYPE_READONLY (ttl) < TYPE_READONLY (ttr);
+ volatile_parity |= TYPE_VOLATILE (ttl) < TYPE_VOLATILE (ttr);
+
+ if (! left_const
+ && (TYPE_READONLY (ttl) > TYPE_READONLY (ttr)
+ || TYPE_VOLATILE (ttl) > TYPE_VOLATILE (ttr)))
+ add_quals = 1;
+ left_const &= TYPE_READONLY (ttl);
+
+ if (TREE_CODE (ttl) != POINTER_TYPE
+ || TREE_CODE (ttr) != POINTER_TYPE)
+ break;
+ }
+ unsigned_parity = TREE_UNSIGNED (ttl) - TREE_UNSIGNED (ttr);
+ if (unsigned_parity)
+ {
+ if (TREE_UNSIGNED (ttl))
+ ttr = unsigned_type (ttr);
+ else
+ ttl = unsigned_type (ttl);
+ }
+
+ if (comp_target_types (ttl, ttr, nptrs) > 0)
+ {
+ if (add_quals)
+ {
+ if (fndecl)
+ cp_pedwarn ("passing `%T' as argument %P of `%D' adds cv-quals without intervening `const'",
+ rhstype, parmnum, fndecl);
+ else
+ cp_pedwarn ("%s to `%T' from `%T' adds cv-quals without intervening `const'",
+ errtype, type, rhstype);
+ }
+ if (const_parity)
+ {
+ if (fndecl)
+ cp_pedwarn ("passing `%T' as argument %P of `%D' discards const",
+ rhstype, parmnum, fndecl);
+ else
+ cp_pedwarn ("%s to `%T' from `%T' discards const",
+ errtype, type, rhstype);
+ }
+ if (volatile_parity)
+ {
+ if (fndecl)
+ cp_pedwarn ("passing `%T' as argument %P of `%D' discards volatile",
+ rhstype, parmnum, fndecl);
+ else
+ cp_pedwarn ("%s to `%T' from `%T' discards volatile",
+ errtype, type, rhstype);
+ }
+ if (unsigned_parity > 0)
+ {
+ if (fndecl)
+ cp_pedwarn ("passing `%T' as argument %P of `%D' changes signed to unsigned",
+ rhstype, parmnum, fndecl);
+ else
+ cp_pedwarn ("%s to `%T' from `%T' changes signed to unsigned",
+ errtype, type, rhstype);
+ }
+ else if (unsigned_parity < 0)
+ {
+ if (fndecl)
+ cp_pedwarn ("passing `%T' as argument %P of `%D' changes unsigned to signed",
+ rhstype, parmnum, fndecl);
+ else
+ cp_pedwarn ("%s to `%T' from `%T' changes unsigned to signed",
+ errtype, type, rhstype);
+ }
+
+ /* C++ is not so friendly about converting function and
+ member function pointers as C. Emit warnings here. */
+ if (TREE_CODE (ttl) == FUNCTION_TYPE
+ || TREE_CODE (ttl) == METHOD_TYPE)
+ if (! comptypes (ttl, ttr, 0))
+ {
+ warning ("conflicting function types in %s:", errtype);
+ cp_warning ("\t`%T' != `%T'", type, rhstype);
+ }
+ }
+ else if (TREE_CODE (TREE_TYPE (rhs)) == METHOD_TYPE)
+ {
+ /* When does this happen? */
+ my_friendly_abort (119);
+ /* Conversion of a pointer-to-member type to void *. */
+ rhs = build_unary_op (ADDR_EXPR, rhs, 0);
+ TREE_TYPE (rhs) = type;
+ return rhs;
+ }
+ else if (TREE_CODE (TREE_TYPE (rhs)) == OFFSET_TYPE)
+ {
+ /* When does this happen? */
+ my_friendly_abort (120);
+ /* Conversion of a pointer-to-member type to void *. */
+ rhs = build_unary_op (ADDR_EXPR, rhs, 0);
+ TREE_TYPE (rhs) = type;
+ return rhs;
+ }
+ else
+ {
+ if (fndecl)
+ cp_error ("passing `%T' as argument %P of `%D'",
+ rhstype, parmnum, fndecl);
+ else
+ cp_error ("%s to `%T' from `%T'", errtype, type, rhstype);
+ return error_mark_node;
+ }
+ }
+ return convert (type, rhs);
+ }
+ else if (codel == POINTER_TYPE && coder == INTEGER_TYPE)
+ {
+ /* An explicit constant 0 can convert to a pointer,
+ but not a 0 that results from casting or folding. */
+ if (! (TREE_CODE (rhs) == INTEGER_CST && integer_zerop (rhs)))
+ {
+ if (fndecl)
+ cp_pedwarn ("passing `%T' to argument %P of `%D' lacks a cast",
+ rhstype, parmnum, fndecl);
+ else
+ cp_pedwarn ("%s to `%T' from `%T' lacks a cast",
+ errtype, type, rhstype);
+ return convert (type, rhs);
+ }
+ return null_pointer_node;
+ }
+ else if (codel == INTEGER_TYPE
+ && (coder == POINTER_TYPE
+ || (coder == RECORD_TYPE
+ && (IS_SIGNATURE_POINTER (rhstype)
+ || TYPE_PTRMEMFUNC_FLAG (rhstype)
+ || IS_SIGNATURE_REFERENCE (rhstype)))))
+ {
+ if (fndecl)
+ cp_pedwarn ("passing `%T' to argument %P of `%D' lacks a cast",
+ rhstype, parmnum, fndecl);
+ else
+ cp_pedwarn ("%s to `%T' from `%T' lacks a cast",
+ errtype, type, rhstype);
+ return convert (type, rhs);
+ }
+ else if (codel == BOOLEAN_TYPE
+ && (coder == POINTER_TYPE
+ || (coder == RECORD_TYPE
+ && (IS_SIGNATURE_POINTER (rhstype)
+ || TYPE_PTRMEMFUNC_FLAG (rhstype)
+ || IS_SIGNATURE_REFERENCE (rhstype)))))
+ return convert (type, rhs);
+
+ /* C++ */
+ else if (((coder == POINTER_TYPE
+ && TREE_CODE (TREE_TYPE (rhstype)) == METHOD_TYPE)
+ || integer_zerop (rhs)
+ || TYPE_PTRMEMFUNC_P (rhstype))
+ && TYPE_PTRMEMFUNC_P (type))
+ {
+ tree ttl = TYPE_PTRMEMFUNC_FN_TYPE (type);
+ tree ttr = (TREE_CODE (rhstype) == POINTER_TYPE ? rhstype
+ : TYPE_PTRMEMFUNC_FN_TYPE (type));
+ int ctt = comp_target_types (ttl, ttr, 1);
+
+ if (ctt < 0)
+ cp_pedwarn ("converting `%T' to `%T' is a contravariance violation",
+ ttr, ttl);
+ else if (ctt == 0)
+ cp_error ("%s to `%T' from `%T'", errtype, ttl, ttr);
+
+ /* compatible pointer to member functions. */
+ return build_ptrmemfunc (ttl, rhs, 0);
+ }
+ else if (codel == ERROR_MARK || coder == ERROR_MARK)
+ return error_mark_node;
+
+ /* This should no longer happen. References are initialized via
+ `convert_for_initialization'. They should otherwise be
+ bashed before coming here. */
+ else if (codel == REFERENCE_TYPE)
+ my_friendly_abort (317);
+ else if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (TREE_TYPE (rhs)))
+ {
+ tree nrhs = build1 (NOP_EXPR, type, rhs);
+ TREE_CONSTANT (nrhs) = TREE_CONSTANT (rhs);
+ return nrhs;
+ }
+ else if (TYPE_HAS_CONSTRUCTOR (type) || IS_AGGR_TYPE (TREE_TYPE (rhs)))
+ return convert (type, rhs);
+
+ cp_error ("%s to `%T' from `%T'", errtype, type, rhstype);
+ return error_mark_node;
+}
+
+/* Convert RHS to be of type TYPE. If EXP is non-zero,
+ it is the target of the initialization.
+ ERRTYPE is a string to use in error messages.
+
+ Two major differences between the behavior of
+ `convert_for_assignment' and `convert_for_initialization'
+ are that references are bashed in the former, while
+ copied in the latter, and aggregates are assigned in
+ the former (operator=) while initialized in the
+ latter (X(X&)).
+
+ If using constructor make sure no conversion operator exists, if one does
+ exist, an ambiguity exists.
+
+ If flags doesn't include LOOKUP_COMPLAIN, don't complain about anything. */
+tree
+convert_for_initialization (exp, type, rhs, flags, errtype, fndecl, parmnum)
+ tree exp, type, rhs;
+ int flags;
+ char *errtype;
+ tree fndecl;
+ int parmnum;
+{
+ register enum tree_code codel = TREE_CODE (type);
+ register tree rhstype;
+ register enum tree_code coder;
+
+ /* build_c_cast puts on a NOP_EXPR to make the result not an lvalue.
+ Strip such NOP_EXPRs, since RHS is used in non-lvalue context. */
+ if (TREE_CODE (rhs) == NOP_EXPR
+ && TREE_TYPE (rhs) == TREE_TYPE (TREE_OPERAND (rhs, 0))
+ && codel != REFERENCE_TYPE)
+ rhs = TREE_OPERAND (rhs, 0);
+
+ if (rhs == error_mark_node
+ || (TREE_CODE (rhs) == TREE_LIST && TREE_VALUE (rhs) == error_mark_node))
+ return error_mark_node;
+
+ if (TREE_CODE (TREE_TYPE (rhs)) == OFFSET_TYPE)
+ {
+ rhs = resolve_offset_ref (rhs);
+ if (rhs == error_mark_node)
+ return error_mark_node;
+ }
+
+ if (TREE_CODE (TREE_TYPE (rhs)) == REFERENCE_TYPE)
+ rhs = convert_from_reference (rhs);
+
+ if ((TREE_CODE (TREE_TYPE (rhs)) == ARRAY_TYPE
+ && TREE_CODE (type) != ARRAY_TYPE
+ && (TREE_CODE (type) != REFERENCE_TYPE
+ || TREE_CODE (TREE_TYPE (type)) != ARRAY_TYPE))
+ || TREE_CODE (TREE_TYPE (rhs)) == FUNCTION_TYPE
+ || TREE_CODE (TREE_TYPE (rhs)) == METHOD_TYPE)
+ rhs = default_conversion (rhs);
+
+ rhstype = TREE_TYPE (rhs);
+ coder = TREE_CODE (rhstype);
+
+ if (coder == UNKNOWN_TYPE)
+ {
+ rhs = instantiate_type (type, rhs, 1);
+ rhstype = TREE_TYPE (rhs);
+ coder = TREE_CODE (rhstype);
+ }
+
+ if (coder == ERROR_MARK)
+ return error_mark_node;
+
+#if 0
+ /* This is *not* the quick way out! It is the way to disaster. */
+ if (type == rhstype)
+ goto converted;
+#endif
+
+ /* We accept references to incomplete types, so we can
+ return here before checking if RHS is of complete type. */
+
+ if (codel == REFERENCE_TYPE)
+ {
+ /* This should eventually happen in convert_arguments. */
+ extern int warningcount, errorcount;
+ int savew, savee;
+
+ if (fndecl)
+ savew = warningcount, savee = errorcount;
+ rhs = convert_to_reference (type, rhs, CONV_IMPLICIT, flags,
+ exp ? exp : error_mark_node);
+ if (fndecl)
+ {
+ if (warningcount > savew)
+ cp_warning_at ("in passing argument %P of `%+D'", parmnum, fndecl);
+ else if (errorcount > savee)
+ cp_error_at ("in passing argument %P of `%+D'", parmnum, fndecl);
+ }
+ return rhs;
+ }
+
+ rhs = require_complete_type (rhs);
+ if (rhs == error_mark_node)
+ return error_mark_node;
+
+ if (exp != 0) exp = require_complete_type (exp);
+ if (exp == error_mark_node)
+ return error_mark_node;
+
+ if (TREE_CODE (rhstype) == REFERENCE_TYPE)
+ rhstype = TREE_TYPE (rhstype);
+
+ if (TYPE_LANG_SPECIFIC (type)
+ && (IS_SIGNATURE_POINTER (type) || IS_SIGNATURE_REFERENCE (type)))
+ return build_signature_pointer_constructor (type, rhs);
+
+ if (IS_AGGR_TYPE (type)
+ && (TYPE_NEEDS_CONSTRUCTING (type) || TREE_HAS_CONSTRUCTOR (rhs)))
+ {
+ if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (rhstype))
+ {
+ /* This is sufficient to perform initialization. No need,
+ apparently, to go through X(X&) to do first-cut
+ initialization. Return through a TARGET_EXPR so that we get
+ cleanups if it is used. */
+ if (TREE_CODE (rhs) == CALL_EXPR)
+ {
+ rhs = build_cplus_new (type, rhs, 0);
+ return rhs;
+ }
+ /* Handle the case of default parameter initialization and
+ initialization of static variables. */
+ else if (TREE_CODE (rhs) == TARGET_EXPR)
+ return rhs;
+ else if (TREE_CODE (rhs) == INDIRECT_REF && TREE_HAS_CONSTRUCTOR (rhs))
+ {
+ my_friendly_assert (TREE_CODE (TREE_OPERAND (rhs, 0)) == CALL_EXPR, 318);
+ if (exp)
+ {
+ my_friendly_assert (TREE_VALUE (TREE_OPERAND (TREE_OPERAND (rhs, 0), 1)) == NULL_TREE, 316);
+ TREE_VALUE (TREE_OPERAND (TREE_OPERAND (rhs, 0), 1))
+ = build_unary_op (ADDR_EXPR, exp, 0);
+ }
+ else
+ rhs = build_cplus_new (type, TREE_OPERAND (rhs, 0), 0);
+ return rhs;
+ }
+ else if (TYPE_HAS_TRIVIAL_INIT_REF (type))
+ return rhs;
+ }
+ if (TYPE_MAIN_VARIANT (type) == TYPE_MAIN_VARIANT (rhstype)
+ || (IS_AGGR_TYPE (rhstype) && UNIQUELY_DERIVED_FROM_P (type, rhstype)))
+ {
+ if (TYPE_HAS_INIT_REF (type))
+ {
+ tree init = build_method_call (exp, constructor_name_full (type),
+ build_tree_list (NULL_TREE, rhs),
+ TYPE_BINFO (type), LOOKUP_NORMAL);
+
+ if (init == error_mark_node)
+ return error_mark_node;
+
+ if (exp == 0)
+ {
+ exp = build_cplus_new (type, init, 0);
+ return exp;
+ }
+
+ return build (COMPOUND_EXPR, type, init, exp);
+ }
+
+ /* ??? The following warnings are turned off because
+ this is another place where the default X(X&) constructor
+ is implemented. */
+ if (TYPE_HAS_ASSIGNMENT (type))
+ cp_warning ("bitwise copy: `%T' defines operator=", type);
+
+ if (TREE_CODE (TREE_TYPE (rhs)) == REFERENCE_TYPE)
+ rhs = convert_from_reference (rhs);
+ if (type != rhstype)
+ {
+ tree nrhs = build1 (NOP_EXPR, type, rhs);
+ TREE_CONSTANT (nrhs) = TREE_CONSTANT (rhs);
+ rhs = nrhs;
+ }
+ return rhs;
+ }
+
+ return cp_convert (type, rhs, CONV_OLD_CONVERT, flags);
+ }
+
+ if (type == TREE_TYPE (rhs))
+ {
+ if (TREE_READONLY_DECL_P (rhs))
+ rhs = decl_constant_value (rhs);
+ return rhs;
+ }
+
+ return convert_for_assignment (type, rhs, errtype, fndecl, parmnum);
+}
+
+/* Expand an ASM statement with operands, handling output operands
+ that are not variables or INDIRECT_REFS by transforming such
+ cases into cases that expand_asm_operands can handle.
+
+ Arguments are same as for expand_asm_operands.
+
+ We don't do default conversions on all inputs, because it can screw
+ up operands that are expected to be in memory. */
+
+void
+c_expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line)
+ tree string, outputs, inputs, clobbers;
+ int vol;
+ char *filename;
+ int line;
+{
+ int noutputs = list_length (outputs);
+ register int i;
+ /* o[I] is the place that output number I should be written. */
+ register tree *o = (tree *) alloca (noutputs * sizeof (tree));
+ register tree tail;
+
+ /* Record the contents of OUTPUTS before it is modified. */
+ for (i = 0, tail = outputs; tail; tail = TREE_CHAIN (tail), i++)
+ o[i] = TREE_VALUE (tail);
+
+ /* Generate the ASM_OPERANDS insn;
+ store into the TREE_VALUEs of OUTPUTS some trees for
+ where the values were actually stored. */
+ expand_asm_operands (string, outputs, inputs, clobbers, vol, filename, line);
+
+ /* Copy all the intermediate outputs into the specified outputs. */
+ for (i = 0, tail = outputs; tail; tail = TREE_CHAIN (tail), i++)
+ {
+ if (o[i] != TREE_VALUE (tail))
+ {
+ expand_expr (build_modify_expr (o[i], NOP_EXPR, TREE_VALUE (tail)),
+ const0_rtx, VOIDmode, 0);
+ free_temp_slots ();
+ }
+ /* Detect modification of read-only values.
+ (Otherwise done by build_modify_expr.) */
+ else
+ {
+ tree type = TREE_TYPE (o[i]);
+ if (TYPE_READONLY (type)
+ || ((TREE_CODE (type) == RECORD_TYPE
+ || TREE_CODE (type) == UNION_TYPE)
+ && C_TYPE_FIELDS_READONLY (type)))
+ readonly_error (o[i], "modification by `asm'", 1);
+ }
+ }
+
+ /* Those MODIFY_EXPRs could do autoincrements. */
+ emit_queue ();
+}
+
+/* Expand a C `return' statement.
+ RETVAL is the expression for what to return,
+ or a null pointer for `return;' with no value.
+
+ C++: upon seeing a `return', we must call destructors on all
+ variables in scope which had constructors called on them.
+ This means that if in a destructor, the base class destructors
+ must be called before returning.
+
+ The RETURN statement in C++ has initialization semantics. */
+
+void
+c_expand_return (retval)
+ tree retval;
+{
+ extern struct nesting *cond_stack, *loop_stack, *case_stack;
+ extern tree dtor_label, ctor_label;
+ tree result = DECL_RESULT (current_function_decl);
+ tree valtype = TREE_TYPE (result);
+ register int use_temp = 0;
+ int returns_value = 1;
+
+ if (TREE_THIS_VOLATILE (current_function_decl))
+ warning ("function declared `noreturn' has a `return' statement");
+
+ if (retval == error_mark_node)
+ {
+ current_function_returns_null = 1;
+ return;
+ }
+
+ if (retval == NULL_TREE)
+ {
+ /* A non-named return value does not count. */
+
+ /* Can't just return from a destructor. */
+ if (dtor_label)
+ {
+ expand_goto (dtor_label);
+ return;
+ }
+
+ if (DECL_CONSTRUCTOR_P (current_function_decl))
+ retval = current_class_decl;
+ else if (DECL_NAME (result) != NULL_TREE
+ && TREE_CODE (valtype) != VOID_TYPE)
+ retval = result;
+ else
+ {
+ current_function_returns_null = 1;
+
+ if (valtype != NULL_TREE && TREE_CODE (valtype) != VOID_TYPE)
+ {
+ if (DECL_NAME (DECL_RESULT (current_function_decl)) == NULL_TREE)
+ {
+ pedwarn ("`return' with no value, in function returning non-void");
+ /* Clear this, so finish_function won't say that we
+ reach the end of a non-void function (which we don't,
+ we gave a return!). */
+ current_function_returns_null = 0;
+ }
+ }
+
+ expand_null_return ();
+ return;
+ }
+ }
+ else if (DECL_CONSTRUCTOR_P (current_function_decl)
+ && retval != current_class_decl)
+ {
+ error ("return from a constructor: use `this = ...' instead");
+ retval = current_class_decl;
+ }
+
+ if (valtype == NULL_TREE || TREE_CODE (valtype) == VOID_TYPE)
+ {
+ current_function_returns_null = 1;
+ /* We do this here so we'll avoid a warning about how the function
+ "may or may not return a value" in finish_function. */
+ returns_value = 0;
+
+ if (retval)
+ pedwarn ("`return' with a value, in function returning void");
+ expand_return (retval);
+ }
+ /* Add some useful error checking for C++. */
+ else if (TREE_CODE (valtype) == REFERENCE_TYPE)
+ {
+ tree whats_returned;
+ tree tmp_result = result;
+
+ /* Don't initialize directly into a non-BLKmode retval, since that
+ could lose when being inlined by another caller. (GCC can't
+ read the function return register in an inline function when
+ the return value is being ignored). */
+ if (result && TYPE_MODE (TREE_TYPE (tmp_result)) != BLKmode)
+ tmp_result = 0;
+
+ /* convert to reference now, so we can give error if we
+ return an reference to a non-lvalue. */
+ retval = convert_for_initialization (tmp_result, valtype, retval,
+ LOOKUP_NORMAL, "return",
+ NULL_TREE, 0);
+
+ /* Sort through common things to see what it is
+ we are returning. */
+ whats_returned = retval;
+ if (TREE_CODE (whats_returned) == COMPOUND_EXPR)
+ {
+ whats_returned = TREE_OPERAND (whats_returned, 1);
+ if (TREE_CODE (whats_returned) == ADDR_EXPR)
+ whats_returned = TREE_OPERAND (whats_returned, 0);
+ }
+ if (TREE_CODE (whats_returned) == ADDR_EXPR)
+ {
+ whats_returned = TREE_OPERAND (whats_returned, 0);
+ while (TREE_CODE (whats_returned) == NEW_EXPR
+ || TREE_CODE (whats_returned) == TARGET_EXPR
+ || TREE_CODE (whats_returned) == WITH_CLEANUP_EXPR)
+ {
+ /* Get the target. */
+ whats_returned = TREE_OPERAND (whats_returned, 0);
+ warning ("returning reference to temporary");
+ }
+ }
+
+ if (TREE_CODE (whats_returned) == VAR_DECL && DECL_NAME (whats_returned))
+ {
+ if (TEMP_NAME_P (DECL_NAME (whats_returned)))
+ warning ("reference to non-lvalue returned");
+ else if (! TREE_STATIC (whats_returned)
+ && IDENTIFIER_LOCAL_VALUE (DECL_NAME (whats_returned)))
+ cp_warning_at ("reference to local variable `%D' returned", whats_returned);
+ }
+ }
+ else if (TREE_CODE (retval) == ADDR_EXPR)
+ {
+ tree whats_returned = TREE_OPERAND (retval, 0);
+
+ if (TREE_CODE (whats_returned) == VAR_DECL
+ && DECL_NAME (whats_returned)
+ && IDENTIFIER_LOCAL_VALUE (DECL_NAME (whats_returned))
+ && !TREE_STATIC (whats_returned))
+ cp_warning_at ("address of local variable `%D' returned", whats_returned);
+ }
+
+ /* Now deal with possible C++ hair:
+ (1) Compute the return value.
+ (2) If there are aggregate values with destructors which
+ must be cleaned up, clean them (taking care
+ not to clobber the return value).
+ (3) If an X(X&) constructor is defined, the return
+ value must be returned via that. */
+
+ /* If we're returning in a register, we can't initialize the
+ return value from a TARGET_EXPR. */
+ if (TREE_CODE (retval) == TARGET_EXPR
+ && TYPE_MAIN_VARIANT (TREE_TYPE (retval)) == TYPE_MAIN_VARIANT (valtype)
+ && ! current_function_returns_struct)
+ retval = expand_target_expr (retval);
+
+ if (retval == result
+ /* Watch out for constructors, which "return" aggregates
+ via initialization, but which otherwise "return" a pointer. */
+ || DECL_CONSTRUCTOR_P (current_function_decl))
+ {
+ /* This is just an error--it's already been reported. */
+ if (TYPE_SIZE (valtype) == NULL_TREE)
+ return;
+
+ if (TYPE_MODE (valtype) != BLKmode
+ && any_pending_cleanups (1))
+ {
+ retval = get_temp_regvar (valtype, retval);
+ use_temp = obey_regdecls;
+ }
+ }
+ else if (IS_AGGR_TYPE (valtype) && current_function_returns_struct)
+ {
+ expand_aggr_init (result, retval, 0, LOOKUP_ONLYCONVERTING);
+ expand_cleanups_to (NULL_TREE);
+ DECL_INITIAL (result) = NULL_TREE;
+ retval = 0;
+ }
+ else
+ {
+ if (TYPE_MODE (valtype) == VOIDmode)
+ {
+ if (TYPE_MODE (TREE_TYPE (result)) != VOIDmode
+ && warn_return_type)
+ warning ("return of void value in function returning non-void");
+ expand_expr_stmt (retval);
+ retval = 0;
+ result = 0;
+ }
+ else if (TYPE_MODE (valtype) != BLKmode
+ && any_pending_cleanups (1))
+ {
+ retval = get_temp_regvar (valtype, retval);
+ expand_cleanups_to (NULL_TREE);
+ use_temp = obey_regdecls;
+ result = 0;
+ }
+ else
+ {
+ retval = convert_for_initialization (result, valtype, retval,
+ LOOKUP_NORMAL,
+ "return", NULL_TREE, 0);
+ DECL_INITIAL (result) = NULL_TREE;
+ }
+ if (retval == error_mark_node)
+ return;
+ }
+
+ emit_queue ();
+
+ if (retval != NULL_TREE
+ && TREE_CODE_CLASS (TREE_CODE (retval)) == 'd'
+ && cond_stack == 0 && loop_stack == 0 && case_stack == 0)
+ current_function_return_value = retval;
+
+ if (result)
+ {
+ /* Everything's great--RETVAL is in RESULT. */
+ if (original_result_rtx)
+ {
+ store_expr (result, original_result_rtx, 0);
+ expand_cleanups_to (NULL_TREE);
+ use_variable (DECL_RTL (result));
+ if (ctor_label && TREE_CODE (ctor_label) != ERROR_MARK)
+ expand_goto (ctor_label);
+ else
+ expand_null_return ();
+ }
+ else if (retval && retval != result)
+ {
+ /* Clear this out so the later call to decl_function_context
+ won't end up bombing on us. */
+ if (DECL_CONTEXT (result) == error_mark_node)
+ DECL_CONTEXT (result) = NULL_TREE;
+ /* Here is where we finally get RETVAL into RESULT.
+ `expand_return' does the magic of protecting
+ RESULT from cleanups. */
+ retval = fold (build1 (CLEANUP_POINT_EXPR, TREE_TYPE (result),
+ retval));
+ /* This part _must_ come second, because expand_return looks for
+ the INIT_EXPR as the toplevel node only. :-( */
+ retval = build (INIT_EXPR, TREE_TYPE (result), result, retval);
+ TREE_SIDE_EFFECTS (retval) = 1;
+ expand_return (retval);
+ }
+ else
+ expand_return (result);
+ }
+ else
+ {
+ /* We may still need to put RETVAL into RESULT. */
+ result = DECL_RESULT (current_function_decl);
+ if (original_result_rtx)
+ {
+ /* Here we have a named return value that went
+ into memory. We can compute RETVAL into that. */
+ if (retval)
+ expand_assignment (result, retval, 0, 0);
+ else
+ store_expr (result, original_result_rtx, 0);
+ result = make_tree (TREE_TYPE (result), original_result_rtx);
+ }
+ else if (ctor_label && TREE_CODE (ctor_label) != ERROR_MARK)
+ {
+ /* Here RETVAL is CURRENT_CLASS_DECL, so there's nothing to do. */
+ expand_goto (ctor_label);
+ }
+ else if (retval)
+ {
+ /* Here is where we finally get RETVAL into RESULT.
+ `expand_return' does the magic of protecting
+ RESULT from cleanups. */
+ result = build (INIT_EXPR, TREE_TYPE (result), result, retval);
+ TREE_SIDE_EFFECTS (result) = 1;
+ expand_return (result);
+ }
+ else if (TYPE_MODE (TREE_TYPE (result)) != VOIDmode)
+ expand_return (result);
+ }
+
+ current_function_returns_value = returns_value;
+#if 0
+ /* These wind up after the BARRIER, which causes problems for
+ expand_end_binding. What purpose were they supposed to serve? */
+ if (original_result_rtx)
+ use_variable (original_result_rtx);
+ if (use_temp)
+ use_variable (DECL_RTL (DECL_RESULT (current_function_decl)));
+#endif
+
+ /* One way to clear out cleanups that EXPR might
+ generate. Note that this code will really be
+ dead code, but that is ok--cleanups that were
+ needed were handled by the magic of `return'. */
+ expand_cleanups_to (NULL_TREE);
+}
+
+/* Start a C switch statement, testing expression EXP.
+ Return EXP if it is valid, an error node otherwise. */
+
+tree
+c_expand_start_case (exp)
+ tree exp;
+{
+ tree type;
+ register enum tree_code code;
+
+ /* Convert from references, etc. */
+ exp = default_conversion (exp);
+ type = TREE_TYPE (exp);
+ code = TREE_CODE (type);
+
+ if (IS_AGGR_TYPE_CODE (code))
+ exp = build_type_conversion (CONVERT_EXPR, integer_type_node, exp, 1);
+
+ if (exp == NULL_TREE)
+ {
+ error ("switch quantity not an integer");
+ exp = error_mark_node;
+ }
+ type = TREE_TYPE (exp);
+ code = TREE_CODE (type);
+
+ if (code != INTEGER_TYPE && code != ENUMERAL_TYPE && code != ERROR_MARK)
+ {
+ error ("switch quantity not an integer");
+ exp = error_mark_node;
+ }
+ else
+ {
+ tree index;
+
+ exp = default_conversion (exp);
+ type = TREE_TYPE (exp);
+ index = get_unwidened (exp, 0);
+ /* We can't strip a conversion from a signed type to an unsigned,
+ because if we did, int_fits_type_p would do the wrong thing
+ when checking case values for being in range,
+ and it's too hard to do the right thing. */
+ if (TREE_UNSIGNED (TREE_TYPE (exp))
+ == TREE_UNSIGNED (TREE_TYPE (index)))
+ exp = index;
+ }
+
+ expand_start_case
+ (1, fold (build1 (CLEANUP_POINT_EXPR, TREE_TYPE (exp), exp)),
+ type, "switch statement");
+
+ return exp;
+}
+
+/* CONSTP remembers whether or not all the intervening pointers in the `to'
+ type have been const. */
+int
+comp_ptr_ttypes_real (to, from, constp)
+ tree to, from;
+ int constp;
+{
+ for (; ; to = TREE_TYPE (to), from = TREE_TYPE (from))
+ {
+ if (TREE_CODE (to) != TREE_CODE (from))
+ return 0;
+
+ /* Const and volatile mean something different for function types,
+ so the usual checks are not appropriate. */
+ if (TREE_CODE (to) != FUNCTION_TYPE && TREE_CODE (to) != METHOD_TYPE)
+ {
+ if (TYPE_READONLY (from) > TYPE_READONLY (to)
+ || TYPE_VOLATILE (from) > TYPE_VOLATILE (to))
+ return 0;
+
+ if (! constp
+ && (TYPE_READONLY (to) > TYPE_READONLY (from)
+ || TYPE_VOLATILE (to) > TYPE_READONLY (from)))
+ return 0;
+ constp &= TYPE_READONLY (to);
+ }
+
+ if (TREE_CODE (to) != POINTER_TYPE)
+ return comptypes (TYPE_MAIN_VARIANT (to), TYPE_MAIN_VARIANT (from), 1);
+ }
+}
+
+/* When comparing, say, char ** to char const **, this function takes the
+ 'char *' and 'char const *'. Do not pass non-pointer types to this
+ function. */
+int
+comp_ptr_ttypes (to, from)
+ tree to, from;
+{
+ return comp_ptr_ttypes_real (to, from, 1);
+}
diff --git a/contrib/gcc/cp/typeck2.c b/contrib/gcc/cp/typeck2.c
new file mode 100644
index 0000000..653d6a5
--- /dev/null
+++ b/contrib/gcc/cp/typeck2.c
@@ -0,0 +1,1681 @@
+/* Report error messages, build initializers, and perform
+ some front-end optimizations for C++ compiler.
+ Copyright (C) 1987, 88, 89, 92, 93, 94, 1995 Free Software Foundation, Inc.
+ Hacked by Michael Tiemann (tiemann@cygnus.com)
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+/* This file is part of the C++ front end.
+ It contains routines to build C++ expressions given their operands,
+ including computing the types of the result, C and C++ specific error
+ checks, and some optimization.
+
+ There are also routines to build RETURN_STMT nodes and CASE_STMT nodes,
+ and to process initializations in declarations (since they work
+ like a strange sort of assignment). */
+
+#include "config.h"
+#include <stdio.h>
+#include "tree.h"
+#include "cp-tree.h"
+#include "flags.h"
+
+static tree process_init_constructor ();
+extern void pedwarn (), error ();
+
+extern int errorcount;
+extern int sorrycount;
+
+/* Print an error message stemming from an attempt to use
+ BASETYPE as a base class for TYPE. */
+tree
+error_not_base_type (basetype, type)
+ tree basetype, type;
+{
+ if (TREE_CODE (basetype) == FUNCTION_DECL)
+ basetype = DECL_CLASS_CONTEXT (basetype);
+ cp_error ("type `%T' is not a base type for type `%T'", basetype, type);
+ return error_mark_node;
+}
+
+tree
+binfo_or_else (parent_or_type, type)
+ tree parent_or_type, type;
+{
+ tree binfo;
+ if (TYPE_MAIN_VARIANT (parent_or_type) == TYPE_MAIN_VARIANT (type))
+ return TYPE_BINFO (parent_or_type);
+ if ((binfo = get_binfo (parent_or_type, TYPE_MAIN_VARIANT (type), 0)))
+ {
+ if (binfo == error_mark_node)
+ return NULL_TREE;
+ return binfo;
+ }
+ error_not_base_type (parent_or_type, type);
+ return NULL_TREE;
+}
+
+/* Print an error message stemming from an invalid use of an
+ aggregate type.
+
+ TYPE is the type or binfo which draws the error.
+ MSG is the message to print.
+ ARG is an optional argument which may provide more information. */
+void
+error_with_aggr_type (type, msg, arg)
+ tree type;
+ char *msg;
+ HOST_WIDE_INT arg;
+{
+ tree name;
+
+ if (TREE_CODE (type) == TREE_VEC)
+ type = BINFO_TYPE (type);
+
+ name = TYPE_NAME (type);
+ if (TREE_CODE (name) == TYPE_DECL)
+ name = DECL_NAME (name);
+ error (msg, IDENTIFIER_POINTER (name), arg);
+}
+
+/* According to ARM $7.1.6, "A `const' object may be initialized, but its
+ value may not be changed thereafter. Thus, we emit hard errors for these,
+ rather than just pedwarns. If `SOFT' is 1, then we just pedwarn. (For
+ example, conversions to references.) */
+void
+readonly_error (arg, string, soft)
+ tree arg;
+ char *string;
+ int soft;
+{
+ char *fmt;
+ void (*fn)();
+
+ if (soft)
+ fn = pedwarn;
+ else
+ fn = error;
+
+ if (TREE_CODE (arg) == COMPONENT_REF)
+ {
+ if (TYPE_READONLY (TREE_TYPE (TREE_OPERAND (arg, 0))))
+ fmt = "%s of member `%s' in read-only structure";
+ else
+ fmt = "%s of read-only member `%s'";
+ (*fn) (fmt, string, lang_printable_name (TREE_OPERAND (arg, 1)));
+ }
+ else if (TREE_CODE (arg) == VAR_DECL)
+ {
+ if (DECL_LANG_SPECIFIC (arg)
+ && DECL_IN_AGGR_P (arg)
+ && !TREE_STATIC (arg))
+ fmt = "%s of constant field `%s'";
+ else
+ fmt = "%s of read-only variable `%s'";
+ (*fn) (fmt, string, lang_printable_name (arg));
+ }
+ else if (TREE_CODE (arg) == PARM_DECL)
+ (*fn) ("%s of read-only parameter `%s'", string,
+ lang_printable_name (arg));
+ else if (TREE_CODE (arg) == INDIRECT_REF
+ && TREE_CODE (TREE_TYPE (TREE_OPERAND (arg, 0))) == REFERENCE_TYPE
+ && (TREE_CODE (TREE_OPERAND (arg, 0)) == VAR_DECL
+ || TREE_CODE (TREE_OPERAND (arg, 0)) == PARM_DECL))
+ (*fn) ("%s of read-only reference `%s'",
+ string, lang_printable_name (TREE_OPERAND (arg, 0)));
+ else if (TREE_CODE (arg) == RESULT_DECL)
+ (*fn) ("%s of read-only named return value `%s'",
+ string, lang_printable_name (arg));
+ else
+ (*fn) ("%s of read-only location", string);
+}
+
+/* Print an error message for invalid use of a type which declares
+ virtual functions which are not inheritable. */
+void
+abstract_virtuals_error (decl, type)
+ tree decl;
+ tree type;
+{
+ tree u = CLASSTYPE_ABSTRACT_VIRTUALS (type);
+
+ if (decl)
+ {
+ if (TREE_CODE (decl) == RESULT_DECL)
+ return;
+
+ if (TREE_CODE (decl) == VAR_DECL)
+ cp_error ("cannot declare variable `%D' to be of type `%T'",
+ decl, type);
+ else if (TREE_CODE (decl) == PARM_DECL)
+ cp_error ("cannot declare parameter `%D' to be of type `%T'",
+ decl, type);
+ else if (TREE_CODE (decl) == FIELD_DECL)
+ cp_error ("cannot declare field `%D' to be of type `%T'",
+ decl, type);
+ else if (TREE_CODE (decl) == FUNCTION_DECL
+ && TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)
+ cp_error ("invalid return type for method `%#D'", decl);
+ else if (TREE_CODE (decl) == FUNCTION_DECL)
+ cp_error ("invalid return type for function `%#D'", decl);
+ }
+ else cp_error ("cannot allocate an object of type `%T'", type);
+ /* Only go through this once. */
+ if (TREE_PURPOSE (u) == NULL_TREE)
+ {
+ error (" since the following virtual functions are abstract:");
+ TREE_PURPOSE (u) = error_mark_node;
+ while (u)
+ {
+ cp_error ("\t%#D", TREE_VALUE (u));
+ u = TREE_CHAIN (u);
+ }
+ }
+ else cp_error (" since type `%T' has abstract virtual functions", type);
+}
+
+/* Print an error message for invalid use of a signature type.
+ Signatures are treated similar to abstract classes here, they
+ cannot be instantiated. */
+void
+signature_error (decl, type)
+ tree decl;
+ tree type;
+{
+ if (decl)
+ {
+ if (TREE_CODE (decl) == RESULT_DECL)
+ return;
+
+ if (TREE_CODE (decl) == VAR_DECL)
+ cp_error ("cannot declare variable `%D' to be of signature type `%T'",
+ decl, type);
+ else if (TREE_CODE (decl) == PARM_DECL)
+ cp_error ("cannot declare parameter `%D' to be of signature type `%T'",
+ decl, type);
+ else if (TREE_CODE (decl) == FIELD_DECL)
+ cp_error ("cannot declare field `%D' to be of signature type `%T'",
+ decl, type);
+ else if (TREE_CODE (decl) == FUNCTION_DECL
+ && TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)
+ cp_error ("invalid return type for method `%#D'", decl);
+ else if (TREE_CODE (decl) == FUNCTION_DECL)
+ cp_error ("invalid return type for function `%#D'", decl);
+ }
+ else
+ cp_error ("cannot allocate an object of signature type `%T'", type);
+}
+
+/* Print an error message for invalid use of an incomplete type.
+ VALUE is the expression that was used (or 0 if that isn't known)
+ and TYPE is the type that was invalid. */
+
+void
+incomplete_type_error (value, type)
+ tree value;
+ tree type;
+{
+ char *errmsg;
+
+ /* Avoid duplicate error message. */
+ if (TREE_CODE (type) == ERROR_MARK)
+ return;
+
+ if (value != 0 && (TREE_CODE (value) == VAR_DECL
+ || TREE_CODE (value) == PARM_DECL))
+ error ("`%s' has an incomplete type",
+ IDENTIFIER_POINTER (DECL_NAME (value)));
+ else
+ {
+ retry:
+ /* We must print an error message. Be clever about what it says. */
+
+ switch (TREE_CODE (type))
+ {
+ case RECORD_TYPE:
+ errmsg = "invalid use of undefined type `struct %s'";
+ break;
+
+ case UNION_TYPE:
+ errmsg = "invalid use of undefined type `union %s'";
+ break;
+
+ case ENUMERAL_TYPE:
+ errmsg = "invalid use of undefined type `enum %s'";
+ break;
+
+ case VOID_TYPE:
+ error ("invalid use of void expression");
+ return;
+
+ case ARRAY_TYPE:
+ if (TYPE_DOMAIN (type))
+ {
+ type = TREE_TYPE (type);
+ goto retry;
+ }
+ error ("invalid use of array with unspecified bounds");
+ return;
+
+ case OFFSET_TYPE:
+ error ("invalid use of member type (did you forget the `&' ?)");
+ return;
+
+ default:
+ my_friendly_abort (108);
+ }
+
+ error_with_aggr_type (type, errmsg);
+ }
+}
+
+/* Like error(), but don't call report_error_function(). */
+static void
+ack (s, v, v2)
+ char *s;
+ HOST_WIDE_INT v;
+ HOST_WIDE_INT v2;
+{
+ extern char * progname;
+
+ if (input_filename)
+ fprintf (stderr, "%s:%d: ", input_filename, lineno);
+ else
+ fprintf (stderr, "%s: ", progname);
+
+ fprintf (stderr, s, v, v2);
+ fprintf (stderr, "\n");
+}
+
+/* There are times when the compiler can get very confused, confused
+ to the point of giving up by aborting, simply because of previous
+ input errors. It is much better to have the user go back and
+ correct those errors first, and see if it makes us happier, than it
+ is to abort on him. This is because when one has a 10,000 line
+ program, and the compiler comes back with ``core dump'', the user
+ is left not knowing even where to begin to fix things and no place
+ to even try and work around things.
+
+ The parameter is to uniquely identify the problem to the user, so
+ that they can say, I am having problem 59, and know that fix 7 will
+ probably solve their problem. Or, we can document what problem
+ 59 is, so they can understand how to work around it, should they
+ ever run into it.
+
+ Note, there will be no more calls in the C++ front end to abort,
+ because the C++ front end is so unreliable still. The C front end
+ can get away with calling abort, because for most of the calls to
+ abort on most machines, it, I suspect, can be proven that it is
+ impossible to ever call abort. The same is not yet true for C++,
+ one day, maybe it will be.
+
+ We used to tell people to "fix the above error[s] and try recompiling
+ the program" via a call to fatal, but that message tended to look
+ silly. So instead, we just do the equivalent of a call to fatal in the
+ same situation (call exit). */
+
+/* First used: 0 (reserved), Last used: 366. Free: */
+
+static int abortcount = 0;
+
+void
+my_friendly_abort (i)
+ int i;
+{
+ /* if the previous error came through here, i.e. report_error_function
+ ended up calling us again, don't just exit; we want a diagnostic of
+ some kind. */
+ if (abortcount == 1)
+ current_function_decl = NULL_TREE;
+ else if (errorcount > 0 || sorrycount > 0)
+ {
+ if (abortcount > 1)
+ {
+ if (i == 0)
+ ack ("Internal compiler error.");
+ else
+ ack ("Internal compiler error %d.", i);
+ ack ("Please submit a full bug report to `bug-g++@prep.ai.mit.edu'.");
+ }
+ else
+ error ("confused by earlier errors, bailing out");
+
+ exit (34);
+ }
+ ++abortcount;
+
+ if (i == 0)
+ error ("Internal compiler error.");
+ else
+ error ("Internal compiler error %d.", i);
+
+ fatal ("Please submit a full bug report to `bug-g++@prep.ai.mit.edu'.");
+}
+
+void
+my_friendly_assert (cond, where)
+ int cond, where;
+{
+ if (cond == 0)
+ my_friendly_abort (where);
+}
+
+/* Return nonzero if VALUE is a valid constant-valued expression
+ for use in initializing a static variable; one that can be an
+ element of a "constant" initializer.
+
+ Return null_pointer_node if the value is absolute;
+ if it is relocatable, return the variable that determines the relocation.
+ We assume that VALUE has been folded as much as possible;
+ therefore, we do not need to check for such things as
+ arithmetic-combinations of integers. */
+
+tree
+initializer_constant_valid_p (value, endtype)
+ tree value;
+ tree endtype;
+{
+ switch (TREE_CODE (value))
+ {
+ case CONSTRUCTOR:
+ if (TREE_CODE (TREE_TYPE (value)) == UNION_TYPE
+ && TREE_CONSTANT (value))
+ return
+ initializer_constant_valid_p (TREE_VALUE (CONSTRUCTOR_ELTS (value)),
+ endtype);
+
+ return TREE_STATIC (value) ? null_pointer_node : 0;
+
+ case INTEGER_CST:
+ case REAL_CST:
+ case STRING_CST:
+ case COMPLEX_CST:
+ return null_pointer_node;
+
+ case ADDR_EXPR:
+ return TREE_OPERAND (value, 0);
+
+ case NON_LVALUE_EXPR:
+ return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
+
+ case CONVERT_EXPR:
+ case NOP_EXPR:
+ /* Allow conversions between pointer types. */
+ if (TREE_CODE (TREE_TYPE (value)) == POINTER_TYPE
+ && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == POINTER_TYPE)
+ return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
+
+ /* Allow conversions between real types. */
+ if (TREE_CODE (TREE_TYPE (value)) == REAL_TYPE
+ && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == REAL_TYPE)
+ return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
+
+ /* Allow length-preserving conversions between integer types. */
+ if (TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE
+ && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == INTEGER_TYPE
+ && (TYPE_PRECISION (TREE_TYPE (value))
+ == TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))))
+ return initializer_constant_valid_p (TREE_OPERAND (value, 0), endtype);
+
+ /* Allow conversions between other integer types only if
+ explicit value. */
+ if (TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE
+ && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == INTEGER_TYPE)
+ {
+ tree inner = initializer_constant_valid_p (TREE_OPERAND (value, 0),
+ endtype);
+ if (inner == null_pointer_node)
+ return null_pointer_node;
+ return 0;
+ }
+
+ /* Allow (int) &foo provided int is as wide as a pointer. */
+ if (TREE_CODE (TREE_TYPE (value)) == INTEGER_TYPE
+ && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == POINTER_TYPE
+ && (TYPE_PRECISION (TREE_TYPE (value))
+ >= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))))
+ return initializer_constant_valid_p (TREE_OPERAND (value, 0),
+ endtype);
+
+ /* Likewise conversions from int to pointers. */
+ if (TREE_CODE (TREE_TYPE (value)) == POINTER_TYPE
+ && TREE_CODE (TREE_TYPE (TREE_OPERAND (value, 0))) == INTEGER_TYPE
+ && (TYPE_PRECISION (TREE_TYPE (value))
+ <= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (value, 0)))))
+ return initializer_constant_valid_p (TREE_OPERAND (value, 0),
+ endtype);
+
+ /* Allow conversions to union types if the value inside is okay. */
+ if (TREE_CODE (TREE_TYPE (value)) == UNION_TYPE)
+ return initializer_constant_valid_p (TREE_OPERAND (value, 0),
+ endtype);
+ return 0;
+
+ case PLUS_EXPR:
+ if (TREE_CODE (endtype) == INTEGER_TYPE
+ && TYPE_PRECISION (endtype) < POINTER_SIZE)
+ return 0;
+ {
+ tree valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0),
+ endtype);
+ tree valid1 = initializer_constant_valid_p (TREE_OPERAND (value, 1),
+ endtype);
+ /* If either term is absolute, use the other terms relocation. */
+ if (valid0 == null_pointer_node)
+ return valid1;
+ if (valid1 == null_pointer_node)
+ return valid0;
+ return 0;
+ }
+
+ case MINUS_EXPR:
+ if (TREE_CODE (endtype) == INTEGER_TYPE
+ && TYPE_PRECISION (endtype) < POINTER_SIZE)
+ return 0;
+ {
+ tree valid0 = initializer_constant_valid_p (TREE_OPERAND (value, 0),
+ endtype);
+ tree valid1 = initializer_constant_valid_p (TREE_OPERAND (value, 1),
+ endtype);
+ /* Win if second argument is absolute. */
+ if (valid1 == null_pointer_node)
+ return valid0;
+ /* Win if both arguments have the same relocation.
+ Then the value is absolute. */
+ if (valid0 == valid1)
+ return null_pointer_node;
+ return 0;
+ }
+ }
+
+ return 0;
+}
+
+/* Perform appropriate conversions on the initial value of a variable,
+ store it in the declaration DECL,
+ and print any error messages that are appropriate.
+ If the init is invalid, store an ERROR_MARK.
+
+ C++: Note that INIT might be a TREE_LIST, which would mean that it is
+ a base class initializer for some aggregate type, hopefully compatible
+ with DECL. If INIT is a single element, and DECL is an aggregate
+ type, we silently convert INIT into a TREE_LIST, allowing a constructor
+ to be called.
+
+ If INIT is a TREE_LIST and there is no constructor, turn INIT
+ into a CONSTRUCTOR and use standard initialization techniques.
+ Perhaps a warning should be generated?
+
+ Returns value of initializer if initialization could not be
+ performed for static variable. In that case, caller must do
+ the storing. */
+
+tree
+store_init_value (decl, init)
+ tree decl, init;
+{
+ register tree value, type;
+
+ /* If variable's type was invalidly declared, just ignore it. */
+
+ type = TREE_TYPE (decl);
+ if (TREE_CODE (type) == ERROR_MARK)
+ return NULL_TREE;
+
+#if 0
+ /* This breaks arrays, and should not have any effect for other decls. */
+ /* Take care of C++ business up here. */
+ type = TYPE_MAIN_VARIANT (type);
+#endif
+
+ if (IS_AGGR_TYPE (type))
+ {
+ if (! TYPE_HAS_TRIVIAL_INIT_REF (type)
+ && TREE_CODE (init) != CONSTRUCTOR)
+ my_friendly_abort (109);
+
+ /* Although we are not allowed to declare variables of signature
+ type, we complain about a possible constructor call in such a
+ declaration as well. */
+ if (TREE_CODE (init) == TREE_LIST
+ && IS_SIGNATURE (type))
+ {
+ cp_error ("constructor syntax cannot be used with signature type `%T'",
+ type);
+ init = error_mark_node;
+ }
+ else if (TREE_CODE (init) == TREE_LIST)
+ {
+ cp_error ("constructor syntax used, but no constructor declared for type `%T'", type);
+ init = build_nt (CONSTRUCTOR, NULL_TREE, nreverse (init));
+ }
+#if 0
+ if (TREE_CODE (init) == CONSTRUCTOR)
+ {
+ tree field;
+ tree funcs;
+ int func;
+
+ /* Check that we're really an aggregate as ARM 8.4.1 defines it. */
+ if (CLASSTYPE_N_BASECLASSES (type))
+ cp_error_at ("initializer list construction invalid for derived class object `%D'", decl);
+ if (CLASSTYPE_VTBL_PTR (type))
+ cp_error_at ("initializer list construction invalid for polymorphic class object `%D'", decl);
+ if (TYPE_NEEDS_CONSTRUCTING (type))
+ {
+ cp_error_at ("initializer list construction invalid for `%D'", decl);
+ error ("due to the presence of a constructor");
+ }
+ for (field = TYPE_FIELDS (type); field; field = TREE_CHAIN (field))
+ if (TREE_PRIVATE (field) || TREE_PROTECTED (field))
+ {
+ cp_error_at ("initializer list construction invalid for `%D'", decl);
+ cp_error_at ("due to non-public access of member `%D'", field);
+ }
+ funcs = TYPE_METHODS (type);
+ if (funcs)
+ for (func = 0; func < TREE_VEC_LENGTH (funcs); func++)
+ {
+ field = TREE_VEC_ELT (funcs, func);
+ if (field && (TREE_PRIVATE (field) || TREE_PROTECTED (field)))
+ {
+ cp_error_at ("initializer list construction invalid for `%D'", decl);
+ cp_error_at ("due to non-public access of member `%D'", field);
+ }
+ }
+ }
+#endif
+ }
+ else if (TREE_CODE (init) == TREE_LIST
+ && TREE_TYPE (init) != unknown_type_node)
+ {
+ if (TREE_CODE (decl) == RESULT_DECL)
+ {
+ if (TREE_CHAIN (init))
+ {
+ warning ("comma expression used to initialize return value");
+ init = build_compound_expr (init);
+ }
+ else
+ init = TREE_VALUE (init);
+ }
+ else if (TREE_TYPE (init) != 0
+ && TREE_CODE (TREE_TYPE (init)) == OFFSET_TYPE)
+ {
+ /* Use the type of our variable to instantiate
+ the type of our initializer. */
+ init = instantiate_type (type, init, 1);
+ }
+ else if (TREE_CODE (init) == TREE_LIST
+ && TREE_CODE (TREE_TYPE (decl)) == ARRAY_TYPE)
+ {
+ error ("cannot initialize arrays using this syntax");
+ return NULL_TREE;
+ }
+ else
+ {
+ /* We get here with code like `int a (2);' */
+
+ if (TREE_CHAIN (init) != NULL_TREE)
+ {
+ pedwarn ("initializer list being treated as compound expression");
+ init = build_compound_expr (init);
+ }
+ else
+ init = TREE_VALUE (init);
+ }
+ }
+
+ /* End of special C++ code. */
+
+ /* Digest the specified initializer into an expression. */
+
+ value = digest_init (type, init, (tree *) 0);
+
+ /* Store the expression if valid; else report error. */
+
+ if (TREE_CODE (value) == ERROR_MARK)
+ ;
+ else if (TREE_STATIC (decl)
+ && (! TREE_CONSTANT (value)
+ || ! initializer_constant_valid_p (value, TREE_TYPE (value))
+#if 0
+ /* A STATIC PUBLIC int variable doesn't have to be
+ run time inited when doing pic. (mrs) */
+ /* Since ctors and dtors are the only things that can
+ reference vtables, and they are always written down
+ the the vtable definition, we can leave the
+ vtables in initialized data space.
+ However, other initialized data cannot be initialized
+ this way. Instead a global file-level initializer
+ must do the job. */
+ || (flag_pic && !DECL_VIRTUAL_P (decl) && TREE_PUBLIC (decl))
+#endif
+ ))
+
+ return value;
+#if 0 /* No, that's C. jason 9/19/94 */
+ else
+ {
+ if (pedantic && TREE_CODE (value) == CONSTRUCTOR
+ /* Don't complain about non-constant initializers of
+ signature tables and signature pointers/references. */
+ && ! (TYPE_LANG_SPECIFIC (type)
+ && (IS_SIGNATURE (type)
+ || IS_SIGNATURE_POINTER (type)
+ || IS_SIGNATURE_REFERENCE (type))))
+ {
+ if (! TREE_CONSTANT (value) || ! TREE_STATIC (value))
+ pedwarn ("ANSI C++ forbids non-constant aggregate initializer expressions");
+ }
+ }
+#endif
+ DECL_INITIAL (decl) = value;
+ return NULL_TREE;
+}
+
+/* Digest the parser output INIT as an initializer for type TYPE.
+ Return a C expression of type TYPE to represent the initial value.
+
+ If TAIL is nonzero, it points to a variable holding a list of elements
+ of which INIT is the first. We update the list stored there by
+ removing from the head all the elements that we use.
+ Normally this is only one; we use more than one element only if
+ TYPE is an aggregate and INIT is not a constructor. */
+
+tree
+digest_init (type, init, tail)
+ tree type, init, *tail;
+{
+ enum tree_code code = TREE_CODE (type);
+ tree element = NULL_TREE;
+ tree old_tail_contents;
+ /* Nonzero if INIT is a braced grouping, which comes in as a CONSTRUCTOR
+ tree node which has no TREE_TYPE. */
+ int raw_constructor;
+
+ /* By default, assume we use one element from a list.
+ We correct this later in the sole case where it is not true. */
+
+ if (tail)
+ {
+ old_tail_contents = *tail;
+ *tail = TREE_CHAIN (*tail);
+ }
+
+ if (init == error_mark_node || (TREE_CODE (init) == TREE_LIST
+ && TREE_VALUE (init) == error_mark_node))
+ return error_mark_node;
+
+ /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */
+ if (TREE_CODE (init) == NON_LVALUE_EXPR)
+ init = TREE_OPERAND (init, 0);
+
+ if (init && TREE_TYPE (init) && TYPE_PTRMEMFUNC_P (type))
+ init = default_conversion (init);
+
+ if (init && TYPE_PTRMEMFUNC_P (type)
+ && ((TREE_CODE (init) == ADDR_EXPR
+ && ((TREE_CODE (TREE_TYPE (init)) == POINTER_TYPE
+ && TREE_CODE (TREE_TYPE (TREE_TYPE (init))) == METHOD_TYPE)
+ || TREE_CODE (TREE_OPERAND (init, 0)) == TREE_LIST))
+ || TREE_CODE (init) == TREE_LIST
+ || integer_zerop (init)
+ || (TREE_TYPE (init) && TYPE_PTRMEMFUNC_P (TREE_TYPE (init)))))
+ {
+ return build_ptrmemfunc (TYPE_PTRMEMFUNC_FN_TYPE (type), init, 0);
+ }
+
+ raw_constructor = TREE_CODE (init) == CONSTRUCTOR && TREE_TYPE (init) == 0;
+
+ if (init && raw_constructor
+ && CONSTRUCTOR_ELTS (init) != 0
+ && TREE_CHAIN (CONSTRUCTOR_ELTS (init)) == 0)
+ {
+ element = TREE_VALUE (CONSTRUCTOR_ELTS (init));
+ /* Strip NON_LVALUE_EXPRs since we aren't using as an lvalue. */
+ if (element && TREE_CODE (element) == NON_LVALUE_EXPR)
+ element = TREE_OPERAND (element, 0);
+ if (element == error_mark_node)
+ return element;
+ }
+
+ /* Any type can be initialized from an expression of the same type,
+ optionally with braces. */
+
+ if (init && TREE_TYPE (init)
+ && (TYPE_MAIN_VARIANT (TREE_TYPE (init)) == type
+ || (code == ARRAY_TYPE && comptypes (TREE_TYPE (init), type, 1))))
+ {
+ if (pedantic && code == ARRAY_TYPE
+ && TREE_CODE (init) != STRING_CST)
+ pedwarn ("ANSI C++ forbids initializing array from array expression");
+ if (TREE_CODE (init) == CONST_DECL)
+ init = DECL_INITIAL (init);
+ else if (TREE_READONLY_DECL_P (init))
+ init = decl_constant_value (init);
+ return init;
+ }
+
+ if (element && (TREE_TYPE (element) == type
+ || (code == ARRAY_TYPE && TREE_TYPE (element)
+ && comptypes (TREE_TYPE (element), type, 1))))
+ {
+ if (pedantic && code == ARRAY_TYPE)
+ pedwarn ("ANSI C++ forbids initializing array from array expression");
+ if (pedantic && (code == RECORD_TYPE || code == UNION_TYPE))
+ pedwarn ("ANSI C++ forbids single nonscalar initializer with braces");
+ if (TREE_CODE (element) == CONST_DECL)
+ element = DECL_INITIAL (element);
+ else if (TREE_READONLY_DECL_P (element))
+ element = decl_constant_value (element);
+ return element;
+ }
+
+ /* Initialization of an array of chars from a string constant
+ optionally enclosed in braces. */
+
+ if (code == ARRAY_TYPE)
+ {
+ tree typ1 = TYPE_MAIN_VARIANT (TREE_TYPE (type));
+ if ((typ1 == char_type_node
+ || typ1 == signed_char_type_node
+ || typ1 == unsigned_char_type_node
+ || typ1 == unsigned_wchar_type_node
+ || typ1 == signed_wchar_type_node)
+ && ((init && TREE_CODE (init) == STRING_CST)
+ || (element && TREE_CODE (element) == STRING_CST)))
+ {
+ tree string = element ? element : init;
+
+ if ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (string)))
+ != char_type_node)
+ && TYPE_PRECISION (typ1) == BITS_PER_UNIT)
+ {
+ error ("char-array initialized from wide string");
+ return error_mark_node;
+ }
+ if ((TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (string)))
+ == char_type_node)
+ && TYPE_PRECISION (typ1) != BITS_PER_UNIT)
+ {
+ error ("int-array initialized from non-wide string");
+ return error_mark_node;
+ }
+
+ if (pedantic
+ && typ1 != char_type_node
+ && typ1 != signed_char_type_node
+ && typ1 != unsigned_char_type_node)
+ pedwarn ("ANSI C++ forbids string initializer except for `char' elements");
+ TREE_TYPE (string) = type;
+ if (TYPE_DOMAIN (type) != 0
+ && TREE_CONSTANT (TYPE_SIZE (type)))
+ {
+ register int size
+ = TREE_INT_CST_LOW (TYPE_SIZE (type));
+ size = (size + BITS_PER_UNIT - 1) / BITS_PER_UNIT;
+ /* In C it is ok to subtract 1 from the length of the string
+ because it's ok to ignore the terminating null char that is
+ counted in the length of the constant, but in C++ this would
+ be invalid. */
+ if (size < TREE_STRING_LENGTH (string))
+ pedwarn ("initializer-string for array of chars is too long");
+ }
+ return string;
+ }
+ }
+
+ /* Handle scalar types, including conversions,
+ and signature pointers and references. */
+
+ if (code == INTEGER_TYPE || code == REAL_TYPE || code == POINTER_TYPE
+ || code == ENUMERAL_TYPE || code == REFERENCE_TYPE
+ || code == BOOLEAN_TYPE
+ || (code == RECORD_TYPE && ! raw_constructor
+ && (IS_SIGNATURE_POINTER (type) || IS_SIGNATURE_REFERENCE (type))))
+ {
+ if (raw_constructor)
+ {
+ if (element == 0)
+ {
+ error ("initializer for scalar variable requires one element");
+ return error_mark_node;
+ }
+ init = element;
+ }
+ while (TREE_CODE (init) == CONSTRUCTOR)
+ {
+ cp_pedwarn ("braces around scalar initializer for `%T'", type);
+ init = CONSTRUCTOR_ELTS (init);
+ if (TREE_CHAIN (init))
+ cp_pedwarn ("ignoring extra initializers for `%T'", type);
+ init = TREE_VALUE (init);
+ }
+
+ return convert_for_initialization (0, type, init, LOOKUP_NORMAL,
+ "initialization", NULL_TREE, 0);
+ }
+
+ /* Come here only for records and arrays (and unions with constructors). */
+
+ if (TYPE_SIZE (type) && ! TREE_CONSTANT (TYPE_SIZE (type)))
+ {
+ cp_error ("variable-sized object of type `%T' may not be initialized",
+ type);
+ return error_mark_node;
+ }
+
+ if (code == ARRAY_TYPE || code == RECORD_TYPE || code == UNION_TYPE)
+ {
+ if (raw_constructor && TYPE_NON_AGGREGATE_CLASS (type))
+ {
+ cp_error ("subobject of type `%T' must be initialized by constructor, not by `%E'",
+ type, init);
+ return error_mark_node;
+ }
+ else if (raw_constructor)
+ return process_init_constructor (type, init, (tree *)0);
+ else if (TYPE_NON_AGGREGATE_CLASS (type))
+ {
+ /* This can only be reached when caller is initializing
+ ARRAY_TYPE. In that case, we don't want to convert
+ INIT to TYPE. We will let `expand_vec_init' do it. */
+ return init;
+ }
+ else if (tail != 0)
+ {
+ *tail = old_tail_contents;
+ return process_init_constructor (type, 0, tail);
+ }
+ else if (flag_traditional)
+ /* Traditionally one can say `char x[100] = 0;'. */
+ return process_init_constructor (type,
+ build_nt (CONSTRUCTOR, 0,
+ tree_cons (0, init, 0)),
+ 0);
+ if (code != ARRAY_TYPE)
+ return convert_for_initialization (0, type, init, LOOKUP_NORMAL,
+ "initialization", NULL_TREE, 0);
+ }
+
+ error ("invalid initializer");
+ return error_mark_node;
+}
+
+/* Process a constructor for a variable of type TYPE.
+ The constructor elements may be specified either with INIT or with ELTS,
+ only one of which should be non-null.
+
+ If INIT is specified, it is a CONSTRUCTOR node which is specifically
+ and solely for initializing this datum.
+
+ If ELTS is specified, it is the address of a variable containing
+ a list of expressions. We take as many elements as we need
+ from the head of the list and update the list.
+
+ In the resulting constructor, TREE_CONSTANT is set if all elts are
+ constant, and TREE_STATIC is set if, in addition, all elts are simple enough
+ constants that the assembler and linker can compute them. */
+
+static tree
+process_init_constructor (type, init, elts)
+ tree type, init, *elts;
+{
+ register tree tail;
+ /* List of the elements of the result constructor,
+ in reverse order. */
+ register tree members = NULL;
+ tree result;
+ int allconstant = 1;
+ int allsimple = 1;
+ int erroneous = 0;
+
+ /* Make TAIL be the list of elements to use for the initialization,
+ no matter how the data was given to us. */
+
+ if (elts)
+ {
+ if (warn_missing_braces)
+ warning ("aggregate has a partly bracketed initializer");
+ tail = *elts;
+ }
+ else
+ tail = CONSTRUCTOR_ELTS (init);
+
+ /* Gobble as many elements as needed, and make a constructor or initial value
+ for each element of this aggregate. Chain them together in result.
+ If there are too few, use 0 for each scalar ultimate component. */
+
+ if (TREE_CODE (type) == ARRAY_TYPE)
+ {
+ tree domain = TYPE_DOMAIN (type);
+ register long len;
+ register int i;
+
+ if (domain)
+ len = (TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain))
+ - TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain))
+ + 1);
+ else
+ len = -1; /* Take as many as there are */
+
+ for (i = 0; (len < 0 || i < len) && tail != 0; i++)
+ {
+ register tree next1;
+
+ if (TREE_VALUE (tail) != 0)
+ {
+ tree tail1 = tail;
+ next1 = digest_init (TYPE_MAIN_VARIANT (TREE_TYPE (type)),
+ TREE_VALUE (tail), &tail1);
+ if (TYPE_NEEDS_CONSTRUCTING (TREE_TYPE (type))
+ && TYPE_MAIN_VARIANT (TREE_TYPE (type)) != TYPE_MAIN_VARIANT (TREE_TYPE (next1)))
+ {
+ /* The fact this needs to be done suggests this code needs
+ to be totally rewritten. */
+ next1 = convert_for_initialization (NULL_TREE, TREE_TYPE (type), next1, LOOKUP_NORMAL, "initialization", NULL_TREE, 0);
+ }
+ my_friendly_assert (tail1 == 0
+ || TREE_CODE (tail1) == TREE_LIST, 319);
+ if (tail == tail1 && len < 0)
+ {
+ error ("non-empty initializer for array of empty elements");
+ /* Just ignore what we were supposed to use. */
+ tail1 = NULL_TREE;
+ }
+ tail = tail1;
+ }
+ else
+ {
+ next1 = error_mark_node;
+ tail = TREE_CHAIN (tail);
+ }
+
+ if (next1 == error_mark_node)
+ erroneous = 1;
+ else if (!TREE_CONSTANT (next1))
+ allconstant = 0;
+ else if (! initializer_constant_valid_p (next1, TREE_TYPE (next1)))
+ allsimple = 0;
+ members = tree_cons (NULL_TREE, next1, members);
+ }
+ }
+ if (TREE_CODE (type) == RECORD_TYPE)
+ {
+ register tree field;
+
+ if (tail)
+ {
+ if (TYPE_USES_VIRTUAL_BASECLASSES (type))
+ {
+ sorry ("initializer list for object of class with virtual baseclasses");
+ return error_mark_node;
+ }
+
+ if (TYPE_BINFO_BASETYPES (type))
+ {
+ sorry ("initializer list for object of class with baseclasses");
+ return error_mark_node;
+ }
+
+ if (TYPE_VIRTUAL_P (type))
+ {
+ sorry ("initializer list for object using virtual functions");
+ return error_mark_node;
+ }
+ }
+
+ for (field = TYPE_FIELDS (type); field && tail;
+ field = TREE_CHAIN (field))
+ {
+ register tree next1;
+
+ if (! DECL_NAME (field))
+ {
+ members = tree_cons (field, integer_zero_node, members);
+ continue;
+ }
+
+ if (TREE_CODE (field) != FIELD_DECL)
+ continue;
+
+ if (TREE_VALUE (tail) != 0)
+ {
+ tree tail1 = tail;
+
+ next1 = digest_init (TREE_TYPE (field),
+ TREE_VALUE (tail), &tail1);
+ my_friendly_assert (tail1 == 0
+ || TREE_CODE (tail1) == TREE_LIST, 320);
+ tail = tail1;
+ }
+ else
+ {
+ next1 = error_mark_node;
+ tail = TREE_CHAIN (tail);
+ }
+
+ if (next1 == error_mark_node)
+ erroneous = 1;
+ else if (!TREE_CONSTANT (next1))
+ allconstant = 0;
+ else if (! initializer_constant_valid_p (next1, TREE_TYPE (next1)))
+ allsimple = 0;
+ members = tree_cons (field, next1, members);
+ }
+ for (; field; field = TREE_CHAIN (field))
+ {
+ if (TREE_CODE (field) != FIELD_DECL)
+ continue;
+
+ /* Does this field have a default initialization? */
+ if (DECL_INITIAL (field))
+ {
+ register tree next1 = DECL_INITIAL (field);
+ if (TREE_CODE (next1) == ERROR_MARK)
+ erroneous = 1;
+ else if (!TREE_CONSTANT (next1))
+ allconstant = 0;
+ else if (! initializer_constant_valid_p (next1, TREE_TYPE (next1)))
+ allsimple = 0;
+ members = tree_cons (field, next1, members);
+ }
+ else if (TREE_READONLY (field))
+ error ("uninitialized const member `%s'",
+ IDENTIFIER_POINTER (DECL_NAME (field)));
+ else if (TYPE_LANG_SPECIFIC (TREE_TYPE (field))
+ && CLASSTYPE_READONLY_FIELDS_NEED_INIT (TREE_TYPE (field)))
+ error ("member `%s' with uninitialized const fields",
+ IDENTIFIER_POINTER (DECL_NAME (field)));
+ else if (TREE_CODE (TREE_TYPE (field)) == REFERENCE_TYPE)
+ error ("member `%s' is uninitialized reference",
+ IDENTIFIER_POINTER (DECL_NAME (field)));
+ }
+ }
+
+ if (TREE_CODE (type) == UNION_TYPE)
+ {
+ register tree field = TYPE_FIELDS (type);
+ register tree next1;
+
+ /* Find the first named field. ANSI decided in September 1990
+ that only named fields count here. */
+ while (field && DECL_NAME (field) == 0)
+ field = TREE_CHAIN (field);
+
+ /* If this element specifies a field, initialize via that field. */
+ if (TREE_PURPOSE (tail) != NULL_TREE)
+ {
+ int win = 0;
+
+ if (TREE_CODE (TREE_PURPOSE (tail)) == FIELD_DECL)
+ /* Handle the case of a call by build_c_cast. */
+ field = TREE_PURPOSE (tail), win = 1;
+ else if (TREE_CODE (TREE_PURPOSE (tail)) != IDENTIFIER_NODE)
+ error ("index value instead of field name in union initializer");
+ else
+ {
+ tree temp;
+ for (temp = TYPE_FIELDS (type);
+ temp;
+ temp = TREE_CHAIN (temp))
+ if (DECL_NAME (temp) == TREE_PURPOSE (tail))
+ break;
+ if (temp)
+ field = temp, win = 1;
+ else
+ error ("no field `%s' in union being initialized",
+ IDENTIFIER_POINTER (TREE_PURPOSE (tail)));
+ }
+ if (!win)
+ TREE_VALUE (tail) = error_mark_node;
+ }
+ else if (field == 0)
+ {
+ cp_error ("union `%T' with no named members cannot be initialized",
+ type);
+ TREE_VALUE (tail) = error_mark_node;
+ }
+
+ if (TREE_VALUE (tail) != 0)
+ {
+ tree tail1 = tail;
+
+ next1 = digest_init (TREE_TYPE (field),
+ TREE_VALUE (tail), &tail1);
+ if (tail1 != 0 && TREE_CODE (tail1) != TREE_LIST)
+ my_friendly_abort (357);
+ tail = tail1;
+ }
+ else
+ {
+ next1 = error_mark_node;
+ tail = TREE_CHAIN (tail);
+ }
+
+ if (next1 == error_mark_node)
+ erroneous = 1;
+ else if (!TREE_CONSTANT (next1))
+ allconstant = 0;
+ else if (initializer_constant_valid_p (next1, TREE_TYPE (next1)) == 0)
+ allsimple = 0;
+ members = tree_cons (field, next1, members);
+ }
+
+ /* If arguments were specified as a list, just remove the ones we used. */
+ if (elts)
+ *elts = tail;
+ /* If arguments were specified as a constructor,
+ complain unless we used all the elements of the constructor. */
+ else if (tail)
+ pedwarn ("excess elements in aggregate initializer");
+
+ if (erroneous)
+ return error_mark_node;
+
+ result = build (CONSTRUCTOR, type, NULL_TREE, nreverse (members));
+ if (init)
+ TREE_HAS_CONSTRUCTOR (result) = TREE_HAS_CONSTRUCTOR (init);
+ if (allconstant) TREE_CONSTANT (result) = 1;
+ if (allconstant && allsimple) TREE_STATIC (result) = 1;
+ return result;
+}
+
+/* Given a structure or union value DATUM, construct and return
+ the structure or union component which results from narrowing
+ that value by the types specified in TYPES. For example, given the
+ hierarchy
+
+ class L { int ii; };
+ class A : L { ... };
+ class B : L { ... };
+ class C : A, B { ... };
+
+ and the declaration
+
+ C x;
+
+ then the expression
+
+ x::C::A::L::ii refers to the ii member of the L part of
+ of A part of the C object named by X. In this case,
+ DATUM would be x, and TYPES would be a SCOPE_REF consisting of
+
+ SCOPE_REF
+ SCOPE_REF
+ C A
+ L
+
+ The last entry in the SCOPE_REF is always an IDENTIFIER_NODE.
+
+*/
+
+tree
+build_scoped_ref (datum, types)
+ tree datum;
+ tree types;
+{
+ tree ref;
+ tree type = TREE_TYPE (datum);
+
+ if (datum == error_mark_node)
+ return error_mark_node;
+
+ if (TREE_CODE (type) == REFERENCE_TYPE)
+ type = TREE_TYPE (type);
+
+ type = TYPE_MAIN_VARIANT (type);
+
+ if (TREE_CODE (types) == SCOPE_REF)
+ {
+ /* We have some work to do. */
+ struct type_chain
+ { tree type; struct type_chain *next; }
+ *chain = NULL, *head = NULL, scratch;
+ ref = build_unary_op (ADDR_EXPR, datum, 0);
+ while (TREE_CODE (types) == SCOPE_REF)
+ {
+ tree t = TREE_OPERAND (types, 1);
+ if (is_aggr_typedef (t, 1))
+ {
+ head = (struct type_chain *)alloca (sizeof (struct type_chain));
+ head->type = IDENTIFIER_TYPE_VALUE (t);
+ head->next = chain;
+ chain = head;
+ types = TREE_OPERAND (types, 0);
+ }
+ else return error_mark_node;
+ }
+ if (! is_aggr_typedef (types, 1))
+ return error_mark_node;
+
+ head = &scratch;
+ head->type = IDENTIFIER_TYPE_VALUE (types);
+ head->next = chain;
+ chain = head;
+ while (chain)
+ {
+ tree binfo = chain->type;
+ type = TREE_TYPE (TREE_TYPE (ref));
+ if (binfo != TYPE_BINFO (type))
+ {
+ binfo = get_binfo (binfo, type, 1);
+ if (binfo == error_mark_node)
+ return error_mark_node;
+ if (binfo == 0)
+ return error_not_base_type (chain->type, type);
+ ref = convert_pointer_to (binfo, ref);
+ }
+ chain = chain->next;
+ }
+ return build_indirect_ref (ref, "(compiler error in build_scoped_ref)");
+ }
+
+ /* This is an easy conversion. */
+ if (is_aggr_typedef (types, 1))
+ {
+ tree binfo = TYPE_BINFO (IDENTIFIER_TYPE_VALUE (types));
+ if (binfo != TYPE_BINFO (type))
+ {
+ binfo = get_binfo (binfo, type, 1);
+ if (binfo == error_mark_node)
+ return error_mark_node;
+ if (binfo == 0)
+ return error_not_base_type (IDENTIFIER_TYPE_VALUE (types), type);
+ }
+
+ switch (TREE_CODE (datum))
+ {
+ case NOP_EXPR:
+ case CONVERT_EXPR:
+ case FLOAT_EXPR:
+ case FIX_TRUNC_EXPR:
+ case FIX_FLOOR_EXPR:
+ case FIX_ROUND_EXPR:
+ case FIX_CEIL_EXPR:
+ ref = convert_pointer_to (binfo,
+ build_unary_op (ADDR_EXPR, TREE_OPERAND (datum, 0), 0));
+ break;
+ default:
+ ref = convert_pointer_to (binfo,
+ build_unary_op (ADDR_EXPR, datum, 0));
+ }
+ return build_indirect_ref (ref, "(compiler error in build_scoped_ref)");
+ }
+ return error_mark_node;
+}
+
+/* Build a reference to an object specified by the C++ `->' operator.
+ Usually this just involves dereferencing the object, but if the
+ `->' operator is overloaded, then such overloads must be
+ performed until an object which does not have the `->' operator
+ overloaded is found. An error is reported when circular pointer
+ delegation is detected. */
+tree
+build_x_arrow (datum)
+ tree datum;
+{
+ tree types_memoized = NULL_TREE;
+ register tree rval = datum;
+ tree type = TREE_TYPE (rval);
+ tree last_rval;
+
+ if (type == error_mark_node)
+ return error_mark_node;
+
+ if (TREE_CODE (rval) == OFFSET_REF)
+ {
+ rval = resolve_offset_ref (datum);
+ type = TREE_TYPE (rval);
+ }
+
+ if (TREE_CODE (type) == REFERENCE_TYPE)
+ {
+ rval = convert_from_reference (rval);
+ type = TREE_TYPE (rval);
+ }
+
+ if (IS_AGGR_TYPE (type) && TYPE_OVERLOADS_ARROW (type))
+ {
+ while ((rval = build_opfncall (COMPONENT_REF, LOOKUP_NORMAL, rval, NULL_TREE, NULL_TREE)))
+ {
+ if (rval == error_mark_node)
+ return error_mark_node;
+
+ if (value_member (TREE_TYPE (rval), types_memoized))
+ {
+ error ("circular pointer delegation detected");
+ return error_mark_node;
+ }
+ else
+ {
+ types_memoized = tree_cons (NULL_TREE, TREE_TYPE (rval),
+ types_memoized);
+ }
+ last_rval = rval;
+ }
+ if (TREE_CODE (TREE_TYPE (last_rval)) == REFERENCE_TYPE)
+ last_rval = convert_from_reference (last_rval);
+ }
+ else
+ last_rval = default_conversion (rval);
+
+ /* Signature pointers are not dereferenced. */
+ if (TYPE_LANG_SPECIFIC (TREE_TYPE (last_rval))
+ && IS_SIGNATURE_POINTER (TREE_TYPE (last_rval)))
+ return last_rval;
+
+ if (TREE_CODE (TREE_TYPE (last_rval)) == POINTER_TYPE)
+ return build_indirect_ref (last_rval, NULL_PTR);
+
+ if (types_memoized)
+ error ("result of `operator->()' yields non-pointer result");
+ else
+ error ("base operand of `->' is not a pointer");
+ return error_mark_node;
+}
+
+/* Make an expression to refer to the COMPONENT field of
+ structure or union value DATUM. COMPONENT is an arbitrary
+ expression. DATUM has not already been checked out to be of
+ aggregate type.
+
+ For C++, COMPONENT may be a TREE_LIST. This happens when we must
+ return an object of member type to a method of the current class,
+ but there is not yet enough typing information to know which one.
+ As a special case, if there is only one method by that name,
+ it is returned. Otherwise we return an expression which other
+ routines will have to know how to deal with later. */
+tree
+build_m_component_ref (datum, component)
+ tree datum, component;
+{
+ tree type;
+ tree objtype = TREE_TYPE (datum);
+ tree rettype;
+ tree binfo;
+
+ if (TYPE_PTRMEMFUNC_P (TREE_TYPE (component)))
+ {
+ type = TREE_TYPE (TYPE_PTRMEMFUNC_FN_TYPE (TREE_TYPE (component)));
+ rettype = type;
+ }
+ else
+ {
+ component = build_indirect_ref (component, NULL_PTR);
+ type = TREE_TYPE (component);
+ rettype = TREE_TYPE (TREE_TYPE (component));
+ }
+
+ if (datum == error_mark_node || component == error_mark_node)
+ return error_mark_node;
+
+ if (TREE_CODE (type) != OFFSET_TYPE && TREE_CODE (type) != METHOD_TYPE)
+ {
+ cp_error ("`%E' cannot be used as a member pointer, since it is of type `%T'", component, type);
+ return error_mark_node;
+ }
+
+ if (TREE_CODE (objtype) == REFERENCE_TYPE)
+ objtype = TREE_TYPE (objtype);
+ objtype = TYPE_MAIN_VARIANT (objtype);
+
+ if (! IS_AGGR_TYPE (objtype))
+ {
+ cp_error ("cannot apply member pointer `%E' to `%E'", component, datum);
+ cp_error ("which is of non-aggregate type `%T'", objtype);
+ return error_mark_node;
+ }
+
+ binfo = get_binfo (TYPE_METHOD_BASETYPE (type), objtype, 1);
+ if (binfo == NULL_TREE)
+ {
+ cp_error ("member type `%T::' incompatible with object type `%T'",
+ TYPE_METHOD_BASETYPE (type), objtype);
+ return error_mark_node;
+ }
+ else if (binfo == error_mark_node)
+ return error_mark_node;
+
+ return build (OFFSET_REF, rettype, datum, component);
+}
+
+/* Return a tree node for the expression TYPENAME '(' PARMS ')'.
+
+ Because we cannot tell whether this construct is really a call to a
+ constructor or a request for a type conversion, we try both, and
+ report any ambiguities we find. */
+tree
+build_functional_cast (exp, parms)
+ tree exp;
+ tree parms;
+{
+ /* This is either a call to a constructor,
+ or a C cast in C++'s `functional' notation. */
+ tree type, name = NULL_TREE;
+ tree expr_as_ctor = NULL_TREE;
+
+ if (exp == error_mark_node || parms == error_mark_node)
+ return error_mark_node;
+
+ if (TREE_CODE (exp) == IDENTIFIER_NODE)
+ {
+ name = exp;
+
+ if (IDENTIFIER_HAS_TYPE_VALUE (exp))
+ /* Either an enum or an aggregate type. */
+ type = IDENTIFIER_TYPE_VALUE (exp);
+ else
+ {
+ type = lookup_name (exp, 1);
+ if (!type || TREE_CODE (type) != TYPE_DECL)
+ {
+ cp_error ("`%T' fails to be a typedef or built-in type", name);
+ return error_mark_node;
+ }
+ type = TREE_TYPE (type);
+ }
+ }
+ else
+ type = exp;
+
+ if (IS_SIGNATURE (type))
+ {
+ error ("signature type not allowed in cast or constructor expression");
+ return error_mark_node;
+ }
+
+ /* Prepare to evaluate as a call to a constructor. If this expression
+ is actually used, for example,
+
+ return X (arg1, arg2, ...);
+
+ then the slot being initialized will be filled in. */
+
+ if (name == NULL_TREE)
+ {
+ name = TYPE_NAME (type);
+ if (TREE_CODE (name) == TYPE_DECL)
+ name = DECL_NESTED_TYPENAME (name);
+ }
+
+ if (! IS_AGGR_TYPE (type))
+ {
+ /* this must build a C cast */
+ if (parms == NULL_TREE)
+ parms = integer_zero_node;
+ else
+ {
+ if (TREE_CHAIN (parms) != NULL_TREE)
+ pedwarn ("initializer list being treated as compound expression");
+ parms = build_compound_expr (parms);
+ }
+
+ return build_c_cast (type, parms, 1);
+ }
+
+ if (TYPE_SIZE (type) == NULL_TREE)
+ {
+ cp_error ("type `%T' is not yet defined", type);
+ return error_mark_node;
+ }
+
+ if (parms && TREE_CHAIN (parms) == NULL_TREE)
+ return build_c_cast (type, parms, 1);
+
+ expr_as_ctor = build_method_call (NULL_TREE, name, parms,
+ NULL_TREE, LOOKUP_NORMAL);
+
+ if (expr_as_ctor == error_mark_node)
+ return error_mark_node;
+
+ return build_cplus_new (type, expr_as_ctor, 1);
+}
+
+/* Return the character string for the name that encodes the
+ enumeral value VALUE in the domain TYPE. */
+char *
+enum_name_string (value, type)
+ tree value;
+ tree type;
+{
+ register tree values = TYPE_VALUES (type);
+ register HOST_WIDE_INT intval = TREE_INT_CST_LOW (value);
+
+ my_friendly_assert (TREE_CODE (type) == ENUMERAL_TYPE, 324);
+ while (values
+ && TREE_INT_CST_LOW (TREE_VALUE (values)) != intval)
+ values = TREE_CHAIN (values);
+ if (values == NULL_TREE)
+ {
+ char *buf = (char *)oballoc (16 + TYPE_NAME_LENGTH (type));
+
+ /* Value must have been cast. */
+ sprintf (buf, "(enum %s)%d",
+ TYPE_NAME_STRING (type), intval);
+ return buf;
+ }
+ return IDENTIFIER_POINTER (TREE_PURPOSE (values));
+}
+
+#if 0
+/* Print out a language-specific error message for
+ (Pascal) case or (C) switch statements.
+ CODE tells what sort of message to print.
+ TYPE is the type of the switch index expression.
+ NEW is the new value that we were trying to add.
+ OLD is the old value that stopped us from adding it. */
+void
+report_case_error (code, type, new_value, old_value)
+ int code;
+ tree type;
+ tree new_value, old_value;
+{
+ if (code == 1)
+ {
+ if (new_value)
+ error ("case label not within a switch statement");
+ else
+ error ("default label not within a switch statement");
+ }
+ else if (code == 2)
+ {
+ if (new_value == 0)
+ {
+ error ("multiple default labels in one switch");
+ return;
+ }
+ if (TREE_CODE (new_value) == RANGE_EXPR)
+ if (TREE_CODE (old_value) == RANGE_EXPR)
+ {
+ char *buf = (char *)alloca (4 * (8 + TYPE_NAME_LENGTH (type)));
+ if (TREE_CODE (type) == ENUMERAL_TYPE)
+ sprintf (buf, "overlapping ranges [%s..%s], [%s..%s] in case expression",
+ enum_name_string (TREE_OPERAND (new_value, 0), type),
+ enum_name_string (TREE_OPERAND (new_value, 1), type),
+ enum_name_string (TREE_OPERAND (old_value, 0), type),
+ enum_name_string (TREE_OPERAND (old_value, 1), type));
+ else
+ sprintf (buf, "overlapping ranges [%d..%d], [%d..%d] in case expression",
+ TREE_INT_CST_LOW (TREE_OPERAND (new_value, 0)),
+ TREE_INT_CST_LOW (TREE_OPERAND (new_value, 1)),
+ TREE_INT_CST_LOW (TREE_OPERAND (old_value, 0)),
+ TREE_INT_CST_LOW (TREE_OPERAND (old_value, 1)));
+ error (buf);
+ }
+ else
+ {
+ char *buf = (char *)alloca (4 * (8 + TYPE_NAME_LENGTH (type)));
+ if (TREE_CODE (type) == ENUMERAL_TYPE)
+ sprintf (buf, "range [%s..%s] includes element `%s' in case expression",
+ enum_name_string (TREE_OPERAND (new_value, 0), type),
+ enum_name_string (TREE_OPERAND (new_value, 1), type),
+ enum_name_string (old_value, type));
+ else
+ sprintf (buf, "range [%d..%d] includes (%d) in case expression",
+ TREE_INT_CST_LOW (TREE_OPERAND (new_value, 0)),
+ TREE_INT_CST_LOW (TREE_OPERAND (new_value, 1)),
+ TREE_INT_CST_LOW (old_value));
+ error (buf);
+ }
+ else if (TREE_CODE (old_value) == RANGE_EXPR)
+ {
+ char *buf = (char *)alloca (4 * (8 + TYPE_NAME_LENGTH (type)));
+ if (TREE_CODE (type) == ENUMERAL_TYPE)
+ sprintf (buf, "range [%s..%s] includes element `%s' in case expression",
+ enum_name_string (TREE_OPERAND (old_value, 0), type),
+ enum_name_string (TREE_OPERAND (old_value, 1), type),
+ enum_name_string (new_value, type));
+ else
+ sprintf (buf, "range [%d..%d] includes (%d) in case expression",
+ TREE_INT_CST_LOW (TREE_OPERAND (old_value, 0)),
+ TREE_INT_CST_LOW (TREE_OPERAND (old_value, 1)),
+ TREE_INT_CST_LOW (new_value));
+ error (buf);
+ }
+ else
+ {
+ if (TREE_CODE (type) == ENUMERAL_TYPE)
+ error ("duplicate label `%s' in switch statement",
+ enum_name_string (new_value, type));
+ else
+ error ("duplicate label (%d) in switch statement",
+ TREE_INT_CST_LOW (new_value));
+ }
+ }
+ else if (code == 3)
+ {
+ if (TREE_CODE (type) == ENUMERAL_TYPE)
+ warning ("case value out of range for enum %s",
+ TYPE_NAME_STRING (type));
+ else
+ warning ("case value out of range");
+ }
+ else if (code == 4)
+ {
+ if (TREE_CODE (type) == ENUMERAL_TYPE)
+ error ("range values `%s' and `%s' reversed",
+ enum_name_string (new_value, type),
+ enum_name_string (old_value, type));
+ else
+ error ("range values reversed");
+ }
+}
+#endif
diff --git a/contrib/gcc/cp/xref.c b/contrib/gcc/cp/xref.c
new file mode 100644
index 0000000..ec4b174
--- /dev/null
+++ b/contrib/gcc/cp/xref.c
@@ -0,0 +1,840 @@
+/* Code for handling XREF output from GNU C++.
+ Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+ Contributed by Michael Tiemann (tiemann@cygnus.com)
+
+This file is part of GNU CC.
+
+GNU CC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GNU CC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GNU CC; see the file COPYING. If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA. */
+
+
+#include "config.h"
+#include "tree.h"
+#include <stdio.h>
+#include "cp-tree.h"
+#include "input.h"
+
+#include <ctype.h>
+
+extern char *getpwd ();
+
+extern char *index ();
+extern char *rindex ();
+
+/* The character(s) used to join a directory specification (obtained with
+ getwd or equivalent) with a non-absolute file name. */
+
+#ifndef FILE_NAME_JOINER
+#define FILE_NAME_JOINER "/"
+#endif
+
+/* Nonzero if NAME as a file name is absolute. */
+#ifndef FILE_NAME_ABSOLUTE_P
+#define FILE_NAME_ABSOLUTE_P(NAME) (NAME[0] == '/')
+#endif
+
+/* For cross referencing. */
+
+int flag_gnu_xref;
+
+/************************************************************************/
+/* */
+/* Common definitions */
+/* */
+/************************************************************************/
+
+#ifndef TRUE
+#define TRUE 1
+#endif
+#ifndef FALSE
+#define FALSE 0
+#endif
+#ifndef NULL
+#define NULL 0
+#endif
+
+#define PALLOC(typ) ((typ *) calloc(1,sizeof(typ)))
+
+
+/* Return a malloc'd copy of STR. */
+#define SALLOC(str) \
+ ((char *) ((str) == NULL ? NULL \
+ : (char *) strcpy ((char *) malloc (strlen ((str)) + 1), (str))))
+#define SFREE(str) (str != NULL && (free(str),0))
+
+#define STREQL(s1,s2) (strcmp((s1),(s2)) == 0)
+#define STRNEQ(s1,s2) (strcmp((s1),(s2)) != 0)
+#define STRLSS(s1,s2) (strcmp((s1),(s2)) < 0)
+#define STRLEQ(s1,s2) (strcmp((s1),(s2)) <= 0)
+#define STRGTR(s1,s2) (strcmp((s1),(s2)) > 0)
+#define STRGEQ(s1,s2) (strcmp((s1),(s2)) >= 0)
+
+/************************************************************************/
+/* */
+/* Type definitions */
+/* */
+/************************************************************************/
+
+
+typedef struct _XREF_FILE * XREF_FILE;
+typedef struct _XREF_SCOPE * XREF_SCOPE;
+
+typedef struct _XREF_FILE
+{
+ char *name;
+ char *outname;
+ XREF_FILE next;
+} XREF_FILE_INFO;
+
+typedef struct _XREF_SCOPE
+{
+ int gid;
+ int lid;
+ XREF_FILE file;
+ int start;
+ XREF_SCOPE outer;
+} XREF_SCOPE_INFO;
+
+/************************************************************************/
+/* */
+/* Local storage */
+/* */
+/************************************************************************/
+
+static char doing_xref = 0;
+static FILE * xref_file = NULL;
+static char xref_name[1024];
+static XREF_FILE all_files = NULL;
+static char * wd_name = NULL;
+static XREF_SCOPE cur_scope = NULL;
+static int scope_ctr = 0;
+static XREF_FILE last_file = NULL;
+static tree last_fndecl = NULL;
+
+/************************************************************************/
+/* */
+/* Forward definitions */
+/* */
+/************************************************************************/
+
+extern void GNU_xref_begin();
+extern void GNU_xref_end();
+extern void GNU_xref_file();
+extern void GNU_xref_start_scope();
+extern void GNU_xref_end_scope();
+extern void GNU_xref_ref();
+extern void GNU_xref_decl();
+extern void GNU_xref_call();
+extern void GNU_xref_function();
+extern void GNU_xref_assign();
+extern void GNU_xref_hier();
+extern void GNU_xref_member();
+
+static void gen_assign();
+static XREF_FILE find_file();
+static char * filename();
+static char * fctname();
+static char * declname();
+static void simplify_type();
+static char * fixname();
+static void open_xref_file();
+
+extern char * type_as_string();
+
+/* Start cross referencing. FILE is the name of the file we xref. */
+
+void
+GNU_xref_begin (file)
+ char *file;
+{
+ doing_xref = 1;
+
+ if (file != NULL && STRNEQ (file,"-"))
+ {
+ open_xref_file(file);
+ GNU_xref_file(file);
+ }
+}
+
+/* Finish cross-referencing. ERRCNT is the number of errors
+ we encountered. */
+
+void
+GNU_xref_end (ect)
+ int ect;
+{
+ XREF_FILE xf;
+
+ if (!doing_xref) return;
+
+ xf = find_file (input_filename);
+ if (xf == NULL) return;
+
+ while (cur_scope != NULL)
+ GNU_xref_end_scope(cur_scope->gid,0,0,0,0);
+
+ doing_xref = 0;
+
+ if (xref_file == NULL) return;
+
+ fclose (xref_file);
+
+ xref_file = NULL;
+ all_files = NULL;
+
+ if (ect > 0) unlink (xref_name);
+}
+
+/* Write out xref for file named NAME. */
+
+void
+GNU_xref_file (name)
+ char *name;
+{
+ XREF_FILE xf;
+
+ if (!doing_xref || name == NULL) return;
+
+ if (xref_file == NULL)
+ {
+ open_xref_file (name);
+ if (!doing_xref) return;
+ }
+
+ if (all_files == NULL)
+ fprintf(xref_file,"SCP * 0 0 0 0 RESET\n");
+
+ xf = find_file (name);
+ if (xf != NULL) return;
+
+ xf = PALLOC (XREF_FILE_INFO);
+ xf->name = SALLOC (name);
+ xf->next = all_files;
+ all_files = xf;
+
+ if (wd_name == NULL)
+ wd_name = getpwd ();
+
+ if (FILE_NAME_ABSOLUTE_P (name) || ! wd_name)
+ xf->outname = xf->name;
+ else
+ {
+ char *nmbuf
+ = (char *) malloc (strlen (wd_name) + strlen (FILE_NAME_JOINER)
+ + strlen (name) + 1);
+ sprintf (nmbuf, "%s%s%s", wd_name, FILE_NAME_JOINER, name);
+ name = nmbuf;
+ xf->outname = nmbuf;
+ }
+
+ fprintf (xref_file, "FIL %s %s 0\n", name, wd_name);
+
+ filename (xf);
+ fctname (NULL);
+}
+
+/* Start a scope identified at level ID. */
+
+void
+GNU_xref_start_scope (id)
+ HOST_WIDE_INT id;
+{
+ XREF_SCOPE xs;
+ XREF_FILE xf;
+
+ if (!doing_xref) return;
+ xf = find_file (input_filename);
+
+ xs = PALLOC (XREF_SCOPE_INFO);
+ xs->file = xf;
+ xs->start = lineno;
+ if (xs->start <= 0) xs->start = 1;
+ xs->gid = id;
+ xs->lid = ++scope_ctr;
+ xs->outer = cur_scope;
+ cur_scope = xs;
+}
+
+/* Finish a scope at level ID.
+ INID is ???
+ PRM is ???
+ KEEP is nonzero iff this scope is retained (nonzero if it's
+ a compiler-generated invisible scope).
+ TRNS is ??? */
+
+void
+GNU_xref_end_scope (id,inid,prm,keep,trns)
+ HOST_WIDE_INT id;
+ HOST_WIDE_INT inid;
+ int prm,keep,trns;
+{
+ XREF_FILE xf;
+ XREF_SCOPE xs,lxs,oxs;
+ char *stype;
+
+ if (!doing_xref) return;
+ xf = find_file (input_filename);
+ if (xf == NULL) return;
+
+ lxs = NULL;
+ for (xs = cur_scope; xs != NULL; xs = xs->outer)
+ {
+ if (xs->gid == id) break;
+ lxs = xs;
+ }
+ if (xs == NULL) return;
+
+ if (inid != 0) {
+ for (oxs = cur_scope; oxs != NULL; oxs = oxs->outer) {
+ if (oxs->gid == inid) break;
+ }
+ if (oxs == NULL) return;
+ inid = oxs->lid;
+ }
+
+ if (prm == 2) stype = "SUE";
+ else if (prm != 0) stype = "ARGS";
+ else if (keep == 2 || inid != 0) stype = "INTERN";
+ else stype = "EXTERN";
+
+ fprintf (xref_file,"SCP %s %d %d %d %d %s\n",
+ filename (xf), xs->start, lineno,xs->lid, inid, stype);
+
+ if (lxs == NULL) cur_scope = xs->outer;
+ else lxs->outer = xs->outer;
+
+ free (xs);
+}
+
+/* Output a reference to NAME in FNDECL. */
+
+void
+GNU_xref_ref (fndecl,name)
+ tree fndecl;
+ char *name;
+{
+ XREF_FILE xf;
+
+ if (!doing_xref) return;
+ xf = find_file (input_filename);
+ if (xf == NULL) return;
+
+ fprintf (xref_file, "REF %s %d %s %s\n",
+ filename (xf), lineno, fctname (fndecl), name);
+}
+
+/* Output a reference to DECL in FNDECL. */
+
+void
+GNU_xref_decl (fndecl,decl)
+ tree fndecl;
+ tree decl;
+{
+ XREF_FILE xf,xf1;
+ char *cls;
+ char *name;
+ char buf[10240];
+ int uselin;
+
+ if (!doing_xref) return;
+ xf = find_file (input_filename);
+ if (xf == NULL) return;
+
+ uselin = FALSE;
+
+ if (TREE_CODE (decl) == TYPE_DECL) cls = "TYPEDEF";
+ else if (TREE_CODE (decl) == FIELD_DECL) cls = "FIELD";
+ else if (TREE_CODE (decl) == VAR_DECL)
+ {
+ if (fndecl == NULL && TREE_STATIC(decl)
+ && TREE_READONLY(decl) && DECL_INITIAL(decl) != 0
+ && !TREE_PUBLIC(decl) && !DECL_EXTERNAL(decl)
+ && DECL_MODE(decl) != BLKmode) cls = "CONST";
+ else if (DECL_EXTERNAL(decl)) cls = "EXTERN";
+ else if (TREE_PUBLIC(decl)) cls = "EXTDEF";
+ else if (TREE_STATIC(decl)) cls = "STATIC";
+ else if (DECL_REGISTER(decl)) cls = "REGISTER";
+ else cls = "AUTO";
+ }
+ else if (TREE_CODE (decl) == PARM_DECL) cls = "PARAM";
+ else if (TREE_CODE (decl) == FIELD_DECL) cls = "FIELD";
+ else if (TREE_CODE (decl) == CONST_DECL) cls = "CONST";
+ else if (TREE_CODE (decl) == FUNCTION_DECL)
+ {
+ if (DECL_EXTERNAL (decl)) cls = "EXTERN";
+ else if (TREE_PUBLIC (decl)) cls = "EFUNCTION";
+ else cls = "SFUNCTION";
+ }
+ else if (TREE_CODE (decl) == LABEL_DECL) cls = "LABEL";
+ else if (TREE_CODE (decl) == UNION_TYPE)
+ {
+ cls = "UNIONID";
+ decl = TYPE_NAME (decl);
+ uselin = TRUE;
+ }
+ else if (TREE_CODE (decl) == RECORD_TYPE)
+ {
+ if (CLASSTYPE_DECLARED_CLASS (decl)) cls = "CLASSID";
+ else if (IS_SIGNATURE (decl)) cls = "SIGNATUREID";
+ else cls = "STRUCTID";
+ decl = TYPE_NAME (decl);
+ uselin = TRUE;
+ }
+ else if (TREE_CODE (decl) == ENUMERAL_TYPE)
+ {
+ cls = "ENUMID";
+ decl = TYPE_NAME (decl);
+ uselin = TRUE;
+ }
+ else if (TREE_CODE (decl) == TEMPLATE_DECL)
+ {
+ if (DECL_TEMPLATE_IS_CLASS (decl))
+ cls = "CLASSTEMP";
+ else if (TREE_CODE (DECL_RESULT (decl)) == FUNCTION_DECL)
+ cls = "FUNCTEMP";
+ else if (TREE_CODE (DECL_RESULT (decl)) == VAR_DECL)
+ cls = "VARTEMP";
+ else
+ my_friendly_abort (358);
+ uselin = TRUE;
+ }
+ else cls = "UNKNOWN";
+
+ if (decl == NULL || DECL_NAME (decl) == NULL) return;
+
+ if (uselin && decl->decl.linenum > 0 && decl->decl.filename != NULL)
+ {
+ xf1 = find_file (decl->decl.filename);
+ if (xf1 != NULL)
+ {
+ lineno = decl->decl.linenum;
+ xf = xf1;
+ }
+ }
+
+ if (DECL_ASSEMBLER_NAME (decl))
+ name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
+ else
+ name = IDENTIFIER_POINTER (DECL_NAME (decl));
+
+ strcpy (buf, type_as_string (TREE_TYPE (decl), 0));
+ simplify_type (buf);
+
+ fprintf (xref_file, "DCL %s %d %s %d %s %s %s\n",
+ filename(xf), lineno, name,
+ (cur_scope != NULL ? cur_scope->lid : 0),
+ cls, fctname(fndecl), buf);
+
+ if (STREQL (cls, "STRUCTID") || STREQL (cls, "UNIONID")
+ || STREQL (cls, "SIGNATUREID"))
+ {
+ cls = "CLASSID";
+ fprintf (xref_file, "DCL %s %d %s %d %s %s %s\n",
+ filename(xf), lineno,name,
+ (cur_scope != NULL ? cur_scope->lid : 0),
+ cls, fctname(fndecl), buf);
+ }
+}
+
+/* Output a reference to a call to NAME in FNDECL. */
+
+void
+GNU_xref_call (fndecl, name)
+ tree fndecl;
+ char *name;
+{
+ XREF_FILE xf;
+ char buf[1024];
+ char *s;
+
+ if (!doing_xref) return;
+ xf = find_file (input_filename);
+ if (xf == NULL) return;
+ name = fixname (name, buf);
+
+ for (s = name; *s != 0; ++s)
+ if (*s == '_' && s[1] == '_') break;
+ if (*s != 0) GNU_xref_ref (fndecl, name);
+
+ fprintf (xref_file, "CAL %s %d %s %s\n",
+ filename (xf), lineno, name, fctname (fndecl));
+}
+
+/* Output cross-reference info about FNDECL. If non-NULL,
+ ARGS are the arguments for the function (i.e., before the FUNCTION_DECL
+ has been fully built). */
+
+void
+GNU_xref_function (fndecl, args)
+ tree fndecl;
+ tree args;
+{
+ XREF_FILE xf;
+ int ct;
+ char buf[1024];
+
+ if (!doing_xref) return;
+ xf = find_file (input_filename);
+ if (xf == NULL) return;
+
+ ct = 0;
+ buf[0] = 0;
+ if (args == NULL) args = DECL_ARGUMENTS (fndecl);
+
+ GNU_xref_decl (NULL, fndecl);
+
+ for ( ; args != NULL; args = TREE_CHAIN (args))
+ {
+ GNU_xref_decl (fndecl,args);
+ if (ct != 0) strcat (buf,",");
+ strcat (buf, declname (args));
+ ++ct;
+ }
+
+ fprintf (xref_file, "PRC %s %d %s %d %d %s\n",
+ filename(xf), lineno, declname(fndecl),
+ (cur_scope != NULL ? cur_scope->lid : 0),
+ ct, buf);
+}
+
+/* Output cross-reference info about an assignment to NAME. */
+
+void
+GNU_xref_assign(name)
+ tree name;
+{
+ XREF_FILE xf;
+
+ if (!doing_xref) return;
+ xf = find_file(input_filename);
+ if (xf == NULL) return;
+
+ gen_assign(xf, name);
+}
+
+static void
+gen_assign(xf, name)
+ XREF_FILE xf;
+ tree name;
+{
+ char *s;
+
+ s = NULL;
+
+ switch (TREE_CODE (name))
+ {
+ case IDENTIFIER_NODE :
+ s = IDENTIFIER_POINTER(name);
+ break;
+ case VAR_DECL :
+ s = declname(name);
+ break;
+ case COMPONENT_REF :
+ gen_assign(xf, TREE_OPERAND(name, 0));
+ gen_assign(xf, TREE_OPERAND(name, 1));
+ break;
+ case INDIRECT_REF :
+ case OFFSET_REF :
+ case ARRAY_REF :
+ case BUFFER_REF :
+ gen_assign(xf, TREE_OPERAND(name, 0));
+ break;
+ case COMPOUND_EXPR :
+ gen_assign(xf, TREE_OPERAND(name, 1));
+ break;
+ default :
+ break;
+ }
+
+ if (s != NULL)
+ fprintf(xref_file, "ASG %s %d %s\n", filename(xf), lineno, s);
+}
+
+/* Output cross-reference info about a class hierarchy.
+ CLS is the class type of interest. BASE is a baseclass
+ for CLS. PUB and VIRT give the access info about
+ the class derivation. FRND is nonzero iff BASE is a friend
+ of CLS.
+
+ ??? Needs to handle nested classes. */
+void
+GNU_xref_hier(cls, base, pub, virt, frnd)
+ char *cls;
+ char *base;
+ int pub;
+ int virt;
+ int frnd;
+{
+ XREF_FILE xf;
+
+ if (!doing_xref) return;
+ xf = find_file(input_filename);
+ if (xf == NULL) return;
+
+ fprintf(xref_file, "HIE %s %d %s %s %d %d %d\n",
+ filename(xf), lineno, cls, base, pub, virt, frnd);
+}
+
+/* Output cross-reference info about class members. CLS
+ is the containing type; FLD is the class member. */
+
+void
+GNU_xref_member(cls, fld)
+ tree cls;
+ tree fld;
+{
+ XREF_FILE xf;
+ char *prot;
+ int confg, pure;
+ char *d;
+ int i;
+ char buf[1024], bufa[1024];
+
+ if (!doing_xref) return;
+ xf = find_file(fld->decl.filename);
+ if (xf == NULL) return;
+
+ if (TREE_PRIVATE (fld)) prot = "PRIVATE";
+ else if (TREE_PROTECTED(fld)) prot = "PROTECTED";
+ else prot = "PUBLIC";
+
+ confg = 0;
+ if (TREE_CODE (fld) == FUNCTION_DECL && DECL_CONST_MEMFUNC_P(fld))
+ confg = 1;
+ else if (TREE_CODE (fld) == CONST_DECL)
+ confg = 1;
+
+ pure = 0;
+ if (TREE_CODE (fld) == FUNCTION_DECL && DECL_ABSTRACT_VIRTUAL_P(fld))
+ pure = 1;
+
+ d = IDENTIFIER_POINTER(cls);
+ sprintf(buf, "%d%s", strlen(d), d);
+ i = strlen(buf);
+ strcpy(bufa, declname(fld));
+
+#ifdef XREF_SHORT_MEMBER_NAMES
+ for (p = &bufa[1]; *p != 0; ++p)
+ {
+ if (p[0] == '_' && p[1] == '_' && p[2] >= '0' && p[2] <= '9') {
+ if (strncmp(&p[2], buf, i) == 0) *p = 0;
+ break;
+ }
+ else if (p[0] == '_' && p[1] == '_' && p[2] == 'C' && p[3] >= '0' && p[3] <= '9') {
+ if (strncmp(&p[3], buf, i) == 0) *p = 0;
+ break;
+ }
+ }
+#endif
+
+ fprintf(xref_file, "MEM %s %d %s %s %s %d %d %d %d %d %d %d\n",
+ filename(xf), fld->decl.linenum, d, bufa, prot,
+ (TREE_CODE (fld) == FUNCTION_DECL ? 0 : 1),
+ (DECL_INLINE (fld) ? 1 : 0),
+ (DECL_FRIEND_P(fld) ? 1 : 0),
+ (DECL_VINDEX(fld) ? 1 : 0),
+ (TREE_STATIC(fld) ? 1 : 0),
+ pure, confg);
+}
+
+/* Find file entry given name. */
+
+static XREF_FILE
+find_file(name)
+ char *name;
+{
+ XREF_FILE xf;
+
+ for (xf = all_files; xf != NULL; xf = xf->next) {
+ if (STREQL(name, xf->name)) break;
+ }
+
+ return xf;
+}
+
+/* Return filename for output purposes. */
+
+static char *
+filename(xf)
+ XREF_FILE xf;
+{
+ if (xf == NULL) {
+ last_file = NULL;
+ return "*";
+ }
+
+ if (last_file == xf) return "*";
+
+ last_file = xf;
+
+ return xf->outname;
+}
+
+/* Return function name for output purposes. */
+
+static char *
+fctname(fndecl)
+ tree fndecl;
+{
+ static char fctbuf[1024];
+ char *s;
+
+ if (fndecl == NULL && last_fndecl == NULL) return "*";
+
+ if (fndecl == NULL)
+ {
+ last_fndecl = NULL;
+ return "*TOP*";
+ }
+
+ if (fndecl == last_fndecl) return "*";
+
+ last_fndecl = fndecl;
+
+ s = declname(fndecl);
+ s = fixname(s, fctbuf);
+
+ return s;
+}
+
+/* Return decl name for output purposes. */
+
+static char *
+declname(dcl)
+ tree dcl;
+{
+ if (DECL_NAME (dcl) == NULL) return "?";
+
+ if (DECL_ASSEMBLER_NAME (dcl))
+ return IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (dcl));
+ else
+ return IDENTIFIER_POINTER (DECL_NAME (dcl));
+}
+
+/* Simplify a type string by removing unneeded parenthesis. */
+
+static void
+simplify_type(typ)
+ char *typ;
+{
+ char *s;
+ int lvl, i;
+
+ i = strlen(typ);
+ while (i > 0 && isspace(typ[i-1])) typ[--i] = 0;
+
+ if (i > 7 && STREQL(&typ[i-5], "const"))
+ {
+ typ[i-5] = 0;
+ i -= 5;
+ }
+
+ if (typ[i-1] != ')') return;
+
+ s = &typ[i-2];
+ lvl = 1;
+ while (*s != 0) {
+ if (*s == ')') ++lvl;
+ else if (*s == '(')
+ {
+ --lvl;
+ if (lvl == 0)
+ {
+ s[1] = ')';
+ s[2] = 0;
+ break;
+ }
+ }
+ --s;
+ }
+
+ if (*s != 0 && s[-1] == ')')
+ {
+ --s;
+ --s;
+ if (*s == '(') s[2] = 0;
+ else if (*s == ':') {
+ while (*s != '(') --s;
+ s[1] = ')';
+ s[2] = 0;
+ }
+ }
+}
+
+/* Fixup a function name (take care of embedded spaces). */
+
+static char *
+fixname(nam, buf)
+ char *nam;
+ char *buf;
+{
+ char *s, *t;
+ int fg;
+
+ s = nam;
+ t = buf;
+ fg = 0;
+
+ while (*s != 0)
+ {
+ if (*s == ' ')
+ {
+ *t++ = '\36';
+ ++fg;
+ }
+ else *t++ = *s;
+ ++s;
+ }
+ *t = 0;
+
+ if (fg == 0) return nam;
+
+ return buf;
+}
+
+/* Open file for xreffing. */
+
+static void
+open_xref_file(file)
+ char *file;
+{
+ char *s, *t;
+
+#ifdef XREF_FILE_NAME
+ XREF_FILE_NAME (xref_name, file);
+#else
+ s = rindex (file, '/');
+ if (s == NULL)
+ sprintf (xref_name, ".%s.gxref", file);
+ else
+ {
+ ++s;
+ strcpy (xref_name, file);
+ t = rindex (xref_name, '/');
+ ++t;
+ *t++ = '.';
+ strcpy (t, s);
+ strcat (t, ".gxref");
+ }
+#endif /* no XREF_FILE_NAME */
+
+ xref_file = fopen(xref_name, "w");
+
+ if (xref_file == NULL)
+ {
+ error("Can't create cross-reference file `%s'", xref_name);
+ doing_xref = 0;
+ }
+}
OpenPOWER on IntegriCloud