diff options
author | Steve Naroff <snaroff@apple.com> | 2008-06-04 15:07:33 +0000 |
---|---|---|
committer | Steve Naroff <snaroff@apple.com> | 2008-06-04 15:07:33 +0000 |
commit | 97341620065b89f5197b846be94c4cfad5df2af4 (patch) | |
tree | 6350d90b367cce50281683f60260f3e5443487dd | |
parent | 9ad23d6f454e64b2ff960721becc5b90dea4d353 (diff) |
ASTContext::typesAreCompatible(): id is compatible with all qualified id types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51939 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/AST/ASTContext.cpp | 11 | ||||
-rw-r--r-- | test/Sema/objc-types-compatible.m | 16 |
2 files changed, 26 insertions, 1 deletions
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index 5a3ca44a6b..a87efa7425 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -1639,7 +1639,16 @@ bool ASTContext::typesAreCompatible(QualType LHS_NC, QualType RHS_NC) { return isObjCIdType(RHS); if (isa<ObjCInterfaceType>(RHS)) return isObjCIdType(LHS); - + + // ID is compatible with all qualified id types. + if (isa<ObjCQualifiedIdType>(LHS)) { + if (const PointerType *PT = RHS->getAsPointerType()) + return isObjCIdType(PT->getPointeeType()); + } + if (isa<ObjCQualifiedIdType>(RHS)) { + if (const PointerType *PT = LHS->getAsPointerType()) + return isObjCIdType(PT->getPointeeType()); + } // C99 6.7.2.2p4: Each enumerated type shall be compatible with char, // a signed integer type, or an unsigned integer type. if (LHS->isEnumeralType() && RHS->isIntegralType()) { diff --git a/test/Sema/objc-types-compatible.m b/test/Sema/objc-types-compatible.m new file mode 100644 index 0000000000..a07962bf08 --- /dev/null +++ b/test/Sema/objc-types-compatible.m @@ -0,0 +1,16 @@ +// RUN: clang -fsyntax-only -verify %s +typedef signed char BOOL; +typedef int NSInteger; + +@class NSString; + +@protocol PBXCompletionItem +- (NSString *) name; +- (NSInteger)priority; +@end + +extern NSInteger codeAssistantCaseCompareItems(id a, id b, void *context); + +NSInteger codeAssistantCaseCompareItems(id<PBXCompletionItem> a, id<PBXCompletionItem> b, void *context) +{ +} |