[clang] Add support for anyAppleOS availability (PR #181953)

Akira Hatanaka via cfe-commits cfe-commits at lists.llvm.org
Thu Feb 19 11:50:49 PST 2026


================
@@ -0,0 +1,131 @@
+// RUN: %clang_cc1 -triple arm64-apple-ios26.0 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macos26.0 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple arm64-apple-tvos26.0 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-apple-macos26.0 -darwin-target-variant-triple x86_64-apple-ios27.0-macabi -fsyntax-only -verify %s
+
+// Test @available and __builtin_available with anyAppleOS.
+
+// Declarations with anyAppleOS availability.
+void func_introduced_26(void) __attribute__((availability(anyAppleOS, introduced=26.0)));
+void func_introduced_27(void) __attribute__((availability(anyAppleOS, introduced=27.0))); // expected-note {{has been marked as being introduced in}}
+void func_deprecated_27(void) __attribute__((availability(anyAppleOS, introduced=26.0, deprecated=27.0)));
+void func_obsoleted_28(void) __attribute__((availability(anyAppleOS, introduced=26.0, obsoleted=28.0)));
+void func_unavailable(void) __attribute__((availability(anyAppleOS, unavailable))); // expected-note 2 {{has been explicitly marked unavailable here}}
+
+void test_unguarded() {
+  // Should be available - no warning
+  func_introduced_26();
+
+  // Should warn - introduced in 27.0, deployment target is 26.0
+  func_introduced_27(); // expected-warning {{only available on}} expected-note {{enclose 'func_introduced_27' in an @available check to silence this warning}}
+
+  // Should be available but deprecated - might warn depending on deployment target
----------------
ahatanak wrote:

I moved tests here to `attr-availability-anyappleos.c` and added a few more tests there.

https://github.com/llvm/llvm-project/pull/181953


More information about the cfe-commits mailing list