File: objc-available.m

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (33 lines) | stat: -rw-r--r-- 1,348 bytes parent folder | download | duplicates (15)
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
// RUN: %clang_cc1 -fsyntax-only -Wunguarded-availability -Wno-unsupported-availability-guard -triple x86_64-apple-macosx10.10.0 -verify %s

void f() {

  if (@available(macos 10.12, *)) {}
  else if (@available(macos 10.11, *)) {}
  else {}

  (void)__builtin_available(ios 8, macos 10.10, *);

  (void)@available(macos 10.11); // expected-error{{must handle potential future platforms with '*'}}
  (void)@available(macos 10.11, macos 10.11, *); // expected-error{{version for 'macos' already specified}}

  (void)@available(erik_os 10.11, *); // expected-error{{unrecognized platform name erik_os}}

  (void)@available(erik_os 10.10, hat_os 1.0, *); // expected-error 2 {{unrecognized platform name}}

  (void)@available(); // expected-error{{expected a platform name here}}
  (void)@available(macos 10.10,); // expected-error{{expected a platform name here}}
  (void)@available(macos); // expected-error{{expected a version}}
  (void)@available; // expected-error{{expected '('}}
}

void prettyPlatformNames() {
  (void)@available(iOS 8, tvOS 10, watchOS 3, macOS 10.11, *);
  (void)__builtin_available(iOSApplicationExtension 8, tvOSApplicationExtension 10,
                   watchOSApplicationExtension 3, macOSApplicationExtension 10.11, *);
}

#if __has_builtin(__builtin_available)
#error expected
// expected-error@-1 {{expected}}
#endif