Patchwork C++ PATCH for c++/57825 (ref-qualifier lost on template argument)

login
register
mail settings
Submitter Jason Merrill
Date Aug. 7, 2013, 1:17 a.m.
Message ID <5201A018.1080600@redhat.com>
Download mbox | patch
Permalink /patch/265294/
State New
Headers show

Comments

Jason Merrill - Aug. 7, 2013, 1:17 a.m.
Simple oversight.

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

Patch

commit e468033b49ddb6cadfd3c07d3ac0b81d80bc523a
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Aug 6 19:49:40 2013 -0400

    	PR c++/57825
    	* tree.c (strip_typedefs) [METHOD_TYPE]: Preserve ref-qualifier.

diff --git a/gcc/cp/tree.c b/gcc/cp/tree.c
index f8b4bbc..63ec7fa 100644
--- a/gcc/cp/tree.c
+++ b/gcc/cp/tree.c
@@ -1236,6 +1236,8 @@  strip_typedefs (tree t)
 	    result =
 	      build_method_type_directly (class_type, type,
 					  TREE_CHAIN (arg_types));
+	    result
+	      = build_ref_qualified_type (result, type_memfn_rqual (t));
 	  }
 	else
 	  {
diff --git a/gcc/testsuite/g++.dg/cpp0x/ref-qual14.C b/gcc/testsuite/g++.dg/cpp0x/ref-qual14.C
new file mode 100644
index 0000000..8e55551
--- /dev/null
+++ b/gcc/testsuite/g++.dg/cpp0x/ref-qual14.C
@@ -0,0 +1,18 @@ 
+// PR c++/57825
+// { dg-do compile { target c++11 } }
+
+template<typename T>
+struct target_class
+{};
+
+template<typename Class, typename Ret, typename... Args>
+struct target_class<Ret (Class::*)(Args...)>
+{};
+
+template<typename Class, typename Ret, typename... Args>
+struct target_class<Ret (Class::*)(Args...) &>
+{};
+
+template<typename Class, typename Ret, typename... Args>
+struct target_class<Ret (Class::*)(Args...) &&>
+{};