| 1 |
// RUN: %clang_cc1 -triple x86_64-apple-darwin9 -fsyntax-only -fblocks -verify %s |
| 2 |
// RUN: %clang_cc1 -D WARN_PARTIAL -Wpartial-availability -triple x86_64-apple-darwin9 -fsyntax-only -fblocks -verify %s |
| 3 |
// |
| 4 |
|
| 5 |
void f0(void) __attribute__((availability(macosx,introduced=10.4,deprecated=10.2))); // expected-warning{{feature cannot be deprecated in macOS version 10.2 before it was introduced in version 10.4; attribute ignored}} |
| 6 |
void f1(void) __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}} |
| 7 |
void f2(void) __attribute__((availability(ios,introduced=2.1,deprecated=2.1))); |
| 8 |
|
| 9 |
void f3(void) __attribute__((availability(otheros,introduced=2.2))); // expected-warning{{unknown platform 'otheros' in availability macro}} |
| 10 |
|
| 11 |
extern void |
| 12 |
ATSFontGetName(const char *oName) __attribute__((availability(macosx,introduced=8.0,deprecated=9.0, message="use CTFontCopyFullName"))); // expected-note {{'ATSFontGetName' has been explicitly marked deprecated here}} |
| 13 |
|
| 14 |
extern void |
| 15 |
ATSFontGetPostScriptName(int flags) __attribute__((availability(macosx,introduced=8.0,obsoleted=9.0, message="use ATSFontGetFullPostScriptName"))); // expected-note {{'ATSFontGetPostScriptName' has been explicitly marked unavailable here}} |
| 16 |
|
| 17 |
#if defined(WARN_PARTIAL) |
| 18 |
// expected-note@+3 {{'PartiallyAvailable' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5}} |
| 19 |
#endif |
| 20 |
extern void |
| 21 |
PartiallyAvailable(void) __attribute__((availability(macosx,introduced=10.8))); |
| 22 |
|
| 23 |
#ifdef WARN_PARTIAL |
| 24 |
// expected-note@+2 2 {{'PartialEnum' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5}} |
| 25 |
#endif |
| 26 |
enum __attribute__((availability(macosx,introduced=10.8))) PartialEnum { |
| 27 |
kPartialEnumConstant, |
| 28 |
}; |
| 29 |
|
| 30 |
void test_10095131(void) { |
| 31 |
ATSFontGetName("Hello"); // expected-warning {{'ATSFontGetName' is deprecated: first deprecated in macOS 9.0 - use CTFontCopyFullName}} |
| 32 |
ATSFontGetPostScriptName(100); // expected-error {{'ATSFontGetPostScriptName' is unavailable: obsoleted in macOS 9.0 - use ATSFontGetFullPostScriptName}} |
| 33 |
|
| 34 |
#if defined(WARN_PARTIAL) |
| 35 |
// expected-warning@+2 {{is only available on macOS 10.8 or newer}} expected-note@+2 {{enclose 'PartiallyAvailable' in a __builtin_available check to silence this warning}} |
| 36 |
#endif |
| 37 |
PartiallyAvailable(); |
| 38 |
} |
| 39 |
|
| 40 |
#ifdef WARN_PARTIAL |
| 41 |
// FIXME: This note should point to the declaration with the availability |
| 42 |
// attribute. |
| 43 |
// expected-note@+2 5 {{'PartiallyAvailable' has been marked as being introduced in macOS 10.8 here, but the deployment target is macOS 10.5}} |
| 44 |
#endif |
| 45 |
extern void PartiallyAvailable(void) ; |
| 46 |
void with_redeclaration(void) { |
| 47 |
#ifdef WARN_PARTIAL |
| 48 |
// expected-warning@+4 {{'PartiallyAvailable' is only available on macOS 10.8 or newer}} expected-note@+4 {{__builtin_available}} |
| 49 |
// expected-warning@+4 {{'PartialEnum' is only available on macOS 10.8 or newer}} expected-note@+4 {{__builtin_available}} |
| 50 |
// expected-warning@+3 {{'kPartialEnumConstant' is only available on macOS 10.8 or newer}} expected-note@+3 {{__builtin_available}} |
| 51 |
#endif |
| 52 |
PartiallyAvailable(); |
| 53 |
enum PartialEnum p = kPartialEnumConstant; |
| 54 |
} |
| 55 |
|
| 56 |
#ifdef WARN_PARTIAL |
| 57 |
void conditional_warnings() { |
| 58 |
if (__builtin_available(macos 10.8, *)) { |
| 59 |
PartiallyAvailable(); |
| 60 |
} else { |
| 61 |
PartiallyAvailable(); // expected-warning {{only available on macOS 10.8 or newer}} expected-note {{enclose 'PartiallyAvailable'}} |
| 62 |
} |
| 63 |
if (!__builtin_available(macos 10.8, *)) { |
| 64 |
PartiallyAvailable(); // expected-warning {{only available on macOS 10.8 or newer}} expected-note {{enclose 'PartiallyAvailable'}} |
| 65 |
} else { |
| 66 |
PartiallyAvailable(); |
| 67 |
} |
| 68 |
if (!!!(!__builtin_available(macos 10.8, *))) { |
| 69 |
PartiallyAvailable(); |
| 70 |
} else { |
| 71 |
PartiallyAvailable(); // expected-warning {{only available on macOS 10.8 or newer}} expected-note {{enclose 'PartiallyAvailable'}} |
| 72 |
} |
| 73 |
if (~__builtin_available(macos 10.8, *)) { // expected-warning {{does not guard availability here}} |
| 74 |
PartiallyAvailable(); // expected-warning {{only available on macOS 10.8 or newer}} expected-note {{enclose 'PartiallyAvailable'}} |
| 75 |
} |
| 76 |
} |
| 77 |
#endif |
| 78 |
|
| 79 |
__attribute__((availability(macos, unavailable))) // expected-warning {{attribute 'availability' is ignored}} |
| 80 |
enum { |
| 81 |
NSDataWritingFileProtectionWriteOnly = 0x30000000, |
| 82 |
NSDataWritingFileProtectionCompleteUntilUserAuthentication = 0x40000000, |
| 83 |
}; |
| 84 |
|
| 85 |
void f4(int) __attribute__((availability(ios,deprecated=3.0))); |
| 86 |
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}} |
| 87 |
|
| 88 |
void f5(int) __attribute__((availability(ios,deprecated=3.0), // expected-warning {{feature cannot be deprecated in iOS version 3.0 before it was introduced in version 4.0; attribute ignored}} |
| 89 |
availability(ios,introduced=4.0))); |
| 90 |
|
| 91 |
void f6(int) __attribute__((availability(ios,deprecated=3.0))); // expected-note {{previous attribute is here}} |
| 92 |
void f6(int) __attribute__((availability(ios,deprecated=4.0))); // expected-warning {{availability does not match previous declaration}} |
| 93 |
|
| 94 |
void f7(int) __attribute__((availability(ios,introduced=2.0))); |
| 95 |
void f7(int) __attribute__((availability(ios,deprecated=3.0))); // expected-note {{previous attribute is here}} |
| 96 |
void f7(int) __attribute__((availability(ios,deprecated=4.0))); // expected-warning {{availability does not match previous declaration}} |
| 97 |
|
| 98 |
#if !__has_feature(attribute_availability_with_message) |
| 99 |
# error "Missing __has_feature" |
| 100 |
#endif |
| 101 |
|
| 102 |
extern int x __attribute__((availability(macosx,introduced=10.5))); |
| 103 |
extern int x; |
| 104 |
|
| 105 |
void f8(void) { |
| 106 |
int (^b)(int); |
| 107 |
b = ^ (int i) __attribute__((availability(macosx,introduced=10.2))) { return 1; }; // expected-warning {{'availability' attribute only applies to named declarations}} |
| 108 |
} |
| 109 |
|
| 110 |
extern int x2 __attribute__((availability(macosx,introduced=10.2))); // expected-note {{previous attribute is here}} |
| 111 |
extern int x2 __attribute__((availability(macosx,introduced=10.5))); // expected-warning {{availability does not match previous declaration}} |
| 112 |
|
| 113 |
|
| 114 |
enum Original { |
| 115 |
OriginalDeprecated __attribute__((availability(macosx, deprecated=10.2))), // expected-note + {{'OriginalDeprecated' has been explicitly marked deprecated here}} |
| 116 |
OriginalUnavailable __attribute__((availability(macosx, unavailable))) // expected-note + {{'OriginalUnavailable' has been explicitly marked unavailable here}} |
| 117 |
}; |
| 118 |
|
| 119 |
enum AllDeprecated { // expected-note + {{'AllDeprecated' has been explicitly marked deprecated here}} |
| 120 |
AllDeprecatedCase, |
| 121 |
AllDeprecatedUnavailable __attribute__((availability(macosx, unavailable))) // expected-note + {{'AllDeprecatedUnavailable' has been explicitly marked unavailable here}} |
| 122 |
} __attribute__((availability(macosx, deprecated=10.2))); |
| 123 |
|
| 124 |
enum AllUnavailable { // expected-note + {{'AllUnavailable' has been explicitly marked unavailable here}} |
| 125 |
AllUnavailableCase, |
| 126 |
} __attribute__((availability(macosx, unavailable))); |
| 127 |
|
| 128 |
enum User { |
| 129 |
UserOD = OriginalDeprecated, // expected-warning {{deprecated}} |
| 130 |
UserODDeprecated __attribute__((availability(macosx, deprecated=10.2))) = OriginalDeprecated, |
| 131 |
UserODUnavailable __attribute__((availability(macosx, unavailable))) = OriginalDeprecated, |
| 132 |
|
| 133 |
UserOU = OriginalUnavailable, // expected-error {{unavailable}} |
| 134 |
UserOUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = OriginalUnavailable, // expected-error {{unavailable}} |
| 135 |
UserOUUnavailable __attribute__((availability(macosx, unavailable))) = OriginalUnavailable, |
| 136 |
|
| 137 |
UserAD = AllDeprecatedCase, // expected-warning {{deprecated}} |
| 138 |
UserADDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllDeprecatedCase, |
| 139 |
UserADUnavailable __attribute__((availability(macosx, unavailable))) = AllDeprecatedCase, |
| 140 |
|
| 141 |
UserADU = AllDeprecatedUnavailable, // expected-error {{unavailable}} |
| 142 |
UserADUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllDeprecatedUnavailable, // expected-error {{unavailable}} |
| 143 |
UserADUUnavailable __attribute__((availability(macosx, unavailable))) = AllDeprecatedUnavailable, |
| 144 |
|
| 145 |
UserAU = AllUnavailableCase, // expected-error {{unavailable}} |
| 146 |
UserAUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllUnavailableCase, // expected-error {{unavailable}} |
| 147 |
UserAUUnavailable __attribute__((availability(macosx, unavailable))) = AllUnavailableCase, |
| 148 |
}; |
| 149 |
|
| 150 |
enum UserDeprecated { |
| 151 |
UserDeprecatedOD = OriginalDeprecated, |
| 152 |
UserDeprecatedODDeprecated __attribute__((availability(macosx, deprecated=10.2))) = OriginalDeprecated, |
| 153 |
UserDeprecatedODUnavailable __attribute__((availability(macosx, unavailable))) = OriginalDeprecated, |
| 154 |
|
| 155 |
UserDeprecatedOU = OriginalUnavailable, // expected-error {{unavailable}} |
| 156 |
UserDeprecatedOUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = OriginalUnavailable, // expected-error {{unavailable}} |
| 157 |
UserDeprecatedOUUnavailable __attribute__((availability(macosx, unavailable))) = OriginalUnavailable, |
| 158 |
|
| 159 |
UserDeprecatedAD = AllDeprecatedCase, |
| 160 |
UserDeprecatedADDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllDeprecatedCase, |
| 161 |
UserDeprecatedADUnavailable __attribute__((availability(macosx, unavailable))) = AllDeprecatedCase, |
| 162 |
|
| 163 |
UserDeprecatedADU = AllDeprecatedUnavailable, // expected-error {{unavailable}} |
| 164 |
UserDeprecatedADUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllDeprecatedUnavailable, // expected-error {{unavailable}} |
| 165 |
UserDeprecatedADUUnavailable __attribute__((availability(macosx, unavailable))) = AllDeprecatedUnavailable, |
| 166 |
|
| 167 |
UserDeprecatedAU = AllUnavailableCase, // expected-error {{unavailable}} |
| 168 |
UserDeprecatedAUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllUnavailableCase, // expected-error {{unavailable}} |
| 169 |
UserDeprecatedAUUnavailable __attribute__((availability(macosx, unavailable))) = AllUnavailableCase, |
| 170 |
} __attribute__((availability(macosx, deprecated=10.2))); |
| 171 |
|
| 172 |
enum UserUnavailable { |
| 173 |
UserUnavailableOD = OriginalDeprecated, |
| 174 |
UserUnavailableODDeprecated __attribute__((availability(macosx, deprecated=10.2))) = OriginalDeprecated, |
| 175 |
UserUnavailableODUnavailable __attribute__((availability(macosx, unavailable))) = OriginalDeprecated, |
| 176 |
|
| 177 |
UserUnavailableOU = OriginalUnavailable, |
| 178 |
UserUnavailableOUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = OriginalUnavailable, |
| 179 |
UserUnavailableOUUnavailable __attribute__((availability(macosx, unavailable))) = OriginalUnavailable, |
| 180 |
|
| 181 |
UserUnavailableAD = AllDeprecatedCase, |
| 182 |
UserUnavailableADDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllDeprecatedCase, |
| 183 |
UserUnavailableADUnavailable __attribute__((availability(macosx, unavailable))) = AllDeprecatedCase, |
| 184 |
|
| 185 |
UserUnavailableADU = AllDeprecatedUnavailable, |
| 186 |
UserUnavailableADUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllDeprecatedUnavailable, |
| 187 |
UserUnavailableADUUnavailable __attribute__((availability(macosx, unavailable))) = AllDeprecatedUnavailable, |
| 188 |
|
| 189 |
UserUnavailableAU = AllUnavailableCase, |
| 190 |
UserUnavailableAUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllUnavailableCase, |
| 191 |
UserUnavailableAUUnavailable __attribute__((availability(macosx, unavailable))) = AllUnavailableCase, |
| 192 |
} __attribute__((availability(macosx, unavailable))); |