diff mbox

C++ PATCH for c++/49458 (rvalue reference to function and conversion ops)

Message ID 4DFC3D5E.5080900@redhat.com
State New
Headers show

Commit Message

Jason Merrill June 18, 2011, 5:53 a.m. UTC
Another special case for the rule that an rvalue reference to function 
is an lvalue.

Tested x86_64-pc-linux-gnu, applying to trunk.
diff mbox

Patch

commit df1f90245e5436ceadf6b3df5cc6f7ef7e0536c0
Author: Jason Merrill <jason@redhat.com>
Date:   Fri Jun 17 16:45:44 2011 -0400

    	PR c++/49458
    	* call.c (convert_class_to_reference_1): Allow binding function
    	lvalue to rvalue reference.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index b43d078..05bf983 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -1362,6 +1362,8 @@  convert_class_to_reference_1 (tree reference_type, tree s, tree expr, int flags)
 
               /* Don't allow binding of lvalues to rvalue references.  */
               if (TYPE_REF_IS_RVALUE (reference_type)
+                  /* Function lvalues are OK, though.  */
+                  && TREE_CODE (TREE_TYPE (reference_type)) != FUNCTION_TYPE
                   && !TYPE_REF_IS_RVALUE (TREE_TYPE (TREE_TYPE (cand->fn))))
                 cand->second_conv->bad_p = true;
 	    }
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-func2.C b/gcc/testsuite/g++.dg/cpp0x/rv-func2.C
new file mode 100644
index 0000000..b792342
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/rv-func2.C
@@ -0,0 +1,10 @@ 
+// PR c++/49458
+// { dg-options -std=c++0x }
+
+typedef void ftype();
+
+struct A {
+  operator ftype&(void);
+};
+
+ftype &&frvref = A();