objc++: Some level of covariance is allowed in ObjC properties.

Make it also available in ObjC++ propeties. // rdar://9740328

llvm-svn: 135001
This commit is contained in:
Fariborz Jahanian 2011-07-12 22:05:16 +00:00
parent ce206000d3
commit c0f6af2103
4 changed files with 25 additions and 1 deletions

View File

@ -1417,6 +1417,7 @@ public:
bool typesAreCompatible(QualType T1, QualType T2,
bool CompareUnqualified = false); // C99 6.2.7p1
bool propertyTypesAreCompatible(QualType, QualType);
bool typesAreBlockPointerCompatible(QualType, QualType);
bool isObjCIdType(QualType T) const {

View File

@ -5441,6 +5441,10 @@ bool ASTContext::typesAreCompatible(QualType LHS, QualType RHS,
return !mergeTypes(LHS, RHS, false, CompareUnqualified).isNull();
}
bool ASTContext::propertyTypesAreCompatible(QualType LHS, QualType RHS) {
return !mergeTypes(LHS, RHS, false, false).isNull();
}
bool ASTContext::typesAreBlockPointerCompatible(QualType LHS, QualType RHS) {
return !mergeTypes(LHS, RHS, true).isNull();
}

View File

@ -909,7 +909,7 @@ Sema::DiagnosePropertyMismatch(ObjCPropertyDecl *Property,
QualType RHSType =
Context.getCanonicalType(Property->getType());
if (!Context.typesAreCompatible(LHSType, RHSType)) {
if (!Context.propertyTypesAreCompatible(LHSType, RHSType)) {
// FIXME: Incorporate this test with typesAreCompatible.
if (LHSType->isObjCQualifiedIdType() && RHSType->isObjCQualifiedIdType())
if (Context.ObjCQualifiedIdTypesAreCompatible(LHSType, RHSType, false))

View File

@ -0,0 +1,19 @@
// RUN: %clang_cc1 -fsyntax-only -verify %s
// rdar://9740328
@protocol P1;
@interface NSObject
@end
@interface A : NSObject
@property (assign) NSObject<P1> *prop;
@end
@protocol P2 <P1>
@end
@interface B : A
@property (assign) NSObject<P2> *prop;
@end