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