Sema::CheckCompareOperands() and ASTContext::mergeTypes(): Change handling of ObjC qualified id types to be consistent with gcc. This changes a handful of test case errors into warnings (diff will tell you which cases have changed).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@57841 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index deb8090..f4266fb 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -2036,14 +2036,30 @@
if (LHSClass != RHSClass) {
// ID is compatible with all qualified id types.
if (LHS->isObjCQualifiedIdType()) {
- if (const PointerType *PT = RHS->getAsPointerType())
- if (isObjCIdType(PT->getPointeeType()))
+ if (const PointerType *PT = RHS->getAsPointerType()) {
+ QualType pType = PT->getPointeeType();
+ if (isObjCIdType(pType))
return LHS;
+ // FIXME: need to use ObjCQualifiedIdTypesAreCompatible(LHS, RHS, true).
+ // Unfortunately, this API is part of Sema (which we don't have access
+ // to. Need to refactor. The following check is insufficient, since we
+ // need to make sure the class implements the protocol.
+ if (pType->isObjCInterfaceType())
+ return LHS;
+ }
}
if (RHS->isObjCQualifiedIdType()) {
- if (const PointerType *PT = LHS->getAsPointerType())
- if (isObjCIdType(PT->getPointeeType()))
+ if (const PointerType *PT = LHS->getAsPointerType()) {
+ QualType pType = PT->getPointeeType();
+ if (isObjCIdType(pType))
return RHS;
+ // FIXME: need to use ObjCQualifiedIdTypesAreCompatible(LHS, RHS, true).
+ // Unfortunately, this API is part of Sema (which we don't have access
+ // to. Need to refactor. The following check is insufficient, since we
+ // need to make sure the class implements the protocol.
+ if (pType->isObjCInterfaceType())
+ return RHS;
+ }
}
// C99 6.7.2.2p4: Each enumerated type shall be compatible with char,