Debian Codegraph @

clang/test/SemaObjC/unguarded-availability-maccatalyst.m

raw
1 // RUN: %clang_cc1 -triple x86_64-apple-ios14-macabi -fblocks -fsyntax-only -verify %s
2 // RUN: %clang_cc1 -xobjective-c++ -triple x86_64-apple-ios14-macabi -fblocks -fsyntax-only -verify %s
3
4 // RUN: %clang_cc1 -triple x86_64-apple-ios14.1-macabi -DNO_WARNING -fblocks -fsyntax-only -verify %s
5
6 #ifdef NO_WARNING
7 // expected-no-diagnostics
8 #endif
9
10 #define AVAILABLE_PREV __attribute__((availability(macCatalyst, introduced = 13.1)))
11 #define AVAILABLE_CURRENT __attribute__((availability(macCatalyst, introduced = 14)))
12 #define AVAILABLE_NEXT __attribute__((availability(macCatalyst, introduced = 14.1)))
13
14 void previouslyAvailable(void) AVAILABLE_PREV;
15 void currentlyAvailable(void) AVAILABLE_CURRENT;
16 void willBeAvailabile(void) AVAILABLE_NEXT;
17 #ifndef NO_WARNING
18 // expected-note@-2 {{'willBeAvailabile' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14}}
19 #endif
20
21
22 typedef struct {
23
24 } Record AVAILABLE_NEXT;
25 #ifndef NO_WARNING
26 // expected-note@-2 {{'Record' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14}}
27 #endif
28
29 AVAILABLE_PREV
30 Record var;
31 #ifndef NO_WARNING
32 // expected-warning@-2 {{'Record' is only available on macCatalyst 14.1 or newer}}
33 // expected-note@-3 {{annotate 'var' with an availability attribute to silence this warnin}}
34 #endif
35
36 AVAILABLE_NEXT
37 Record var2;
38
39 void test(void) {
40 previouslyAvailable();
41 currentlyAvailable();
42 willBeAvailabile();
43 #ifndef NO_WARNING
44 // expected-warning@-2 {{'willBeAvailabile' is only available on macCatalyst 14.1 or newer}}
45 // expected-note@-3 {{enclose 'willBeAvailabile' in an @available check to silence this warning}}
46 #endif
47 if (@available(maccatalyst 14.1, *))
48 willBeAvailabile(); // OK
49 if (@available(ios 14.1, *))
50 willBeAvailabile(); // Also OK
51 if (@available(macCatalyst 14.1, *))
52 willBeAvailabile(); // OK
53 }
54
55 void previouslyAvailableIOS(void) __attribute__((availability(ios, introduced = 10)));
56 void currentlyAvailableIOS(void) __attribute__((availability(ios, introduced = 14)));
57 void willBeAvailabileIOS(void) __attribute__((availability(ios, introduced = 14.1)));
58 #ifndef NO_WARNING
59 // expected-note@-2 {{'willBeAvailabileIOS' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14}}
60 #endif
61
62 void testIOSAvailabilityAlsoWorks(void) {
63 previouslyAvailableIOS();
64 currentlyAvailableIOS();
65 willBeAvailabileIOS();
66 #ifndef NO_WARNING
67 // expected-warning@-2 {{'willBeAvailabileIOS' is only available on macCatalyst 14.1 or newer}}
68 // expected-note@-3 {{enclose 'willBeAvailabileIOS' in an @available check to silence this warning}}
69 #endif
70 if (@available(macCatalyst 14.1, *))
71 willBeAvailabileIOS(); // OK
72 if (@available(ios 14.1, *))
73 willBeAvailabile(); // Also OK
74 }
75
76 typedef struct {
77
78 } Record2 __attribute__((availability(ios, introduced = 14.1)));
79 #ifndef NO_WARNING
80 // expected-note@-2 {{'Record2' has been marked as being introduced in macCatalyst 14.1 here, but the deployment target is macCatalyst 14}}
81 #endif
82
83 __attribute__((availability(ios, introduced = 10)))
84 Record2 var11;
85 #ifndef NO_WARNING
86 // expected-warning@-2 {{'Record2' is only available on macCatalyst 14.1 or newer}}
87 // expected-note@-3 {{annotate 'var11' with an availability attribute to silence this warnin}}
88 #endif
89
90 __attribute__((availability(ios, introduced = 14.1)))
91 Record2 var12;