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 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311
|
// RUN: %clang_cc1 -fsyntax-only -triple x86_64-apple-darwin10.4 -verify -Wno-objc-root-class %s
// RUN: %clang_cc1 -x objective-c++ -fsyntax-only -triple x86_64-apple-darwin10.4 -verify -Wno-objc-root-class %s
@interface A {
int X __attribute__((deprecated)); // expected-note 2 {{'X' has been explicitly marked deprecated here}}
}
+ (void)F __attribute__((deprecated)); // expected-note 2 {{'F' has been explicitly marked deprecated here}}
- (void)f __attribute__((deprecated)); // expected-note 5 {{'f' has been explicitly marked deprecated here}}
@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)); // expected-note {{'p' has been explicitly marked deprecated here}}
@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]; // expected-warning {{'f' is deprecated}}
}
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)); // expected-note 2 {{'FooBar' has been explicitly marked deprecated here}}
- (void) MySetter : (int) value;
@end
int t5(void) {
Bar *f;
f.FooBar = 1; // expected-warning {{'FooBar' is deprecated}}
return f.FooBar; // expected-warning {{'FooBar' is deprecated}}
}
__attribute ((deprecated)) // expected-note {{'DEPRECATED' has been explicitly marked deprecated here}}
@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.
- (id)meth;
@end
__attribute__((deprecated))
void depr_function(void);
@implementation DEPRECATED (Category2) // no warning
- (id)meth {
depr_function(); // no warning.
return 0;
}
@end
@interface NS : DEPRECATED // expected-warning {{'DEPRECATED' is deprecated}}
@end
@interface Test2
@property int test2 __attribute__((deprecated)); // expected-note 2 {{property 'test2' is declared deprecated here}} expected-note 3 {{'test2' has been explicitly marked deprecated here}} \
// expected-note {{'setTest2:' has been explicitly marked deprecated here}}
@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) // no warning
- (A*)getA;
@end
@implementation A(Blah) // Don't warn by default
- (A*)getA {
return self;
}
@end
typedef struct {
int x;
} footype __attribute((deprecated)); // expected-note 2 {{'footype' has been explicitly marked deprecated here}}
@interface foo {
footype a; // expected-warning {{'footype' is deprecated}}
footype b __attribute((deprecated));
}
@property footype c; // expected-warning {{'footype' is deprecated}}
@property footype d __attribute((deprecated));
@end
// rdar://13569424
@interface NewI
+(void)cmeth;
@end
typedef NewI DeprI __attribute__((deprecated("blah"))); // expected-note 4 {{'DeprI' has been explicitly marked deprecated here}}
@interface SI : DeprI // expected-warning {{'DeprI' is deprecated: blah}}
-(DeprI*)meth; // expected-warning {{'DeprI' is deprecated: blah}}
@end
@implementation SI
-(DeprI*)meth { // expected-warning {{'DeprI' is deprecated: blah}}
[DeprI cmeth]; // expected-warning {{'DeprI' is deprecated: blah}}
return 0;
}
@end
// <rdar://problem/15407366> and <rdar://problem/15466783>:
// - Using deprecated class name inside class should not warn about deprecation.
// - Implementations of deprecated classes should not result in deprecation warnings.
__attribute__((deprecated))
@interface DeprecatedClassA
@end
__attribute__((deprecated))
@interface DeprecatedClassB
// The self-reference return value should not be
// flagged as the use of a deprecated declaration.
+ (DeprecatedClassB *)sharedInstance; // no-warning
// Since this class is deprecated, returning a reference
// to another deprecated class is fine as they may
// have been deprecated together. From a user's
// perspective they are all deprecated.
+ (DeprecatedClassA *)somethingElse; // no-warning
@end
@implementation DeprecatedClassB
+ (DeprecatedClassB *)sharedInstance
{
// This self-reference should not
// be flagged as a use of a deprecated
// declaration.
static DeprecatedClassB *x; // no-warning
return x;
}
+ (DeprecatedClassA *)somethingElse {
// Since this class is deprecated, referencing
// another deprecated class is also OK.
static DeprecatedClassA *x; // no-warning
return x;
}
@end
// rdar://16068470
@interface TestBase
@property (nonatomic, strong) id object __attribute__((deprecated("deprecated"))); // expected-note {{'object' has been explicitly marked deprecated here}} \
expected-note {{property 'object' is declared deprecated here}} \
expected-note {{'setObject:' has been explicitly marked deprecated here}} \
expected-note {{property declared here}}
@end
@interface TestDerived : TestBase
@property (nonatomic, strong) id object; //expected-warning {{auto property synthesis will not synthesize property 'object'; it will be implemented by its superclass}}
@end
@interface TestUse @end
@implementation TestBase @end
@implementation TestDerived @end // expected-note {{detected while default synthesizing properties in class implementation}}
@implementation TestUse
- (void) use
{
TestBase *base = (id)0;
TestDerived *derived = (id)0;
id object = (id)0;
base.object = object; // expected-warning {{'object' is deprecated: deprecated}}
derived.object = object;
[base setObject:object]; // expected-warning {{'setObject:' is deprecated: deprecated}}
[derived setObject:object];
}
@end
// rdar://18848183
@interface NSString
- (const char *)cString __attribute__((availability(macosx,introduced=10.0 ,deprecated=10.4,message="" ))); // expected-note {{'cString' has been explicitly marked deprecated here}}
@end
id PID = 0;
const char * func(void) {
return [PID cString]; // expected-warning {{'cString' is deprecated: first deprecated in macOS 10.4}}
}
// rdar://18960378
@interface NSObject
+ (instancetype)alloc;
- (instancetype)init;
@end
@interface NSLocale
- (instancetype)init __attribute__((unavailable));
@end
@interface PLBatteryProperties : NSObject
+ (id)properties;
@end
@implementation PLBatteryProperties
+ (id)properties {
return [[self alloc] init];
}
@end
@implementation UndeclaredImpl // expected-warning{{cannot find interface declaration}}
- (void)partiallyUnavailableMethod {}
@end
@interface InterfaceWithSameMethodAsUndeclaredImpl
- (void)partiallyUnavailableMethod __attribute__((unavailable));
@end
void f(id a) {
[a partiallyUnavailableMethod]; // no warning, `a` could be an UndeclaredImpl.
}
@interface InterfaceWithImplementation
- (void)anotherPartiallyUnavailableMethod;
@end
@implementation InterfaceWithImplementation
- (void)anotherPartiallyUnavailableMethod {}
@end
@interface InterfaceWithSameMethodAsInterfaceWithImplementation
- (void)anotherPartiallyUnavailableMethod __attribute__((unavailable));
@end
void g(id a) {
[a anotherPartiallyUnavailableMethod]; // no warning, `a` could be an InterfaceWithImplementation.
}
typedef struct {} S1 __attribute__((unavailable)); // expected-note2{{marked unavailable here}}
typedef struct {} S2 __attribute__((deprecated)); // expected-note2{{marked deprecated here}}
@interface ExtensionForMissingInterface() // expected-error{{cannot find interface declaration}}
- (void)method1:(S1) x; // expected-error{{is unavailable}}
- (void)method2:(S2) x; // expected-warning{{is deprecated}}
@end
@interface CategoryForMissingInterface(Cat) // expected-error{{cannot find interface declaration}}
- (void)method1:(S1) x; // expected-error{{is unavailable}}
- (void)method2:(S2) x; // expected-warning{{is deprecated}}
@end
|