mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
SILGen: Don't try to project static stored properties as addressable from their base.
An oversight from https://github.com/swiftlang/swift/pull/82288. Fixes #82368 / rdar://153837014.
This commit is contained in:
@@ -3622,8 +3622,8 @@ SILGenFunction::tryEmitAddressableParameterAsAddress(ArgumentSource &&arg,
|
||||
auto vd = cast<VarDecl>(memberStorage);
|
||||
// TODO: Is it possible and/or useful for class storage to be
|
||||
// addressable?
|
||||
if (!vd->getDeclContext()->getInnermostTypeContext()
|
||||
->getDeclaredTypeInContext()->getStructOrBoundGenericStruct()) {
|
||||
if (!vd->isInstanceMember()
|
||||
|| !isa<StructDecl>(vd->getDeclContext())) {
|
||||
return notAddressable();
|
||||
}
|
||||
|
||||
|
||||
@@ -684,7 +684,8 @@ static void deallocateAddressable(SILGenFunction &SGF,
|
||||
const SILGenFunction::VarLoc::AddressableBuffer::State &state) {
|
||||
SGF.B.createEndBorrow(l, state.storeBorrow);
|
||||
SGF.B.createDeallocStack(l, state.allocStack);
|
||||
if (state.reabstraction) {
|
||||
if (state.reabstraction
|
||||
&& !state.reabstraction->getType().isTrivial(SGF.F)) {
|
||||
SGF.B.createDestroyValue(l, state.reabstraction);
|
||||
}
|
||||
}
|
||||
|
||||
11
test/SILGen/82368.swift
Normal file
11
test/SILGen/82368.swift
Normal file
@@ -0,0 +1,11 @@
|
||||
// RUN: %target-swift-emit-silgen -disable-availability-checking -verify %s
|
||||
|
||||
struct A {
|
||||
static let a: InlineArray = [1]
|
||||
|
||||
static func foo() {
|
||||
a.span.withUnsafeBufferPointer({ buffer in
|
||||
print("\(buffer.baseAddress!)")
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user