File: weak_import_clang.swift

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 (37 lines) | stat: -rw-r--r-- 1,204 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
// RUN: %empty-directory(%t)
// RUN: %build-irgen-test-overlays
//
// Specify explicit target triples for the deployment target to test weak
// linking for a symbol introduced in OS X 10.51.
//
// RUN: %target-swift-frontend(mock-sdk: -target %target-cpu-apple-macosx10.50 -sdk %S/Inputs -I %t) -primary-file %s -emit-ir | %FileCheck -check-prefix=CHECK-10_50 %s
// RUN: %target-swift-frontend(mock-sdk: -target %target-cpu-apple-macosx10.51 -sdk %S/Inputs -I %t) -primary-file %s -emit-ir | %FileCheck -check-prefix=CHECK-10_51 %s

// REQUIRES: OS=macosx
// REQUIRES: objc_interop

// FIXME: This test in written in Swift because the SIL parser fails
// when referencing weak_variable.

import Foundation

// CHECK-10_50: @weak_variable = extern_weak global
// CHECK-10_51: @weak_variable = extern_weak global

func testObjCClass() {
  if #available(OSX 10.51, *) {
    let action = NSUserNotificationAction()
  }
}

func testGlobalVariable() {
  let i = weak_variable
}


@available(OSX 10.51, *)
func wrapWeakFunction() {
  // CHECK-10_50: declare extern_weak void @future_function_should_be_weak()
  // CHECK-10_51: declare void @future_function_should_be_weak()
  future_function_should_be_weak()
}