[cfe-commits] r140438 - in /cfe/trunk: include/clang/Basic/DiagnosticSemaKinds.td lib/Sema/SemaObjCProperty.cpp test/SemaObjC/continuation-class-property.m test/SemaObjCXX/property-synthesis-error.mm

Fariborz Jahanian fjahanian at apple.com
Fri Sep 23 17:57:00 PDT 2011


Author: fjahanian
Date: Fri Sep 23 19:56:59 2011
New Revision: 140438

URL: http://llvm.org/viewvc/llvm-project?rev=140438&view=rev
Log:
objc - redeclaration of property in extension class
must match property type declaration in its
primary class. // rdar://10142679

Modified:
    cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
    cfe/trunk/lib/Sema/SemaObjCProperty.cpp
    cfe/trunk/test/SemaObjC/continuation-class-property.m
    cfe/trunk/test/SemaObjCXX/property-synthesis-error.mm

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=140438&r1=140437&r2=140438&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Sep 23 19:56:59 2011
@@ -516,6 +516,9 @@
 def err_use_continuation_class : Error<
   "illegal redeclaration of property in continuation class %0"
   " (attribute must be 'readwrite', while its primary must be 'readonly')">;
+def error_type_mismatch_continuation_class : Error<
+  "type of property %0 in continuation class does not match"
+  "property type in primary class">;
 def err_use_continuation_class_redeclaration_readwrite : Error<
   "illegal redeclaration of 'readwrite' property in continuation class %0"
   " (perhaps you intended this to be a 'readwrite' redeclaration of a "

Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=140438&r1=140437&r2=140438&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Fri Sep 23 19:56:59 2011
@@ -235,7 +235,13 @@
                         /* lexicalDC = */ CDecl);
     return PDecl;
   }
-
+  if (PIDecl->getType().getCanonicalType() 
+      != PDecl->getType().getCanonicalType()) {
+    Diag(AtLoc, 
+         diag::error_type_mismatch_continuation_class) << PDecl->getType();
+    Diag(PIDecl->getLocation(), diag::note_property_declare);
+  }
+    
   // The property 'PIDecl's readonly attribute will be over-ridden
   // with continuation class's readwrite property attribute!
   unsigned PIkind = PIDecl->getPropertyAttributesAsWritten();

Modified: cfe/trunk/test/SemaObjC/continuation-class-property.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/continuation-class-property.m?rev=140438&r1=140437&r2=140438&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/continuation-class-property.m (original)
+++ cfe/trunk/test/SemaObjC/continuation-class-property.m Fri Sep 23 19:56:59 2011
@@ -22,3 +22,22 @@
 @property (readwrite, copy) id foos;
 @end
 
+
+// rdar://10142679
+ at class NSString;
+
+typedef struct {
+  float width;
+  float length;
+} NSRect;
+
+ at interface MyClass  {
+}
+ at property (readonly) NSRect foo; // expected-note {{property declared here}}
+ at property (readonly, strong) NSString *bar; // expected-note {{property declared here}}
+ at end
+
+ at interface MyClass ()
+ at property (readwrite) NSString *foo; // expected-error {{type of property 'NSString *' in continuation class does not matchproperty type in primary class}}
+ at property (readwrite, strong) NSRect bar; // expected-error {{type of property 'NSRect' in continuation class does not matchproperty type in primary class}}
+ at end

Modified: cfe/trunk/test/SemaObjCXX/property-synthesis-error.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/property-synthesis-error.mm?rev=140438&r1=140437&r2=140438&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/property-synthesis-error.mm (original)
+++ cfe/trunk/test/SemaObjCXX/property-synthesis-error.mm Fri Sep 23 19:56:59 2011
@@ -10,7 +10,7 @@
   NSMutableArray * _array;
 }
 
- at property (readonly) NSArray * array;
+ at property (readonly) NSMutableArray * array;
 
 @end
 





More information about the cfe-commits mailing list