From: Fariborz Jahanian Date: Thu, 1 May 2008 18:05:01 +0000 (+0000) Subject: Patch to match and issue diagnostics on property type mismatch. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3435096781465f6b8e69de4b35d9dd3a94a76468;p=clang Patch to match and issue diagnostics on property type mismatch. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50532 91177308-0d34-0410-b5e6-96231b3b80d8 --- 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 +