diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2011-07-12 22:05:16 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2011-07-12 22:05:16 +0000 |
commit | c286f3835eb6001c61664cef5d610dfaf80a6e9b (patch) | |
tree | e85d8866baac3af7dbab9fb66fbcc6b6059e57a3 | |
parent | c51af6ce4c609bc3181ad8c28bad8af168db49db (diff) |
objc++: Some level of covariance is allowed in ObjC properties.
Make it also available in ObjC++ propeties. // rdar://9740328
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135001 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | include/clang/AST/ASTContext.h | 1 | ||||
-rw-r--r-- | lib/AST/ASTContext.cpp | 4 | ||||
-rw-r--r-- | lib/Sema/SemaObjCProperty.cpp | 2 | ||||
-rw-r--r-- | test/SemaObjCXX/property-type-mismatch.mm | 19 |
4 files changed, 25 insertions, 1 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index 6d8158661d..1526f36ba2 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -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 { diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index c844adea3e..71b76c9d32 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -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(); } diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index c830c3e166..27f25c27ad 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -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)) diff --git a/test/SemaObjCXX/property-type-mismatch.mm b/test/SemaObjCXX/property-type-mismatch.mm new file mode 100644 index 0000000000..059793cf5c --- /dev/null +++ b/test/SemaObjCXX/property-type-mismatch.mm @@ -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 + |