pt.c (do_decl_instantiate): Explicitly clone constructors and destructors that haven...
authorMark Mitchell <mark@codesourcery.com>
Wed, 22 Nov 2000 22:43:49 +0000 (22:43 +0000)
committerMark Mitchell <mmitchel@gcc.gnu.org>
Wed, 22 Nov 2000 22:43:49 +0000 (22:43 +0000)
* pt.c (do_decl_instantiate): Explicitly clone constructors and
destructors that haven't already been cloned.

From-SVN: r37673

gcc/cp/ChangeLog
gcc/cp/pt.c
gcc/testsuite/g++.old-deja/g++.other/ctor1-aux.cc [new file with mode: 0644]
gcc/testsuite/g++.old-deja/g++.other/ctor1.C [new file with mode: 0644]

index bc73be5a6f4992570dd75fa0e678224b29ba82b5..ef02d3d889ad972e58c5bbf7fc646a4d28f79100 100644 (file)
@@ -1,3 +1,8 @@
+2000-11-22  Mark Mitchell  <mark@codesourcery.com>
+
+       * pt.c (do_decl_instantiate): Explicitly clone constructors and
+       destructors that haven't already been cloned.
+
 2000-11-20  Richard Henderson  <rth@redhat.com>
 
        * parse.y (yyparse_1): Rename the parser entry point.
index 3327110f949bd44f0897ae58e73017a62d756d0d..ddcdf8a433172429b9510010b720d7268b59ead7 100644 (file)
@@ -9214,6 +9214,15 @@ do_decl_instantiation (declspecs, declarator, storage)
     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);
diff --git a/gcc/testsuite/g++.old-deja/g++.other/ctor1-aux.cc b/gcc/testsuite/g++.old-deja/g++.other/ctor1-aux.cc
new file mode 100644 (file)
index 0000000..9990ca2
--- /dev/null
@@ -0,0 +1,12 @@
+// Origin: Mark Mitchell <mark@codesourcery.com>
+
+template <class T>
+struct S {
+  template <class U>
+  S (U);
+};
+
+int main ()
+{
+  S<int> (3.0);
+}
diff --git a/gcc/testsuite/g++.old-deja/g++.other/ctor1.C b/gcc/testsuite/g++.old-deja/g++.other/ctor1.C
new file mode 100644 (file)
index 0000000..1c67d0a
--- /dev/null
@@ -0,0 +1,14 @@
+// Additional sources: ctor1-aux.cc
+// Origin: Mark Mitchell <mark@codesourcery.com>
+
+template <class T>
+struct S {
+  template <class U>
+  S (U);
+};
+
+template <class T>
+template <class U>
+S<T>::S (U) {}
+
+template S<int>::S (double);