Commit e5ba9b70 by Marek Polacek Committed by Marek Polacek

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
parent 3075affd
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.
......
......@@ -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;
......
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.
* g++.dg/cpp0x/lambda/lambda-const-this.C: Add dg-warning.
* g++.dg/cpp0x/lambda/lambda-in-class-neg.C: Likewise.
......
// 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" }
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment