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