Fix <rdar://problem/6315646> clang on xcode: error: invalid operands to binary expression ('id<NSTableViewDelegate>' and 'XCExtendedArrayController *').

There is still a bug here (as the FIXME in the test case indicates). Prior to this patch, the bug would generate an error. Now, we simply do nothing (which is less harmful until we can get it right). The complete bug fix will require changing ASTContext::mergeTypes(), which I'd like to defer for now.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@58241 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 5304fd9..d1be2a4 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -2147,11 +2147,14 @@
   }
 
   if ((lType->isObjCQualifiedIdType() || rType->isObjCQualifiedIdType())) {
-    if ((lType->isPointerType() || rType->isPointerType()) &&
-        !Context.typesAreCompatible(lType, rType)) {
-      Diag(loc, diag::ext_typecheck_comparison_of_distinct_pointers,
-           lType.getAsString(), rType.getAsString(),
-           lex->getSourceRange(), rex->getSourceRange());
+    if (lType->isPointerType() || rType->isPointerType()) {
+      if (!Context.typesAreCompatible(lType, rType)) {
+        Diag(loc, diag::ext_typecheck_comparison_of_distinct_pointers,
+             lType.getAsString(), rType.getAsString(),
+             lex->getSourceRange(), rex->getSourceRange());
+        ImpCastExprToType(rex, lType);
+        return Context.IntTy;
+      }
       ImpCastExprToType(rex, lType);
       return Context.IntTy;
     }