__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 1e3a310..e4811df 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -556,7 +556,7 @@
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;
}
diff --git a/test/SemaObjC/warn-weak-field.m b/test/SemaObjC/warn-weak-field.m
index 93c23be..a342acb 100644
--- a/test/SemaObjC/warn-weak-field.m
+++ b/test/SemaObjC/warn-weak-field.m
@@ -5,6 +5,17 @@
__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 {