re PR c++/59296 ([c++11] ref-qualified member function is ambiguous)
authorJason Merrill <jason@redhat.com>
Wed, 18 Jun 2014 22:13:51 +0000 (18:13 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Wed, 18 Jun 2014 22:13:51 +0000 (18:13 -0400)
PR c++/59296
* call.c (add_function_candidate): Set LOOKUP_NO_RVAL_BIND for
ref-qualifier handling.

From-SVN: r211809

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

index 74eefea..7e7521b 100644 (file)
@@ -1,5 +1,9 @@
 2014-06-18  Jason Merrill  <jason@redhat.com>
 
+       PR c++/59296
+       * call.c (add_function_candidate): Set LOOKUP_NO_RVAL_BIND for
+       ref-qualifier handling.
+
        PR c++/61507
        * pt.c (resolve_overloaded_unification): Preserve
        ARGUMENT_PACK_EXPLICIT_ARGS.
index 1d4c4f9..b4adf36 100644 (file)
@@ -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 (file)
index 0000000..ca333c2
--- /dev/null
@@ -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();
+}