diff options
| author | Douglas Gregor <dgregor@apple.com> | 2015-09-30 21:34:33 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2015-09-30 21:34:33 +0000 |
| commit | e5e83474966a67e2fb1964fd847f975a65bc3699 (patch) | |
| tree | ce4475263a5baa990ccaa8082eb6a9ef89153796 /clang | |
| parent | d2a713e41bd362125ba80a3eecc7e05876e06adb (diff) | |
| download | bcm5719-llvm-e5e83474966a67e2fb1964fd847f975a65bc3699.tar.gz bcm5719-llvm-e5e83474966a67e2fb1964fd847f975a65bc3699.zip | |
Don't inherit the "unavailable" attribute from an overridden superclass method.
Fixes rdar://problem/22922259.
llvm-svn: 248950
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 |

