From: Fariborz Jahanian Date: Tue, 13 Jul 2010 22:04:56 +0000 (+0000) Subject: Check on property attributes which are declared X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ae415dc21ee6402cee1675ec8bb965a24f9e5b6b;p=clang Check on property attributes which are declared in class extensions (radar 8171968). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108283 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaObjCProperty.cpp b/lib/Sema/SemaObjCProperty.cpp index 44cd271753..b2b6e13717 100644 --- a/lib/Sema/SemaObjCProperty.cpp +++ b/lib/Sema/SemaObjCProperty.cpp @@ -52,18 +52,22 @@ Sema::DeclPtrTy Sema::ActOnProperty(Scope *S, SourceLocation AtLoc, cast(ClassCategory.getAs()); if (ObjCCategoryDecl *CDecl = dyn_cast(ClassDecl)) - if (CDecl->IsClassExtension()) - return HandlePropertyInClassExtension(S, CDecl, AtLoc, - FD, GetterSel, SetterSel, - isAssign, isReadWrite, - Attributes, - isOverridingProperty, TSI, - MethodImplKind); - + if (CDecl->IsClassExtension()) { + DeclPtrTy Res = HandlePropertyInClassExtension(S, CDecl, AtLoc, + FD, GetterSel, SetterSel, + isAssign, isReadWrite, + Attributes, + isOverridingProperty, TSI, + MethodImplKind); + if (Res) + CheckObjCPropertyAttributes(Res, AtLoc, Attributes); + return Res; + } + DeclPtrTy Res = DeclPtrTy::make(CreatePropertyDecl(S, ClassDecl, AtLoc, FD, - GetterSel, SetterSel, - isAssign, isReadWrite, - Attributes, TSI, MethodImplKind)); + GetterSel, SetterSel, + isAssign, isReadWrite, + Attributes, TSI, MethodImplKind)); // Validate the attributes on the @property. CheckObjCPropertyAttributes(Res, AtLoc, Attributes); return Res; diff --git a/test/SemaObjC/property-10.m b/test/SemaObjC/property-10.m index bd07df685d..011927368f 100644 --- a/test/SemaObjC/property-10.m +++ b/test/SemaObjC/property-10.m @@ -20,3 +20,9 @@ @property(nonatomic,copy) int (*includeMailboxCondition2)(); // expected-error {{property with 'copy' attribute must be of object type}} @end + +@interface I0() +@property (retain) int PROP; // expected-error {{property with 'retain' attribute must be of object type}} +@property(nonatomic,copy) int (*PROP1)(); // expected-error {{property with 'copy' attribute must be of object type}} +@end +