public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jason Merrill <jason@redhat.com>
To: gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: C++ PATCH for c++/49458 (rvalue reference to function and conversion ops)
Date: Sat, 18 Jun 2011 07:58:00 -0000	[thread overview]
Message-ID: <4DFC3D5E.5080900@redhat.com> (raw)

[-- 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();

                 reply	other threads:[~2011-06-18  5:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DFC3D5E.5080900@redhat.com \
    --to=jason@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).