Allow implicit pointer/int conversions on ObjCQualifiedIdTypes in Sema::CheckCompareOperands() and Sema::CheckAssignmentConstraints().
Fixes <rdar://problem/5980804> clang on xcode: error: incompatible type sending 'id<XDUMLType>', expected 'NSCellType'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51902 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index c384a9a..8b31d88 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -1301,6 +1301,11 @@
if (lhsType->isObjCQualifiedIdType() || rhsType->isObjCQualifiedIdType()) {
if (ObjCQualifiedIdTypesAreCompatible(lhsType, rhsType, false))
return Compatible;
+ // Relax integer conversions like we do for pointers below.
+ if (rhsType->isIntegerType())
+ return IntToPointer;
+ if (lhsType->isIntegerType())
+ return PointerToInt;
return Incompatible;
}
@@ -1647,12 +1652,14 @@
ImpCastExprToType(rex, lType); // promote the pointer to pointer
return Context.IntTy;
}
- if ((lType->isObjCQualifiedIdType() || rType->isObjCQualifiedIdType())
- && ObjCQualifiedIdTypesAreCompatible(lType, rType, true)) {
- ImpCastExprToType(rex, lType);
- return Context.IntTy;
+ if ((lType->isObjCQualifiedIdType() || rType->isObjCQualifiedIdType())) {
+ if (ObjCQualifiedIdTypesAreCompatible(lType, rType, true)) {
+ ImpCastExprToType(rex, lType);
+ return Context.IntTy;
+ }
}
- if (lType->isPointerType() && rType->isIntegerType()) {
+ if ((lType->isPointerType() || lType->isObjCQualifiedIdType()) &&
+ rType->isIntegerType()) {
if (!RHSIsNull)
Diag(loc, diag::ext_typecheck_comparison_of_pointer_integer,
lType.getAsString(), rType.getAsString(),
@@ -1660,7 +1667,8 @@
ImpCastExprToType(rex, lType); // promote the integer to pointer
return Context.IntTy;
}
- if (lType->isIntegerType() && rType->isPointerType()) {
+ if (lType->isIntegerType() &&
+ (rType->isPointerType() || rType->isObjCQualifiedIdType())) {
if (!LHSIsNull)
Diag(loc, diag::ext_typecheck_comparison_of_pointer_integer,
lType.getAsString(), rType.getAsString(),