]> granicus.if.org Git - clang/commitdiff
Fix regression from llvm-gcc where we should NOT emit a warning about __attribute__...
authorTed Kremenek <kremenek@apple.com>
Thu, 1 Mar 2012 01:40:32 +0000 (01:40 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 1 Mar 2012 01:40:32 +0000 (01:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@151786 91177308-0d34-0410-b5e6-96231b3b80d8

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

index f0fcd6e91c2f65f91832dc05f9b6770ec3665c4c..4f3b03f6e511d1d97eee06b6cdc9ce772e0c527d 100644 (file)
@@ -1794,8 +1794,15 @@ static void handleObjCNSObject(Sema &S, Decl *D, const AttributeList &Attr) {
       return;
     }
   }
-  else 
+  else if (!isa<ObjCPropertyDecl>(D)) {
+    // It is okay to include this attribute on properties, e.g.:
+    //
+    //  @property (retain, nonatomic) struct Bork *Q __attribute__((NSObject));
+    //
+    // In this case it follows tradition and suppresses an error in the above
+    // case.    
     S.Diag(D->getLocation(), diag::warn_nsobject_attribute);
+  }
   D->addAttr(::new (S.Context) ObjCNSObjectAttr(Attr.getRange(), S.Context));
 }
 
index 46e84d207cb06ec8a75c413609eb07ccdd239d08..bbeb31a85962c4f963fcb23cdcb686e3cbccb6ba 100644 (file)
@@ -45,7 +45,8 @@ int main(int argc, char *argv[]) {
 {
    __attribute__((NSObject)) void * color; // expected-warning {{__attribute ((NSObject)) may be put on a typedef only, attribute is ignored}}
 }
-@property (nonatomic, retain) __attribute__((NSObject)) void * color; // expected-warning {{__attribute ((NSObject)) may be put on a typedef only, attribute is ignored}}
+  // <rdar://problem/10930507>
+@property (nonatomic, retain) __attribute__((NSObject)) void * color; // // no-warning
 @end
 void test_10453342() {
     char* __attribute__((NSObject)) string2 = 0; // expected-warning {{__attribute ((NSObject)) may be put on a typedef only, attribute is ignored}}