3
3
// RUN: %FileCheck %s < %t/output.sil
4
4
// RUN: %FileCheck -check-prefix=CHECK-ALL %s < %t/output.sil
5
5
6
+ // RUN: %target-swift-frontend -primary-file %s -O -sil-verify-all -swift-version 6 -Xllvm -sil-print-types -emit-sil >%t/output6.sil
7
+ // RUN: %FileCheck %s < %t/output6.sil
8
+ // RUN: %FileCheck -check-prefix=CHECK-ALL %s < %t/output6.sil
9
+
6
10
// RUN: %target-build-swift -O %s -o %t/a.out
7
- // RUN: %target-run %t/a.out | %FileCheck %s -check-prefix=CHECK-OUTPUT
11
+ // RUN: %target-run %t/a.out | %FileCheck %s -check-prefix=CHECK-OUTPUT -check-prefix=CHECK5-OUTPUT
12
+
13
+ // RUN: %target-build-swift -swift-version 6 -O %s -o %t/a6.out
14
+ // RUN: %target-run %t/a6.out | %FileCheck %s -check-prefix=CHECK-OUTPUT
15
+
8
16
// REQUIRES: executable_test,optimized_stdlib
9
17
// REQUIRES: CPU=arm64 || CPU=x86_64
10
18
@@ -28,7 +36,9 @@ struct GenStruct<T : P> : P {
28
36
}
29
37
}
30
38
39
+ #if !swift(>=6)
31
40
var numGenClassObjs = 0
41
+ #endif
32
42
33
43
final class GenClass < T : P > : P {
34
44
var ct : T
@@ -39,11 +49,15 @@ final class GenClass<T : P> : P {
39
49
init ( _ ct: T ) {
40
50
self . ct = ct
41
51
self . gs = . init( ct)
52
+ #if !swift(>=6)
42
53
numGenClassObjs += 1
54
+ #endif
43
55
}
44
56
45
57
deinit {
58
+ #if !swift(>=6)
46
59
numGenClassObjs -= 1
60
+ #endif
47
61
}
48
62
49
63
func modifyIt( ) {
@@ -63,7 +77,9 @@ final class DerivedClass2 : DerivedClass<Int> {
63
77
64
78
final class SimpleClass : P {
65
79
var i : Int
80
+ #if !swift(>=6)
66
81
static var numObjs = 0
82
+ #endif
67
83
68
84
var tuple = ( 0 , 1 )
69
85
@@ -78,11 +94,15 @@ final class SimpleClass : P {
78
94
init ( _ i: Int , nested: Int ? = nil ) {
79
95
self . i = i
80
96
self . opt = nested. map { Nested ( i: $0) }
97
+ #if !swift(>=6)
81
98
Self . numObjs += 1
99
+ #endif
82
100
}
83
101
84
102
deinit {
103
+ #if !swift(>=6)
85
104
Self . numObjs -= 1
105
+ #endif
86
106
}
87
107
88
108
func modifyIt( ) {
@@ -422,7 +442,7 @@ func testModifyOptionalForceClass(_ s: inout SimpleClass) {
422
442
//
423
443
// Check if value is null
424
444
// CHECK: switch_enum [[O:%[0-9]+]]
425
- // CHECK: {{bb. }}:
445
+ // CHECK: bb{{.* }}:
426
446
// Unwrap value
427
447
// CHECK: [[A1:%[0-9]+]] = alloc_stack
428
448
// CHECK: store [[O]] to [[A1]]
@@ -453,7 +473,7 @@ func testOptionalChain(_ s: SimpleStruct) -> Int? {
453
473
// CHECK: [[E2:%[0-9]+]] = begin_access [read] [dynamic] [no_nested_conflict] [[E1]]
454
474
// Check if value is null
455
475
// CHECK: switch_enum [[O:%[0-9]+]]
456
- // CHECK: {{bb. }}:
476
+ // CHECK: bb{{.* }}:
457
477
// Unwrap value
458
478
// CHECK: [[A1:%[0-9]+]] = alloc_stack
459
479
// CHECK: store [[O]] to [[A1]]
@@ -483,15 +503,15 @@ func testOptionalChainClass(_ s: SimpleClass) -> Int? {
483
503
//
484
504
// Check if value is null
485
505
// CHECK: switch_enum [[O:%[0-9]+]]
486
- // CHECK: {{bb. }}:
506
+ // CHECK: bb{{.* }}:
487
507
// Unwrap value
488
508
// CHECK: [[A1:%[0-9]+]] = alloc_stack
489
509
// CHECK: store [[O]] to [[A1]]
490
510
// CHECK: [[U:%[0-9]+]] = unchecked_take_enum_data_addr [[A1]]
491
511
//
492
512
// Unwrap nested optional
493
513
// CHECK: switch_enum [[O2:%[0-9]+]]
494
- // CHECK: {{bb. }}:
514
+ // CHECK: bb{{.* }}:
495
515
// CHECK: [[A2:%[0-9]+]] = alloc_stack
496
516
// CHECK: store [[O2]] to [[A2]]
497
517
// CHECK: [[U2:%[0-9]+]] = unchecked_take_enum_data_addr [[A2]]
@@ -705,9 +725,11 @@ func testit() {
705
725
706
726
testit ( )
707
727
708
- // CHECK-OUTPUT: SimpleClass obj count: 0
728
+ #if !swift(>=6)
729
+ // CHECK5-OUTPUT: SimpleClass obj count: 0
709
730
print ( " SimpleClass obj count: \( SimpleClass . numObjs) " )
710
- // CHECK -OUTPUT: GenClass obj count: 0
731
+ // CHECK5 -OUTPUT: GenClass obj count: 0
711
732
print ( " GenClass obj count: \( numGenClassObjs) " )
733
+ #endif
712
734
713
735
0 commit comments