EmbeddedSwiftDiagnostics: fix a wrong "cannot use co-routines (like accessors) in -no-allocations mode" error

rdar://150890424
This commit is contained in:
Erik Eckstein
2025-05-08 08:38:59 +02:00
parent 9348f5e8d4
commit d9c7a68249
2 changed files with 27 additions and 2 deletions

View File

@@ -130,10 +130,16 @@ private struct FunctionChecker {
throw Diagnostic(.embedded_swift_allocating_type, (instruction as! SingleValueInstruction).type,
at: instruction.location)
}
case is BeginApplyInst:
throw Diagnostic(.embedded_swift_allocating_coroutine, at: instruction.location)
if context.options.noAllocations {
throw Diagnostic(.embedded_swift_allocating_coroutine, at: instruction.location)
}
case is ThunkInst:
throw Diagnostic(.embedded_swift_allocating, at: instruction.location)
if context.options.noAllocations {
throw Diagnostic(.embedded_swift_allocating, at: instruction.location)
}
case let pai as PartialApplyInst:
if context.options.noAllocations && !pai.isOnStack {

View File

@@ -0,0 +1,19 @@
// Make sure this can be compiled without any errors
// RUN: %target-swift-frontend %s -emit-ir -o /dev/null -enable-experimental-feature Embedded -enable-testing
// RUN: %target-swift-frontend %s -emit-ir -o /dev/null -enable-experimental-feature Embedded -enable-testing -no-allocations
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx
// REQUIRES: swift_feature_Embedded
public protocol P {
var storage: UInt32 { get set }
}
struct MyStruct: P {
var storage: UInt32
}