Fix a bug where we didn't check the RHS for null, we checked
the LHS for null twice.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@49138 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 9d75f4f..d4a97c1 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1494,13 +1494,15 @@
   // when handling null pointer constants. One day, we can consider making them
   // errors (when -pedantic-errors is enabled).
   if (lType->isPointerType() && rType->isPointerType()) { // C99 6.5.8p2
-    QualType lpointee = lType->getAsPointerType()->getPointeeType();
-    QualType rpointee = rType->getAsPointerType()->getPointeeType();
+    QualType LCanPointeeTy =
+      lType->getAsPointerType()->getPointeeType().getCanonicalType();
+    QualType RCanPointeeTy =
+      rType->getAsPointerType()->getPointeeType().getCanonicalType();
     
     if (!LHSIsNull && !RHSIsNull &&                       // C99 6.5.9p2
-        !lpointee->isVoidType() && !lpointee->isVoidType() &&
-        !Context.typesAreCompatible(lpointee.getUnqualifiedType(),
-                                    rpointee.getUnqualifiedType())) {
+        !LCanPointeeTy->isVoidType() && !RCanPointeeTy->isVoidType() &&
+        !Context.typesAreCompatible(LCanPointeeTy.getUnqualifiedType(),
+                                    RCanPointeeTy.getUnqualifiedType())) {
       Diag(loc, diag::ext_typecheck_comparison_of_distinct_pointers,
            lType.getAsString(), rType.getAsString(),
            lex->getSourceRange(), rex->getSourceRange());