33// RUN: %FileCheck %s < %t/output.sil
44// RUN: %FileCheck -check-prefix=CHECK-ALL %s < %t/output.sil
55
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+
610// 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+
816// REQUIRES: executable_test,optimized_stdlib
917// REQUIRES: CPU=arm64 || CPU=x86_64
1018
@@ -28,7 +36,9 @@ struct GenStruct<T : P> : P {
2836 }
2937}
3038
39+ #if !swift(>=6)
3140var numGenClassObjs = 0
41+ #endif
3242
3343final class GenClass < T : P > : P {
3444 var ct : T
@@ -39,11 +49,15 @@ final class GenClass<T : P> : P {
3949 init ( _ ct: T ) {
4050 self . ct = ct
4151 self . gs = . init( ct)
52+ #if !swift(>=6)
4253 numGenClassObjs += 1
54+ #endif
4355 }
4456
4557 deinit {
58+ #if !swift(>=6)
4659 numGenClassObjs -= 1
60+ #endif
4761 }
4862
4963 func modifyIt( ) {
@@ -63,7 +77,9 @@ final class DerivedClass2 : DerivedClass<Int> {
6377
6478final class SimpleClass : P {
6579 var i : Int
80+ #if !swift(>=6)
6681 static var numObjs = 0
82+ #endif
6783
6884 var tuple = ( 0 , 1 )
6985
@@ -78,11 +94,15 @@ final class SimpleClass : P {
7894 init ( _ i: Int , nested: Int ? = nil ) {
7995 self . i = i
8096 self . opt = nested. map { Nested ( i: $0) }
97+ #if !swift(>=6)
8198 Self . numObjs += 1
99+ #endif
82100 }
83101
84102 deinit {
103+ #if !swift(>=6)
85104 Self . numObjs -= 1
105+ #endif
86106 }
87107
88108 func modifyIt( ) {
@@ -422,7 +442,7 @@ func testModifyOptionalForceClass(_ s: inout SimpleClass) {
422442//
423443// Check if value is null
424444// CHECK: switch_enum [[O:%[0-9]+]]
425- // CHECK: {{bb. }}:
445+ // CHECK: bb{{.* }}:
426446// Unwrap value
427447// CHECK: [[A1:%[0-9]+]] = alloc_stack
428448// CHECK: store [[O]] to [[A1]]
@@ -453,7 +473,7 @@ func testOptionalChain(_ s: SimpleStruct) -> Int? {
453473// CHECK: [[E2:%[0-9]+]] = begin_access [read] [dynamic] [no_nested_conflict] [[E1]]
454474// Check if value is null
455475// CHECK: switch_enum [[O:%[0-9]+]]
456- // CHECK: {{bb. }}:
476+ // CHECK: bb{{.* }}:
457477// Unwrap value
458478// CHECK: [[A1:%[0-9]+]] = alloc_stack
459479// CHECK: store [[O]] to [[A1]]
@@ -483,15 +503,15 @@ func testOptionalChainClass(_ s: SimpleClass) -> Int? {
483503//
484504// Check if value is null
485505// CHECK: switch_enum [[O:%[0-9]+]]
486- // CHECK: {{bb. }}:
506+ // CHECK: bb{{.* }}:
487507// Unwrap value
488508// CHECK: [[A1:%[0-9]+]] = alloc_stack
489509// CHECK: store [[O]] to [[A1]]
490510// CHECK: [[U:%[0-9]+]] = unchecked_take_enum_data_addr [[A1]]
491511//
492512// Unwrap nested optional
493513// CHECK: switch_enum [[O2:%[0-9]+]]
494- // CHECK: {{bb. }}:
514+ // CHECK: bb{{.* }}:
495515// CHECK: [[A2:%[0-9]+]] = alloc_stack
496516// CHECK: store [[O2]] to [[A2]]
497517// CHECK: [[U2:%[0-9]+]] = unchecked_take_enum_data_addr [[A2]]
@@ -705,9 +725,11 @@ func testit() {
705725
706726testit ( )
707727
708- // CHECK-OUTPUT: SimpleClass obj count: 0
728+ #if !swift(>=6)
729+ // CHECK5-OUTPUT: SimpleClass obj count: 0
709730print ( " SimpleClass obj count: \( SimpleClass . numObjs) " )
710- // CHECK -OUTPUT: GenClass obj count: 0
731+ // CHECK5 -OUTPUT: GenClass obj count: 0
711732print ( " GenClass obj count: \( numGenClassObjs) " )
733+ #endif
712734
713735
0 commit comments