78 lines · c
1// RUN: %clang_cc1 "-triple" "arm64-apple-watchos4.0" -fsyntax-only -verify %s2// RUN: %clang_cc1 "-triple" "arm64-apple-watchos4.0" -DUSE_VERSION_MAP -isysroot %S/Inputs/WatchOS7.0.sdk -fsyntax-only -verify %s3 4void f0(int) __attribute__((availability(ios,introduced=2.0,deprecated=2.1))); // expected-note {{'f0' has been explicitly marked deprecated here}}5void f1(int) __attribute__((availability(ios,introduced=2.1)));6void f2(int) __attribute__((availability(ios,introduced=2.0,deprecated=3.0))); // expected-note {{'f2' has been explicitly marked deprecated here}}7void f3(int) __attribute__((availability(ios,introduced=3.0)));8void 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}}9void f5(int) __attribute__((availability(ios,introduced=2.0))) __attribute__((availability(ios,deprecated=3.0))); // expected-note {{'f5' has been explicitly marked deprecated here}}10void f6(int) __attribute__((availability(ios,deprecated=12.1))); // OK - not deprecated for watchOS11void f7(int) __attribute__((availability(ios,deprecated=8.3))); // expected-note {{'f7' has been explicitly marked deprecated here}}12void f8(int) __attribute__((availability(ios,introduced=2.0,obsoleted=10.0))); // expected-note {{explicitly marked unavailable}}13 14void test(void) {15 f0(0); // expected-warning{{'f0' is deprecated: first deprecated in watchOS 2.0}}16 f1(0);17 f2(0); // expected-warning{{'f2' is deprecated: first deprecated in watchOS 2.0}}18 f3(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}}21 f6(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}}24}25 26// Test watchOS specific attributes.27void f0_watchos(int) __attribute__((availability(watchos,introduced=2.0,deprecated=2.1))); // expected-note {{'f0_watchos' has been explicitly marked deprecated here}}28void f1_watchos(int) __attribute__((availability(watchos,introduced=2.1)));29void f2_watchos(int) __attribute__((availability(watchOS,introduced=2.0,deprecated=3.0))); // expected-note {{'f2_watchos' has been explicitly marked deprecated here}}30void f3_watchos(int) __attribute__((availability(watchos,introduced=3.0)));31void 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}}32void f5_watchos(int) __attribute__((availability(watchos,introduced=2.0))) __attribute__((availability(ios,deprecated=3.0)));33void f5_attr_reversed_watchos(int) __attribute__((availability(ios, deprecated=3.0))) __attribute__((availability(watchos,introduced=2.0)));34void 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}}35void 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}}36void f6_watchos(int) __attribute__((availability(watchos,deprecated=3.0))); // expected-note {{'f6_watchos' has been explicitly marked deprecated here}}37void f6_watchos(int) __attribute__((availability(watchOS,introduced=2.0)));38 39void test_watchos(void) {40 f0_watchos(0); // expected-warning{{'f0_watchos' is deprecated: first deprecated in watchOS 2.1}}41 f1_watchos(0);42 f2_watchos(0); // expected-warning{{'f2_watchos' is deprecated: first deprecated in watchOS 3.0}}43 f3_watchos(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 causes46 // the ios availability to not implicitly become 'watchos' availability. Otherwise we'd get47 // a deprecated warning.48 f5_watchos(0); // no-warning49 f5_attr_reversed_watchos(0); // no-warning50 // 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}}55}56 57void deprecatedAfterIntroduced(void) __attribute__((availability(ios,introduced=9.3,deprecated=10))); // expected-note {{here}}58 59void test_ios_correctly_map_to_watchos(void) {60 deprecatedAfterIntroduced(); // expected-warning {{'deprecatedAfterIntroduced' is deprecated: first deprecated in watchOS 3}}61}62 63#ifdef USE_VERSION_MAP64// iOS 10.3.1 corresponds to watchOS 3.2, as indicated in 'SDKSettings.json'.65void f9(int) __attribute__((availability(ios,deprecated=10.3.1))); // expected-note {{'f9' has been explicitly marked deprecated here}}66 67void testWithVersionMap(void) {68 f9(0); // expected-warning {{'f9' is deprecated: first deprecated in watchOS 3.2}}69}70#else71// Without VersionMap, watchOS version is inferred incorrectly as 3.3.1.72void f9(int) __attribute__((availability(ios,deprecated=10.3.1))); // expected-note {{'f9' has been explicitly marked deprecated here}}73 74void testWithoutVersionMap(void) {75 f9(0); // expected-warning {{'f9' is deprecated: first deprecated in watchOS 3.3.1}}76}77#endif78