1 // RUN: %clang_cc1 "-triple" "arm64-apple-watchos4.0" -fsyntax-only -verify %s
2 // RUN: %clang_cc1 "-triple" "arm64-apple-watchos4.0" -DUSE_VERSION_MAP -isysroot %S/Inputs/WatchOS7.0.sdk -fsyntax-only -verify %s
4 void f0(int) __attribute__((availability(ios
,introduced
=2.0,deprecated
=2.1))); // expected-note {{'f0' has been explicitly marked deprecated here}}
5 void f1(int) __attribute__((availability(ios
,introduced
=2.1)));
6 void f2(int) __attribute__((availability(ios
,introduced
=2.0,deprecated
=3.0))); // expected-note {{'f2' has been explicitly marked deprecated here}}
7 void f3(int) __attribute__((availability(ios
,introduced
=3.0)));
8 void f4(int) __attribute__((availability(macosx
,introduced
=10.1,deprecated
=10.3,obsoleted
=10.5), availability(ios
,introduced
=2.0,deprecated
=2.1,obsoleted
=3.0))); // expected-note{{explicitly marked unavailable}}
9 void f5(int) __attribute__((availability(ios
,introduced
=2.0))) __attribute__((availability(ios
,deprecated
=3.0))); // expected-note {{'f5' has been explicitly marked deprecated here}}
10 void f6(int) __attribute__((availability(ios
,deprecated
=12.1))); // OK - not deprecated for watchOS
11 void f7(int) __attribute__((availability(ios
,deprecated
=8.3))); // expected-note {{'f7' has been explicitly marked deprecated here}}
12 void f8(int) __attribute__((availability(ios
,introduced
=2.0,obsoleted
=10.0))); // expected-note {{explicitly marked unavailable}}
15 f0(0); // expected-warning{{'f0' is deprecated: first deprecated in watchOS 2.0}}
17 f2(0); // expected-warning{{'f2' is deprecated: first deprecated in watchOS 2.0}}
19 f4(0); // expected-error {{f4' is unavailable: obsoleted in watchOS 2.0}}
20 f5(0); // expected-warning {{'f5' is deprecated: first deprecated in watchOS 2.0}}
22 f7(0); // expected-warning {{'f7' is deprecated: first deprecated in watchOS 2.0}}
23 f8(0); // expected-error {{'f8' is unavailable: obsoleted in watchOS 3.0}}
26 // Test watchOS specific attributes.
27 void f0_watchos(int) __attribute__((availability(watchos
,introduced
=2.0,deprecated
=2.1))); // expected-note {{'f0_watchos' has been explicitly marked deprecated here}}
28 void f1_watchos(int) __attribute__((availability(watchos
,introduced
=2.1)));
29 void f2_watchos(int) __attribute__((availability(watchOS
,introduced
=2.0,deprecated
=3.0))); // expected-note {{'f2_watchos' has been explicitly marked deprecated here}}
30 void f3_watchos(int) __attribute__((availability(watchos
,introduced
=3.0)));
31 void f4_watchos(int) __attribute__((availability(macosx
,introduced
=10.1,deprecated
=10.3,obsoleted
=10.5), availability(watchos
,introduced
=2.0,deprecated
=2.1,obsoleted
=3.0))); // expected-note{{explicitly marked unavailable}}
32 void f5_watchos(int) __attribute__((availability(watchos
,introduced
=2.0))) __attribute__((availability(ios
,deprecated
=3.0)));
33 void f5_attr_reversed_watchos(int) __attribute__((availability(ios
, deprecated
=3.0))) __attribute__((availability(watchos
,introduced
=2.0)));
34 void f5b_watchos(int) __attribute__((availability(watchos
,introduced
=2.0))) __attribute__((availability(watchos
,deprecated
=3.0))); // expected-note {{'f5b_watchos' has been explicitly marked deprecated here}}
35 void f5c_watchos(int) __attribute__((availability(ios
,introduced
=2.0))) __attribute__((availability(ios
,deprecated
=3.0))); // expected-note {{'f5c_watchos' has been explicitly marked deprecated here}}
36 void f6_watchos(int) __attribute__((availability(watchos
,deprecated
=3.0))); // expected-note {{'f6_watchos' has been explicitly marked deprecated here}}
37 void f6_watchos(int) __attribute__((availability(watchOS
,introduced
=2.0)));
39 void test_watchos(void) {
40 f0_watchos(0); // expected-warning{{'f0_watchos' is deprecated: first deprecated in watchOS 2.1}}
42 f2_watchos(0); // expected-warning{{'f2_watchos' is deprecated: first deprecated in watchOS 3.0}}
44 f4_watchos(0); // expected-error{{'f4_watchos' is unavailable: obsoleted in watchOS 3.0}}
45 // We get no warning here because any explicit 'watchos' availability causes
46 // the ios availability to not implicitly become 'watchos' availability. Otherwise we'd get
47 // a deprecated warning.
48 f5_watchos(0); // no-warning
49 f5_attr_reversed_watchos(0); // no-warning
50 // We get a deprecated warning here because both attributes are explicitly 'watchos'.
51 f5b_watchos(0); // expected-warning {{'f5b_watchos' is deprecated: first deprecated in watchOS 3.0}}
52 // We get a deprecated warning here because both attributes are 'ios' (both get mapped to 'watchos').
53 f5c_watchos(0); // expected-warning {{'f5c_watchos' is deprecated: first deprecated in watchOS 2.0}}
54 f6_watchos(0); // expected-warning {{'f6_watchos' is deprecated: first deprecated in watchOS 3.0}}
57 void deprecatedAfterIntroduced(void) __attribute__((availability(ios
,introduced
=9.3,deprecated
=10))); // expected-note {{here}}
59 void test_ios_correctly_map_to_watchos(void) {
60 deprecatedAfterIntroduced(); // expected-warning {{'deprecatedAfterIntroduced' is deprecated: first deprecated in watchOS 3}}
63 #ifdef USE_VERSION_MAP
64 // iOS 10.3.1 corresponds to watchOS 3.2, as indicated in 'SDKSettings.json'.
65 void f9(int) __attribute__((availability(ios
,deprecated
=10.3.1))); // expected-note {{'f9' has been explicitly marked deprecated here}}
67 void testWithVersionMap(void) {
68 f9(0); // expected-warning {{'f9' is deprecated: first deprecated in watchOS 3.2}}
71 // Without VersionMap, watchOS version is inferred incorrectly as 3.3.1.
72 void f9(int) __attribute__((availability(ios
,deprecated
=10.3.1))); // expected-note {{'f9' has been explicitly marked deprecated here}}
74 void testWithoutVersionMap(void) {
75 f9(0); // expected-warning {{'f9' is deprecated: first deprecated in watchOS 3.3.1}}