* tree.c (build_vec_init_elt): Strip TARGET_EXPR.
authorJason Merrill <jason@redhat.com>
Sat, 9 Jul 2011 17:01:11 +0000 (13:01 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sat, 9 Jul 2011 17:01:11 +0000 (13:01 -0400)
From-SVN: r176084

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

index cbdc4d83df2b5a5a7f60db58bb25b66e4e788134..c19e8b38762ce48137a2108f5e8b5713e63fd1fa 100644 (file)
@@ -1,3 +1,7 @@
+2011-07-09  Jason Merrill  <jason@redhat.com>
+
+       * tree.c (build_vec_init_elt): Strip TARGET_EXPR.
+
 2011-07-08  Jason Merrill  <jason@redhat.com>
 
        PR c++/45437
index dcd85e40c98618b6472fc7eff716923b2d0dcd81..4ef89c45f650f3c8f0daced97d38b81ac0a46e8d 100644 (file)
@@ -511,6 +511,11 @@ build_vec_init_elt (tree type, tree init, tsubst_flags_t complain)
                                    complain);
   release_tree_vector (argvec);
 
+  /* For a trivial constructor, build_over_call creates a TARGET_EXPR.  But
+     we don't want one here because we aren't creating a temporary.  */
+  if (TREE_CODE (init) == TARGET_EXPR)
+    init = TARGET_EXPR_INITIAL (init);
+
   return init;
 }
 
index 5b8be3309cbd0382e1e1f2cdd65c30d2495f6cae..badb65e816322df7c5e65c0c12fd2de7bd73fde4 100644 (file)
@@ -1,3 +1,7 @@
+2011-07-09  Jason Merrill  <jason@redhat.com>
+
+       * g++.dg/cpp0x/regress/regress5.C: New.
+
 2011-07-08  Jason Merrill  <jason@redhat.com>
 
        PR c++/45437
diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/regress5.C b/gcc/testsuite/g++.dg/cpp0x/regress/regress5.C
new file mode 100644 (file)
index 0000000..b193591
--- /dev/null
@@ -0,0 +1,16 @@
+// { dg-options -std=c++0x }
+
+struct A
+{
+  int i;
+  A(int);
+};
+
+struct B
+{
+  virtual void f();
+  A ar[3];
+};
+
+extern B b;
+B b2(b);