Add support for member pointers to const_cast.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@63055 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaNamedCast.cpp b/lib/Sema/SemaNamedCast.cpp
index 06fc9d8..2aeab44 100644
--- a/lib/Sema/SemaNamedCast.cpp
+++ b/lib/Sema/SemaNamedCast.cpp
@@ -133,7 +133,10 @@
     SrcType = SrcExpr->getType();
   }
 
-  if (!DestType->isPointerType()) {
+  // C++ 5.2.11p5: For a const_cast involving pointers to data members [...]
+  //   the rules for const_cast are the same as those used for pointers.
+
+  if (!DestType->isPointerType() && !DestType->isMemberPointerType()) {
     // Cannot cast to non-pointer, non-reference type. Note that, if DestType
     // was a reference type, we converted it to a pointer above.
     // C++ 5.2.11p3: For two pointer types [...]
@@ -141,7 +144,8 @@
       << OrigDestType << DestRange;
     return;
   }
-  if (DestType->isFunctionPointerType()) {
+  if (DestType->isFunctionPointerType() ||
+      DestType->isMemberFunctionPointerType()) {
     // Cannot cast direct function pointers.
     // C++ 5.2.11p2: [...] where T is any object type or the void type [...]
     // T is the ultimate pointee of source and target type.