Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,7 @@ inline int extractValueFromRefToPtr(IntBox *&b) { return b->value; }
inline int extractValueFromRefToConstPtr(IntBox const *&b) { return b->value; }
inline int extractValueFromConstRefToPtr(IntBox *const &b) { return b->value; }
inline int extractValueFromConstRefToConstPtr(IntBox const *const &b) { return b->value; }

inline void initializeByPtr(int value, IntBox **b) {
*b = IntBox::create(value);
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@
// CHECK: func extractValueFromRefToConstPtr(_ b: inout IntBox!) -> Int32
// CHECK: func extractValueFromConstRefToPtr(_ b: IntBox!) -> Int32
// CHECK: func extractValueFromConstRefToConstPtr(_ b: IntBox!) -> Int32

// CHECK: func initializeByPtr(_ value: Int32, _ b: UnsafeMutablePointer<IntBox?>!)
6 changes: 6 additions & 0 deletions test/Interop/Cxx/foreign-reference/pass-as-parameter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,10 @@ PassAsParameterTestSuite.test("pass as const reference to const pointer") {
expectEqual(aValue, 789)
}

PassAsParameterTestSuite.test("initialize by pointer") {
var a: IntBox!
initializeByPtr(987, &a)
expectEqual(a.value, 987)
}

runAllTests()