File tree Expand file tree Collapse file tree 2 files changed +41
-3
lines changed
test/SIL/ownership-verifier Expand file tree Collapse file tree 2 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -1035,9 +1035,16 @@ OwnershipUseCheckerResult OwnershipCompatibilityUseChecker::visitEnumArgument(
1035
1035
// The operand has a non-trivial ownership kind. It must match the argument
1036
1036
// convention.
1037
1037
auto ownership = getOwnershipKind ();
1038
- auto lifetimeConstraint = (ownership == ValueOwnershipKind::Owned)
1039
- ? UseLifetimeConstraint::MustBeInvalidated
1040
- : UseLifetimeConstraint::MustBeLive;
1038
+ UseLifetimeConstraint lifetimeConstraint;
1039
+ if (ownership == ValueOwnershipKind::Owned) {
1040
+ if (RequiredKind != ValueOwnershipKind::Owned) {
1041
+ lifetimeConstraint = UseLifetimeConstraint::MustBeLive;
1042
+ } else {
1043
+ lifetimeConstraint = UseLifetimeConstraint::MustBeInvalidated;
1044
+ }
1045
+ } else {
1046
+ lifetimeConstraint = UseLifetimeConstraint::MustBeLive;
1047
+ }
1041
1048
return {compatibleOwnershipKinds (ownership, RequiredKind),
1042
1049
lifetimeConstraint};
1043
1050
}
Original file line number Diff line number Diff line change
1
+ // RUN: %target-sil-opt -enable-sil-ownership -enable-sil-verify-all=0 -module-name Swift -o /dev/null 2>&1 %s
2
+ // REQUIRES: asserts
3
+
4
+ // This file is meant to contain tests that previously the verifier treated
5
+ // incorrectly. This is important to ensure that the verifier does not
6
+ // regress. It should only deal with dataflow over consuming failures.
7
+
8
+ sil_stage canonical
9
+
10
+ import Builtin
11
+
12
+ enum FakeOptional<T> {
13
+ case some(T)
14
+ case none
15
+ }
16
+
17
+ class Klass {
18
+ }
19
+
20
+ sil @klass_user : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> ()
21
+
22
+ sil @guaranteed_is_not_owned_use : $@convention(thin) (@guaranteed Klass) -> () {
23
+ bb0(%0 : @guaranteed $Klass):
24
+ %1 = copy_value %0 : $Klass
25
+ %2 = function_ref @klass_user : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> ()
26
+ %3 = enum $FakeOptional<Klass>, #FakeOptional.some!enumelt.1, %1 : $Klass
27
+ %4 = apply %2(%3) : $@convention(thin) (@guaranteed FakeOptional<Klass>) -> ()
28
+ destroy_value %3 : $FakeOptional<Klass>
29
+ %9999 = tuple()
30
+ return %9999 : $()
31
+ }
You can’t perform that action at this time.
0 commit comments