File: weak_import_clang.swift

package info (click to toggle)
swiftlang 6.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,532 kB
  • sloc: cpp: 9,901,743; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (37 lines) | stat: -rw-r--r-- 1,204 bytes parent folder | download | duplicates (2)
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()
}