OSDN Git Service

PR c++/46103
authorjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 22 Oct 2010 18:37:41 +0000 (18:37 +0000)
committerjason <jason@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 22 Oct 2010 18:37:41 +0000 (18:37 +0000)
* init.c (build_vec_init): Handle memberwise move.

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

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

index ea83f25..7e4bdbf 100644 (file)
@@ -1,3 +1,8 @@
+2010-10-22  Jason Merrill  <jason@redhat.com>
+
+       PR c++/46103
+       * init.c (build_vec_init): Handle memberwise move.
+
 2010-10-21  Paolo Carlini  <paolo.carlini@oracle.com>
 
        PR c++/46117
index 5091d4e..72fcf78 100644 (file)
@@ -2849,6 +2849,7 @@ build_vec_init (tree base, tree maxindex, tree init,
   tree try_block = NULL_TREE;
   int num_initialized_elts = 0;
   bool is_global;
+  bool xvalue = false;
 
   if (TREE_CODE (atype) == ARRAY_TYPE && TYPE_DOMAIN (atype))
     maxindex = array_type_nelts (atype);
@@ -2939,6 +2940,8 @@ build_vec_init (tree base, tree maxindex, tree init,
      checking.  Evaluate the initializer before entering the try block.  */
   if (from_array && init && TREE_CODE (init) != CONSTRUCTOR)
     {
+      if (lvalue_kind (init) & clk_rvalueref)
+       xvalue = true;
       base2 = decay_conversion (init);
       itype = TREE_TYPE (base2);
       base2 = get_temp_regvar (itype, base2);
@@ -3033,7 +3036,11 @@ build_vec_init (tree base, tree maxindex, tree init,
          tree from;
 
          if (base2)
-           from = build1 (INDIRECT_REF, itype, base2);
+           {
+             from = build1 (INDIRECT_REF, itype, base2);
+             if (xvalue)
+               from = move (from);
+           }
          else
            from = NULL_TREE;
 
index 96e42b8..b1bf64f 100644 (file)
@@ -1,3 +1,8 @@
+2010-10-22  Jason Merrill  <jason@redhat.com>
+
+       PR c++/46103
+       * g++.dg/cpp0x/implicit10.C: New.
+
 2010-10-22  Uros Bizjak  <ubizjak@gmail.com>
 
        PR target/46098
diff --git a/gcc/testsuite/g++.dg/cpp0x/implicit10.C b/gcc/testsuite/g++.dg/cpp0x/implicit10.C
new file mode 100644 (file)
index 0000000..721a93d
--- /dev/null
@@ -0,0 +1,19 @@
+// PR c++/46103
+// { dg-options -std=c++0x }
+
+struct MoveOnly {
+  MoveOnly(const MoveOnly&) = delete;
+  MoveOnly(MoveOnly&&) { }
+  MoveOnly() = default;
+};
+
+struct A {
+  MoveOnly mo[1];
+  A() = default;
+  A(A&&) = default;
+};
+
+int main() {
+  A a;
+  A aa = static_cast<A&&>(a);
+}