* C++ PATCH for c++/49458 (rvalue reference to function and conversion ops)
@ 2011-06-18 7:58 Jason Merrill
0 siblings, 0 replies; only message in thread
From: Jason Merrill @ 2011-06-18 7:58 UTC (permalink / raw)
To: gcc-patches List
[-- Attachment #1: Type: text/plain, Size: 134 bytes --]
Another special case for the rule that an rvalue reference to function
is an lvalue.
Tested x86_64-pc-linux-gnu, applying to trunk.
[-- Attachment #2: 49458.patch --]
[-- Type: text/x-patch, Size: 1222 bytes --]
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();
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-06-18 5:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-06-18 7:58 C++ PATCH for c++/49458 (rvalue reference to function and conversion ops) Jason Merrill
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).