diff --git a/test/SIL/manual_ownership.swift b/test/SIL/manual_ownership.swift index b4e929542f78d..14bd0ac0542fe 100644 --- a/test/SIL/manual_ownership.swift +++ b/test/SIL/manual_ownership.swift @@ -56,6 +56,24 @@ public func basic_return3() -> Triangle { return Triangle() } +// FIXME: we need copy propagation in -Onone to eliminate all these copies +@_manualOwnership +func reassign_with_lets() -> Triangle { + let x = Triangle() + let y = x // expected-error {{explicit 'copy' required here}} + let z = y // expected-error {{explicit 'copy' required here}} + return z // expected-error {{explicit 'copy' required here}} +} + +// FIXME: we need copy propagation in -Onone to eliminate all but the copies for returning +@_manualOwnership +func renamed_return(_ cond: Bool, _ a: Triangle) -> Triangle { + let b = a // expected-error {{explicit 'copy' required here}} + let c = b // expected-error {{explicit 'copy' required here}} + if cond { return b } // expected-error {{explicit 'copy' required here}} + return c // expected-error {{explicit 'copy' required here}} +} + /// MARK: method calls @_manualOwnership @@ -152,3 +170,17 @@ public func basic_loop_nontrivial_values_fixed(_ t: Triangle, _ xs: [Triangle]) } (copy t.nontrivial).a = p // expected-error {{explicit 'copy' required here}} } + + +/// MARK: Globals +let ref_result = [5, 13, 29] + +@_manualOwnership +func access_global_1() -> Int { + return ref_result[2] // expected-error {{explicit 'copy' required here}} +} +@_manualOwnership +func access_global_1_fixed() -> Int { +return (copy ref_result)[2] +} +