diff options
author | Fariborz Jahanian <fjahanian@apple.com> | 2012-02-02 18:54:58 +0000 |
---|---|---|
committer | Fariborz Jahanian <fjahanian@apple.com> | 2012-02-02 18:54:58 +0000 |
commit | e23518342e326e3d6e9139f05384f030e2a94d4a (patch) | |
tree | 03474664dc4825e4bc4f6b1661ea412e8ee758a9 | |
parent | ee2127733af888638f830de5d5c4057cd98d7c77 (diff) |
objective-c: When redeclaraing in continuation class a 'readonly'
property to 'readwrite', also allow redeclaration of
property type to a narrowring object type.
// rdar://10790488
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149614 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/Sema/SemaObjCProperty.cpp | 17 | ||||
-rw-r--r-- | test/SemaObjC/narrow-property-type-in-cont-class.m | 19 |
2 files changed, 31 insertions, 5 deletions
diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index b4aee7c0dd..7f6d8c34f4 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -276,11 +276,18 @@ Sema::HandlePropertyInClassExtension(Scope *S, L->AddedObjCPropertyInClassExtension(PDecl, /*OrigProp=*/0, CDecl); return PDecl; } - if (PIDecl->getType().getCanonicalType() - != PDecl->getType().getCanonicalType()) { - Diag(AtLoc, - diag::err_type_mismatch_continuation_class) << PDecl->getType(); - Diag(PIDecl->getLocation(), diag::note_property_declare); + if (!Context.hasSameType(PIDecl->getType(), PDecl->getType())) { + bool IncompatibleObjC = false; + QualType ConvertedType; + if (!isa<ObjCObjectPointerType>(PIDecl->getType()) || + !isa<ObjCObjectPointerType>(PDecl->getType()) || + (!isObjCPointerConversion(PDecl->getType(), PIDecl->getType(), + ConvertedType, IncompatibleObjC)) + || IncompatibleObjC) { + Diag(AtLoc, + diag::err_type_mismatch_continuation_class) << PDecl->getType(); + Diag(PIDecl->getLocation(), diag::note_property_declare); + } } // The property 'PIDecl's readonly attribute will be over-ridden diff --git a/test/SemaObjC/narrow-property-type-in-cont-class.m b/test/SemaObjC/narrow-property-type-in-cont-class.m new file mode 100644 index 0000000000..3ba848f03a --- /dev/null +++ b/test/SemaObjC/narrow-property-type-in-cont-class.m @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -x objective-c -fsyntax-only -verify %s +// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify %s +// rdar://10790488 + +@interface NSArray @end + +@interface NSMutableArray : NSArray +@end + +@interface GKTurnBasedMatchMakerKVO +@property(nonatomic,readonly,retain) NSArray* outline; +@property(nonatomic,readonly,retain) NSMutableArray* err_outline; // expected-note {{property declared here}} +@end + +@interface GKTurnBasedMatchMakerKVO () +@property(nonatomic,readwrite,retain) NSMutableArray* outline; +@property(nonatomic,readwrite,retain) NSArray* err_outline; // expected-error {{type of property 'NSArray *' in continuation class does not match property type in primary class}} +@end + |