public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ PATCH for c++/59296 (rvalue object and lvalue ref-qualifier)
@ 2014-06-18 22:12 Jason Merrill
  2014-06-19  9:32 ` Jason Merrill
  2014-06-19 11:29 ` Marc Glisse
  0 siblings, 2 replies; 5+ messages in thread
From: Jason Merrill @ 2014-06-18 22:12 UTC (permalink / raw)
  To: gcc-patches List

[-- Attachment #1: Type: text/plain, Size: 200 bytes --]

We were treating a const & member function like a normal const 
reference, and binding an rvalue object argument to it.  But it doesn't 
work that way.

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

[-- Attachment #2: 59296.patch --]
[-- Type: text/x-patch, Size: 1108 bytes --]

commit 20a165532a9b0b0dada391716a1fb781af3ec005
Author: Jason Merrill <jason@redhat.com>
Date:   Wed Jun 18 22:56:25 2014 +0200

    	PR c++/59296
    	* call.c (add_function_candidate): Set LOOKUP_NO_RVAL_BIND for
    	ref-qualifier handling.

diff --git a/gcc/cp/call.c b/gcc/cp/call.c
index 1d4c4f9..b4adf36 100644
--- a/gcc/cp/call.c
+++ b/gcc/cp/call.c
@@ -2025,6 +2025,8 @@ add_function_candidate (struct z_candidate **candidates,
 		     object parameter has reference type.  */
 		  bool rv = FUNCTION_RVALUE_QUALIFIED (TREE_TYPE (fn));
 		  parmtype = cp_build_reference_type (parmtype, rv);
+		  /* Don't bind an rvalue to a const lvalue ref-qualifier.  */
+		  lflags |= LOOKUP_NO_RVAL_BIND;
 		}
 	      else
 		{
diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-qual15.C b/gcc/testsuite/g++.dg/cpp0x/ref-qual15.C
new file mode 100644
index 0000000..ca333c2
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/ref-qual15.C
@@ -0,0 +1,13 @@
+// PR c++/59296
+// { dg-do compile { target c++11 } }
+
+struct Type
+{
+  void get() const& { }
+  void get() const&& { }
+};
+
+int main()
+{
+  Type{}.get();
+}

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2014-06-20 18:28 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-18 22:12 C++ PATCH for c++/59296 (rvalue object and lvalue ref-qualifier) Jason Merrill
2014-06-19  9:32 ` Jason Merrill
2014-06-19 11:29 ` Marc Glisse
2014-06-20 13:12   ` Jason Merrill
2014-06-20 18:28     ` 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).