aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorJason Merrill <jason@redhat.com>2014-05-09 14:16:05 -0400
committerJason Merrill <jason@gcc.gnu.org>2014-05-09 14:16:05 -0400
commitfc2bfea1399d51ab99516266948a40de92b14a0c (patch)
tree4c0b1995d3da6aa7557c08611b753024359fbc41 /gcc
parent5f901ccf18953b699bd290a4a169e2b7c7aa870a (diff)
downloadgcc-fc2bfea1399d51ab99516266948a40de92b14a0c.zip
gcc-fc2bfea1399d51ab99516266948a40de92b14a0c.tar.gz
gcc-fc2bfea1399d51ab99516266948a40de92b14a0c.tar.bz2
re PR c++/58714 (Bogus overload resolution for the assignment operator in assignment to a conditional)
PR c++/58714 * tree.c (stabilize_expr): A stabilized prvalue is an xvalue. From-SVN: r210283
Diffstat (limited to 'gcc')
-rw-r--r--gcc/cp/ChangeLog3
-rw-r--r--gcc/cp/tree.c4
-rw-r--r--gcc/testsuite/g++.dg/cpp0x/rv-cond1.C13
-rw-r--r--gcc/testsuite/g++.dg/expr/cond12.C12
4 files changed, 32 insertions, 0 deletions
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 6bddd49..b13bd99 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,5 +1,8 @@
2014-05-09 Jason Merrill <jason@redhat.com>
+ PR c++/58714
+ * tree.c (stabilize_expr): A stabilized prvalue is an xvalue.
+
PR c++/54348
* call.c (build_conditional_expr_1): If overload resolution finds
no match, just say "different types".
diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index e140024..229d476 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -3785,6 +3785,10 @@ stabilize_expr (tree exp, tree* initp)
{
init_expr = get_target_expr (exp);
exp = TARGET_EXPR_SLOT (init_expr);
+ if (CLASS_TYPE_P (TREE_TYPE (exp)))
+ exp = move (exp);
+ else
+ exp = rvalue (exp);
}
else
{
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-cond1.C b/gcc/testsuite/g++.dg/cpp0x/rv-cond1.C
new file mode 100644
index 0000000..a8f598f
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/rv-cond1.C
@@ -0,0 +1,13 @@
+// PR c++/58714
+// { dg-do compile { target c++11 } }
+
+struct X {
+ X& operator=(const X&) = delete;
+ X& operator=(X&& ) = default;
+};
+
+void f(bool t) {
+ X a, b;
+ *(t ? &a : &b) = X();
+ (t ? a : b) = X();
+}
diff --git a/gcc/testsuite/g++.dg/expr/cond12.C b/gcc/testsuite/g++.dg/expr/cond12.C
new file mode 100644
index 0000000..9134f816
--- /dev/null
+++ b/gcc/testsuite/g++.dg/expr/cond12.C
@@ -0,0 +1,12 @@
+// PR c++/58714
+// { dg-do run }
+
+struct X {
+ X& operator=(const X&){}
+ X& operator=(X&){__builtin_abort();}
+};
+
+int main(int argv,char**) {
+ X a, b;
+ ((argv > 2) ? a : b) = X();
+}