2
0
mirror of git://gcc.gnu.org/git/gcc.git synced 2025-04-09 20:31:36 +08:00

re PR c++/88103 (Wrong value category when conditional expression result is used as object expression)

PR c++/88103
	* typeck.c (build_class_member_access_expr): If unary_complex_lvalue
	turned xvalue_p into non-xvalue_p, call move on it.

	* g++.dg/cpp0x/rv-cond3.C: New test.

From-SVN: r266772
This commit is contained in:
Jakub Jelinek 2018-12-04 09:44:12 +01:00 committed by Jakub Jelinek
parent 056775650a
commit 580b8d9b54
4 changed files with 40 additions and 1 deletions
gcc

@ -1,3 +1,9 @@
2018-12-04 Jakub Jelinek <jakub@redhat.com>
PR c++/88103
* typeck.c (build_class_member_access_expr): If unary_complex_lvalue
turned xvalue_p into non-xvalue_p, call move on it.
2018-12-02 Jakub Jelinek <jakub@redhat.com>
PR c++/88258

@ -2422,7 +2422,13 @@ build_class_member_access_expr (cp_expr object, tree member,
{
tree temp = unary_complex_lvalue (ADDR_EXPR, object);
if (temp)
object = cp_build_fold_indirect_ref (temp);
{
temp = cp_build_fold_indirect_ref (temp);
if (xvalue_p (object) && !xvalue_p (temp))
/* Preserve xvalue kind. */
temp = move (temp);
object = temp;
}
}
/* In [expr.ref], there is an explicit list of the valid choices for

@ -1,3 +1,8 @@
2018-12-04 Jakub Jelinek <jakub@redhat.com>
PR c++/88103
* g++.dg/cpp0x/rv-cond3.C: New test.
2018-12-04 Richard Biener <rguenther@suse.de>
PR tree-optimization/88315

@ -0,0 +1,22 @@
// PR c++/88103
// { dg-do compile { target c++11 } }
struct A {
A (int);
A&& foo () &&;
int i;
};
void free (A&&);
void test_xvalue (A a){
A&& ref = true ? static_cast<A&&> (a) : static_cast<A&&> (a);
free (true ? static_cast<A&&> (a) : static_cast<A&&> (a));
(true ? static_cast<A&&> (a) : static_cast<A&&> (a)).foo ();
int&& k = (true ? static_cast<A&&> (a) : static_cast<A&&> (a)).i;
}
void test_prvalue (A a){
A&& ref = true ? static_cast<A&&> (a) : 1;
free (true ? static_cast<A&&> (a) : 1);
(true ? static_cast<A&&> (a) : 1).foo ();
int&& k = (true ? static_cast<A&&> (a) : 1).i;
}