[Heikki Kultala] This patch contains the ABI changes for the TCE target.
[clang.git] / test / SemaObjC / attr-deprecated.m
blobd3d5f9537b738eaa16ccfc29dd86dab4b5ad63c9
1 // RUN: %clang_cc1 %s -fsyntax-only -verify
3 @interface A {
4   int X __attribute__((deprecated));
6 + (void)F __attribute__((deprecated));
7 - (void)f __attribute__((deprecated));
8 @end
10 @implementation A
11 + (void)F __attribute__((deprecated))
12 {       // expected-warning {{method attribute can only be specified on method declarations}}
13   [self F]; // no warning, since the caller is also deprecated.
16 - (void)g
18   X++;        // expected-warning{{'X' is deprecated}}
19   self->X++;  // expected-warning{{'X' is deprecated}}
20   [self f]; // expected-warning{{'f' is deprecated}}
23 - (void)f
25   [self f]; // no warning, the caller is deprecated in its interface.
27 @end
29 @interface B: A
30 @end
31   
32 @implementation B
33 + (void)G
35   [super F]; // expected-warning{{'F' is deprecated}}
38 - (void)g
40   [super f]; // // expected-warning{{'f' is deprecated}}
42 @end
44 @protocol P
45 - (void)p __attribute__((deprecated));
46 @end
48 void t1(A *a)
50   [A F]; // expected-warning{{'F' is deprecated}}
51   [a f]; // expected-warning{{'f' is deprecated}}
54 void t2(id a)
56   [a f];
59 void t3(A<P>* a)
61   [a f]; // expected-warning{{'f' is deprecated}}
62   [a p]; // expected-warning{{'p' is deprecated}}
63
65 void t4(Class c)
67   [c F];
72 @interface Bar 
74 @property (assign, setter = MySetter:) int FooBar __attribute__ ((deprecated));
75 - (void) MySetter : (int) value;
76 @end
78 int t5() {
79   Bar *f;
80   f.FooBar = 1;    // expected-warning {{warning: 'FooBar' is deprecated}}
81   return f.FooBar; // expected-warning {{warning: 'FooBar' is deprecated}}
85 __attribute ((deprecated))  
86 @interface DEPRECATED {
87   @public int ivar; 
88
89 - (int) instancemethod;
90 @property  int prop; 
91 @end
93 @interface DEPRECATED (Category) // expected-warning {{warning: 'DEPRECATED' is deprecated}}
94 @end
96 @interface NS : DEPRECATED  // expected-warning {{warning: 'DEPRECATED' is deprecated}}
97 @end
100 @interface Test2
101 @property int test2 __attribute__((deprecated));
102 @end
104 void test(Test2 *foo) {
105   int x;
106   x = foo.test2; // expected-warning {{'test2' is deprecated}}
107   x = [foo test2]; // expected-warning {{'test2' is deprecated}}
108   foo.test2 = x; // expected-warning {{'test2' is deprecated}}
109   [foo setTest2: x]; // expected-warning {{'setTest2:' is deprecated}}