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
14void previouslyAvailable() AVAILABLE_PREV;
15void currentlyAvailable() AVAILABLE_CURRENT;
16void willBeAvailabile() 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.0.0}}
19#endif
20
21
22typedef 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.0.0}}
27#endif
28
29AVAILABLE_PREV
30Record 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
36AVAILABLE_NEXT
37Record var2;
38
39void test() {
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
55void previouslyAvailableIOS() __attribute__((availability(ios, introduced = 10)));
56void currentlyAvailableIOS() __attribute__((availability(ios, introduced = 14)));
57void willBeAvailabileIOS() __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.0.0}}
60#endif
61
62void testIOSAvailabilityAlsoWorks() {
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
76typedef 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.0.0}}
81#endif
82
83__attribute__((availability(ios, introduced = 10)))
84Record2 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)))
91Record2 var12;
92