2010-12-21 08:44:01 +08:00
|
|
|
// RUN: %clang_cc1 -fsyntax-only -verify %s
|
|
|
|
// rdar://8769853
|
|
|
|
|
|
|
|
@interface B
|
|
|
|
- (void) depInA;
|
2011-06-16 07:02:42 +08:00
|
|
|
- (void) unavailMeth __attribute__((unavailable)); // expected-note {{has been explicitly marked unavailable here}}
|
2010-12-21 08:44:01 +08:00
|
|
|
- (void) depInA1 __attribute__((deprecated));
|
|
|
|
- (void) unavailMeth1;
|
|
|
|
- (void) depInA2 __attribute__((deprecated));
|
2011-06-16 07:02:42 +08:00
|
|
|
- (void) unavailMeth2 __attribute__((unavailable)); // expected-note {{has been explicitly marked unavailable here}}
|
2010-12-21 08:44:01 +08:00
|
|
|
- (void) depunavailInA;
|
2011-06-16 07:02:42 +08:00
|
|
|
- (void) depunavailInA1 __attribute__((deprecated)) __attribute__((unavailable)); // expected-note {{has been explicitly marked unavailable here}}
|
2010-12-21 08:44:01 +08:00
|
|
|
- (void)FuzzyMeth __attribute__((deprecated));
|
|
|
|
- (void)FuzzyMeth1 __attribute__((unavailable));
|
|
|
|
@end
|
|
|
|
|
|
|
|
@interface A
|
2011-06-16 07:02:42 +08:00
|
|
|
- (void) unavailMeth1 __attribute__((unavailable)); // expected-note {{has been explicitly marked unavailable here}}
|
2010-12-21 08:44:01 +08:00
|
|
|
- (void) depInA __attribute__((deprecated));
|
|
|
|
- (void) depInA2 __attribute__((deprecated));
|
|
|
|
- (void) depInA1;
|
|
|
|
- (void) unavailMeth2 __attribute__((unavailable));
|
2011-06-16 07:02:42 +08:00
|
|
|
- (void) depunavailInA __attribute__((deprecated)) __attribute__((unavailable)); // expected-note {{has been explicitly marked unavailable here}}
|
2010-12-21 08:44:01 +08:00
|
|
|
- (void) depunavailInA1;
|
|
|
|
- (void)FuzzyMeth __attribute__((unavailable));
|
|
|
|
- (void)FuzzyMeth1 __attribute__((deprecated));
|
|
|
|
@end
|
|
|
|
|
|
|
|
|
2011-11-15 06:10:01 +08:00
|
|
|
@class C; // expected-note 5 {{forward declaration of class here}}
|
2010-12-21 08:44:01 +08:00
|
|
|
|
|
|
|
void test(C *c) {
|
|
|
|
[c depInA]; // expected-warning {{'depInA' maybe deprecated because receiver type is unknown}}
|
|
|
|
[c unavailMeth]; // expected-warning {{'unavailMeth' maybe unavailable because receiver type is unknown}}
|
|
|
|
[c depInA1]; // expected-warning {{'depInA1' maybe deprecated because receiver type is unknown}}
|
|
|
|
[c unavailMeth1]; // expected-warning {{'unavailMeth1' maybe unavailable because receiver type is unknown}}
|
|
|
|
[c depInA2]; // expected-warning {{'depInA2' maybe deprecated because receiver type is unknown}}
|
|
|
|
[c unavailMeth2]; // expected-warning {{'unavailMeth2' maybe unavailable because receiver type is unknown}}
|
Implement a new 'availability' attribute, that allows one to specify
which versions of an OS provide a certain facility. For example,
void foo()
__attribute__((availability(macosx,introduced=10.2,deprecated=10.4,obsoleted=10.6)));
says that the function "foo" was introduced in 10.2, deprecated in
10.4, and completely obsoleted in 10.6. This attribute ties in with
the deployment targets (e.g., -mmacosx-version-min=10.1 specifies that
we want to deploy back to Mac OS X 10.1). There are several concrete
behaviors that this attribute enables, as illustrated with the
function foo() above:
- If we choose a deployment target >= Mac OS X 10.4, uses of "foo"
will result in a deprecation warning, as if we had placed
attribute((deprecated)) on it (but with a better diagnostic)
- If we choose a deployment target >= Mac OS X 10.6, uses of "foo"
will result in an "unavailable" warning (in C)/error (in C++), as
if we had placed attribute((unavailable)) on it
- If we choose a deployment target prior to 10.2, foo() is
weak-imported (if it is a kind of entity that can be weak
imported), as if we had placed the weak_import attribute on it.
Naturally, there can be multiple availability attributes on a
declaration, for different platforms; only the current platform
matters when checking availability attributes.
The only platforms this attribute currently works for are "ios" and
"macosx", since we already have -mxxxx-version-min flags for them and we
have experience there with macro tricks translating down to the
deprecated/unavailable/weak_import attributes. The end goal is to open
this up to other platforms, and even extension to other "platforms"
that are really libraries (say, through a #pragma clang
define_system), but that hasn't yet been designed and we may want to
shake out more issues with this narrower problem first.
Addresses <rdar://problem/6690412>.
As a drive-by bug-fix, if an entity is both deprecated and
unavailable, we only emit the "unavailable" diagnostic.
llvm-svn: 128127
2011-03-23 08:50:03 +08:00
|
|
|
[c depunavailInA]; // expected-warning {{'depunavailInA' maybe unavailable because receiver type is unknown}}
|
|
|
|
[c depunavailInA1];// expected-warning {{'depunavailInA1' maybe unavailable because receiver type is unknown}}
|
2010-12-21 08:44:01 +08:00
|
|
|
[c FuzzyMeth]; // expected-warning {{'FuzzyMeth' maybe deprecated because receiver type is unknown}}
|
|
|
|
[c FuzzyMeth1]; // expected-warning {{'FuzzyMeth1' maybe deprecated because receiver type is unknown}}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2011-10-16 03:18:36 +08:00
|
|
|
// rdar://10268422
|
|
|
|
__attribute ((deprecated))
|
|
|
|
@interface DEPRECATED
|
|
|
|
+(id)new;
|
|
|
|
@end
|
|
|
|
|
|
|
|
void foo() {
|
2011-12-15 08:38:15 +08:00
|
|
|
[DEPRECATED new]; // expected-warning {{'DEPRECATED' is deprecated}}
|
2011-10-16 03:18:36 +08:00
|
|
|
}
|
|
|
|
|