Template argument deduction for member pointers.

Also, introduced some of the framework for performing instantiation as
part of template argument deduction.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@73175 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp
index 0ad7935..6e7a47a 100644
--- a/lib/Sema/SemaTemplateDeduction.cpp
+++ b/lib/Sema/SemaTemplateDeduction.cpp
@@ -408,6 +408,37 @@
       return true;
     }
 
+    //     T type::*
+    //     T T::*
+    //     T (type::*)()
+    //     type (T::*)()
+    //     type (type::*)(T)
+    //     type (T::*)(T)
+    //     T (type::*)(T)
+    //     T (T::*)()
+    //     T (T::*)(T)
+    case Type::MemberPointer: {
+      const MemberPointerType *MemPtrParam = cast<MemberPointerType>(Param);
+      const MemberPointerType *MemPtrArg = dyn_cast<MemberPointerType>(Arg);
+      if (!MemPtrArg)
+        return false;
+
+      return DeduceTemplateArguments(Context,
+                                     MemPtrParam->getPointeeType(),
+                                     MemPtrArg->getPointeeType(),
+                                     Deduced) &&
+        DeduceTemplateArguments(Context,
+                                QualType(MemPtrParam->getClass(), 0),
+                                QualType(MemPtrArg->getClass(), 0),
+                                Deduced);
+    }
+
+    case Type::TypeOfExpr:
+    case Type::TypeOf:
+    case Type::Typename:
+      // No template argument deduction for these types
+      return true;
+
     default:
       break;
   }
@@ -492,6 +523,14 @@
   if (! ::DeduceTemplateArguments(Context, Partial->getTemplateArgs(), 
                                   TemplateArgs, Deduced))
     return 0;
+
+  // FIXME: It isn't clear whether we want the diagnostic to point at
+  // the partial specialization itself or at the actual point of
+  // instantiation.
+  InstantiatingTemplate Inst(*this, Partial->getLocation(), Partial,
+                             Deduced.data(), Deduced.size());
+  if (Inst)
+    return 0;
   
   // FIXME: Substitute the deduced template arguments into the template
   // arguments of the class template partial specialization; the resulting