summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2011-09-24 00:56:59 +0000
committerFariborz Jahanian <fjahanian@apple.com>2011-09-24 00:56:59 +0000
commit11ee283e2a9e6af8b5b9acde742ed712d9e8c791 (patch)
treefd0c41a45169ef31297086e2121cec1e40ea68d5
parentcac9c5f971eb7fda865982dbb6180d77aa5a45bf (diff)
downloadbcm5719-llvm-11ee283e2a9e6af8b5b9acde742ed712d9e8c791.tar.gz
bcm5719-llvm-11ee283e2a9e6af8b5b9acde742ed712d9e8c791.zip
objc - redeclaration of property in extension class
must match property type declaration in its primary class. // rdar://10142679 llvm-svn: 140438
-rw-r--r--clang/include/clang/Basic/DiagnosticSemaKinds.td3
-rw-r--r--clang/lib/Sema/SemaObjCProperty.cpp8
-rw-r--r--clang/test/SemaObjC/continuation-class-property.m19
-rw-r--r--clang/test/SemaObjCXX/property-synthesis-error.mm2
4 files changed, 30 insertions, 2 deletions
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 0dd84d221dc..5da5288cca0 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -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 "
diff --git a/clang/lib/Sema/SemaObjCProperty.cpp b/clang/lib/Sema/SemaObjCProperty.cpp
index 2bb54560b76..6284f36e416 100644
--- a/clang/lib/Sema/SemaObjCProperty.cpp
+++ b/clang/lib/Sema/SemaObjCProperty.cpp
@@ -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();
diff --git a/clang/test/SemaObjC/continuation-class-property.m b/clang/test/SemaObjC/continuation-class-property.m
index c48a23d62a9..e398ae54985 100644
--- a/clang/test/SemaObjC/continuation-class-property.m
+++ b/clang/test/SemaObjC/continuation-class-property.m
@@ -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
diff --git a/clang/test/SemaObjCXX/property-synthesis-error.mm b/clang/test/SemaObjCXX/property-synthesis-error.mm
index c7a279cfd7a..c67f0a45c74 100644
--- a/clang/test/SemaObjCXX/property-synthesis-error.mm
+++ b/clang/test/SemaObjCXX/property-synthesis-error.mm
@@ -10,7 +10,7 @@
NSMutableArray * _array;
}
-@property (readonly) NSArray * array;
+@property (readonly) NSMutableArray * array;
@end
OpenPOWER on IntegriCloud