diff mbox

C++ PATCH for c++/48157 (loss of explicit template args in member template signature)

Message ID 4E13E1FB.3030303@redhat.com
State New
Headers show

Commit Message

Jason Merrill July 6, 2011, 4:18 a.m. UTC
We were accidentally discarding the args from a template-id when doing a 
partial instantiation of a qualified-id.

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

Patch

commit 50ab88c80a398570a84f65802c3e004e46f27eeb
Author: Jason Merrill <jason@redhat.com>
Date:   Tue Jul 5 21:54:43 2011 -0400

    	PR c++/48157
    	* pt.c (tsubst_qualified_id): Preserve TEMPLATE_ID_EXPR in
    	partial instantiation.

diff --git a/gcc/cp/pt.c b/gcc/cp/pt.c
index e7be08b..17ca44c 100644
--- a/gcc/cp/pt.c
+++ b/gcc/cp/pt.c
@@ -11287,8 +11287,12 @@  tsubst_qualified_id (tree qualified_id, tree args,
     expr = name;
 
   if (dependent_scope_p (scope))
-    return build_qualified_name (NULL_TREE, scope, expr,
-				 QUALIFIED_NAME_IS_TEMPLATE (qualified_id));
+    {
+      if (is_template)
+	expr = build_min_nt (TEMPLATE_ID_EXPR, expr, template_args);
+      return build_qualified_name (NULL_TREE, scope, expr,
+				   QUALIFIED_NAME_IS_TEMPLATE (qualified_id));
+    }
 
   if (!BASELINK_P (name) && !DECL_P (expr))
     {
diff --git a/gcc/testsuite/g++.dg/template/template-id-4.C b/gcc/testsuite/g++.dg/template/template-id-4.C
new file mode 100644
index 0000000..26f4809
--- /dev/null
+++ b/gcc/testsuite/g++.dg/template/template-id-4.C
@@ -0,0 +1,22 @@ 
+// PR c++/48157
+
+struct AType
+{
+  template<class AA>
+  void SomeFuncTemplate()
+  { }
+};
+
+template < class T >
+struct TTest2
+{
+  template<T> struct helper;
+
+  template<class U>
+  static void check(helper<&U::template SomeFuncTemplate<int> > *);
+};
+
+int main()
+{
+  TTest2< void (AType::*)() >::check<AType>(0);
+}