summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2008-06-04 15:07:33 +0000
committerSteve Naroff <snaroff@apple.com>2008-06-04 15:07:33 +0000
commitc68e382ba923f0148720c017a475bd0ce1a10ed4 (patch)
tree68c0ee69c86266f9e9bc67db670faf6266e67b7e
parentf4308aac534fddcb3bac972f3dd37f984f043638 (diff)
downloadbcm5719-llvm-c68e382ba923f0148720c017a475bd0ce1a10ed4.tar.gz
bcm5719-llvm-c68e382ba923f0148720c017a475bd0ce1a10ed4.zip
ASTContext::typesAreCompatible(): id is compatible with all qualified id types.
llvm-svn: 51939
-rw-r--r--clang/lib/AST/ASTContext.cpp11
-rw-r--r--clang/test/Sema/objc-types-compatible.m16
2 files changed, 26 insertions, 1 deletions
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 5a3ca44a6b0..a87efa7425e 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/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/clang/test/Sema/objc-types-compatible.m b/clang/test/Sema/objc-types-compatible.m
new file mode 100644
index 00000000000..a07962bf08b
--- /dev/null
+++ b/clang/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)
+{
+}
OpenPOWER on IntegriCloud