PR c++/87150 - wrong ctor with maybe-rvalue semantics.

* call.c (struct conversion): Update commentary.
	(standard_conversion): Set rvaluedness_matches_p if LOOKUP_PREFER_RVALUE
	for ck_base.

	* g++.dg/cpp0x/move-return2.C: New test.

From-SVN: r264172
This commit is contained in:
Marek Polacek 2018-09-08 17:36:08 +00:00 committed by Marek Polacek
parent 3075affdbc
commit e5ba9b702f
4 changed files with 29 additions and 3 deletions

View File

@ -1,3 +1,10 @@
2018-09-08 Marek Polacek <polacek@redhat.com>
PR c++/87150 - wrong ctor with maybe-rvalue semantics.
* call.c (struct conversion): Update commentary.
(standard_conversion): Set rvaluedness_matches_p if LOOKUP_PREFER_RVALUE
for ck_base.
2018-09-08 Jason Merrill <jason@redhat.com>
PR c++/86678 - constexpr function with non-constant after return.

View File

@ -102,10 +102,10 @@ struct conversion {
BOOL_BITFIELD base_p : 1;
/* If KIND is ck_ref_bind, true when either an lvalue reference is
being bound to an lvalue expression or an rvalue reference is
being bound to an rvalue expression. If KIND is ck_rvalue,
being bound to an rvalue expression. If KIND is ck_rvalue or ck_base,
true when we are treating an lvalue as an rvalue (12.8p33). If
KIND is ck_base, always false. If ck_identity, we will be
binding a reference directly or decaying to a pointer. */
ck_identity, we will be binding a reference directly or decaying to
a pointer. */
BOOL_BITFIELD rvaluedness_matches_p: 1;
BOOL_BITFIELD check_narrowing: 1;
/* Whether check_narrowing should only check TREE_CONSTANTs; used
@ -1425,6 +1425,9 @@ standard_conversion (tree to, tree from, tree expr, bool c_cast_p,
type. A temporary object is created to hold the result of
the conversion unless we're binding directly to a reference. */
conv->need_temporary_p = !(flags & LOOKUP_NO_TEMP_BIND);
if (flags & LOOKUP_PREFER_RVALUE)
/* Tell convert_like_real to set LOOKUP_PREFER_RVALUE. */
conv->rvaluedness_matches_p = true;
}
else
return NULL;

View File

@ -1,3 +1,8 @@
2018-09-08 Marek Polacek <polacek@redhat.com>
PR c++/87150 - wrong ctor with maybe-rvalue semantics.
* g++.dg/cpp0x/move-return2.C: New test.
2018-09-08 Marek Polacek <polacek@redhat.com>
* c-c++-common/array-init.c: Add dg-prune-output.

View File

@ -0,0 +1,11 @@
// PR c++/87150
// { dg-do compile { target c++11 } }
struct S1 { S1(S1 &&); };
struct S2 : S1 {};
S1
f (S2 s)
{
return s; // { dg-error "use of deleted function" }
}