- Notifications
You must be signed in to change notification settings - Fork 10.5k
/
Copy pathunsafe_stdlib.swift
19 lines (17 loc) · 867 Bytes
/
unsafe_stdlib.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// RUN: %target-typecheck-verify-swift -strict-memory-safety
// Make sure everything compiles without error when unsafe code is allowed.
// RUN: %target-swift-frontend -typecheck -warnings-as-errors %s
func test(
x:OpaquePointer,
other:UnsafeMutablePointer<Int>
){
vararray=[1,2,3]
// expected-warning@+2{{expression uses unsafe constructs but is not marked with 'unsafe'}}{{3-3=unsafe }}
// expected-note@+1{{argument #0 in call to instance method 'withUnsafeBufferPointer' has unsafe type '(UnsafeBufferPointer<Element>) throws(E) -> R'}}
array.withUnsafeBufferPointer{ buffer in
// expected-warning@+1{{expression uses unsafe constructs but is not marked with 'unsafe'}}{{5-5=unsafe }}
print(buffer) // expected-note{{reference to parameter 'buffer' involves unsafe type 'UnsafeBufferPointer<Int>'}}
}
array.append(4)
_ = array
}