150
|
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
|
|
3
|
|
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
|
|
6
|
|
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
|
|
12
|
|
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
|
|
17
|
|
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
|
|
22
|
|
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
|
|
27
|
|
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
|
|
32
|
|
33 #ifdef MAC
|
|
34 #define PLATFORM macos
|
|
35 #define NEXT 10.14
|
|
36
|
|
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)))
|
|
40 #endif
|
|
41
|
|
42 #ifdef IOS
|
|
43 #define PLATFORM ios
|
|
44 #define NEXT 12
|
|
45
|
|
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)))
|
|
49 #endif
|
|
50
|
|
51 #ifdef TVOS
|
|
52 #define PLATFORM tvos
|
|
53 #define NEXT 13
|
|
54
|
|
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)))
|
|
58 #endif
|
|
59
|
|
60 #ifdef WATCHOS
|
|
61 #define PLATFORM watchos
|
|
62 #define NEXT 5
|
|
63
|
|
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)))
|
|
67 #endif
|
|
68
|
|
69 void previouslyAvailable() AVAILABLE_PREV;
|
|
70 #ifdef WARN_PREV
|
|
71 // expected-note@-2 {{'previouslyAvailable' has been marked as being introduced}}
|
|
72 #endif
|
|
73 void currentlyAvailable() AVAILABLE_CURRENT;
|
|
74 #ifdef WARN_CURRENT
|
|
75 // expected-note@-2 {{'currentlyAvailable' has been marked as being introduced}}
|
|
76 #endif
|
|
77 void willBeAvailabile() AVAILABLE_NEXT;
|
|
78 #ifndef NO_WARNING
|
|
79 // expected-note@-2 {{'willBeAvailabile' has been marked as being introduced in}}
|
|
80 #endif
|
|
81
|
|
82 #ifdef TEST_FUNC_CURRENT
|
|
83 #define FUNC_AVAILABLE AVAILABLE_CURRENT
|
|
84 #endif
|
|
85 #ifdef TEST_FUNC_NEXT
|
|
86 #define FUNC_AVAILABLE AVAILABLE_NEXT
|
|
87 #endif
|
|
88 #ifndef FUNC_AVAILABLE
|
|
89 #define FUNC_AVAILABLE
|
|
90 #endif
|
|
91
|
|
92 typedef int AVAILABLE_NEXT new_int;
|
|
93 #ifndef NO_WARNING
|
|
94 // expected-note@-2 {{'new_int' has been marked as being introduced in}}
|
|
95 #endif
|
|
96 FUNC_AVAILABLE new_int x;
|
|
97 #ifndef NO_WARNING
|
|
98 #ifdef MAC
|
|
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}}
|
|
100 #endif
|
|
101 #ifdef IOS
|
|
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}}
|
|
103 #endif
|
|
104 #ifdef TVOS
|
|
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}}
|
|
106 #endif
|
|
107 #ifdef WATCHOS
|
|
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}}
|
|
109 #endif
|
|
110 #endif
|
|
111
|
|
112 void test() FUNC_AVAILABLE {
|
|
113 previouslyAvailable();
|
|
114 #ifdef WARN_PREV
|
|
115 #ifdef MAC
|
|
116 // expected-warning@-3 {{'previouslyAvailable' is only available on macOS 10.12 or newer}}
|
|
117 #endif
|
|
118 // expected-note@-5 {{enclose 'previouslyAvailable' in an @available check to silence this warning}}
|
|
119 #endif
|
|
120 currentlyAvailable();
|
|
121 #ifdef WARN_CURRENT
|
|
122 #ifdef MAC
|
|
123 // expected-warning@-3 {{'currentlyAvailable' is only available on macOS 10.13 or newer}}
|
|
124 #endif
|
|
125 #ifdef IOS
|
|
126 // expected-warning@-6 {{'currentlyAvailable' is only available on iOS 11 or newer}}
|
|
127 #endif
|
|
128 #ifdef TVOS
|
|
129 // expected-warning@-9 {{'currentlyAvailable' is only available on tvOS 11 or newer}}
|
|
130 #endif
|
|
131 #ifdef WATCHOS
|
|
132 // expected-warning@-12 {{'currentlyAvailable' is only available on watchOS 4 or newer}}
|
|
133 #endif
|
|
134 // expected-note@-14 {{enclose 'currentlyAvailable' in an @available check to silence this warning}}
|
|
135 #endif
|
|
136 willBeAvailabile();
|
|
137 #ifndef NO_WARNING
|
|
138 #ifdef MAC
|
|
139 // expected-warning@-3 {{'willBeAvailabile' is only available on macOS 10.14 or newer}}
|
|
140 #endif
|
|
141 #ifdef IOS
|
|
142 // expected-warning@-6 {{'willBeAvailabile' is only available on iOS 12 or newer}}
|
|
143 #endif
|
|
144 #ifdef TVOS
|
|
145 // expected-warning@-9 {{'willBeAvailabile' is only available on tvOS 13 or newer}}
|
|
146 #endif
|
|
147 #ifdef WATCHOS
|
|
148 // expected-warning@-12 {{'willBeAvailabile' is only available on watchOS 5 or newer}}
|
|
149 #endif
|
|
150 // expected-note@-14 {{enclose 'willBeAvailabile' in an @available check to silence this warning}}
|
|
151 #endif
|
|
152 if (@available(PLATFORM NEXT, *))
|
|
153 willBeAvailabile(); // OK
|
|
154 }
|
|
155
|
|
156 #ifdef NO_WARNING
|
|
157 #ifndef WARN_PREV
|
|
158 // expected-no-diagnostics
|
|
159 #endif
|
|
160 #endif
|