Handle CK_NullToMemberPointer in ScalarExprEmitter::EmitCast

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79929 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index d94ee5b..0524b44 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -656,7 +656,14 @@
                                        CastExpr::CastKind Kind) {
   if (!DestTy->isVoidType())
     TestAndClearIgnoreResultAssign();
-
+  
+  switch (Kind) {
+  default:
+    break;
+  case CastExpr::CK_NullToMemberPointer:
+    return CGF.CGM.EmitNullConstant(DestTy);
+  }
+  
   // Handle cases where the source is an non-complex type.
   
   if (!CGF.hasAggregateLLVMType(E->getType())) {
diff --git a/test/CodeGenCXX/member-pointers-zero-init.cpp b/test/CodeGenCXX/member-pointers-zero-init.cpp
index d533600..e7b0fda 100644
--- a/test/CodeGenCXX/member-pointers-zero-init.cpp
+++ b/test/CodeGenCXX/member-pointers-zero-init.cpp
@@ -17,11 +17,18 @@
 int A::* b = 0;
 
 void f() {
-  // RUN: grep "%.* = icmp ne i64 %.*, -1" %t
+  // RUN: grep "%.* = icmp ne i64 %.*, -1" %t | count 2 &&
   if (a) { }
+  if (a != 0) { }
+
+  // RUN: grep "%.* = icmp ne i64 -1, %.*" %t | count 1 &&
+  if (0 != a) { }
   
-  // FIXME: This doesn't yet work
-//  if (a != 0) { }
+  // RUN: grep "%.* = icmp eq i64 %.*, -1" %t | count 1 &&
+  if (a == 0) { }
+
+  // RUN: grep "%.* = icmp eq i64 -1, %.*" %t | count 1
+  if (0 == a) { }
     
 }