diff options
Diffstat (limited to 'clang')
-rw-r--r-- | clang/lib/Sema/SemaDecl.cpp | 4 | ||||
-rw-r--r-- | clang/test/SemaObjC/attr-availability.m | 16 |
2 files changed, 17 insertions, 3 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp index a359ef49311..467b36dfeec 100644 --- a/clang/lib/Sema/SemaDecl.cpp +++ b/clang/lib/Sema/SemaDecl.cpp @@ -2220,12 +2220,10 @@ 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) && + 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)); diff --git a/clang/test/SemaObjC/attr-availability.m b/clang/test/SemaObjC/attr-availability.m index 8323139e590..dad2d5b7e79 100644 --- a/clang/test/SemaObjC/attr-availability.m +++ b/clang/test/SemaObjC/attr-availability.m @@ -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 |