Skip to content

Commit 2622fa7

Browse files
authored
Merge pull request #70710 from kubamracek/embedded-ump-allocate
[embedded] Add -no-allocations test for UnsafeMutablePointer.allocate(), improve diag messsage
2 parents 4259e4f + 31057e4 commit 2622fa7

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

include/swift/AST/DiagnosticsSIL.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,7 +367,7 @@ ERROR(embedded_swift_metatype,none,
367367
ERROR(embedded_swift_allocating_type,none,
368368
"cannot use allocating type %0 in -no-allocations mode", (Type))
369369
ERROR(embedded_swift_allocating,none,
370-
"cannot use allocating type in -no-allocations mode", ())
370+
"cannot use allocating operation in -no-allocations mode", ())
371371
NOTE(performance_called_from,none,
372372
"called from here", ())
373373

test/embedded/no-allocations.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,7 @@ public func use_an_array() -> Int {
1616
let a = [1, 2, 3] // expected-error {{cannot use allocating type '_ContiguousArrayStorage<Int>' in -no-allocations mode}}
1717
return a.count
1818
}
19+
20+
public func use_unsafepointer_allocate() -> UnsafeMutablePointer<UInt8> {
21+
return UnsafeMutablePointer<UInt8>.allocate(capacity: 10) // expected-error {{cannot use allocating operation in -no-allocations mode}}
22+
}

0 commit comments

Comments
 (0)