From b93355e9b1d712670e3a4fa4c06950b83a0a2192 Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Thu, 17 Jul 2014 17:05:04 +0000 Subject: [PATCH] Objective-C. deprecated attribute is not inherited on methods overriden in interfaces and protocols (this is already the case for properties). rdar://16068470 llvm-svn: 213282 --- clang/lib/Sema/SemaDecl.cpp | 2 ++ clang/test/SemaObjC/attr-deprecated.m | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index a7018cd..72fbe88 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -2076,6 +2076,8 @@ static bool mergeDeclAttribute(Sema &S, NamedDecl *D, // AlignedAttrs are handled separately, because we need to handle all // such attributes on a declaration at the same time. NewAttr = nullptr; + else if (isa(Attr) && Override) + NewAttr = nullptr; else if (Attr->duplicatesAllowed() || !DeclHasAttr(D, Attr)) NewAttr = cast(Attr->clone(S.Context)); diff --git a/clang/test/SemaObjC/attr-deprecated.m b/clang/test/SemaObjC/attr-deprecated.m index 9dba48e..ca30d0a 100644 --- a/clang/test/SemaObjC/attr-deprecated.m +++ b/clang/test/SemaObjC/attr-deprecated.m @@ -192,3 +192,38 @@ __attribute__((deprecated)) } @end + +// rdar://16068470 +@interface TestBase +@property (nonatomic, strong) id object __attribute__((deprecated("deprecated"))); // expected-note {{'object' has been explicitly marked deprecated here}} \ +expected-note {{property 'object' is declared deprecated here}} \ +expected-note {{'setObject:' has been explicitly marked deprecated here}} +@end + +@interface TestDerived : TestBase +@property (nonatomic, strong) id object; +@end + +@interface TestUse @end + +@implementation TestBase @end + +@implementation TestDerived @end + +@implementation TestUse + +- (void) use +{ + TestBase *base = (id)0; + TestDerived *derived = (id)0; + id object = (id)0; + + base.object = object; // expected-warning {{'object' is deprecated: deprecated}} + derived.object = object; + + [base setObject:object]; // expected-warning {{'setObject:' is deprecated: deprecated}} + [derived setObject:object]; +} + +@end + -- 2.7.4