[clang-cl] Ignore /Wv and /Wv:17 flags
[llvm-project.git] / clang / test / Sema / attr-availability.c
blobba7051520c7be776db17001808069e7ce2750a2f
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 //
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}}
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}}
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}}
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}}
20 #endif
21 extern void
22 PartiallyAvailable(void) __attribute__((availability(macosx,introduced=10.8)));
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}}
26 #endif
27 enum __attribute__((availability(macosx,introduced=10.8))) PartialEnum {
28 kPartialEnumConstant,
31 void test_10095131(void) {
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}}
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();
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}}
45 #endif
46 extern void PartiallyAvailable(void) ;
47 void with_redeclaration(void) {
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;
57 // rdar://10711037
58 __attribute__((availability(macos, unavailable))) // expected-warning {{attribute 'availability' is ignored}}
59 enum {
60 NSDataWritingFileProtectionWriteOnly = 0x30000000,
61 NSDataWritingFileProtectionCompleteUntilUserAuthentication = 0x40000000,
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}}
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)));
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}}
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}}
78 // <rdar://problem/11886458>
79 #if !__has_feature(attribute_availability_with_message)
80 # error "Missing __has_feature"
81 #endif
83 extern int x __attribute__((availability(macosx,introduced=10.5)));
84 extern int x;
86 void f8(void) {
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}}
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}}
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}}
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)));
105 enum AllUnavailable { // expected-note + {{'AllUnavailable' has been explicitly marked unavailable here}}
106 AllUnavailableCase,
107 } __attribute__((availability(macosx, unavailable)));
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,
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,
118 UserAD = AllDeprecatedCase, // expected-warning {{deprecated}}
119 UserADDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllDeprecatedCase,
120 UserADUnavailable __attribute__((availability(macosx, unavailable))) = AllDeprecatedCase,
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,
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,
131 enum UserDeprecated {
132 UserDeprecatedOD = OriginalDeprecated,
133 UserDeprecatedODDeprecated __attribute__((availability(macosx, deprecated=10.2))) = OriginalDeprecated,
134 UserDeprecatedODUnavailable __attribute__((availability(macosx, unavailable))) = OriginalDeprecated,
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,
140 UserDeprecatedAD = AllDeprecatedCase,
141 UserDeprecatedADDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllDeprecatedCase,
142 UserDeprecatedADUnavailable __attribute__((availability(macosx, unavailable))) = AllDeprecatedCase,
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,
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)));
153 enum UserUnavailable {
154 UserUnavailableOD = OriginalDeprecated,
155 UserUnavailableODDeprecated __attribute__((availability(macosx, deprecated=10.2))) = OriginalDeprecated,
156 UserUnavailableODUnavailable __attribute__((availability(macosx, unavailable))) = OriginalDeprecated,
158 UserUnavailableOU = OriginalUnavailable,
159 UserUnavailableOUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = OriginalUnavailable,
160 UserUnavailableOUUnavailable __attribute__((availability(macosx, unavailable))) = OriginalUnavailable,
162 UserUnavailableAD = AllDeprecatedCase,
163 UserUnavailableADDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllDeprecatedCase,
164 UserUnavailableADUnavailable __attribute__((availability(macosx, unavailable))) = AllDeprecatedCase,
166 UserUnavailableADU = AllDeprecatedUnavailable,
167 UserUnavailableADUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllDeprecatedUnavailable,
168 UserUnavailableADUUnavailable __attribute__((availability(macosx, unavailable))) = AllDeprecatedUnavailable,
170 UserUnavailableAU = AllUnavailableCase,
171 UserUnavailableAUDeprecated __attribute__((availability(macosx, deprecated=10.2))) = AllUnavailableCase,
172 UserUnavailableAUUnavailable __attribute__((availability(macosx, unavailable))) = AllUnavailableCase,
173 } __attribute__((availability(macosx, unavailable)));