This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH: Explicit instantiations of constructors
>>>>> "Mark" == Mark Mitchell <mark@codesourcery.com> writes:
>>>>> "Jason" == Jason Merrill <jason@redhat.com> writes:
>>> * pt.c (do_decl_instantiate): Explicitly clone constructors and
>>> destructors that haven't already been cloned.
Jason> I don't think this should be necessary. Why aren't the
Jason> clone decls automatically generated along with
Jason> the cloned decl?
> When you mean generated, what do you mean? Instantiated, declared,
> etc.?
Built, i.e. in tsubst. Does this make sense to you? I haven't
checked it in yet.
2000-11-29 Jason Merrill <jason@redhat.com>
* pt.c (tsubst_decl): Call clone_function_decl here.
(do_decl_instantiation): Not here.
* class.c (clone_function_decl): Robustify.
*** pt.c.~1~ Wed Nov 29 15:06:56 2000
--- pt.c Wed Nov 29 15:07:08 2000
*************** tsubst_decl (t, args, type, in_decl)
*** 5786,5791 ****
--- 5786,5792 ----
maybe_retrofit_in_chrg (r);
if (DECL_CONSTRUCTOR_P (r))
grok_ctor_properties (ctx, r);
+ clone_function_decl(r, /*update_method_vec_p=*/0);
}
else if (IDENTIFIER_OPNAME_P (DECL_NAME (r)))
grok_op_properties (r, DECL_VIRTUAL_P (r), DECL_FRIEND_P (r));
*************** do_decl_instantiation (declspecs, declar
*** 9222,9236 ****
cp_error ("storage class `%D' applied to template instantiation",
storage);
- /* Under the new ABI, we need to make sure to instantiate all the
- cloned versions of constructors or destructors. */
- if (flag_new_abi &&
- (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (result) ||
- DECL_MAYBE_IN_CHARGE_DESTRUCTOR_P (result)) &&
- !(TREE_CHAIN (result) &&
- DECL_CLONED_FUNCTION (TREE_CHAIN (result))))
- clone_function_decl(result, /*update_method_vec_p=*/0);
-
SET_DECL_EXPLICIT_INSTANTIATION (result);
mark_decl_instantiated (result, extern_p);
repo_template_instantiated (result, extern_p);
--- 9223,9228 ----
*** class.c.~1~ Wed Nov 29 15:06:55 2000
--- class.c Wed Nov 29 15:07:05 2000
*************** clone_function_decl (fn, update_method_v
*** 4316,4321 ****
--- 4316,4327 ----
{
tree clone;
+ /* Avoid inappropriate cloning. */
+ if (! flag_new_abi
+ || (TREE_CHAIN (fn)
+ && DECL_CLONED_FUNCTION (TREE_CHAIN (fn))))
+ return;
+
if (DECL_MAYBE_IN_CHARGE_CONSTRUCTOR_P (fn))
{
/* For each constructor, we need two variants: an in-charge version