re PR c++/49458 ([C++0x][DR 1328] Obvious candidate for conversion to function lvalue...
authorJason Merrill <jason@redhat.com>
Sat, 18 Jun 2011 05:58:38 +0000 (01:58 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Sat, 18 Jun 2011 05:58:38 +0000 (01:58 -0400)
PR c++/49458
* call.c (convert_class_to_reference_1): Allow binding function
lvalue to rvalue reference.

From-SVN: r175164

gcc/cp/ChangeLog
gcc/cp/call.c
gcc/testsuite/ChangeLog
gcc/testsuite/g++.dg/cpp0x/rv-func2.C [new file with mode: 0644]

index f3fca847a082b6585466f5a3dda8f8354991607e..3217c8ffb20b7bc395586f2f7402262fb7f14217 100644 (file)
@@ -1,5 +1,9 @@
 2011-06-17  Jason Merrill  <jason@redhat.com>
 
+       PR c++/49458
+       * call.c (convert_class_to_reference_1): Allow binding function
+       lvalue to rvalue reference.
+
        PR c++/43912
        Generate proxy VAR_DECLs for better lambda debug info.
        * cp-tree.h (FUNCTION_NEEDS_BODY_BLOCK): Add lambda operator().
index b43d078dedd7ec481b3d3d60b50e2b9fe7593beb..05bf983f558ffa3fe8833334fce9b0a1a410eb8d 100644 (file)
@@ -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;
            }
index 805c5b178f1918406e8d3dead671eebdd87d6273..d7826412ad8fef5b9754a77d4baaecda3bccdedd 100644 (file)
@@ -1,5 +1,7 @@
 2011-06-17  Jason Merrill  <jason@redhat.com>
 
+       * g++.dg/cpp0x/rv-func2.C: New.
+
        * g++.dg/debug/dwarf2/lambda1.C: New.
        * g++.dg/warn/Wshadow-6.C: Adjust.
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/rv-func2.C b/gcc/testsuite/g++.dg/cpp0x/rv-func2.C
new file mode 100644 (file)
index 0000000..b792342
--- /dev/null
@@ -0,0 +1,10 @@
+// PR c++/49458
+// { dg-options -std=c++0x }
+
+typedef void ftype();
+
+struct A {
+  operator ftype&(void);
+};
+
+ftype &&frvref = A();