forked from OSchip/llvm-project
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 llvm-svn: 149888
This commit is contained in:
parent
206dddda15
commit
adfe905145
|
@ -5960,11 +5960,13 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS,
|
||||||
// Compatibility is based on the underlying type, not the promotion
|
// Compatibility is based on the underlying type, not the promotion
|
||||||
// type.
|
// type.
|
||||||
if (const EnumType* ETy = LHS->getAs<EnumType>()) {
|
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;
|
return RHS;
|
||||||
}
|
}
|
||||||
if (const EnumType* ETy = RHS->getAs<EnumType>()) {
|
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;
|
return LHS;
|
||||||
}
|
}
|
||||||
// allow block pointer type to match an 'id' type.
|
// allow block pointer type to match an 'id' type.
|
||||||
|
|
|
@ -138,3 +138,20 @@ int test5() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// rdar://10798770
|
||||||
|
typedef int NSInteger;
|
||||||
|
|
||||||
|
typedef enum : NSInteger {NSOrderedAscending = -1L, NSOrderedSame, NSOrderedDescending} NSComparisonResult;
|
||||||
|
|
||||||
|
typedef NSComparisonResult (^NSComparator)(id obj1, id obj2);
|
||||||
|
|
||||||
|
@interface radar10798770
|
||||||
|
- (void)sortUsingComparator:(NSComparator)c;
|
||||||
|
@end
|
||||||
|
|
||||||
|
void f() {
|
||||||
|
radar10798770 *f;
|
||||||
|
[f sortUsingComparator:^(id a, id b) {
|
||||||
|
return NSOrderedSame;
|
||||||
|
}];
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue