On Feb 2, 2012, at 2:20 PM, Ted Kremenek wrote:

> Thanks Fariborz.  After reading your comment, is this patch enough?  This is 
> safe *only* when the original property is declared readonly.  If the original 
> property is declared readwrite, then this isn't safe.  In other words, 
> readonly overridden by readwrite is ok, readwrite overridden by readwrite 
> (with a different type) is NOT ok.  Does this patch guard for this case?

Yes, or conversion would not have been safe.

Only 'readonly' to 'readwrite' is allowed for a property in continuation class. 
Anything else results in an error. Note that this was the only original 
intention of redeclaring a property in continuation class.

Test case.

@interface NSArray @end
@interface NSMutableArray : NSArray @end

@interface GKTurnBasedMatchMakerKVO
@property(nonatomic,readwrite,retain) NSArray* outline;
@end

@interface GKTurnBasedMatchMakerKVO ()
@property(nonatomic,readwrite,retain) NSMutableArray* outline;
@end

% $CLANG -c test.m
test.m:9:1: error: illegal redeclaration of 'readwrite' property in 
continuation class 'GKTurnBasedMatchMakerKVO' (perhaps you intended this to be 
a 'readwrite' redeclaration of a 'readonly' public
      property?)
@property(nonatomic,readwrite,retain) NSMutableArray* outline;
^
test.m:5:48: note: property declared here
@property(nonatomic,readwrite,retain) NSArray* outline;
                                               ^
1 error generated.


- fariborz


> 
> On Feb 2, 2012, at 11:34 AM, Fariborz Jahanian wrote:
> 
>> Author: fjahanian
>> Date: Thu Feb  2 13:34:05 2012
>> New Revision: 149625
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=149625&view=rev
>> Log:
>> objc: comment the code which allows narroing of property object
>> type in continuation class.
>> 
>> Modified:
>>   cfe/trunk/lib/Sema/SemaObjCProperty.cpp
>> 
>> Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=149625&r1=149624&r2=149625&view=diff
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Thu Feb  2 13:34:05 2012
>> @@ -279,6 +279,9 @@
>>  if (!Context.hasSameType(PIDecl->getType(), PDecl->getType())) {
>>    bool IncompatibleObjC = false;
>>    QualType ConvertedType;
>> +    // Relax the strict type matching for property type in continuation 
>> class.
>> +    // Allow property object type of continuation class to be different as 
>> long
>> +    // as it narrows the object type in its primary class property.
>>    if (!isa<ObjCObjectPointerType>(PIDecl->getType()) ||
>>        !isa<ObjCObjectPointerType>(PDecl->getType()) ||
>>        (!isObjCPointerConversion(PDecl->getType(), PIDecl->getType(), 
>> 
>> 
>> _______________________________________________
>> cfe-commits mailing list
>> [email protected]
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> 

_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to