Patrick Beard | b2f6820 | 2012-04-06 18:12:22 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -fsyntax-only -verify -Wno-objc-root-class %s |
Anders Carlsson | 59843ad | 2009-02-14 19:08:58 +0000 | [diff] [blame] | 2 | |
Chris Lattner | 553905d | 2009-02-16 17:19:12 +0000 | [diff] [blame] | 3 | @interface A { |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 4 | int X __attribute__((deprecated)); // expected-note 2 {{declared here}} |
Chris Lattner | 553905d | 2009-02-16 17:19:12 +0000 | [diff] [blame] | 5 | } |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 6 | + (void)F __attribute__((deprecated)); // expected-note 2 {{declared here}} |
| 7 | - (void)f __attribute__((deprecated)); // expected-note 4 {{declared here}} |
Anders Carlsson | 59843ad | 2009-02-14 19:08:58 +0000 | [diff] [blame] | 8 | @end |
| 9 | |
| 10 | @implementation A |
| 11 | + (void)F __attribute__((deprecated)) |
Fariborz Jahanian | 7fda400 | 2011-10-22 01:21:15 +0000 | [diff] [blame] | 12 | { |
Chris Lattner | b254ca0 | 2009-02-16 17:08:46 +0000 | [diff] [blame] | 13 | [self F]; // no warning, since the caller is also deprecated. |
Anders Carlsson | 59843ad | 2009-02-14 19:08:58 +0000 | [diff] [blame] | 14 | } |
| 15 | |
| 16 | - (void)g |
| 17 | { |
Chris Lattner | 553905d | 2009-02-16 17:19:12 +0000 | [diff] [blame] | 18 | X++; // expected-warning{{'X' is deprecated}} |
| 19 | self->X++; // expected-warning{{'X' is deprecated}} |
Anders Carlsson | 59843ad | 2009-02-14 19:08:58 +0000 | [diff] [blame] | 20 | [self f]; // expected-warning{{'f' is deprecated}} |
| 21 | } |
| 22 | |
| 23 | - (void)f |
| 24 | { |
Chris Lattner | f15970c | 2009-02-16 19:35:30 +0000 | [diff] [blame] | 25 | [self f]; // no warning, the caller is deprecated in its interface. |
Anders Carlsson | 59843ad | 2009-02-14 19:08:58 +0000 | [diff] [blame] | 26 | } |
| 27 | @end |
| 28 | |
| 29 | @interface B: A |
| 30 | @end |
| 31 | |
| 32 | @implementation B |
| 33 | + (void)G |
| 34 | { |
| 35 | [super F]; // expected-warning{{'F' is deprecated}} |
| 36 | } |
| 37 | |
| 38 | - (void)g |
| 39 | { |
| 40 | [super f]; // // expected-warning{{'f' is deprecated}} |
| 41 | } |
| 42 | @end |
| 43 | |
| 44 | @protocol P |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 45 | - (void)p __attribute__((deprecated)); // expected-note {{declared here}} |
Anders Carlsson | 59843ad | 2009-02-14 19:08:58 +0000 | [diff] [blame] | 46 | @end |
| 47 | |
| 48 | void t1(A *a) |
| 49 | { |
| 50 | [A F]; // expected-warning{{'F' is deprecated}} |
| 51 | [a f]; // expected-warning{{'f' is deprecated}} |
| 52 | } |
| 53 | |
| 54 | void t2(id a) |
| 55 | { |
Ted Kremenek | d6cf912 | 2012-02-10 02:45:47 +0000 | [diff] [blame] | 56 | [a f]; |
Anders Carlsson | 59843ad | 2009-02-14 19:08:58 +0000 | [diff] [blame] | 57 | } |
| 58 | |
| 59 | void t3(A<P>* a) |
| 60 | { |
| 61 | [a f]; // expected-warning{{'f' is deprecated}} |
| 62 | [a p]; // expected-warning{{'p' is deprecated}} |
| 63 | } |
| 64 | |
| 65 | void t4(Class c) |
| 66 | { |
| 67 | [c F]; |
| 68 | } |
| 69 | |
Chris Lattner | 7eba82e | 2009-02-16 18:35:08 +0000 | [diff] [blame] | 70 | |
| 71 | |
| 72 | @interface Bar |
| 73 | |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 74 | @property (assign, setter = MySetter:) int FooBar __attribute__ ((deprecated)); // expected-note 2 {{declared here}} |
Chris Lattner | 7eba82e | 2009-02-16 18:35:08 +0000 | [diff] [blame] | 75 | - (void) MySetter : (int) value; |
| 76 | @end |
| 77 | |
| 78 | int t5() { |
| 79 | Bar *f; |
Richard Trieu | 2fe9b7f | 2011-12-15 00:38:15 +0000 | [diff] [blame] | 80 | f.FooBar = 1; // expected-warning {{'FooBar' is deprecated}} |
| 81 | return f.FooBar; // expected-warning {{'FooBar' is deprecated}} |
Chris Lattner | 7eba82e | 2009-02-16 18:35:08 +0000 | [diff] [blame] | 82 | } |
| 83 | |
Chris Lattner | 16b34b4 | 2009-02-16 21:30:01 +0000 | [diff] [blame] | 84 | |
| 85 | __attribute ((deprecated)) |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 86 | @interface DEPRECATED { // expected-note 2 {{declared here}} |
Chris Lattner | 16b34b4 | 2009-02-16 21:30:01 +0000 | [diff] [blame] | 87 | @public int ivar; |
Argyrios Kyrtzidis | 3a38744 | 2011-10-06 23:23:20 +0000 | [diff] [blame] | 88 | DEPRECATED *ivar2; // no warning. |
Chris Lattner | 16b34b4 | 2009-02-16 21:30:01 +0000 | [diff] [blame] | 89 | } |
| 90 | - (int) instancemethod; |
Argyrios Kyrtzidis | 3a38744 | 2011-10-06 23:23:20 +0000 | [diff] [blame] | 91 | - (DEPRECATED *) meth; // no warning. |
Chris Lattner | 16b34b4 | 2009-02-16 21:30:01 +0000 | [diff] [blame] | 92 | @property int prop; |
| 93 | @end |
| 94 | |
Argyrios Kyrtzidis | c076e37 | 2011-10-06 23:23:27 +0000 | [diff] [blame] | 95 | @interface DEPRECATED (Category) // no warning. |
| 96 | - (DEPRECATED *) meth2; // no warning. |
| 97 | @end |
| 98 | |
| 99 | @interface DEPRECATED (Category2) // no warning. |
| 100 | @end |
| 101 | |
Richard Trieu | 2fe9b7f | 2011-12-15 00:38:15 +0000 | [diff] [blame] | 102 | @implementation DEPRECATED (Category2) // expected-warning {{'DEPRECATED' is deprecated}} |
Chris Lattner | 16b34b4 | 2009-02-16 21:30:01 +0000 | [diff] [blame] | 103 | @end |
Chris Lattner | c7984dd | 2009-02-16 21:33:09 +0000 | [diff] [blame] | 104 | |
Richard Trieu | 2fe9b7f | 2011-12-15 00:38:15 +0000 | [diff] [blame] | 105 | @interface NS : DEPRECATED // expected-warning {{'DEPRECATED' is deprecated}} |
Chris Lattner | c7984dd | 2009-02-16 21:33:09 +0000 | [diff] [blame] | 106 | @end |
| 107 | |
| 108 | |
John McCall | 5de74d1 | 2010-11-10 07:01:40 +0000 | [diff] [blame] | 109 | @interface Test2 |
Fariborz Jahanian | 350e956 | 2012-05-27 16:59:48 +0000 | [diff] [blame] | 110 | @property int test2 __attribute__((deprecated)); // expected-note 4 {{declared here}} |
John McCall | 5de74d1 | 2010-11-10 07:01:40 +0000 | [diff] [blame] | 111 | @end |
| 112 | |
| 113 | void test(Test2 *foo) { |
| 114 | int x; |
| 115 | x = foo.test2; // expected-warning {{'test2' is deprecated}} |
| 116 | x = [foo test2]; // expected-warning {{'test2' is deprecated}} |
| 117 | foo.test2 = x; // expected-warning {{'test2' is deprecated}} |
| 118 | [foo setTest2: x]; // expected-warning {{'setTest2:' is deprecated}} |
| 119 | } |
Douglas Gregor | 13d05ac | 2011-09-23 19:19:41 +0000 | [diff] [blame] | 120 | |
| 121 | __attribute__((deprecated)) |
| 122 | @interface A(Blah) // expected-error{{attributes may not be specified on a category}} |
| 123 | @end |
Eli Friedman | f66a0dd | 2012-08-08 23:04:35 +0000 | [diff] [blame] | 124 | |
| 125 | |
| 126 | typedef struct { |
| 127 | int x; |
| 128 | } footype __attribute((deprecated)); // expected-note 2 {{declared here}} |
| 129 | |
| 130 | @interface foo { |
| 131 | footype a; // expected-warning {{'footype' is deprecated}} |
| 132 | footype b __attribute((deprecated)); |
| 133 | } |
| 134 | @property footype c; // expected-warning {{'footype' is deprecated}} |
| 135 | @property footype d __attribute((deprecated)); |
| 136 | @end |