re PR c++/57254 (Overload resolution failure when ref-qualified member function templ...
authorJason Merrill <jason@redhat.com>
Mon, 13 May 2013 19:32:28 +0000 (15:32 -0400)
committerJason Merrill <jason@gcc.gnu.org>
Mon, 13 May 2013 19:32:28 +0000 (15:32 -0400)
PR c++/57254
* typeck.c (merge_types): Propagate ref-qualifier
in METHOD_TYPE case.

From-SVN: r198843

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

index e1eda6a..6c5d210 100644 (file)
@@ -1,5 +1,9 @@
 2013-05-13  Jason Merrill  <jason@redhat.com>
 
+       PR c++/57254
+       * typeck.c (merge_types): Propagate ref-qualifier
+       in METHOD_TYPE case.
+
        PR c++/57253
        * decl.c (grokdeclarator): Apply ref-qualifier
        in the TYPENAME case.
index b8ea555..fb75847 100644 (file)
@@ -851,6 +851,7 @@ merge_types (tree t1, tree t2)
        tree raises = merge_exception_specifiers (TYPE_RAISES_EXCEPTIONS (t1),
                                                  TYPE_RAISES_EXCEPTIONS (t2),
                                                  NULL_TREE);
+       cp_ref_qualifier rqual = type_memfn_rqual (t1);
        tree t3;
 
        /* If this was a member function type, get back to the
@@ -864,6 +865,7 @@ merge_types (tree t1, tree t2)
        t3 = build_method_type_directly (basetype, TREE_TYPE (t3),
                                         TYPE_ARG_TYPES (t3));
        t1 = build_exception_variant (t3, raises);
+       t1 = build_ref_qualified_type (t1, rqual);
        break;
       }
 
diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-qual12.C b/gcc/testsuite/g++.dg/cpp0x/ref-qual12.C
new file mode 100644 (file)
index 0000000..b0a16fe
--- /dev/null
@@ -0,0 +1,22 @@
+// PR c++/57254
+// { dg-require-effective-target c++11 }
+
+struct foo {
+    template<typename T>
+    void bar(T) &;
+
+    template<typename T>
+    void bar(T) &&;
+};
+
+template<typename T>
+void foo::bar(T) & {}
+
+template<typename T>
+void foo::bar(T) && {}
+
+int main()
+{
+  foo f;
+  f.bar(0);
+}