[cfe-commits] r151786 - in /cfe/trunk: lib/Sema/SemaDeclAttr.cpp test/SemaObjC/nsobject-attribute.m

Ted Kremenek kremenek at apple.com
Wed Feb 29 17:40:32 PST 2012


Author: kremenek
Date: Wed Feb 29 19:40:32 2012
New Revision: 151786

URL: http://llvm.org/viewvc/llvm-project?rev=151786&view=rev
Log:
Fix regression from llvm-gcc where we should NOT emit a warning about __attribute__((NSObject)) on a property declaration.  This is needed to have retain properties for non-object pointers.  Fixes <rdar://problem/10930507>.

Modified:
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp
    cfe/trunk/test/SemaObjC/nsobject-attribute.m

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=151786&r1=151785&r2=151786&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Feb 29 19:40:32 2012
@@ -1794,8 +1794,15 @@
       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));
 }
 

Modified: cfe/trunk/test/SemaObjC/nsobject-attribute.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/nsobject-attribute.m?rev=151786&r1=151785&r2=151786&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/nsobject-attribute.m (original)
+++ cfe/trunk/test/SemaObjC/nsobject-attribute.m Wed Feb 29 19:40:32 2012
@@ -45,7 +45,8 @@
 {
    __attribute__((NSObject)) void * color; // expected-warning {{__attribute ((NSObject)) may be put on a typedef only, attribute is ignored}}
 }
- at property (nonatomic, retain) __attribute__((NSObject)) void * color; // expected-warning {{__attribute ((NSObject)) may be put on a typedef only, attribute is ignored}}
+  // <rdar://problem/10930507>
+ at 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}}





More information about the cfe-commits mailing list