objc: do not warn when converting to a const id qualfied by its

list of protools. // rdar://10669694

llvm-svn: 148051
This commit is contained in:
Fariborz Jahanian 2012-01-12 22:12:08 +00:00
parent 99415fea87
commit e74d47ed03
2 changed files with 24 additions and 1 deletions

View File

@ -5304,7 +5304,9 @@ checkObjCPointerTypesForAssignment(Sema &S, QualType LHSType,
QualType lhptee = LHSType->getAs<ObjCObjectPointerType>()->getPointeeType();
QualType rhptee = RHSType->getAs<ObjCObjectPointerType>()->getPointeeType();
if (!lhptee.isAtLeastAsQualifiedAs(rhptee))
if (!lhptee.isAtLeastAsQualifiedAs(rhptee) &&
// make an exception for id<P>
!LHSType->isObjCQualifiedIdType())
return Sema::CompatiblePointerDiscardsQualifiers;
if (S.Context.typesAreCompatible(LHSType, RHSType))

View File

@ -0,0 +1,21 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify %s
// rdar://10667659
@protocol NSCopying @end
@interface NSString <NSCopying>
@end
void takeId(id test) {}
void takeCopyableId(id<NSCopying> test) {}
id<NSCopying> Test () {
NSString const *constantString = @"Test";
takeId(constantString);
takeCopyableId(constantString);
id ID = constantString;
id<NSCopying> IDQNSCopying = constantString;
return constantString;
}