PR c++/55249
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 7 Dec 2012 04:53:46 +0000 (04:53 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 7 Dec 2012 04:53:46 +0000 (04:53 +0000)
* tree.c (build_vec_init_elt): Use the type of the initializer.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@194281 138bc75d-0d04-0410-961f-82ee72b054a4

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

index bcad0c2..22bdb50 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 58725f3..28ff0f2 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;
+}