Skip to content

Commit 1a67fe4

Browse files
committed
[interop][SwiftToCxx] validate that immortal FRTs can be consuming parameters
1 parent 8965b41 commit 1a67fe4

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

test/Interop/CxxToSwiftToCxx/consuming-cxx-struct-parameter-back-to-cxx-execution.cpp

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// RUN: %empty-directory(%t)
22
// RUN: split-file %s %t
33

4-
// RUN: %target-swift-frontend -typecheck %t/use-cxx-types.swift -typecheck -module-name UseCxx -emit-clang-header-path %t/UseCxx.h -I %t -enable-experimental-cxx-interop -clang-header-expose-decls=all-public
4+
// RUN: %target-swift-frontend -typecheck %t/use-cxx-types.swift -typecheck -module-name UseCxx -emit-clang-header-path %t/UseCxx.h -I %t -enable-experimental-cxx-interop -clang-header-expose-decls=all-public -disable-availability-checking
55

66
// RUN: %target-interop-build-clangxx -std=c++20 -c %t/use-swift-cxx-types.cpp -I %t -o %t/swift-cxx-execution.o
7-
// RUN: %target-interop-build-swift %t/use-cxx-types.swift -o %t/swift-cxx-execution -Xlinker %t/swift-cxx-execution.o -module-name UseCxx -Xfrontend -entry-point-function-name -Xfrontend swiftMain -I %t -O
7+
// RUN: %target-interop-build-swift %t/use-cxx-types.swift -o %t/swift-cxx-execution -Xlinker %t/swift-cxx-execution.o -module-name UseCxx -Xfrontend -entry-point-function-name -Xfrontend swiftMain -I %t -O -Xfrontend -disable-availability-checking
88

99
// RUN: %target-codesign %t/swift-cxx-execution
1010
// RUN: %target-run %t/swift-cxx-execution | %FileCheck %s
@@ -44,6 +44,13 @@ struct NonTrivialTemplate {
4444

4545
using NonTrivialTemplateTrivial = NonTrivialTemplate<Trivial>;
4646

47+
class ImmortalFRT {
48+
public:
49+
int x;
50+
} __attribute__((swift_attr("import_reference")))
51+
__attribute__((swift_attr("retain:immortal")))
52+
__attribute__((swift_attr("release:immortal")));
53+
4754
//--- module.modulemap
4855
module CxxTest {
4956
header "header.h"
@@ -66,6 +73,10 @@ public struct TakesNonTrivial {
6673
public var prop: NonTrivialTemplateTrivial
6774
}
6875

76+
public func consumeImmortalFRT(_ x: consuming ImmortalFRT) {
77+
print("frt x \(x.x)")
78+
}
79+
6980
//--- use-swift-cxx-types.cpp
7081

7182
#include "header.h"
@@ -91,7 +102,6 @@ int main() {
91102
puts("DoneCall");
92103
swiftVal.setProp(x);
93104
}
94-
puts("EndOfTest");
95105
// CHECK-NEXT: create NonTrivialTemplate
96106
// CHECK-NEXT: call
97107
// CHECK-NEXT: copy NonTrivialTemplate
@@ -104,6 +114,13 @@ int main() {
104114
// CHECK-NEXT: ~NonTrivialTemplate
105115
// CHECK-NEXT: ~NonTrivialTemplate
106116
// CHECK-NEXT: ~NonTrivialTemplate
117+
{
118+
ImmortalFRT frt;
119+
frt.x = 2;
120+
UseCxx::consumeImmortalFRT(&frt);
121+
}
122+
// CHECK-NEXT: frt x 2
123+
puts("EndOfTest");
107124
// CHECK-NEXT: EndOfTest
108125
return 0;
109126
}

0 commit comments

Comments
 (0)