Skip to content
Open
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
16 changes: 16 additions & 0 deletions stdlib/public/core/EmbeddedRuntime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -579,3 +579,19 @@ func _embeddedReportFatalErrorInFile(prefix: StaticString, message: UnsafeBuffer
if message.count > 0 { print(": ", terminator: "") }
unsafe print(message)
}

// CXX Exception Personality

typealias _Unwind_Action = CInt
typealias _Unwind_Reason_Code = CInt

@_cdecl("_swift_exceptionPersonality")
func _swift_exceptionPersonality(
version: CInt,
actions: _Unwind_Action,
exceptionClass: UInt64,
exceptionObject: UnsafeMutableRawPointer,
context: UnsafeMutableRawPointer
) -> _Unwind_Reason_Code {
fatalError("C++ exception handling detected but the Embedded Swift runtime does not support exceptions")
}
17 changes: 17 additions & 0 deletions test/embedded/linkage/cxx-exceptions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend %s -enable-experimental-feature Embedded -O -c -o %t/main.o -cxx-interoperability-mode=default
// RUN: %target-clang %target-clang-resource-dir-opt %t/main.o -o %t/a.out -dead_strip
// RUN: %target-run %t/a.out | %FileCheck %s

// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: swift_feature_Embedded

@_expose(Cxx)
func f1() {
print("OK!")
}

f1()

// CHECK: OK!