From 1a94ffae3661bae81e3142c6f965939deacf3e72 Mon Sep 17 00:00:00 2001 From: Jason Merrill Date: Mon, 5 Sep 2011 00:33:57 -0400 Subject: [PATCH] re PR c++/49267 (Ambiguity with conversion functions "T&" and "T&&", initializing a "T&&") PR c++/49267 * call.c (reference_binding): Don't set is_lvalue for an rvalue reference rfrom. From-SVN: r178521 --- gcc/cp/ChangeLog | 4 ++++ gcc/cp/call.c | 5 +++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 718bcb3b985..b676dd14073 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,5 +1,9 @@ 2011-09-04 Jason Merrill + PR c++/49267 + * call.c (reference_binding): Don't set is_lvalue for an rvalue + reference rfrom. + PR c++/49267 PR c++/49458 DR 1328 diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 1fa5fc81852..c707d663e24 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -1576,9 +1576,10 @@ reference_binding (tree rto, tree rfrom, tree expr, bool c_cast_p, int flags) if (TREE_CODE (from) == REFERENCE_TYPE) { - /* Anything with reference type is an lvalue. */ - is_lvalue = clk_ordinary; from = TREE_TYPE (from); + if (!TYPE_REF_IS_RVALUE (rfrom) + || TREE_CODE (from) == FUNCTION_TYPE) + is_lvalue = clk_ordinary; } if (expr && BRACE_ENCLOSED_INITIALIZER_P (expr))