|
| 1 | +// RUN: %target-swift-frontend %s %S/Inputs/print.swift -enable-experimental-feature Embedded -c -o %t/main.o |
| 2 | +// RUN: %target-clang %t/main.o -o %t/a.out -dead_strip |
| 3 | +// RUN: %target-run %t/a.out | %FileCheck %s |
| 4 | + |
| 5 | +// REQUIRES: executable_test |
| 6 | +// REQUIRES: optimized_stdlib |
| 7 | +// REQUIRES: VENDOR=apple |
| 8 | +// REQUIRES: OS=macosx |
| 9 | + |
| 10 | +public struct MyStructA { |
| 11 | + static var singleton = MyStructA() |
| 12 | + |
| 13 | + init() { |
| 14 | + print("MyStructA.init") |
| 15 | + _ = MyStructB.singleton |
| 16 | + print("MyStructA.init done") |
| 17 | + } |
| 18 | +} |
| 19 | + |
| 20 | +public struct MyStructB { |
| 21 | + static var singleton = MyStructB() |
| 22 | + |
| 23 | + init() { |
| 24 | + print("MyStructB.init") |
| 25 | + _ = MyStructC.singleton |
| 26 | + print("MyStructB.init done") |
| 27 | + } |
| 28 | +} |
| 29 | + |
| 30 | +public struct MyStructC { |
| 31 | + static var singleton = MyStructC() |
| 32 | + |
| 33 | + init() { |
| 34 | + print("MyStructC.init") |
| 35 | + print("MyStructC.init done") |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +@main |
| 40 | +struct Main { |
| 41 | + static func main() { |
| 42 | + print("Start") |
| 43 | + _ = MyStructA.singleton |
| 44 | + |
| 45 | + // CHECK: Start |
| 46 | + // CHECK-NEXT: MyStructA.init |
| 47 | + // CHECK-NEXT: MyStructB.init |
| 48 | + // CHECK-NEXT: MyStructC.init |
| 49 | + // CHECK-NEXT: MyStructC.init done |
| 50 | + // CHECK-NEXT: MyStructB.init done |
| 51 | + // CHECK-NEXT: MyStructA.init done |
| 52 | + } |
| 53 | +} |
0 commit comments