]> granicus.if.org Git - clang/commitdiff
Patch to match and issue diagnostics on property type mismatch.
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 1 May 2008 18:05:01 +0000 (18:05 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 1 May 2008 18:05:01 +0000 (18:05 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50532 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticKinds.def
lib/Sema/SemaDeclObjC.cpp
test/Sema/objc-property-3.m [new file with mode: 0644]

index 07d15194405949a85f4afb9a00fb0a461dcf5f19..396bd40ae84448cf708bcc0bbf54e79eeafefb61 100644 (file)
@@ -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
index da7b1513c85afdff81f50c3be3ee1d8e7e0e54b2..e95ad6469bab56945dd7955748764319e2c98546 100644 (file)
@@ -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 (file)
index 0000000..565a006
--- /dev/null
@@ -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
+