objc - redeclaration of property in extension class

must match property type declaration in its
primary class. // rdar://10142679

llvm-svn: 140438
This commit is contained in:
Fariborz Jahanian 2011-09-24 00:56:59 +00:00
parent cac9c5f971
commit 11ee283e2a
4 changed files with 30 additions and 2 deletions

View File

@ -516,6 +516,9 @@ def warn_default_atomic_custom_getter_setter : Warning<
def err_use_continuation_class : Error<
"illegal redeclaration of property in continuation class %0"
" (attribute must be 'readwrite', while its primary must be 'readonly')">;
def error_type_mismatch_continuation_class : Error<
"type of property %0 in continuation class does not match"
"property type in primary class">;
def err_use_continuation_class_redeclaration_readwrite : Error<
"illegal redeclaration of 'readwrite' property in continuation class %0"
" (perhaps you intended this to be a 'readwrite' redeclaration of a "

View File

@ -235,7 +235,13 @@ Sema::HandlePropertyInClassExtension(Scope *S,
/* lexicalDC = */ CDecl);
return PDecl;
}
if (PIDecl->getType().getCanonicalType()
!= PDecl->getType().getCanonicalType()) {
Diag(AtLoc,
diag::error_type_mismatch_continuation_class) << PDecl->getType();
Diag(PIDecl->getLocation(), diag::note_property_declare);
}
// The property 'PIDecl's readonly attribute will be over-ridden
// with continuation class's readwrite property attribute!
unsigned PIkind = PIDecl->getPropertyAttributesAsWritten();

View File

@ -22,3 +22,22 @@
@property (readwrite, copy) id foos;
@end
// rdar://10142679
@class NSString;
typedef struct {
float width;
float length;
} NSRect;
@interface MyClass {
}
@property (readonly) NSRect foo; // expected-note {{property declared here}}
@property (readonly, strong) NSString *bar; // expected-note {{property declared here}}
@end
@interface MyClass ()
@property (readwrite) NSString *foo; // expected-error {{type of property 'NSString *' in continuation class does not matchproperty type in primary class}}
@property (readwrite, strong) NSRect bar; // expected-error {{type of property 'NSRect' in continuation class does not matchproperty type in primary class}}
@end

View File

@ -10,7 +10,7 @@
NSMutableArray * _array;
}
@property (readonly) NSArray * array;
@property (readonly) NSMutableArray * array;
@end