Patchwork C++ PATCHes for DR 1328, c++/49267, c++/49458

login
register
mail settings
Submitter Jason Merrill
Date Sept. 5, 2011, 4:29 a.m.
Message ID <4E645014.70508@redhat.com>
Download mbox | patch
Permalink /patch/113304/
State New
Headers show

Comments

Jason Merrill - Sept. 5, 2011, 4:29 a.m.
These two PRs have to do with comparing conversion operators that return 
lvalue or rvalue references.  The fix for 49458 is to consider that 
directly when deciding whether the rvalueness matches the target 
reference, before an rvalue reference to function has decayed to an 
lvalue.  Part of this fixes 49267, but I've also fixed (in the second 
patch) the code that incorrectly decided that an rvalue reference to int 
was an lvalue.

Tested x86_64-pc-linux-gnu, applying to trunk.  Also applying the 
compare_ics hunk to 4.6.
Jason Merrill - Sept. 17, 2011, 10:33 p.m.
On 09/05/2011 12:29 AM, Jason Merrill wrote:
> Also applying the compare_ics hunk to 4.6.

This caused c++/50442, so I'm reverting it.

Jason

Patch

commit 41e2f64d32ca6f850f2907387285ad0d37e93a25
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Aug 31 16:49:33 2011 -0400

    	* call.c (reference_binding): Don't set is_lvalue for an rvalue
    	reference rfrom.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 1fa5fc8..c707d66 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))