File: attr-availability-macos-new.c

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (116 lines) | stat: -rw-r--r-- 3,397 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// RUN: %clang_cc1 "-triple" "x86_64-apple-macos10.15" -fsyntax-only -verify %s
// RUN: %clang_cc1 "-triple" "x86_64-apple-macos11" -DNEW -fsyntax-only -verify %s
// RUN: %clang_cc1 "-triple" "x86_64-apple-darwin20" -DNEW -fsyntax-only -verify %s
// RUN: %clang_cc1 "-triple" "x86_64-apple-macos10.15" -fsyntax-only -verify -fapplication-extension -DAPP_EXT %s

__attribute__((availability(macos,strict,introduced=10.16)))
void fNew1();
#ifndef NEW
// expected-note@-2 {{here}}
#endif

__attribute__((availability(macosx,strict,introduced=10.16)))
void fNew();

__attribute__((availability(macos,strict,introduced=11)))
void fNew() { }
#ifndef NEW
// expected-note@-2 {{here}}
#endif

__attribute__((availability(macosx,strict,deprecated=10.16)))
void fDep();

__attribute__((availability(macos,strict,deprecated=11)))
void fDep() { }
#ifdef NEW
// expected-note@-2 {{here}}
#endif

__attribute__((availability(macosx,strict,obsoleted=10.16)))
void fObs();

__attribute__((availability(macos,strict,obsoleted=11)))
void fObs() { }
#ifdef NEW
// expected-note@-2 {{here}}
#endif

__attribute__((availability(macosx_app_extension,strict,introduced=10.16)))
void fAppExt();

__attribute__((availability(macos_app_extension,strict,introduced=11)))
void fAppExt() { }
#ifdef APP_EXT
// expected-note@-2 {{here}}
#endif

void testVersionRemapping() {
  fNew1();
#ifndef NEW
  // expected-error@-2 {{'fNew1' is unavailable: introduced in macOS 11.0}}
#endif
  fNew();
#ifndef NEW
  // expected-error@-2 {{'fNew' is unavailable: introduced in macOS 11}}
#endif
  fDep();
#ifdef NEW
  // expected-warning@-2 {{'fDep' is deprecated: first deprecated in macOS 11}}
#endif
  fObs();
#ifdef NEW
  // expected-error@-2 {{'fObs' is unavailable: obsoleted in macOS 11}}
#endif

  fAppExt();
#ifdef APP_EXT
  // expected-error@-2 {{'fAppExt' is unavailable: introduced in macOS (App Extension) 11}}
#endif
}

__attribute__((availability(macosx,strict,introduced=10.16.1))) // expected-note {{here}}
void fMatchErr();

__attribute__((availability(macos,strict,introduced=11))) // expected-warning {{availability does not match previous declaration}}
void fMatchErr() { }

__attribute__((availability(macosx_app_extension,strict,introduced=10.16))) // expected-note {{here}}
void fAppExtErr();

__attribute__((availability(macos_app_extension,strict,introduced=11.1))) // expected-warning {{availability does not match previous declaration}}
void fAppExtErr() { }

__attribute__((availability(macos,introduced=11)))
void fNew2();
#ifndef NEW
  // expected-note@-2 {{'fNew2' has been marked as being introduced in macOS 11 here, but the deployment target is macOS 10.15}}
#endif
__attribute__((availability(macos,introduced=10.16)))
void fNew3();

__attribute__((availability(macos,introduced=12)))
void evenNewer();
#ifdef NEW
  // expected-note@-2 {{'evenNewer' has been marked as being introduced in macOS 12 here, but the deployment target is macOS 11}}
#endif

void testAvailabilityCheck() {
  if (__builtin_available(macOS 10.16, *)) {
    fNew2();
    fNew3();
  }
  if (__builtin_available(macOS 11, *)) {
    fNew2();
    fNew3();
  }
  fNew2();
#ifndef NEW
  // expected-warning@-2 {{'fNew2' is only available on macOS 11 or newer}} expected-note@-2 {{enclose}}
#endif
#ifdef NEW
  evenNewer(); // expected-warning {{'evenNewer' is only available on macOS 12 or newer}} expected-note {{enclose}}
#endif
}