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
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)));
9 void f3(void) __attribute__((availability(otheros
,introduced
=2.2))); // expected-warning{{unknown platform 'otheros' in availability macro}}
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}}
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}}
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}}
21 PartiallyAvailable(void) __attribute__((availability(macosx
,introduced
=10.8)));
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}}
26 enum __attribute__((availability(macosx
,introduced
=10.8))) PartialEnum
{
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}}
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}}
41 // FIXME: This note should point to the declaration with the availability
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}}
45 extern void PartiallyAvailable(void) ;
46 void with_redeclaration(void) {
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}}
53 enum PartialEnum p
= kPartialEnumConstant
;
57 void conditional_warnings() {
58 if (__builtin_available(macos
10.8, *)) {
61 PartiallyAvailable(); // expected-warning {{only available on macOS 10.8 or newer}} expected-note {{enclose 'PartiallyAvailable'}}
63 if (!__builtin_available(macos
10.8, *)) {
64 PartiallyAvailable(); // expected-warning {{only available on macOS 10.8 or newer}} expected-note {{enclose 'PartiallyAvailable'}}
68 if (!!!(!__builtin_available(macos
10.8, *))) {
71 PartiallyAvailable(); // expected-warning {{only available on macOS 10.8 or newer}} expected-note {{enclose 'PartiallyAvailable'}}
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'}}
79 __attribute__((availability(macos
, unavailable
))) // expected-warning {{attribute 'availability' is ignored}}
81 NSDataWritingFileProtectionWriteOnly
= 0x30000000,
82 NSDataWritingFileProtectionCompleteUntilUserAuthentication
= 0x40000000,
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}}
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)));
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}}
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}}
98 #if !__has_feature(attribute_availability_with_message)
99 # error "Missing __has_feature"
102 extern int x
__attribute__((availability(macosx
,introduced
=10.5)));
107 b
= ^ (int i
) __attribute__((availability(macosx
,introduced
=10.2))) { return 1; }; // expected-warning {{'availability' attribute only applies to named declarations}}
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}}
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}}
119 enum AllDeprecated
{ // expected-note + {{'AllDeprecated' has been explicitly marked deprecated here}}
121 AllDeprecatedUnavailable
__attribute__((availability(macosx
, unavailable
))) // expected-note + {{'AllDeprecatedUnavailable' has been explicitly marked unavailable here}}
122 } __attribute__((availability(macosx
, deprecated
=10.2)));
124 enum AllUnavailable
{ // expected-note + {{'AllUnavailable' has been explicitly marked unavailable here}}
126 } __attribute__((availability(macosx
, unavailable
)));
129 UserOD
= OriginalDeprecated
, // expected-warning {{deprecated}}
130 UserODDeprecated
__attribute__((availability(macosx
, deprecated
=10.2))) = OriginalDeprecated
,
131 UserODUnavailable
__attribute__((availability(macosx
, unavailable
))) = OriginalDeprecated
,
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
,
137 UserAD
= AllDeprecatedCase
, // expected-warning {{deprecated}}
138 UserADDeprecated
__attribute__((availability(macosx
, deprecated
=10.2))) = AllDeprecatedCase
,
139 UserADUnavailable
__attribute__((availability(macosx
, unavailable
))) = AllDeprecatedCase
,
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
,
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
,
150 enum UserDeprecated
{
151 UserDeprecatedOD
= OriginalDeprecated
,
152 UserDeprecatedODDeprecated
__attribute__((availability(macosx
, deprecated
=10.2))) = OriginalDeprecated
,
153 UserDeprecatedODUnavailable
__attribute__((availability(macosx
, unavailable
))) = OriginalDeprecated
,
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
,
159 UserDeprecatedAD
= AllDeprecatedCase
,
160 UserDeprecatedADDeprecated
__attribute__((availability(macosx
, deprecated
=10.2))) = AllDeprecatedCase
,
161 UserDeprecatedADUnavailable
__attribute__((availability(macosx
, unavailable
))) = AllDeprecatedCase
,
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
,
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)));
172 enum UserUnavailable
{
173 UserUnavailableOD
= OriginalDeprecated
,
174 UserUnavailableODDeprecated
__attribute__((availability(macosx
, deprecated
=10.2))) = OriginalDeprecated
,
175 UserUnavailableODUnavailable
__attribute__((availability(macosx
, unavailable
))) = OriginalDeprecated
,
177 UserUnavailableOU
= OriginalUnavailable
,
178 UserUnavailableOUDeprecated
__attribute__((availability(macosx
, deprecated
=10.2))) = OriginalUnavailable
,
179 UserUnavailableOUUnavailable
__attribute__((availability(macosx
, unavailable
))) = OriginalUnavailable
,
181 UserUnavailableAD
= AllDeprecatedCase
,
182 UserUnavailableADDeprecated
__attribute__((availability(macosx
, deprecated
=10.2))) = AllDeprecatedCase
,
183 UserUnavailableADUnavailable
__attribute__((availability(macosx
, unavailable
))) = AllDeprecatedCase
,
185 UserUnavailableADU
= AllDeprecatedUnavailable
,
186 UserUnavailableADUDeprecated
__attribute__((availability(macosx
, deprecated
=10.2))) = AllDeprecatedUnavailable
,
187 UserUnavailableADUUnavailable
__attribute__((availability(macosx
, unavailable
))) = AllDeprecatedUnavailable
,
189 UserUnavailableAU
= AllUnavailableCase
,
190 UserUnavailableAUDeprecated
__attribute__((availability(macosx
, deprecated
=10.2))) = AllUnavailableCase
,
191 UserUnavailableAUUnavailable
__attribute__((availability(macosx
, unavailable
))) = AllUnavailableCase
,
192 } __attribute__((availability(macosx
, unavailable
)));