summaryrefslogtreecommitdiff
path: root/clang/test/SemaObjC/attr-deprecated.m
diff options
context:
space:
mode:
authorCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-10-15 17:10:06 +1100
committerCarlo Zancanaro <carlo@pc-4w14-0.cs.usyd.edu.au>2012-10-15 17:10:06 +1100
commitbe1de4be954c80875ad4108e0a33e8e131b2f2c0 (patch)
tree1fbbecf276bf7c7bdcbb4dd446099d6d90eaa516 /clang/test/SemaObjC/attr-deprecated.m
parentc4626a62754862d20b41e8a46a3574264ea80e6d (diff)
parentf1bd2e48c5324d3f7cda4090c87f8a5b6f463ce2 (diff)
Merge branch 'master' of ssh://bitbucket.org/czan/honours
Diffstat (limited to 'clang/test/SemaObjC/attr-deprecated.m')
-rw-r--r--clang/test/SemaObjC/attr-deprecated.m123
1 files changed, 123 insertions, 0 deletions
diff --git a/clang/test/SemaObjC/attr-deprecated.m b/clang/test/SemaObjC/attr-deprecated.m
new file mode 100644
index 0000000..db0b958
--- /dev/null
+++ b/clang/test/SemaObjC/attr-deprecated.m
@@ -0,0 +1,123 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s
+
+@interface A {
+ int X __attribute__((deprecated));
+}
++ (void)F __attribute__((deprecated));
+- (void)f __attribute__((deprecated));
+@end
+
+@implementation A
++ (void)F __attribute__((deprecated))
+{
+ [self F]; // no warning, since the caller is also deprecated.
+}
+
+- (void)g
+{
+ X++; // expected-warning{{'X' is deprecated}}
+ self->X++; // expected-warning{{'X' is deprecated}}
+ [self f]; // expected-warning{{'f' is deprecated}}
+}
+
+- (void)f
+{
+ [self f]; // no warning, the caller is deprecated in its interface.
+}
+@end
+
+@interface B: A
+@end
+
+@implementation B
++ (void)G
+{
+ [super F]; // expected-warning{{'F' is deprecated}}
+}
+
+- (void)g
+{
+ [super f]; // // expected-warning{{'f' is deprecated}}
+}
+@end
+
+@protocol P
+- (void)p __attribute__((deprecated));
+@end
+
+void t1(A *a)
+{
+ [A F]; // expected-warning{{'F' is deprecated}}
+ [a f]; // expected-warning{{'f' is deprecated}}
+}
+
+void t2(id a)
+{
+ [a f];
+}
+
+void t3(A<P>* a)
+{
+ [a f]; // expected-warning{{'f' is deprecated}}
+ [a p]; // expected-warning{{'p' is deprecated}}
+}
+
+void t4(Class c)
+{
+ [c F];
+}
+
+
+
+@interface Bar
+
+@property (assign, setter = MySetter:) int FooBar __attribute__ ((deprecated));
+- (void) MySetter : (int) value;
+@end
+
+int t5() {
+ Bar *f;
+ f.FooBar = 1; // expected-warning {{'FooBar' is deprecated}}
+ return f.FooBar; // expected-warning {{'FooBar' is deprecated}}
+}
+
+
+__attribute ((deprecated))
+@interface DEPRECATED {
+ @public int ivar;
+ DEPRECATED *ivar2; // no warning.
+}
+- (int) instancemethod;
+- (DEPRECATED *) meth; // no warning.
+@property int prop;
+@end
+
+@interface DEPRECATED (Category) // no warning.
+- (DEPRECATED *) meth2; // no warning.
+@end
+
+@interface DEPRECATED (Category2) // no warning.
+@end
+
+@implementation DEPRECATED (Category2) // expected-warning {{'DEPRECATED' is deprecated}}
+@end
+
+@interface NS : DEPRECATED // expected-warning {{'DEPRECATED' is deprecated}}
+@end
+
+
+@interface Test2
+@property int test2 __attribute__((deprecated));
+@end
+
+void test(Test2 *foo) {
+ int x;
+ x = foo.test2; // expected-warning {{'test2' is deprecated}}
+ x = [foo test2]; // expected-warning {{'test2' is deprecated}}
+ foo.test2 = x; // expected-warning {{'test2' is deprecated}}
+ [foo setTest2: x]; // expected-warning {{'setTest2:' is deprecated}}
+}
+
+__attribute__((deprecated))
+@interface A(Blah) // expected-error{{attributes may not be specified on a category}}
+@end