|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: split-file %s %t --leading-lines |
| 3 | + |
| 4 | +// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) \ |
| 5 | +// RUN: -emit-module %t/Lib.swift -o %t -I %t \ |
| 6 | +// RUN: -swift-version 6 -enable-library-evolution \ |
| 7 | +// RUN: -emit-module-interface-path %t/Lib.swiftinterface \ |
| 8 | +// RUN: -enable-experimental-feature CDecl \ |
| 9 | +// RUN: -enable-experimental-feature CImplementation |
| 10 | + |
| 11 | +// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -I %t \ |
| 12 | +// RUN: -typecheck-module-from-interface %t/Lib.swiftinterface |
| 13 | + |
| 14 | +// RUN: %FileCheck %s --input-file %t/Lib.swiftinterface |
| 15 | + |
| 16 | +// REQUIRES: objc_interop |
| 17 | +// REQUIRES: swift_feature_CDecl |
| 18 | +// REQUIRES: swift_feature_CImplementation |
| 19 | + |
| 20 | +//--- module.modulemap |
| 21 | +module Lib { |
| 22 | + header "Lib.h" |
| 23 | +} |
| 24 | + |
| 25 | +//--- Lib.h |
| 26 | +extern void cImplFunc(); |
| 27 | +extern void objcImplFunc(); |
| 28 | + |
| 29 | +//--- Lib.swift |
| 30 | +@_exported import Lib |
| 31 | +import Foundation |
| 32 | + |
| 33 | +/// Don't print the implementation functions. |
| 34 | +// CHECK-NOT: @implementation |
| 35 | +// CHECK-NOT: ImplFunc |
| 36 | + |
| 37 | +@c @implementation |
| 38 | +public func cImplFunc() { } |
| 39 | + |
| 40 | +@_cdecl("objcImplFunc") @implementation |
| 41 | +public func objcImplFunc() { } |
| 42 | + |
| 43 | +/// Print other @c functions. |
| 44 | +@c |
| 45 | +public func bareCDecl() {} |
| 46 | +// CHECK: @c |
| 47 | +// CHECK-NEXT: public func bareCDecl |
| 48 | + |
| 49 | +@c(c_name) |
| 50 | +public func namedCDecl() {} |
| 51 | +// CHECK: @c(c_name) |
| 52 | +// CHECK-NEXT: public func namedCDecl |
| 53 | + |
| 54 | +@_cdecl("objc_name") |
| 55 | +public func namedLegacyCDecl() {} |
| 56 | +// CHECK: @_cdecl("objc_name") |
| 57 | +// CHECK-NEXT: public func namedLegacyCDecl |
0 commit comments