[cfe-commits] r149888 - in /cfe/trunk: lib/AST/ASTContext.cpp test/SemaObjC/block-type-safety.m

Fariborz Jahanian fjahanian at apple.com
Mon Feb 6 11:06:20 PST 2012


Author: fjahanian
Date: Mon Feb  6 13:06:20 2012
New Revision: 149888

URL: http://llvm.org/viewvc/llvm-project?rev=149888&view=rev
Log:
objc: fixes a problem in block type comparison involving
enums with underlying type explicitly specified
(feature which is on by default in objective-c). 
// rdar://10798770

Modified:
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/test/SemaObjC/block-type-safety.m

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=149888&r1=149887&r2=149888&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Mon Feb  6 13:06:20 2012
@@ -5960,11 +5960,13 @@
     // Compatibility is based on the underlying type, not the promotion
     // type.
     if (const EnumType* ETy = LHS->getAs<EnumType>()) {
-      if (ETy->getDecl()->getIntegerType() == RHSCan.getUnqualifiedType())
+      QualType TINT = ETy->getDecl()->getIntegerType();
+      if (!TINT.isNull() && hasSameType(TINT, RHSCan.getUnqualifiedType()))
         return RHS;
     }
     if (const EnumType* ETy = RHS->getAs<EnumType>()) {
-      if (ETy->getDecl()->getIntegerType() == LHSCan.getUnqualifiedType())
+      QualType TINT = ETy->getDecl()->getIntegerType();
+      if (!TINT.isNull() && hasSameType(TINT, LHSCan.getUnqualifiedType()))
         return LHS;
     }
     // allow block pointer type to match an 'id' type.

Modified: cfe/trunk/test/SemaObjC/block-type-safety.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/block-type-safety.m?rev=149888&r1=149887&r2=149888&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/block-type-safety.m (original)
+++ cfe/trunk/test/SemaObjC/block-type-safety.m Mon Feb  6 13:06:20 2012
@@ -138,3 +138,20 @@
     return 0;
 }
 
+// rdar://10798770
+typedef int NSInteger;
+
+typedef enum : NSInteger {NSOrderedAscending = -1L, NSOrderedSame, NSOrderedDescending} NSComparisonResult;
+
+typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
+
+ at interface radar10798770
+- (void)sortUsingComparator:(NSComparator)c;
+ at end
+
+void f() {
+   radar10798770 *f;
+   [f sortUsingComparator:^(id a, id b) {
+        return NSOrderedSame;
+   }];
+}





More information about the cfe-commits mailing list