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
+@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
+
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits