Skip to content

Commit 413dd85

Browse files
committed
Test init(rawValue:) behavior for obsolete cases
Also touches the other version numbers so I can use realistic, but far-future, ones.
1 parent 6d8dbfa commit 413dd85

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

test/SILGen/enum_raw_representable_available.swift

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// RUN: %target-typecheck-verify-swift
1+
// RUN: %target-typecheck-verify-swift -target x86_64-apple-macosx10.52
22

3-
// RUN: %target-swift-emit-silgen -emit-sorted-sil -o %t.fragile.sil %s
3+
// RUN: %target-swift-emit-silgen -target x86_64-apple-macosx10.52 -emit-sorted-sil -o %t.fragile.sil %s
44
// RUN: %FileCheck %s < %t.fragile.sil
55
// RUN: %FileCheck -check-prefix NEGATIVE %s < %t.fragile.sil
66

7-
// RUN: %target-swift-emit-silgen -emit-sorted-sil -enable-resilience -o %t.resilient.sil %s
7+
// RUN: %target-swift-emit-silgen -target x86_64-apple-macosx10.52 -emit-sorted-sil -enable-resilience -o %t.resilient.sil %s
88
// RUN: %FileCheck %s < %t.resilient.sil
99
// RUN: %FileCheck -check-prefix NEGATIVE %s < %t.resilient.sil
1010

@@ -19,15 +19,20 @@ public enum E: Int {
1919

2020
case normal = -1000
2121

22-
@available(macOS 10.8, *)
22+
@available(macOS 10.51, *)
2323
case alwaysAvailable = -2000
2424

25-
@available(macOS 500.600.700, *)
25+
@available(macOS 10.55, *)
2626
case potentiallyUnavailable = -3000
2727

2828
@available(macOS, unavailable)
2929
case neverAvailable = -4000
3030

31+
@available(macOS, obsoleted: 10.99)
32+
case notObsoleteYet = -5000
33+
34+
@available(macOS, obsoleted: 10.51)
35+
case nowObsolete = -6000
3136
}
3237

3338
// CHECK-LABEL: sil {{(\[serialized\] )?}}[ossa] @$s4main1EO8rawValueACSgSi_tcfC
@@ -41,10 +46,17 @@ public enum E: Int {
4146
// CHECK: integer_literal $Builtin.IntLiteral, -3000
4247
// CHECK: cond_br {{[^,]+}}, [[potentiallyUnavailable:bb[0-9]+]]
4348

49+
// CHECK: integer_literal $Builtin.IntLiteral, -5000
50+
// CHECK: cond_br {{[^,]+}}, [[notObsoleteYet:bb[0-9]+]]
51+
52+
// CHECK: [[notObsoleteYet]]:
53+
// CHECK-NOT: function_ref @$ss26_stdlib_isOSVersionAtLeastyBi1_Bw_BwBwtF
54+
// CHECK: {{enum \$E|inject_enum_addr %[0-9]+ : \$\*E}}, #E.notObsoleteYet!enumelt
55+
4456
// CHECK: [[potentiallyUnavailable]]:
45-
// CHECK-NEXT: integer_literal $Builtin.Word, 500
46-
// CHECK-NEXT: integer_literal $Builtin.Word, 600
47-
// CHECK-NEXT: integer_literal $Builtin.Word, 700
57+
// CHECK-NEXT: integer_literal $Builtin.Word, 10
58+
// CHECK-NEXT: integer_literal $Builtin.Word, 55
59+
// CHECK-NEXT: integer_literal $Builtin.Word, 0
4860
// CHECK: function_ref @$ss26_stdlib_isOSVersionAtLeastyBi1_Bw_BwBwtF
4961
// CHECK: cond_br {{[^,]+}}, [[potentiallyUnavailable_newEnough:bb[0-9]+]],
5062

@@ -67,5 +79,14 @@ public enum E: Int {
6779
// CHECK: end sil function '$s4main1EO8rawValueSivg'
6880

6981
// NEGATIVE-LABEL: sil {{(\[serialized\] )?}}[ossa] @$s4main1EO8rawValueACSgSi_tcfC
82+
83+
// Should not try to match neverAvailable's raw value
7084
// NEGATIVE-NOT: integer_literal $Builtin.IntLiteral, -4000
85+
86+
// Should not try to match nowObsolete's raw value
87+
// NEGATIVE-NOT: integer_literal $Builtin.IntLiteral, -6000
88+
89+
// Should not have a version check for notObsoleteYet
90+
// NEGATIVE-NOT: integer_literal $Builtin.Word, 99
91+
7192
// NEGATIVE: end sil function '$s4main1EO8rawValueACSgSi_tcfC'

0 commit comments

Comments
 (0)