Downgrade incompatibilities with objc qualified types (e.g. id <P>) to warnings.
Note: One day, we should consider moving the actual diags to ObjCQualifiedIdTypesAreCompatible(), since it has more information on the actual problem. GCC currently emits slightly more instructive errors for some cases involving protocols. I added a FIXME to the code.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57529 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index a6197dd..c8610da 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1587,7 +1587,7 @@
       return IntToPointer;
     if (lhsType->isIntegerType())
       return PointerToInt;
-    return Incompatible;
+    return IncompatibleObjCQualifiedId;
   }
 
   if (lhsType->isVectorType() || rhsType->isVectorType()) {
@@ -2034,6 +2034,13 @@
     if (ObjCQualifiedIdTypesAreCompatible(lType, rType, true)) {
       ImpCastExprToType(rex, lType);
       return Context.IntTy;
+    } else {
+      if ((lType->isObjCQualifiedIdType() && rType->isObjCQualifiedIdType())) {
+        Diag(loc, diag::warn_incompatible_qualified_id_operands, 
+             lex->getType().getAsString(), rex->getType().getAsString(),
+             lex->getSourceRange(), rex->getSourceRange());
+        return QualType();
+      }
     }
   }
   if ((lType->isPointerType() || lType->isObjCQualifiedIdType()) && 
@@ -3078,6 +3085,11 @@
   case BlockVoidPointer:
     DiagKind = diag::ext_typecheck_convert_pointer_void_block;
     break;
+  case IncompatibleObjCQualifiedId:
+    // FIXME: Diagnose the problem in ObjCQualifiedIdTypesAreCompatible, since 
+    // it can give a more specific diagnostic.
+    DiagKind = diag::warn_incompatible_qualified_id;
+    break;
   case Incompatible:
     DiagKind = diag::err_typecheck_convert_incompatible;
     isInvalid = true;