]> granicus.if.org Git - clang/commitdiff
__weak ivar need not warn.
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 20 Nov 2008 19:35:51 +0000 (19:35 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 20 Nov 2008 19:35:51 +0000 (19:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59743 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclAttr.cpp
test/SemaObjC/warn-weak-field.m

index 1e3a310305cd74720ce4960a1f63207d203e3d9d..e4811dfaa61d46bfb6308fc6b7c61010e64af1d4 100644 (file)
@@ -556,7 +556,7 @@ static void HandleObjCGCAttr(Decl *d, const AttributeList &Attr, Sema &S) {
   
   ObjCGCAttr::GCAttrTypes type;
   if (Attr.getParameterName()->isStr("weak")) {
-    if (isa<FieldDecl>(d))
+    if (isa<FieldDecl>(d) && !isa<ObjCIvarDecl>(d))
       S.Diag(Attr.getLoc(), diag::warn_attribute_weak_on_field);
     type = ObjCGCAttr::Weak;
   }
index 93c23be2280a4ef67bd46f3267632fbba2a1ef64..a342acb156fd4ffee14cece479793fe49efb8e53 100644 (file)
@@ -5,6 +5,17 @@ struct S {
        __strong id p1;
 };
 
+@interface I
+{
+   __weak id w;        // OK
+   __strong id LHS;
+}
+- (void) foo;
+@end
+@implementation I
+- (void) foo { w = 0; LHS = w; }
+@end
+
 int main ()
 {
        struct I {