[cfe-commits] r50532 - in /cfe/trunk: include/clang/Basic/DiagnosticKinds.def lib/Sema/SemaDeclObjC.cpp test/Sema/objc-property-3.m

Fariborz Jahanian fjahanian at apple.com
Thu May 1 11:05:01 PDT 2008


Author: fjahanian
Date: Thu May  1 13:05:01 2008
New Revision: 50532

URL: http://llvm.org/viewvc/llvm-project?rev=50532&view=rev
Log:
Patch to match and issue diagnostics on property type mismatch.

Added:
    cfe/trunk/test/Sema/objc-property-3.m
Modified:
    cfe/trunk/include/clang/Basic/DiagnosticKinds.def
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticKinds.def?rev=50532&r1=50531&r2=50532&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticKinds.def (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticKinds.def Thu May  1 13:05:01 2008
@@ -514,6 +514,8 @@
 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

Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=50532&r1=50531&r2=50532&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu May  1 13:05:01 2008
@@ -286,14 +286,10 @@
          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());
   
 }
 

Added: cfe/trunk/test/Sema/objc-property-3.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/objc-property-3.m?rev=50532&view=auto

==============================================================================
--- cfe/trunk/test/Sema/objc-property-3.m (added)
+++ cfe/trunk/test/Sema/objc-property-3.m Thu May  1 13:05:01 2008
@@ -0,0 +1,15 @@
+// RUN: clang -verify %s
+
+ at interface I 
+{
+	id d1;
+}
+ at property (readwrite, copy) id d1;
+ at property (readwrite, copy) id d2;
+ at end
+
+ at interface NOW : I
+ at 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}}
+ at property (readwrite, copy) I* d2; // expected-warning {{property type 'I *' does not match super class 'I' property type}}
+ at end
+





More information about the cfe-commits mailing list