Skip to content

Commit dbc93c5

Browse files
authored
Merge pull request #84383 from kavon/manual-ownership-2
test: add more ManualOwnership coverage
2 parents d7d4ba3 + d03d6d8 commit dbc93c5

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

test/SIL/manual_ownership.swift

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,24 @@ public func basic_return3() -> Triangle {
5656
return Triangle()
5757
}
5858

59+
// FIXME: we need copy propagation in -Onone to eliminate all these copies
60+
@_manualOwnership
61+
func reassign_with_lets() -> Triangle {
62+
let x = Triangle()
63+
let y = x // expected-error {{explicit 'copy' required here}}
64+
let z = y // expected-error {{explicit 'copy' required here}}
65+
return z // expected-error {{explicit 'copy' required here}}
66+
}
67+
68+
// FIXME: we need copy propagation in -Onone to eliminate all but the copies for returning
69+
@_manualOwnership
70+
func renamed_return(_ cond: Bool, _ a: Triangle) -> Triangle {
71+
let b = a // expected-error {{explicit 'copy' required here}}
72+
let c = b // expected-error {{explicit 'copy' required here}}
73+
if cond { return b } // expected-error {{explicit 'copy' required here}}
74+
return c // expected-error {{explicit 'copy' required here}}
75+
}
76+
5977
/// MARK: method calls
6078

6179
@_manualOwnership
@@ -152,3 +170,17 @@ public func basic_loop_nontrivial_values_fixed(_ t: Triangle, _ xs: [Triangle])
152170
}
153171
(copy t.nontrivial).a = p // expected-error {{explicit 'copy' required here}}
154172
}
173+
174+
175+
/// MARK: Globals
176+
let ref_result = [5, 13, 29]
177+
178+
@_manualOwnership
179+
func access_global_1() -> Int {
180+
return ref_result[2] // expected-error {{explicit 'copy' required here}}
181+
}
182+
@_manualOwnership
183+
func access_global_1_fixed() -> Int {
184+
return (copy ref_result)[2]
185+
}
186+

0 commit comments

Comments
 (0)