summaryrefslogtreecommitdiffstats
path: root/clang/test/SemaObjC
diff options
context:
space:
mode:
authorAlex Lorenz <arphaman@gmail.com>2019-01-17 18:12:45 +0000
committerAlex Lorenz <arphaman@gmail.com>2019-01-17 18:12:45 +0000
commit194d00e1425c8aceefc82d4410285310868d74de (patch)
treea98c6d67838d3911538812b58778095e812decac /clang/test/SemaObjC
parent4fce28ca6e42ab48c48279b77e1e9b40729978ad (diff)
downloadbcm5719-llvm-194d00e1425c8aceefc82d4410285310868d74de.tar.gz
bcm5719-llvm-194d00e1425c8aceefc82d4410285310868d74de.zip
[ObjC] Follow-up r350768 and allow the use of unavailable methods that are
declared in a parent class from within the @implementation context This commit extends r350768 and allows the use of methods marked as unavailable that are declared in a parent class/category from within the @implementation of the class where the method is marked as unavailable. This allows users to call init that's marked as unavailable even if they don't define it. rdar://47134898 Differential Revision: https://reviews.llvm.org/D56816 llvm-svn: 351459
Diffstat (limited to 'clang/test/SemaObjC')
-rw-r--r--clang/test/SemaObjC/call-unavailable-init-in-self.m22
-rw-r--r--clang/test/SemaObjC/infer-availability-from-init.m4
2 files changed, 22 insertions, 4 deletions
diff --git a/clang/test/SemaObjC/call-unavailable-init-in-self.m b/clang/test/SemaObjC/call-unavailable-init-in-self.m
index fa6f670cc99..48fc2326af4 100644
--- a/clang/test/SemaObjC/call-unavailable-init-in-self.m
+++ b/clang/test/SemaObjC/call-unavailable-init-in-self.m
@@ -5,13 +5,24 @@
+ (instancetype)new;
+ (instancetype)alloc;
+- (void)declaredInSuper;
+
+@end
+
+@interface NSObject (Category)
+
+- (void)declaredInSuperCategory;
+
@end
@interface Sub: NSObject
- (instancetype)init __attribute__((unavailable)); // expected-note 4 {{'init' has been explicitly marked unavailable here}}
-- (void)notImplemented __attribute__((unavailable)); // expected-note {{'notImplemented' has been explicitly marked unavailable here}}
+- (void)notImplemented __attribute__((unavailable));
+
+- (void)declaredInSuper __attribute__((unavailable));
+- (void)declaredInSuperCategory __attribute__((unavailable));
@end
@@ -34,7 +45,14 @@
}
- (void)reportUseOfUnimplemented {
- [self notImplemented]; // expected-error {{'notImplemented' is unavailable}}
+ [self notImplemented];
+}
+
+- (void)allowSuperCallUsingSelf {
+ [self declaredInSuper];
+ [[Sub alloc] declaredInSuper];
+ [self declaredInSuperCategory];
+ [[Sub alloc] declaredInSuperCategory];
}
@end
diff --git a/clang/test/SemaObjC/infer-availability-from-init.m b/clang/test/SemaObjC/infer-availability-from-init.m
index f9996ec7087..7aa1e53c091 100644
--- a/clang/test/SemaObjC/infer-availability-from-init.m
+++ b/clang/test/SemaObjC/infer-availability-from-init.m
@@ -47,12 +47,12 @@ void usenotmyobject() {
}
@interface FromSelf : NSObject
--(instancetype)init __attribute__((unavailable)); // expected-note {{'init' has been explicitly marked unavailable here}}
+-(instancetype)init __attribute__((unavailable));
+(FromSelf*)another_one;
@end
@implementation FromSelf
+(FromSelf*)another_one {
- [self new]; // expected-error{{'new' is unavailable}}
+ [self new];
}
@end
OpenPOWER on IntegriCloud