Patchwork C++ PATCH to build_vec_init_elt to strip TARGET_EXPR

login
register
mail settings
Submitter Jason Merrill
Date July 9, 2011, 5 p.m.
Message ID <4E188945.2050807@redhat.com>
Download mbox | patch
Permalink /patch/103984/
State New
Headers show

Comments

Jason Merrill - July 9, 2011, 5 p.m.
My patch for 49528 broke this testcase because build_vec_init_elt was 
returning what looks like a temporary of non-literal type.  There isn't 
actually a temporary, so let's not return something that looks like one.

Tested x86_64-pc-linux-gnu, applying to trunk and 4.6.

Patch

commit 3f54d9656d3e65b396940d2f1227126d61bab91f
Author: Jason Merrill <jason@redhat.com>
Date:   Sat Jul 9 00:23:17 2011 -0400

    	* tree.c (build_vec_init_elt): Strip TARGET_EXPR.

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index dcd85e4..4ef89c4 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -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;
 }
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/regress/regress5.C b/gcc/testsuite/g++.dg/cpp0x/regress/regress5.C
new file mode 100644
index 0000000..b193591
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/regress/regress5.C
@@ -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);