]> granicus.if.org Git - clang/commitdiff
Fix serious regression introduced in r157780 where __attribute__((NSObject))
authorTed Kremenek <kremenek@apple.com>
Wed, 29 Aug 2012 22:54:47 +0000 (22:54 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 29 Aug 2012 22:54:47 +0000 (22:54 +0000)
could not be attached to a CFTypeRef.

Fixes <rdar://problem/12197822>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@162872 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclAttr.cpp
test/SemaObjC/nsobject-attribute.m

index fcfa574d599c7d85ffd58ae87e4e2ef0e8c7d78a..2426845312519f7b2556a67afe5b2cf04d674af0 100644 (file)
@@ -2268,16 +2268,14 @@ static void handleObjCNSObject(Sema &S, Decl *D, const AttributeList &Attr) {
   }
   if (TypedefNameDecl *TD = dyn_cast<TypedefNameDecl>(D)) {
     QualType T = TD->getUnderlyingType();
-    if (!T->isPointerType() ||
-        !T->getAs<PointerType>()->getPointeeType()->isRecordType()) {
+    if (!T->isCARCBridgableType()) {
       S.Diag(TD->getLocation(), diag::err_nsobject_attribute);
       return;
     }
   }
   else if (ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(D)) {
     QualType T = PD->getType();
-    if (!T->isPointerType() ||
-        !T->getAs<PointerType>()->getPointeeType()->isRecordType()) {
+    if (!T->isCARCBridgableType()) {
       S.Diag(PD->getLocation(), diag::err_nsobject_attribute);
       return;
     }
index e3f28740dc8f4827c267f335f47571c238b1f8f5..133ca16204cab3041850393cfff013a5b8be9df7 100644 (file)
@@ -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)  {