Index: test/Sema/compare.c
===================================================================
--- test/Sema/compare.c	(revision 74647)
+++ test/Sema/compare.c	(working copy)
@@ -1,5 +1,7 @@
 // RUN: clang-cc -fsyntax-only -pedantic -verify %s
 
+#include <stddef.h>
+
 int test(char *C) { // nothing here should warn.
   return C != ((void*)0);
   return C != (void*)0;
@@ -27,5 +29,10 @@
   return a > b; // expected-warning {{ordered comparison of function pointers}}
   return function_pointers > function_pointers; // expected-warning {{ordered comparison of function pointers}}
   return a == (void *) 0;
-  return a == (void *) 1; // expected-warning {{comparison of distinct pointer types}}
+  return a == (void *) 1;
 }
+
+int void_pointers(void *foo)
+{
+  return foo == NULL;
+}
Index: lib/Sema/SemaExpr.cpp
===================================================================
--- lib/Sema/SemaExpr.cpp	(revision 74647)
+++ lib/Sema/SemaExpr.cpp	(working copy)
@@ -4110,17 +4110,17 @@
     QualType RCanPointeeTy =
       Context.getCanonicalType(rType->getAsPointerType()->getPointeeType());
 
-    if (rType->isFunctionPointerType() || lType->isFunctionPointerType()) {
-      if (isRelational) {
+    if (isRelational) {
+      if (rType->isFunctionPointerType() || lType->isFunctionPointerType()) {
         Diag(Loc, diag::ext_typecheck_ordered_comparison_of_function_pointers)
           << lType << rType << lex->getSourceRange() << rex->getSourceRange();
       }
+      if (LCanPointeeTy->isVoidType() != RCanPointeeTy->isVoidType()) {
+        Diag(Loc, diag::ext_typecheck_comparison_of_distinct_pointers)
+          << lType << rType << lex->getSourceRange() << rex->getSourceRange();
+      }
     }
-    if (((!LHSIsNull || isRelational) && LCanPointeeTy->isVoidType()) !=
-        ((!RHSIsNull || isRelational) && RCanPointeeTy->isVoidType())) {
-      Diag(Loc, diag::ext_typecheck_comparison_of_distinct_pointers)
-        << lType << rType << lex->getSourceRange() << rex->getSourceRange();
-    }
+
     // Simple check: if the pointee types are identical, we're done.
     if (LCanPointeeTy == RCanPointeeTy)
       return ResultTy;
