mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
With the acceptance of SE-0458, allow the use of unsafe expressions, the @safe and @unsafe attributes, and the `unsafe` effect on the for..in loop in all Swift code. Introduce the `-strict-memory-safety` flag detailed in the proposal to enable strict memory safety checking. This enables a new class of feature, an optional feature (that is *not* upcoming or experimental), and which can be detected via `hasFeature(StrictMemorySafety)`.
20 lines
382 B
Swift
20 lines
382 B
Swift
// RUN: %target-typecheck-verify-swift
|
|
|
|
|
|
// Can use @unsafe and @safe without strict memory safety being enabled.
|
|
@unsafe func f() { }
|
|
@safe func g(_: UnsafeRawPointer) { }
|
|
|
|
protocol P {
|
|
func f()
|
|
}
|
|
|
|
struct X: @unsafe P {
|
|
@unsafe func f() { }
|
|
}
|
|
|
|
// The feature flag is not enabled, though.
|
|
#if hasFeature(StrictMemorySafety)
|
|
#error("Strict memory safety is not enabled!")
|
|
#endif
|