Skip to content

Commit 1d8cce5

Browse files
authored
Merge pull request #67572 from kubamracek/section-fptrs
Add a test exercising placing a struct with C function pointers into a custom section
2 parents 5116600 + 7b36b22 commit 1d8cce5

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %{python} %utils/split_file.py -o %t %s
3+
// RUN: %target-swift-frontend -enable-experimental-feature SymbolLinkageMarkers -enforce-exclusivity=unchecked -parse-as-library -emit-sil -import-objc-header %t/bridge.h %t/file.swift -o /dev/null
4+
5+
// REQUIRES: swift_in_compiler
6+
7+
// BEGIN bridge.h
8+
struct MyStruct1 {
9+
int x;
10+
void (*fptr1)();
11+
void (*fptr2)(int);
12+
void (*fptr3)(int, char, void *);
13+
};
14+
15+
// BEGIN file.swift
16+
17+
func foo() { }
18+
@_section("__TEXT,__mysection") var my_global1 = MyStruct1(
19+
x: 42,
20+
fptr1: foo,
21+
fptr2: nil,
22+
fptr3: { arg1, arg2, arg3 in print(arg1, arg2, arg3) }
23+
)

0 commit comments

Comments
 (0)