re PR c++/55249 (Multiple copy constructors for template class lead to link errors)
authorJason Merrill <jason@redhat.com>
Fri, 7 Dec 2012 04:53:46 +0000 (23:53 -0500)
committerJason Merrill <jason@gcc.gnu.org>
Fri, 7 Dec 2012 04:53:46 +0000 (23:53 -0500)
PR c++/55249
* tree.c (build_vec_init_elt): Use the type of the initializer.

From-SVN: r194281

gcc/cp/ChangeLog
gcc/cp/tree.c
gcc/testsuite/g++.dg/template/array25.C [new file with mode: 0644]

index bcad0c24636bf2678113cae9f1557ea2890a746f..22bdb505942db87e953d84cd3d4797f5c4503512 100644 (file)
@@ -1,5 +1,8 @@
 2012-12-06  Jason Merrill  <jason@redhat.com>
 
+       PR c++/55249
+       * tree.c (build_vec_init_elt): Use the type of the initializer.
+
        PR c++/54744
        * pt.c (resolve_typename_type): Check TYPENAME_IS_RESOLVING_P on scope.
        * init.c (expand_member_init): Check for being in a template first.
index 58725f3bd58af37f7bb5497fa548ade9ec60599b..28ff0f20eb11a4ce7c3ae40be2e7ca2da3dd7001 100644 (file)
@@ -524,7 +524,8 @@ build_vec_init_elt (tree type, tree init, tsubst_flags_t complain)
   argvec = make_tree_vector ();
   if (init)
     {
-      tree dummy = build_dummy_object (inner_type);
+      tree init_type = strip_array_types (TREE_TYPE (init));
+      tree dummy = build_dummy_object (init_type);
       if (!real_lvalue_p (init))
        dummy = move (dummy);
       argvec->quick_push (dummy);
diff --git a/gcc/testsuite/g++.dg/template/array25.C b/gcc/testsuite/g++.dg/template/array25.C
new file mode 100644 (file)
index 0000000..4f3ccbf
--- /dev/null
@@ -0,0 +1,18 @@
+// PR c++/55249
+
+template <typename _Tp> struct A
+{
+  _Tp _M_instance[1];
+};
+template <class> struct inner_type
+{
+    inner_type () {}
+    inner_type (inner_type &);
+    inner_type (const inner_type &) {}
+};
+
+int
+main ()
+{
+    A <inner_type <int> > a, b = a;
+}