diff options
Diffstat (limited to 'lib/AST/ASTContext.cpp')
-rw-r--r-- | lib/AST/ASTContext.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 9ed6251089..e24de53314 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -2680,6 +2680,15 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) { // If the canonical type classes don't match. if (LHSClass != RHSClass) { + const ObjCInterfaceType* LHSIface = LHS->getAsObjCInterfaceType(); + const ObjCInterfaceType* RHSIface = RHS->getAsObjCInterfaceType(); + + // ID acts sort of like void* for ObjC interfaces + if (LHSIface && isObjCIdStructType(RHS)) + return LHS; + if (RHSIface && isObjCIdStructType(LHS)) + return RHS; + // ID is compatible with all qualified id types. if (LHS->isObjCQualifiedIdType()) { if (const PointerType *PT = RHS->getAsPointerType()) { @@ -2808,8 +2817,13 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) { return LHS; return QualType(); case Type::ObjCInterface: - // Distinct ObjC interfaces are not compatible; see canAssignObjCInterfaces - // for checking assignment/comparison safety + // Check if the interfaces are assignment compatible. + const ObjCInterfaceType* LHSIface = LHS->getAsObjCInterfaceType(); + const ObjCInterfaceType* RHSIface = RHS->getAsObjCInterfaceType(); + if (LHSIface && RHSIface && + canAssignObjCInterfaces(LHSIface, RHSIface)) + return LHS; + return QualType(); case Type::ObjCQualifiedId: // Distinct qualified id's are not compatible. |