r213282 - Objective-C. deprecated attribute is not inherited on methods
Fariborz Jahanian
fjahanian at apple.com
Thu Jul 17 10:05:04 PDT 2014
Author: fjahanian
Date: Thu Jul 17 12:05:04 2014
New Revision: 213282
URL: http://llvm.org/viewvc/llvm-project?rev=213282&view=rev
Log:
Objective-C. deprecated attribute is not inherited on methods
overriden in interfaces and protocols (this is already the case
for properties). rdar://16068470
Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaObjC/attr-deprecated.m
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=213282&r1=213281&r2=213282&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Jul 17 12:05:04 2014
@@ -2076,6 +2076,8 @@ static bool mergeDeclAttribute(Sema &S,
// 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));
Modified: cfe/trunk/test/SemaObjC/attr-deprecated.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-deprecated.m?rev=213282&r1=213281&r2=213282&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/attr-deprecated.m (original)
+++ cfe/trunk/test/SemaObjC/attr-deprecated.m Thu Jul 17 12:05:04 2014
@@ -192,3 +192,38 @@ __attribute__((deprecated))
}
@end
+
+// rdar://16068470
+ at interface TestBase
+ at 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}}
+ at end
+
+ at interface TestDerived : TestBase
+ at property (nonatomic, strong) id object;
+ at end
+
+ at interface TestUse @end
+
+ at implementation TestBase @end
+
+ at implementation TestDerived @end
+
+ at 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];
+}
+
+ at end
+
More information about the cfe-commits
mailing list