Skip to content

Commit d9c7a68

Browse files
committed
EmbeddedSwiftDiagnostics: fix a wrong "cannot use co-routines (like accessors) in -no-allocations mode" error
rdar://150890424
1 parent 9348f5e commit d9c7a68

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

SwiftCompilerSources/Sources/Optimizer/ModulePasses/EmbeddedSwiftDiagnostics.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,16 @@ private struct FunctionChecker {
130130
throw Diagnostic(.embedded_swift_allocating_type, (instruction as! SingleValueInstruction).type,
131131
at: instruction.location)
132132
}
133+
133134
case is BeginApplyInst:
134-
throw Diagnostic(.embedded_swift_allocating_coroutine, at: instruction.location)
135+
if context.options.noAllocations {
136+
throw Diagnostic(.embedded_swift_allocating_coroutine, at: instruction.location)
137+
}
138+
135139
case is ThunkInst:
136-
throw Diagnostic(.embedded_swift_allocating, at: instruction.location)
140+
if context.options.noAllocations {
141+
throw Diagnostic(.embedded_swift_allocating, at: instruction.location)
142+
}
137143

138144
case let pai as PartialApplyInst:
139145
if context.options.noAllocations && !pai.isOnStack {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Make sure this can be compiled without any errors
2+
3+
// RUN: %target-swift-frontend %s -emit-ir -o /dev/null -enable-experimental-feature Embedded -enable-testing
4+
// RUN: %target-swift-frontend %s -emit-ir -o /dev/null -enable-experimental-feature Embedded -enable-testing -no-allocations
5+
6+
7+
// REQUIRES: VENDOR=apple
8+
// REQUIRES: OS=macosx
9+
// REQUIRES: swift_feature_Embedded
10+
11+
public protocol P {
12+
var storage: UInt32 { get set }
13+
}
14+
15+
struct MyStruct: P {
16+
var storage: UInt32
17+
}
18+
19+

0 commit comments

Comments
 (0)