]> granicus.if.org Git - clang/commitdiff
Objective-C. deprecated attribute is not inherited on methods
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 17 Jul 2014 17:05:04 +0000 (17:05 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 17 Jul 2014 17:05:04 +0000 (17:05 +0000)
overriden in interfaces and protocols (this is already the case
for properties). rdar://16068470

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@213282 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDecl.cpp
test/SemaObjC/attr-deprecated.m

index a7018cd7826338fae4e261b585b1d4ee0e9675bf..72fbe88eec2602938c892fc181aae7f73455fbf1 100644 (file)
@@ -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<DeprecatedAttr>(Attr) && Override)
+    NewAttr = nullptr;
   else if (Attr->duplicatesAllowed() || !DeclHasAttr(D, Attr))
     NewAttr = cast<InheritableAttr>(Attr->clone(S.Context));
 
index 9dba48eced77fca391e7713d46219f0423a983d9..ca30d0a27d8813e32a1d3ca4f9130119513629fb 100644 (file)
@@ -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
+