forked from OSchip/llvm-project
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:
parent
99415fea87
commit
e74d47ed03
|
@ -5304,7 +5304,9 @@ checkObjCPointerTypesForAssignment(Sema &S, QualType LHSType,
|
||||||
QualType lhptee = LHSType->getAs<ObjCObjectPointerType>()->getPointeeType();
|
QualType lhptee = LHSType->getAs<ObjCObjectPointerType>()->getPointeeType();
|
||||||
QualType rhptee = RHSType->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;
|
return Sema::CompatiblePointerDiscardsQualifiers;
|
||||||
|
|
||||||
if (S.Context.typesAreCompatible(LHSType, RHSType))
|
if (S.Context.typesAreCompatible(LHSType, RHSType))
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
Loading…
Reference in New Issue