Files
swift-mirror/test/stdlib/AutoreleasingUnsafeMutablePointerDiagnostics.swift
Hamish Knight 998434f0da Add a -disable-invalid-ephemeralness-as-error flag
Currently this does nothing, as we're warning by
default, but once we error by default, this will
downgrade the diagnostic to a warning.
2019-11-03 08:42:26 -08:00

11 lines
515 B
Swift

// RUN: %target-typecheck-verify-swift -enable-invalid-ephemeralness-as-error
// REQUIRES: objc_interop
func unsafePointerInitEphemeralConversions() {
class C {}
var c: C?
_ = AutoreleasingUnsafeMutablePointer(&c) // expected-error {{initialization of 'AutoreleasingUnsafeMutablePointer<C?>' results in a dangling pointer}}
// expected-note@-1 {{implicit argument conversion from 'C?' to 'AutoreleasingUnsafeMutablePointer<C?>' produces a pointer valid only for the duration of the call to 'init(_:)'}}
}