| 1 |
/// This test verifies several different patterns of iOS, and app extension, availability declarations & usages. |
| 2 |
// RUN: %clang_cc1 "-triple" "arm64-apple-ios26" -DNEW -fsyntax-only -verify %s |
| 3 |
// RUN: %clang_cc1 "-triple" "arm64-apple-ios18" -fsyntax-only -verify -fapplication-extension -DAPP_EXT %s |
| 4 |
// RUN: %clang_cc1 "-triple" "arm64-apple-ios18" -fsyntax-only -verify %s |
| 5 |
|
| 6 |
__attribute__((availability(ios,strict,introduced=19))) |
| 7 |
void fNew1(); |
| 8 |
#ifndef NEW |
| 9 |
// expected-note@-2 {{here}} |
| 10 |
#endif |
| 11 |
|
| 12 |
__attribute__((availability(ios,strict,introduced=19))) |
| 13 |
void fNew(); |
| 14 |
|
| 15 |
__attribute__((availability(ios,strict,introduced=26))) |
| 16 |
void fNew() { } |
| 17 |
#ifndef NEW |
| 18 |
// expected-note@-2 {{here}} |
| 19 |
#endif |
| 20 |
|
| 21 |
__attribute__((availability(ios,strict,deprecated=19))) |
| 22 |
void fDep(); |
| 23 |
|
| 24 |
__attribute__((availability(ios,strict,deprecated=26))) |
| 25 |
void fDep() { } |
| 26 |
#ifdef NEW |
| 27 |
// expected-note@-2 {{here}} |
| 28 |
#endif |
| 29 |
|
| 30 |
__attribute__((availability(ios,strict,obsoleted=19))) |
| 31 |
void fObs(); |
| 32 |
|
| 33 |
__attribute__((availability(ios,strict,obsoleted=26))) |
| 34 |
void fObs() { } |
| 35 |
#ifdef NEW |
| 36 |
// expected-note@-2 {{here}} |
| 37 |
#endif |
| 38 |
|
| 39 |
__attribute__((availability(ios_app_extension,strict,introduced=19))) |
| 40 |
void fAppExt(); |
| 41 |
|
| 42 |
__attribute__((availability(ios_app_extension,strict,introduced=26))) |
| 43 |
void fAppExt() { } |
| 44 |
#ifdef APP_EXT |
| 45 |
// expected-note@-2 {{here}} |
| 46 |
#endif |
| 47 |
|
| 48 |
void testVersionRemapping() { |
| 49 |
fNew1(); |
| 50 |
#ifndef NEW |
| 51 |
// expected-error@-2 {{'fNew1' is unavailable: introduced in iOS 26.0}} |
| 52 |
#endif |
| 53 |
fNew(); |
| 54 |
#ifndef NEW |
| 55 |
// expected-error@-2 {{'fNew' is unavailable: introduced in iOS 26}} |
| 56 |
#endif |
| 57 |
fDep(); |
| 58 |
#ifdef NEW |
| 59 |
// expected-warning@-2 {{'fDep' is deprecated: first deprecated in iOS 26}} |
| 60 |
#endif |
| 61 |
fObs(); |
| 62 |
#ifdef NEW |
| 63 |
// expected-error@-2 {{'fObs' is unavailable: obsoleted in iOS 26}} |
| 64 |
#endif |
| 65 |
|
| 66 |
fAppExt(); |
| 67 |
#ifdef APP_EXT |
| 68 |
// expected-error@-2 {{'fAppExt' is unavailable: introduced in iOS (App Extension) 26}} |
| 69 |
#endif |
| 70 |
} |
| 71 |
|
| 72 |
__attribute__((availability(ios,strict,introduced=18.5))) // expected-note {{here}} |
| 73 |
void fMatchErr(); |
| 74 |
|
| 75 |
__attribute__((availability(ios,strict,introduced=26))) // expected-warning {{availability does not match previous declaration}} |
| 76 |
void fMatchErr() { } |
| 77 |
|
| 78 |
__attribute__((availability(ios_app_extension,strict,introduced=19))) // expected-note {{here}} |
| 79 |
void fAppExtErr(); |
| 80 |
|
| 81 |
__attribute__((availability(ios_app_extension,strict,introduced=26.1))) // expected-warning {{availability does not match previous declaration}} |
| 82 |
void fAppExtErr() { } |
| 83 |
|
| 84 |
__attribute__((availability(ios,introduced=26))) |
| 85 |
void fNew2(); |
| 86 |
#ifndef NEW |
| 87 |
// expected-note@-2 {{'fNew2' has been marked as being introduced in iOS 26 here, but the deployment target is iOS 18}} |
| 88 |
#endif |
| 89 |
__attribute__((availability(ios,introduced=19))) |
| 90 |
void fNew3(); |
| 91 |
|
| 92 |
__attribute__((availability(ios,introduced=27))) |
| 93 |
void evenNewer(); |
| 94 |
#ifdef NEW |
| 95 |
// expected-note@-2 {{'evenNewer' has been marked as being introduced in iOS 27 here, but the deployment target is iOS 26}} |
| 96 |
#endif |
| 97 |
|
| 98 |
void testAvailabilityCheck() { |
| 99 |
if (__builtin_available(iOS 19, *)) { |
| 100 |
fNew2(); |
| 101 |
fNew3(); |
| 102 |
} |
| 103 |
if (__builtin_available(iOS 26, *)) { |
| 104 |
fNew2(); |
| 105 |
fNew3(); |
| 106 |
} |
| 107 |
fNew2(); |
| 108 |
#ifndef NEW |
| 109 |
// expected-warning@-2 {{'fNew2' is only available on iOS 26 or newer}} expected-note@-2 {{enclose}} |
| 110 |
#endif |
| 111 |
#ifdef NEW |
| 112 |
evenNewer(); // expected-warning {{'evenNewer' is only available on iOS 27 or newer}} expected-note {{enclose}} |
| 113 |
#endif |
| 114 |
} |
| 115 |
|
| 116 |
|