[cfe-commits] r149614 - in /cfe/trunk: lib/Sema/SemaObjCProperty.cpp test/SemaObjC/narrow-property-type-in-cont-class.m

Ted Kremenek kremenek at apple.com
Thu Feb 2 11:24:06 PST 2012


Thanks Fariborz.  My only comment is that I think this code merits a comment that indicates why we are doing this.

On Feb 2, 2012, at 10:54 AM, Fariborz Jahanian wrote:

> Author: fjahanian
> Date: Thu Feb  2 12:54:58 2012
> New Revision: 149614
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=149614&view=rev
> Log:
> objective-c: When redeclaraing in continuation class a 'readonly'
> property to 'readwrite', also allow redeclaration of
> property type to a narrowring object type.
> // rdar://10790488
> 
> Added:
>    cfe/trunk/test/SemaObjC/narrow-property-type-in-cont-class.m
> 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=149614&r1=149613&r2=149614&view=diff
> ==============================================================================
> --- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Thu Feb  2 12:54:58 2012
> @@ -276,11 +276,18 @@
>       L->AddedObjCPropertyInClassExtension(PDecl, /*OrigProp=*/0, CDecl);
>     return PDecl;
>   }
> -  if (PIDecl->getType().getCanonicalType() 
> -      != PDecl->getType().getCanonicalType()) {
> -    Diag(AtLoc, 
> -         diag::err_type_mismatch_continuation_class) << PDecl->getType();
> -    Diag(PIDecl->getLocation(), diag::note_property_declare);
> +  if (!Context.hasSameType(PIDecl->getType(), PDecl->getType())) {
> +    bool IncompatibleObjC = false;
> +    QualType ConvertedType;
> +    if (!isa<ObjCObjectPointerType>(PIDecl->getType()) ||
> +        !isa<ObjCObjectPointerType>(PDecl->getType()) ||
> +        (!isObjCPointerConversion(PDecl->getType(), PIDecl->getType(), 
> +                                  ConvertedType, IncompatibleObjC))
> +        || IncompatibleObjC) {
> +      Diag(AtLoc, 
> +          diag::err_type_mismatch_continuation_class) << PDecl->getType();
> +      Diag(PIDecl->getLocation(), diag::note_property_declare);
> +    }
>   }
> 
>   // The property 'PIDecl's readonly attribute will be over-ridden
> 
> Added: cfe/trunk/test/SemaObjC/narrow-property-type-in-cont-class.m
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/narrow-property-type-in-cont-class.m?rev=149614&view=auto
> ==============================================================================
> --- cfe/trunk/test/SemaObjC/narrow-property-type-in-cont-class.m (added)
> +++ cfe/trunk/test/SemaObjC/narrow-property-type-in-cont-class.m Thu Feb  2 12:54:58 2012
> @@ -0,0 +1,19 @@
> +// RUN: %clang_cc1 -x objective-c -fsyntax-only -verify %s
> +// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -verify %s
> +// rdar://10790488
> +
> + at interface NSArray @end
> +
> + at interface NSMutableArray : NSArray
> + at end
> +
> + at interface GKTurnBasedMatchMakerKVO
> + at property(nonatomic,readonly,retain) NSArray* outline;
> + at property(nonatomic,readonly,retain) NSMutableArray* err_outline; // expected-note {{property declared here}}
> + at end
> +
> + at interface GKTurnBasedMatchMakerKVO ()
> + at property(nonatomic,readwrite,retain) NSMutableArray* outline;
> + at property(nonatomic,readwrite,retain) NSArray* err_outline; // expected-error {{type of property 'NSArray *' in continuation class does not match property type in primary class}}
> + at end
> +
> 
> 
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits




More information about the cfe-commits mailing list