[cfe-commits] r51939 - in /cfe/trunk: lib/AST/ASTContext.cpp test/Sema/objc-types-compatible.m

Steve Naroff snaroff at apple.com
Wed Jun 4 08:07:33 PDT 2008


Author: snaroff
Date: Wed Jun  4 10:07:33 2008
New Revision: 51939

URL: http://llvm.org/viewvc/llvm-project?rev=51939&view=rev
Log:
ASTContext::typesAreCompatible(): id is compatible with all qualified id types.

Added:
    cfe/trunk/test/Sema/objc-types-compatible.m
Modified:
    cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=51939&r1=51938&r2=51939&view=diff

==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Wed Jun  4 10:07:33 2008
@@ -1639,7 +1639,16 @@
       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()) {

Added: cfe/trunk/test/Sema/objc-types-compatible.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/objc-types-compatible.m?rev=51939&view=auto

==============================================================================
--- cfe/trunk/test/Sema/objc-types-compatible.m (added)
+++ cfe/trunk/test/Sema/objc-types-compatible.m Wed Jun  4 10:07:33 2008
@@ -0,0 +1,16 @@
+// RUN: clang -fsyntax-only -verify %s
+typedef signed char BOOL;
+typedef int NSInteger;
+
+ at class NSString;
+
+ at protocol PBXCompletionItem
+- (NSString *) name;
+- (NSInteger)priority;
+ at end
+
+extern NSInteger codeAssistantCaseCompareItems(id a, id b, void *context);
+
+NSInteger codeAssistantCaseCompareItems(id<PBXCompletionItem> a, id<PBXCompletionItem> b, void *context)
+{
+}





More information about the cfe-commits mailing list