Skip to content

Commit 5431bb1

Browse files
[test][wasm] Add test to kill the missing func addr reservation
1 parent e12642f commit 5431bb1

File tree

2 files changed

+47
-1
lines changed

2 files changed

+47
-1
lines changed

test/Interpreter/enum.swift

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -745,3 +745,45 @@ func reproduction<T: Init>(_ x: Int, _ y: Int, _ t: T) {
745745

746746
// CHECK: there is no byte
747747
reproduction(2, 3, TrailingByte())
748+
749+
do {
750+
// regression test for https://github.com/swiftlang/swift-driver/pull/1987
751+
@inline(never) func blackhole<T>(_ t: T) { }
752+
753+
final class Context {
754+
func doSomething() {}
755+
deinit {
756+
print("Context deinit")
757+
}
758+
}
759+
760+
enum MyOptional<Value> {
761+
case some(Value)
762+
case none
763+
}
764+
765+
final class _GenericStorage<Value> {
766+
let value: MyOptional<Value>
767+
768+
init(value: Value) {
769+
self.value = .some(value)
770+
}
771+
772+
func unwrapAndCopy() {
773+
if case .some(let value) = value {
774+
blackhole(value)
775+
}
776+
}
777+
}
778+
779+
let test = _GenericStorage(
780+
value: Context().doSomething,
781+
)
782+
// CHECK: test.unwrapAndCopy
783+
print("test.unwrapAndCopy")
784+
test.unwrapAndCopy()
785+
// CHECK: test.unwrapAndCopy
786+
print("test.unwrapAndCopy")
787+
test.unwrapAndCopy()
788+
// CHECK: Context deinit
789+
}

utils/swift_build_support/swift_build_support/products/wasmstdlib.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,11 @@ def _build_stdlib(self, host_target, target_triple, llvm_cmake_dir):
191191
# Test configuration
192192
self.cmake_options.define('SWIFT_INCLUDE_TESTS:BOOL', 'TRUE')
193193
self.cmake_options.define('SWIFT_ENABLE_SOURCEKIT_TESTS:BOOL', 'FALSE')
194-
lit_test_paths = ['IRGen', 'stdlib', 'Concurrency/Runtime', 'embedded']
194+
lit_test_paths = [
195+
'IRGen', 'stdlib', 'Concurrency/Runtime', 'embedded',
196+
# TODO(katei): Enable all interpreter tests
197+
'Interpreter/enum.swift',
198+
]
195199
lit_test_paths = [os.path.join(
196200
self.build_dir, 'test-wasi-wasm32', path) for path in lit_test_paths]
197201
self.cmake_options.define('SWIFT_LIT_TEST_PATHS:STRING',

0 commit comments

Comments
 (0)