From: Ted Kremenek Date: Wed, 29 Aug 2012 22:54:47 +0000 (+0000) Subject: Fix serious regression introduced in r157780 where __attribute__((NSObject)) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9af9122067f1334806a5f22ce907a3209490d506;p=clang Fix serious regression introduced in r157780 where __attribute__((NSObject)) could not be attached to a CFTypeRef. Fixes git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162872 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index fcfa574d59..2426845312 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -2268,16 +2268,14 @@ static void handleObjCNSObject(Sema &S, Decl *D, const AttributeList &Attr) { } if (TypedefNameDecl *TD = dyn_cast(D)) { QualType T = TD->getUnderlyingType(); - if (!T->isPointerType() || - !T->getAs()->getPointeeType()->isRecordType()) { + if (!T->isCARCBridgableType()) { S.Diag(TD->getLocation(), diag::err_nsobject_attribute); return; } } else if (ObjCPropertyDecl *PD = dyn_cast(D)) { QualType T = PD->getType(); - if (!T->isPointerType() || - !T->getAs()->getPointeeType()->isRecordType()) { + if (!T->isCARCBridgableType()) { S.Diag(PD->getLocation(), diag::err_nsobject_attribute); return; } diff --git a/test/SemaObjC/nsobject-attribute.m b/test/SemaObjC/nsobject-attribute.m index e3f28740dc..133ca16204 100644 --- a/test/SemaObjC/nsobject-attribute.m +++ b/test/SemaObjC/nsobject-attribute.m @@ -5,8 +5,8 @@ static int count; static CGColorRef tmp = 0; 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}} - +typedef void * __attribute__ ((NSObject)) CGColorRef2; // no-warning +typedef void * CFTypeRef; @interface HandTested { @public @@ -14,9 +14,11 @@ typedef void * __attribute__ ((NSObject)) CGColorRef2; // expected-error {{__at } @property(copy) CGColorRef x; -// rdar: // 7809460 -typedef struct CGColor * __attribute__((NSObject)) CGColorRefNoNSObject; +// rdar://problem/7809460 +typedef struct CGColor * __attribute__((NSObject)) CGColorRefNoNSObject; // no-warning @property (nonatomic, retain) CGColorRefNoNSObject color; +// rdar://problem/12197822 +@property (strong) __attribute__((NSObject)) CFTypeRef myObj; // no-warning @end void setProperty(id self, id value) {