diff options
Diffstat (limited to 'clang/lib/AST/ASTContext.cpp')
| -rw-r--r-- | clang/lib/AST/ASTContext.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp index deb80900bb3..f4266fb90d1 100644 --- a/clang/lib/AST/ASTContext.cpp +++ b/clang/lib/AST/ASTContext.cpp @@ -2036,14 +2036,30 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) { 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, |

