1 // RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -fblocks -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -xobjective-c++ -DMAC -triple x86_64-apple-macosx10.13 -fblocks -fsyntax-only -verify %s
4 // RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wunguarded-availability-new -fblocks -fsyntax-only -verify %s
5 // RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wno-unguarded-availability-new -DNO_WARNING -fblocks -fsyntax-only -verify %s
7 // unguarded-availability implies unguarded-availability-new:
8 // RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wunguarded-availability -fblocks -fsyntax-only -verify %s
9 // RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.11 -Wunguarded-availability -Wno-unguarded-availability-new -DNO_WARNING -DWARN_PREV -fblocks -fsyntax-only -verify %s
10 // RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wno-unguarded-availability -DNO_WARNING -fblocks -fsyntax-only -verify %s
11 // RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -Wno-unguarded-availability -Wunguarded-availability-new -fblocks -fsyntax-only -verify %s
13 // RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -D TEST_FUNC_CURRENT -fblocks -fsyntax-only -verify %s
14 // RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.13 -D TEST_FUNC_NEXT -DNO_WARNING -fblocks -fsyntax-only -verify %s
15 // RUN: %clang_cc1 -DMAC -triple x86_64-apple-ios11 -DNO_WARNING -fblocks -fsyntax-only -verify %s
16 // RUN: %clang_cc1 -DMAC -triple x86_64-apple-macosx10.12 -DWARN_CURRENT -fblocks -fsyntax-only -verify %s
18 // RUN: %clang_cc1 -DIOS -triple x86_64-apple-ios11 -fblocks -fsyntax-only -verify %s
19 // RUN: %clang_cc1 -DIOS -triple x86_64-apple-ios11 -D TEST_FUNC_CURRENT -fblocks -fsyntax-only -verify %s
20 // RUN: %clang_cc1 -DIOS -triple x86_64-apple-ios11 -D TEST_FUNC_NEXT -DNO_WARNING -fblocks -fsyntax-only -verify %s
21 // RUN: %clang_cc1 -DIOS -triple x86_64-apple-ios10.3 -DWARN_CURRENT -fblocks -fsyntax-only -verify %s
23 // RUN: %clang_cc1 -DTVOS -triple x86_64-apple-tvos11 -fblocks -fsyntax-only -verify %s
24 // RUN: %clang_cc1 -DTVOS -triple x86_64-apple-tvos11 -D TEST_FUNC_CURRENT -fblocks -fsyntax-only -verify %s
25 // RUN: %clang_cc1 -DTVOS -triple x86_64-apple-tvos11 -D TEST_FUNC_NEXT -DNO_WARNING -fblocks -fsyntax-only -verify %s
26 // RUN: %clang_cc1 -DTVOS -triple x86_64-apple-tvos10 -DWARN_CURRENT -fblocks -fsyntax-only -verify %s
28 // RUN: %clang_cc1 -DWATCHOS -triple i386-apple-watchos4 -fblocks -fsyntax-only -verify %s
29 // RUN: %clang_cc1 -DWATCHOS -triple i386-apple-watchos4 -D TEST_FUNC_CURRENT -fblocks -fsyntax-only -verify %s
30 // RUN: %clang_cc1 -DWATCHOS -triple i386-apple-watchos4 -D TEST_FUNC_NEXT -DNO_WARNING -fblocks -fsyntax-only -verify %s
31 // RUN: %clang_cc1 -DWATCHOS -triple i386-apple-watchos3 -DWARN_CURRENT -fblocks -fsyntax-only -verify %s
34 #define PLATFORM macos
37 #define AVAILABLE_PREV __attribute__((availability(macos, introduced = 10.12)))
38 #define AVAILABLE_CURRENT __attribute__((availability(macos, introduced = 10.13)))
39 #define AVAILABLE_NEXT __attribute__((availability(macos, introduced = 10.14)))
46 #define AVAILABLE_PREV __attribute__((availability(ios, introduced = 10)))
47 #define AVAILABLE_CURRENT __attribute__((availability(ios, introduced = 11)))
48 #define AVAILABLE_NEXT __attribute__((availability(ios, introduced = 12)))
55 #define AVAILABLE_PREV __attribute__((availability(tvos, introduced = 10)))
56 #define AVAILABLE_CURRENT __attribute__((availability(tvos, introduced = 11)))
57 #define AVAILABLE_NEXT __attribute__((availability(tvos, introduced = 13)))
61 #define PLATFORM watchos
64 #define AVAILABLE_PREV __attribute__((availability(watchos, introduced = 3)))
65 #define AVAILABLE_CURRENT __attribute__((availability(watchos, introduced = 4)))
66 #define AVAILABLE_NEXT __attribute__((availability(watchos, introduced = 5)))
69 void previouslyAvailable(void) AVAILABLE_PREV;
71 // expected-note@-2 {{'previouslyAvailable' has been marked as being introduced}}
73 void currentlyAvailable(void) AVAILABLE_CURRENT;
75 // expected-note@-2 {{'currentlyAvailable' has been marked as being introduced}}
77 void willBeAvailabile(void) AVAILABLE_NEXT;
79 // expected-note@-2 {{'willBeAvailabile' has been marked as being introduced in}}
82 #ifdef TEST_FUNC_CURRENT
83 #define FUNC_AVAILABLE AVAILABLE_CURRENT
86 #define FUNC_AVAILABLE AVAILABLE_NEXT
88 #ifndef FUNC_AVAILABLE
89 #define FUNC_AVAILABLE
92 typedef int AVAILABLE_NEXT new_int;
94 // expected-note@-2 {{'new_int' has been marked as being introduced in}}
96 FUNC_AVAILABLE new_int x;
99 // expected-warning@-3 {{'new_int' is only available on macOS 10.14 or newer}} expected-note@-3 {{annotate 'x' with an availability attribute to silence this warning}}
102 // expected-warning@-6 {{'new_int' is only available on iOS 12 or newer}} expected-note@-6 {{annotate 'x' with an availability attribute to silence this warning}}
105 // expected-warning@-9 {{'new_int' is only available on tvOS 13 or newer}} expected-note@-9 {{annotate 'x' with an availability attribute to silence this warning}}
108 // expected-warning@-12 {{'new_int' is only available on watchOS 5}} expected-note@-12 {{annotate 'x' with an availability attribute to silence this warning}}
112 void test(void) FUNC_AVAILABLE {
113 previouslyAvailable();
116 // expected-warning@-3 {{'previouslyAvailable' is only available on macOS 10.12 or newer}}
118 // expected-note@-5 {{enclose 'previouslyAvailable' in an @available check to silence this warning}}
120 currentlyAvailable();
123 // expected-warning@-3 {{'currentlyAvailable' is only available on macOS 10.13 or newer}}
126 // expected-warning@-6 {{'currentlyAvailable' is only available on iOS 11 or newer}}
129 // expected-warning@-9 {{'currentlyAvailable' is only available on tvOS 11 or newer}}
132 // expected-warning@-12 {{'currentlyAvailable' is only available on watchOS 4 or newer}}
134 // expected-note@-14 {{enclose 'currentlyAvailable' in an @available check to silence this warning}}
139 // expected-warning@-3 {{'willBeAvailabile' is only available on macOS 10.14 or newer}}
142 // expected-warning@-6 {{'willBeAvailabile' is only available on iOS 12 or newer}}
145 // expected-warning@-9 {{'willBeAvailabile' is only available on tvOS 13 or newer}}
148 // expected-warning@-12 {{'willBeAvailabile' is only available on watchOS 5 or newer}}
150 // expected-note@-14 {{enclose 'willBeAvailabile' in an @available check to silence this warning}}
152 if (@available(PLATFORM NEXT, *))
153 willBeAvailabile(); // OK
158 // expected-no-diagnostics