[cfe-commits] r56838 - /cfe/trunk/lib/Sema/SemaDeclObjC.cpp

Steve Naroff snaroff at apple.com
Tue Sep 30 03:07:56 PDT 2008


Author: snaroff
Date: Tue Sep 30 05:07:56 2008
New Revision: 56838

URL: http://llvm.org/viewvc/llvm-project?rev=56838&view=rev
Log:
Improved fix for <rdar://problem/6247781> Parser rejecting properly mismatched properties.
Needed to make sure the relaxed type checking only applies to "readonly" properties.

Modified:
    cfe/trunk/lib/Sema/SemaDeclObjC.cpp

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

==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Tue Sep 30 05:07:56 2008
@@ -1254,13 +1254,18 @@
            PropertyId->getName());
       return 0;
     }
+    QualType PropType = Context.getCanonicalType(property->getType());
+    QualType IvarType = Context.getCanonicalType(Ivar->getType());
+    
     // Check that type of property and its ivar are type compatible.
-    // A property is allowed to be a sub-class of the instance variable type.
-    if (CheckAssignmentConstraints(property->getType(), 
-                                   Ivar->getType()) != Compatible) {
-      Diag(PropertyLoc, diag::error_property_ivar_type, property->getName(),
-           Ivar->getName());
-      return 0;
+    if (PropType != IvarType) {
+      // A readonly property is allowed to be a sub-class of the ivar type.
+      if (!property->isReadOnly() ||
+          CheckAssignmentConstraints(PropType, IvarType) != Compatible) {
+        Diag(PropertyLoc, diag::error_property_ivar_type, property->getName(),
+            Ivar->getName());
+        return 0;
+      }
     }
   } else if (PropertyIvar) {
     // @dynamic





More information about the cfe-commits mailing list