aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2008-05-01 18:05:01 +0000
committerFariborz Jahanian <fjahanian@apple.com>2008-05-01 18:05:01 +0000
commit3435096781465f6b8e69de4b35d9dd3a94a76468 (patch)
treedeb812226e4d315940452bf492d29acc713f5e2f
parent24cb8a20ccf9fdd520d2935df3c3ab04476ed4e9 (diff)
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
-rw-r--r--include/clang/Basic/DiagnosticKinds.def2
-rw-r--r--lib/Sema/SemaDeclObjC.cpp12
-rw-r--r--test/Sema/objc-property-3.m15
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
+