Author: dgregor Date: Wed Sep 30 16:34:33 2015 New Revision: 248950 URL: http://llvm.org/viewvc/llvm-project?rev=248950&view=rev Log: Don't inherit the "unavailable" attribute from an overridden superclass method.
Fixes rdar://problem/22922259. Modified: cfe/trunk/lib/Sema/SemaDecl.cpp cfe/trunk/test/SemaObjC/attr-availability.m Modified: cfe/trunk/lib/Sema/SemaDecl.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=248950&r1=248949&r2=248950&view=diff ============================================================================== --- cfe/trunk/lib/Sema/SemaDecl.cpp (original) +++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Sep 30 16:34:33 2015 @@ -2220,12 +2220,10 @@ 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) && + else if ((isa<DeprecatedAttr>(Attr) || isa<UnavailableAttr>(Attr)) && (AMK == Sema::AMK_Override || AMK == Sema::AMK_ProtocolImplementation)) NewAttr = nullptr; - else if (isa<UnavailableAttr>(Attr) && AMK == Sema::AMK_ProtocolImplementation) - NewAttr = nullptr; else if (Attr->duplicatesAllowed() || !DeclHasAttr(D, Attr)) NewAttr = cast<InheritableAttr>(Attr->clone(S.Context)); Modified: cfe/trunk/test/SemaObjC/attr-availability.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-availability.m?rev=248950&r1=248949&r2=248950&view=diff ============================================================================== --- cfe/trunk/test/SemaObjC/attr-availability.m (original) +++ cfe/trunk/test/SemaObjC/attr-availability.m Wed Sep 30 16:34:33 2015 @@ -278,3 +278,19 @@ __attribute__((objc_root_class)) -(void)methodB __attribute__((unavailable)) { } @end + +__attribute__((objc_root_class)) +@interface InheritUnavailableSuper +-(void)method __attribute__((unavailable)); // expected-note{{'method' has been explicitly marked unavailable here}} +@end + +@interface InheritUnavailableSub : InheritUnavailableSuper +-(void)method; +@end + +@implementation InheritUnavailableSub +-(void)method { + InheritUnavailableSuper *obj = self; + [obj method]; // expected-error{{'method' is unavailable}} +} +@end _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits