From: Fariborz Jahanian Date: Thu, 20 Nov 2008 19:35:51 +0000 (+0000) Subject: __weak ivar need not warn. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=24b93f2debe1fdb98c7b03a79486a02bf8b9c9e4;p=clang __weak ivar need not warn. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59743 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 1e3a310305..e4811dfaa6 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -556,7 +556,7 @@ static void HandleObjCGCAttr(Decl *d, const AttributeList &Attr, Sema &S) { ObjCGCAttr::GCAttrTypes type; if (Attr.getParameterName()->isStr("weak")) { - if (isa(d)) + if (isa(d) && !isa(d)) S.Diag(Attr.getLoc(), diag::warn_attribute_weak_on_field); type = ObjCGCAttr::Weak; } diff --git a/test/SemaObjC/warn-weak-field.m b/test/SemaObjC/warn-weak-field.m index 93c23be228..a342acb156 100644 --- a/test/SemaObjC/warn-weak-field.m +++ b/test/SemaObjC/warn-weak-field.m @@ -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 {