/// Ensure attributes are consistent with type.
/// \param [in, out] Attributes The attributes to check; they will
/// be modified to be consistent with \arg PropertyTy.
- void CheckObjCPropertyAttributes(QualType PropertyTy,
+ void CheckObjCPropertyAttributes(DeclPtrTy PropertyPtrTy,
SourceLocation Loc,
unsigned &Attributes);
void ProcessPropertyDecl(ObjCPropertyDecl *property, ObjCContainerDecl *DC);
Diag(AtLoc, diag::error_reference_property);
return DeclPtrTy();
}
- // Validate the attributes on the @property.
- CheckObjCPropertyAttributes(T, AtLoc, Attributes);
-
// Proceed with constructing the ObjCPropertDecls.
ObjCContainerDecl *ClassDecl =
cast<ObjCContainerDecl>(ClassCategory.getAs<Decl>());
isOverridingProperty, T,
MethodImplKind);
- return DeclPtrTy::make(CreatePropertyDecl(S, ClassDecl, AtLoc, FD,
+ DeclPtrTy Res = DeclPtrTy::make(CreatePropertyDecl(S, ClassDecl, AtLoc, FD,
GetterSel, SetterSel,
isAssign, isReadWrite,
Attributes, T, MethodImplKind));
+ // Validate the attributes on the @property.
+ CheckObjCPropertyAttributes(Res, AtLoc, Attributes);
+ return Res;
}
Sema::DeclPtrTy
AddInstanceMethodToGlobalPool(SetterMethod);
}
-void Sema::CheckObjCPropertyAttributes(QualType PropertyTy,
+void Sema::CheckObjCPropertyAttributes(DeclPtrTy PropertyPtrTy,
SourceLocation Loc,
unsigned &Attributes) {
// FIXME: Improve the reported location.
+ Decl *PDecl = PropertyPtrTy.getAs<Decl>();
+ ObjCPropertyDecl *PropertyDecl = dyn_cast_or_null<ObjCPropertyDecl>(PDecl);
+ QualType PropertyTy = PropertyDecl->getType();
// readonly and readwrite/assign/retain/copy conflict.
if ((Attributes & ObjCDeclSpec::DQ_PR_readonly) &&
if ((Attributes & (ObjCDeclSpec::DQ_PR_copy | ObjCDeclSpec::DQ_PR_retain)) &&
!PropertyTy->isObjCObjectPointerType() &&
!PropertyTy->isBlockPointerType() &&
- !Context.isObjCNSObjectType(PropertyTy)) {
+ !Context.isObjCNSObjectType(PropertyTy) &&
+ !PropertyDecl->getAttr<ObjCNSObjectAttr>()) {
Diag(Loc, diag::err_objc_property_requires_object)
<< (Attributes & ObjCDeclSpec::DQ_PR_copy ? "copy" : "retain");
Attributes &= ~(ObjCDeclSpec::DQ_PR_copy | ObjCDeclSpec::DQ_PR_retain);
typedef struct S1 __attribute__ ((NSObject)) CGColorRef1; // expected-error {{__attribute ((NSObject)) is for pointer types only}}
typedef void * __attribute__ ((NSObject)) CGColorRef2; // expected-error {{__attribute ((NSObject)) is for pointer types only}}
+
@interface HandTested {
@public
CGColorRef x;
}
+
@property(copy) CGColorRef x;
+// rdar: // 7809460
+typedef struct CGColor *CGColorRefNoNSObject;
+@property (nonatomic, retain) __attribute__((NSObject)) CGColorRefNoNSObject color;
@end
void setProperty(id self, id value) {
@implementation HandTested
@synthesize x=x;
+@dynamic color;
@end
int main(int argc, char *argv[]) {