From 5275b2c7d7c1ae888b1af5b6c86a96de032f12d8 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Sat, 16 Mar 2013 22:35:01 -0400 Subject: re PR c++/55017 ([DR 1051] [C++11] Rvalue-reference member should cause copy constructor to be deleted, but still declared) PR c++/55017 * method.c (walk_field_subobs): Disallow copy of rvalue ref. From-SVN: r196728 --- gcc/cp/ChangeLog | 3 +++ gcc/cp/method.c | 13 +++++++++++++ gcc/testsuite/g++.dg/cpp0x/rv-copy1.C | 10 ++++++++++ 3 files changed, 26 insertions(+) create mode 100644 gcc/testsuite/g++.dg/cpp0x/rv-copy1.C (limited to 'gcc') diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 04eab4a..28b110c 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,8 @@ 2013-03-16 Jason Merrill + 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 ff29b59..55c7e50 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 0000000..70d3d71 --- /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(rr)) {} +}; + +S s1(13); +S s2 = s1; // { dg-error "deleted" } -- cgit v1.1