diff options
-rw-r--r-- | include/clang/Basic/DiagnosticKinds.def | 2 | ||||
-rw-r--r-- | lib/Sema/SemaDeclObjC.cpp | 12 | ||||
-rw-r--r-- | test/Sema/objc-property-3.m | 15 |
3 files changed, 21 insertions, 8 deletions
diff --git a/include/clang/Basic/DiagnosticKinds.def b/include/clang/Basic/DiagnosticKinds.def index 07d1519440..396bd40ae8 100644 --- a/include/clang/Basic/DiagnosticKinds.def +++ b/include/clang/Basic/DiagnosticKinds.def @@ -514,6 +514,8 @@ DIAG(warn_readonly_property, WARNING, DIAG(warn_property_attribute, WARNING, "property '%0' '%1' attribute does not match super class '%2' " "property") +DIAG(warn_property_type, WARNING, + "property type '%0' does not match super class '%1' property type") //===----------------------------------------------------------------------===// // Semantic Analysis diff --git a/lib/Sema/SemaDeclObjC.cpp b/lib/Sema/SemaDeclObjC.cpp index da7b1513c8..e95ad6469b 100644 --- a/lib/Sema/SemaDeclObjC.cpp +++ b/lib/Sema/SemaDeclObjC.cpp @@ -286,14 +286,10 @@ Sema::DiagnosePropertyMismatch(ObjCPropertyDecl *Property, Property->getName(), "getter", SuperIDecl->getName(), SourceRange()); - if (Property->getCanonicalType() != SuperProperty->getCanonicalType()) { - if ((CAttr & ObjCPropertyDecl::OBJC_PR_readonly) - && (SAttr & ObjCPropertyDecl::OBJC_PR_readonly)) - // && objc_compare_types(...)) - ; - else - ; // - } + if (Property->getCanonicalType() != SuperProperty->getCanonicalType()) + Diag(Property->getLocation(), diag::warn_property_type, + Property->getType().getAsString(), + SuperIDecl->getName()); } diff --git a/test/Sema/objc-property-3.m b/test/Sema/objc-property-3.m new file mode 100644 index 0000000000..565a006fe4 --- /dev/null +++ b/test/Sema/objc-property-3.m @@ -0,0 +1,15 @@ +// RUN: clang -verify %s + +@interface I +{ + id d1; +} +@property (readwrite, copy) id d1; +@property (readwrite, copy) id d2; +@end + +@interface NOW : I +@property (readonly, retain) id d1; // expected-warning {{attribute 'readonly' of property 'd1' restricts attribute 'readwrite' of 'I' property in super class}} expected-warning {{property 'd1' 'copy' attribute does not match super class 'I' property}} +@property (readwrite, copy) I* d2; // expected-warning {{property type 'I *' does not match super class 'I' property type}} +@end + |