Home | History | Annotate | Download | only in SemaObjC
      1 // RUN: %clang_cc1 %s -fsyntax-only -verify
      2 
      3 @interface A {
      4   int X __attribute__((deprecated));
      5 }
      6 + (void)F __attribute__((deprecated));
      7 - (void)f __attribute__((deprecated));
      8 @end
      9 
     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.
     14 }
     15 
     16 - (void)g
     17 {
     18   X++;        // expected-warning{{'X' is deprecated}}
     19   self->X++;  // expected-warning{{'X' is deprecated}}
     20   [self f]; // expected-warning{{'f' is deprecated}}
     21 }
     22 
     23 - (void)f
     24 {
     25   [self f]; // no warning, the caller is deprecated in its interface.
     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
     45 - (void)p __attribute__((deprecated));
     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 {
     56   [a f];
     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 
     70 
     71 
     72 @interface Bar 
     73 
     74 @property (assign, setter = MySetter:) int FooBar __attribute__ ((deprecated));
     75 - (void) MySetter : (int) value;
     76 @end
     77 
     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}}
     82 }
     83 
     84 
     85 __attribute ((deprecated))  
     86 @interface DEPRECATED {
     87   @public int ivar; 
     88   DEPRECATED *ivar2; // no warning.
     89 } 
     90 - (int) instancemethod;
     91 - (DEPRECATED *) meth; // no warning.
     92 @property  int prop; 
     93 @end
     94 
     95 @interface DEPRECATED (Category) // no warning.
     96 - (DEPRECATED *) meth2; // no warning.
     97 @end
     98 
     99 @interface DEPRECATED (Category2) // no warning.
    100 @end
    101 
    102 @implementation DEPRECATED (Category2) // expected-warning {{warning: 'DEPRECATED' is deprecated}}
    103 @end
    104 
    105 @interface NS : DEPRECATED  // expected-warning {{warning: 'DEPRECATED' is deprecated}}
    106 @end
    107 
    108 
    109 @interface Test2
    110 @property int test2 __attribute__((deprecated));
    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 }
    120 
    121 __attribute__((deprecated))
    122 @interface A(Blah) // expected-error{{attributes may not be specified on a category}}
    123 @end
    124