summaryrefslogtreecommitdiffstats
path: root/test/SemaObjC/attr-deprecated.m
blob: e385a977f55b3aabf97441aa05c9ad0bb020d458 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// RUN: clang-cc %s -fsyntax-only -verify

@interface A {
  int X __attribute__((deprecated));
}
+ (void)F __attribute__((deprecated));
- (void)f __attribute__((deprecated));
@end

@implementation A
+ (void)F __attribute__((deprecated))
{	// expected-warning {{method attribute can only be specified on method declarations}}
  [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 {{warning: 'FooBar' is deprecated}}
  return f.FooBar; // expected-warning {{warning: 'FooBar' is deprecated}}
}


__attribute ((deprecated))  
@interface DEPRECATED {
  @public int ivar; 
} 
- (int) instancemethod;
@property  int prop; 
@end

@interface DEPRECATED (Category) // expected-warning {{warning: 'DEPRECATED' is deprecated}}
@end

@interface NS : DEPRECATED  // expected-warning {{warning: 'DEPRECATED' is deprecated}}
@end


OpenPOWER on IntegriCloud