diff options
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 2 | ||||
-rw-r--r-- | test/SemaObjC/warn-weak-field.m | 11 |
2 files changed, 12 insertions, 1 deletions
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<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 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 { |