diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-03-17 02:35:01 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2013-03-17 02:35:01 +0000 |
commit | 23d471c12af9afbc18cc9c42e6327754700ade08 (patch) | |
tree | a4da442b8834b4db3354eea10a7a13417cf5982d | |
parent | 7c99bd48472bfd42c38beaddb780c38f0e63e57f (diff) | |
download | gcc-23d471c12af9afbc18cc9c42e6327754700ade08.tar.gz |
PR c++/55017
* method.c (walk_field_subobs): Disallow copy of rvalue ref.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@196728 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/cp/ChangeLog | 3 | ||||
-rw-r--r-- | gcc/cp/method.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/g++.dg/cpp0x/rv-copy1.C | 10 | ||||
-rw-r--r-- | libstdc++-v3/ChangeLog | 5 | ||||
-rw-r--r-- | libstdc++-v3/testsuite/20_util/pair/piecewise2.cc | 3 |
5 files changed, 33 insertions, 1 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 04eab4a67d1..28b110c68a4 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2013-03-16 Jason Merrill <jason@redhat.com> + PR c++/55017 + * method.c (walk_field_subobs): Disallow copy of rvalue ref. + PR c++/55240 * parser.c (parsing_nsdmi): New. * semantics.c (outer_automatic_var_p): Check it. diff --git a/gcc/cp/method.c b/gcc/cp/method.c index ff29b596892..55c7e50d308 100644 --- a/gcc/cp/method.c +++ b/gcc/cp/method.c @@ -1115,6 +1115,19 @@ walk_field_subobs (tree fields, tree fnname, special_function_kind sfk, "initialize %q+#D", field); } } + else if (sfk == sfk_copy_constructor) + { + /* 12.8p11b5 */ + if (TREE_CODE (mem_type) == REFERENCE_TYPE + && TYPE_REF_IS_RVALUE (mem_type)) + { + if (diag) + error ("copying non-static data member %q#D of rvalue " + "reference type", field); + if (deleted_p) + *deleted_p = true; + } + } if (!CLASS_TYPE_P (mem_type)) continue; diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-copy1.C b/gcc/testsuite/g++.dg/cpp0x/rv-copy1.C new file mode 100644 index 00000000000..70d3d719222 --- /dev/null +++ b/gcc/testsuite/g++.dg/cpp0x/rv-copy1.C @@ -0,0 +1,10 @@ +// PR c++/55017 +// { dg-do compile { target c++11 } } + +struct S { // { dg-error "rvalue ref" } + int&& rr; + S(int&& rr) : rr(static_cast<int&&>(rr)) {} +}; + +S s1(13); +S s2 = s1; // { dg-error "deleted" } diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index efca94e202d..6de5bbbd2e6 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,8 @@ +2013-03-16 Jason Merrill <jason@redhat.com> + + PR c++/55017 + * testsuite/20_util/pair/piecewise2.cc (test01): Use std::move. + 2013-03-16 Jonathan Wakely <jwakely.gcc@gmail.com> PR libstdc++/56468 diff --git a/libstdc++-v3/testsuite/20_util/pair/piecewise2.cc b/libstdc++-v3/testsuite/20_util/pair/piecewise2.cc index d53e49c78b5..0273c14ad56 100644 --- a/libstdc++-v3/testsuite/20_util/pair/piecewise2.cc +++ b/libstdc++-v3/testsuite/20_util/pair/piecewise2.cc @@ -51,7 +51,8 @@ struct Default void test01(std::tuple<NoCon&, NoCon&&> t1, std::tuple<NoCon&, NoCon&&, NoCon&> t2) { - std::pair<RefCheck1, RefCheck2>(std::piecewise_construct, t1, t2); + std::pair<RefCheck1, RefCheck2>(std::piecewise_construct, + std::move(t1), std::move(t2)); } void test02(std::tuple<> t1, std::tuple<int> t2) |