2014-11-08 08:23:55 +08:00
|
|
|
// 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
|
2009-02-15 03:08:58 +08:00
|
|
|
|
2009-02-17 01:19:12 +08:00
|
|
|
@interface A {
|
2013-12-19 07:30:06 +08:00
|
|
|
int X __attribute__((deprecated)); // expected-note 2 {{'X' has been explicitly marked deprecated here}}
|
2009-02-17 01:19:12 +08:00
|
|
|
}
|
2013-12-19 07:30:06 +08:00
|
|
|
+ (void)F __attribute__((deprecated)); // expected-note 2 {{'F' has been explicitly marked deprecated here}}
|
2014-11-08 07:51:15 +08:00
|
|
|
- (void)f __attribute__((deprecated)); // expected-note 5 {{'f' has been explicitly marked deprecated here}}
|
2009-02-15 03:08:58 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@implementation A
|
|
|
|
+ (void)F __attribute__((deprecated))
|
2011-10-22 09:21:15 +08:00
|
|
|
{
|
2009-02-17 01:08:46 +08:00
|
|
|
[self F]; // no warning, since the caller is also deprecated.
|
2009-02-15 03:08:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)g
|
|
|
|
{
|
2009-02-17 01:19:12 +08:00
|
|
|
X++; // expected-warning{{'X' is deprecated}}
|
|
|
|
self->X++; // expected-warning{{'X' is deprecated}}
|
2009-02-15 03:08:58 +08:00
|
|
|
[self f]; // expected-warning{{'f' is deprecated}}
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void)f
|
|
|
|
{
|
2009-02-17 03:35:30 +08:00
|
|
|
[self f]; // no warning, the caller is deprecated in its interface.
|
2009-02-15 03:08:58 +08:00
|
|
|
}
|
|
|
|
@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
|
2013-12-19 07:30:06 +08:00
|
|
|
- (void)p __attribute__((deprecated)); // expected-note {{'p' has been explicitly marked deprecated here}}
|
2009-02-15 03:08:58 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
void t1(A *a)
|
|
|
|
{
|
|
|
|
[A F]; // expected-warning{{'F' is deprecated}}
|
|
|
|
[a f]; // expected-warning{{'f' is deprecated}}
|
|
|
|
}
|
|
|
|
|
|
|
|
void t2(id a)
|
|
|
|
{
|
2014-11-08 07:51:15 +08:00
|
|
|
[a f]; // expected-warning {{'f' is deprecated}}
|
2009-02-15 03:08:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
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];
|
|
|
|
}
|
|
|
|
|
2009-02-17 02:35:08 +08:00
|
|
|
|
|
|
|
|
|
|
|
@interface Bar
|
|
|
|
|
2013-12-19 07:30:06 +08:00
|
|
|
@property (assign, setter = MySetter:) int FooBar __attribute__ ((deprecated)); // expected-note 2 {{'FooBar' has been explicitly marked deprecated here}}
|
2009-02-17 02:35:08 +08:00
|
|
|
- (void) MySetter : (int) value;
|
|
|
|
@end
|
|
|
|
|
|
|
|
int t5() {
|
|
|
|
Bar *f;
|
2011-12-15 08:38:15 +08:00
|
|
|
f.FooBar = 1; // expected-warning {{'FooBar' is deprecated}}
|
|
|
|
return f.FooBar; // expected-warning {{'FooBar' is deprecated}}
|
2009-02-17 02:35:08 +08:00
|
|
|
}
|
|
|
|
|
2009-02-17 05:30:01 +08:00
|
|
|
|
|
|
|
__attribute ((deprecated))
|
2013-12-19 07:30:06 +08:00
|
|
|
@interface DEPRECATED { // expected-note 2 {{'DEPRECATED' has been explicitly marked deprecated here}}
|
2009-02-17 05:30:01 +08:00
|
|
|
@public int ivar;
|
2011-10-07 07:23:20 +08:00
|
|
|
DEPRECATED *ivar2; // no warning.
|
2009-02-17 05:30:01 +08:00
|
|
|
}
|
|
|
|
- (int) instancemethod;
|
2011-10-07 07:23:20 +08:00
|
|
|
- (DEPRECATED *) meth; // no warning.
|
2009-02-17 05:30:01 +08:00
|
|
|
@property int prop;
|
|
|
|
@end
|
|
|
|
|
2011-10-07 07:23:27 +08:00
|
|
|
@interface DEPRECATED (Category) // no warning.
|
|
|
|
- (DEPRECATED *) meth2; // no warning.
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface DEPRECATED (Category2) // no warning.
|
|
|
|
@end
|
|
|
|
|
2011-12-15 08:38:15 +08:00
|
|
|
@implementation DEPRECATED (Category2) // expected-warning {{'DEPRECATED' is deprecated}}
|
2009-02-17 05:30:01 +08:00
|
|
|
@end
|
2009-02-17 05:33:09 +08:00
|
|
|
|
2011-12-15 08:38:15 +08:00
|
|
|
@interface NS : DEPRECATED // expected-warning {{'DEPRECATED' is deprecated}}
|
2009-02-17 05:33:09 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
|
2010-11-10 15:01:40 +08:00
|
|
|
@interface Test2
|
2013-12-19 07:30:06 +08:00
|
|
|
@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}}
|
2010-11-10 15:01:40 +08:00
|
|
|
@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}}
|
|
|
|
}
|
2011-09-24 03:19:41 +08:00
|
|
|
|
|
|
|
__attribute__((deprecated))
|
|
|
|
@interface A(Blah) // expected-error{{attributes may not be specified on a category}}
|
|
|
|
@end
|
2012-08-09 07:04:35 +08:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int x;
|
2013-12-19 07:30:06 +08:00
|
|
|
} footype __attribute((deprecated)); // expected-note 2 {{'footype' has been explicitly marked deprecated here}}
|
2012-08-09 07:04:35 +08:00
|
|
|
|
|
|
|
@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
|
2013-04-05 02:45:52 +08:00
|
|
|
|
|
|
|
// rdar://13569424
|
|
|
|
@interface NewI
|
|
|
|
+(void)cmeth;
|
|
|
|
@end
|
|
|
|
|
2013-12-19 07:30:06 +08:00
|
|
|
typedef NewI DeprI __attribute__((deprecated("blah"))); // expected-note 4 {{'DeprI' has been explicitly marked deprecated here}}
|
2013-04-05 02:45:52 +08:00
|
|
|
|
|
|
|
@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
|
2013-11-21 01:24:03 +08:00
|
|
|
|
|
|
|
// <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
|
2014-07-18 01:05:04 +08:00
|
|
|
|
|
|
|
// 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}} \
|
2014-10-11 06:08:23 +08:00
|
|
|
expected-note {{'setObject:' has been explicitly marked deprecated here}} \
|
|
|
|
expected-note {{property declared here}}
|
2014-07-18 01:05:04 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@interface TestDerived : TestBase
|
2014-08-30 02:31:16 +08:00
|
|
|
@property (nonatomic, strong) id object; //expected-warning {{auto property synthesis will not synthesize property 'object'; it will be implemented by its superclass}}
|
2014-07-18 01:05:04 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
@interface TestUse @end
|
|
|
|
|
|
|
|
@implementation TestBase @end
|
|
|
|
|
2014-07-27 04:52:26 +08:00
|
|
|
@implementation TestDerived @end // expected-note {{detected while default synthesizing properties in class implementation}}
|
2014-07-18 01:05:04 +08:00
|
|
|
|
|
|
|
@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
|
|
|
|
|
2014-11-08 07:51:15 +08:00
|
|
|
// 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() {
|
|
|
|
return [PID cString]; // expected-warning {{'cString' is deprecated: first deprecated in OS X 10.4}}
|
|
|
|
}
|
|
|
|
|
2014-11-14 06:27:05 +08:00
|
|
|
// 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
|
|
|
|
|
2014-12-27 09:05:55 +08:00
|
|
|
@implementation UndeclaredImpl // expected-warning{{cannot find interface declaration}}
|
|
|
|
- (void)partiallyUnavailableMethod {}
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface InterfaceWithSameMethodAsUndeclaredImpl
|
2014-12-27 15:09:37 +08:00
|
|
|
- (void)partiallyUnavailableMethod __attribute__((unavailable));
|
2014-12-27 09:05:55 +08:00
|
|
|
@end
|
|
|
|
|
|
|
|
void f(id a) {
|
2014-12-27 15:09:37 +08:00
|
|
|
[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.
|
2014-12-27 09:05:55 +08:00
|
|
|
}
|
2015-01-21 04:41:36 +08:00
|
|
|
|
|
|
|
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
|