Rafael Espindola | 8c4222a | 2013-01-08 21:30:32 +0000 | [diff] [blame] | 1 | // RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -fblocks -verify %s |
Douglas Gregor | 0a0d2b1 | 2011-03-23 00:50:03 +0000 | [diff] [blame] | 2 | |
Fariborz Jahanian | faab561 | 2012-10-01 18:42:25 +0000 | [diff] [blame] | 3 | void f0() __attribute__((availability(macosx,introduced=10.4,deprecated=10.2))); // expected-warning{{feature cannot be deprecated in OS X version 10.2 before it was introduced in version 10.4; attribute ignored}} |
Douglas Gregor | 0a0d2b1 | 2011-03-23 00:50:03 +0000 | [diff] [blame] | 4 | void f1() __attribute__((availability(ios,obsoleted=2.1,deprecated=3.0))); // expected-warning{{feature cannot be obsoleted in iOS version 2.1 before it was deprecated in version 3.0; attribute ignored}} |
Douglas Gregor | 3b6b7ac | 2011-08-10 15:31:35 +0000 | [diff] [blame] | 5 | void f2() __attribute__((availability(ios,introduced=2.1,deprecated=2.1))); |
Douglas Gregor | 0a0d2b1 | 2011-03-23 00:50:03 +0000 | [diff] [blame] | 6 | |
Douglas Gregor | 3b6b7ac | 2011-08-10 15:31:35 +0000 | [diff] [blame] | 7 | void f3() __attribute__((availability(otheros,introduced=2.2))); // expected-warning{{unknown platform 'otheros' in availability macro}} |
Fariborz Jahanian | 006e42f | 2011-12-10 00:28:41 +0000 | [diff] [blame] | 8 | |
| 9 | // rdar://10095131 |
| 10 | extern void |
Fariborz Jahanian | d672436 | 2012-04-23 20:30:52 +0000 | [diff] [blame] | 11 | ATSFontGetName(const char *oName) __attribute__((availability(macosx,introduced=8.0,deprecated=9.0, message="use CTFontCopyFullName"))); // expected-note {{'ATSFontGetName' declared here}} |
Fariborz Jahanian | 006e42f | 2011-12-10 00:28:41 +0000 | [diff] [blame] | 12 | |
| 13 | extern void |
| 14 | ATSFontGetPostScriptName(int flags) __attribute__((availability(macosx,introduced=8.0,obsoleted=9.0, message="use ATSFontGetFullPostScriptName"))); // expected-note {{function has been explicitly marked unavailable here}} |
| 15 | |
| 16 | void test_10095131() { |
Fariborz Jahanian | faab561 | 2012-10-01 18:42:25 +0000 | [diff] [blame] | 17 | ATSFontGetName("Hello"); // expected-warning {{'ATSFontGetName' is deprecated: first deprecated in OS X 9.0 - use CTFontCopyFullName}} |
| 18 | ATSFontGetPostScriptName(100); // expected-error {{'ATSFontGetPostScriptName' is unavailable: obsoleted in OS X 9.0 - use ATSFontGetFullPostScriptName}} |
Fariborz Jahanian | 006e42f | 2011-12-10 00:28:41 +0000 | [diff] [blame] | 19 | } |
Fariborz Jahanian | f96708d | 2012-01-23 23:38:32 +0000 | [diff] [blame] | 20 | |
| 21 | // rdar://10711037 |
| 22 | __attribute__((availability(macos, unavailable))) // expected-warning {{attribute 'availability' is ignored}} |
| 23 | enum { |
| 24 | NSDataWritingFileProtectionWriteOnly = 0x30000000, |
| 25 | NSDataWritingFileProtectionCompleteUntilUserAuthentication = 0x40000000, |
| 26 | }; |
Rafael Espindola | 3b29436 | 2012-05-06 19:56:25 +0000 | [diff] [blame] | 27 | |
| 28 | void f4(int) __attribute__((availability(ios,deprecated=3.0))); |
| 29 | void f4(int) __attribute__((availability(ios,introduced=4.0))); // expected-warning {{feature cannot be deprecated in iOS version 3.0 before it was introduced in version 4.0; attribute ignored}} |
| 30 | |
Rafael Espindola | 9b79fc9 | 2012-05-07 23:58:18 +0000 | [diff] [blame] | 31 | void f5(int) __attribute__((availability(ios,deprecated=3.0), |
| 32 | availability(ios,introduced=4.0))); // expected-warning {{feature cannot be deprecated in iOS version 3.0 before it was introduced in version 4.0; attribute ignored}} |
Rafael Espindola | 3b29436 | 2012-05-06 19:56:25 +0000 | [diff] [blame] | 33 | |
| 34 | void f6(int) __attribute__((availability(ios,deprecated=3.0))); // expected-note {{previous attribute is here}} |
| 35 | void f6(int) __attribute__((availability(ios,deprecated=4.0))); // expected-warning {{availability does not match previous declaration}} |
| 36 | |
| 37 | void f7(int) __attribute__((availability(ios,introduced=2.0))); |
| 38 | void f7(int) __attribute__((availability(ios,deprecated=3.0))); // expected-note {{previous attribute is here}} |
| 39 | void f7(int) __attribute__((availability(ios,deprecated=4.0))); // expected-warning {{availability does not match previous declaration}} |
Jordan Rose | b43f638 | 2012-07-24 21:55:34 +0000 | [diff] [blame] | 40 | |
| 41 | |
| 42 | // <rdar://problem/11886458> |
| 43 | #if !__has_feature(attribute_availability_with_message) |
| 44 | # error "Missing __has_feature" |
| 45 | #endif |
Rafael Espindola | d63b19e | 2013-01-08 04:04:30 +0000 | [diff] [blame] | 46 | |
| 47 | extern int x __attribute__((availability(macosx,introduced=10.5))); |
| 48 | extern int x; |
Rafael Espindola | 8c4222a | 2013-01-08 21:30:32 +0000 | [diff] [blame] | 49 | |
| 50 | void f8() { |
| 51 | int (^b)(int); |
| 52 | b = ^ (int i) __attribute__((availability(macosx,introduced=10.2))) { return 1; }; // expected-warning {{'availability' attribute ignored}} |
| 53 | } |
Rafael Espindola | d130fd2 | 2013-01-08 22:31:36 +0000 | [diff] [blame] | 54 | |
| 55 | extern int x2 __attribute__((availability(macosx,introduced=10.2))); // expected-note {{previous attribute is here}} |
| 56 | extern int x2 __attribute__((availability(macosx,introduced=10.5))); // expected-warning {{availability does not match previous declaration}} |