|
| 1 | +// RUN: %target-swift-emit-sil -enable-experimental-feature NoImplicitCopy -sil-verify-all -verify -enable-library-evolution %s |
| 2 | + |
| 3 | +// This test is used to validate that we properly handle library evolution code |
| 4 | +// until we can get all of the normal moveonly_addresschecker_diagnostics test |
| 5 | +// case to pass. |
| 6 | + |
| 7 | +//////////////////////// |
| 8 | +// MARK: Declarations // |
| 9 | +//////////////////////// |
| 10 | + |
| 11 | +@_moveOnly public struct EmptyStruct {} |
| 12 | +@_moveOnly public struct NonEmptyStruct { |
| 13 | + var e = EmptyStruct() |
| 14 | +} |
| 15 | +public class CopyableKlass { |
| 16 | + var varS = NonEmptyStruct() |
| 17 | + var letS = NonEmptyStruct() |
| 18 | +} |
| 19 | + |
| 20 | +public func borrowVal(_ x: borrowing NonEmptyStruct) {} |
| 21 | +public func borrowVal(_ x: borrowing EmptyStruct) {} |
| 22 | +public func consumeVal(_ x: consuming NonEmptyStruct) {} |
| 23 | +public func consumeVal(_ x: consuming EmptyStruct) {} |
| 24 | + |
| 25 | +let copyableKlassLetGlobal = CopyableKlass() |
| 26 | +var copyableKlassVarGlobal = CopyableKlass() |
| 27 | + |
| 28 | +///////////////// |
| 29 | +// MARK: Tests // |
| 30 | +///////////////// |
| 31 | + |
| 32 | +public struct DeinitTest : ~Copyable { |
| 33 | + deinit {} |
| 34 | +} |
| 35 | + |
| 36 | +public protocol P {} |
| 37 | + |
| 38 | +public struct GenericDeinitTest<T : P> : ~Copyable { |
| 39 | + deinit {} |
| 40 | +} |
| 41 | + |
| 42 | +////////////////////////////////////////// |
| 43 | +// MARK: Caller Argument Let Spill Test // |
| 44 | +////////////////////////////////////////// |
| 45 | + |
| 46 | +public func callerBorrowClassLetFieldForArgumentSpillingTestLet() { |
| 47 | + let x = CopyableKlass() |
| 48 | + borrowVal(x.letS.e) |
| 49 | +} |
| 50 | + |
| 51 | +public func callerBorrowClassLetFieldForArgumentSpillingTestVar() { |
| 52 | + var x = CopyableKlass() |
| 53 | + x = CopyableKlass() |
| 54 | + borrowVal(x.letS.e) |
| 55 | +} |
| 56 | + |
| 57 | +public func callerBorrowClassLetFieldForArgumentSpillingTestArg(_ x: CopyableKlass) { |
| 58 | + borrowVal(x.letS.e) |
| 59 | +} |
| 60 | + |
| 61 | +public func callerBorrowClassLetFieldForArgumentSpillingTestInOutArg(_ x: inout CopyableKlass) { |
| 62 | + borrowVal(x.letS.e) |
| 63 | +} |
| 64 | + |
| 65 | +public func callerBorrowClassLetFieldForArgumentSpillingTestConsumingArg(_ x: consuming CopyableKlass) { |
| 66 | + borrowVal(x.letS.e) |
| 67 | +} |
| 68 | + |
| 69 | +public func callerBorrowClassLetFieldForArgumentSpillingTestLetGlobal() { |
| 70 | + borrowVal(copyableKlassLetGlobal.letS.e) |
| 71 | +} |
| 72 | + |
| 73 | +public func callerBorrowClassLetFieldForArgumentSpillingTestVarGlobal() { |
| 74 | + borrowVal(copyableKlassVarGlobal.letS.e) |
| 75 | +} |
| 76 | + |
| 77 | +public func callerConsumeClassLetFieldForArgumentSpillingTestLet() { |
| 78 | + let x = CopyableKlass() |
| 79 | + consumeVal(x.letS.e) |
| 80 | +} |
| 81 | + |
| 82 | +public func callerConsumeClassLetFieldForArgumentSpillingTestVar() { |
| 83 | + var x = CopyableKlass() |
| 84 | + x = CopyableKlass() |
| 85 | + consumeVal(x.letS.e) |
| 86 | +} |
| 87 | + |
| 88 | +public func callerConsumeClassLetFieldForArgumentSpillingTestArg(_ x: CopyableKlass) { |
| 89 | + consumeVal(x.letS.e) |
| 90 | +} |
| 91 | + |
| 92 | +public func callerConsumeClassLetFieldForArgumentSpillingTestInOutArg(_ x: inout CopyableKlass) { |
| 93 | + consumeVal(x.letS.e) |
| 94 | +} |
| 95 | + |
| 96 | +public func callerConsumeClassLetFieldForArgumentSpillingTestConsumingArg(_ x: consuming CopyableKlass) { |
| 97 | + consumeVal(x.letS.e) |
| 98 | +} |
| 99 | + |
| 100 | +public func callerConsumeClassLetFieldForArgumentSpillingTestLetGlobal() { |
| 101 | + consumeVal(copyableKlassLetGlobal.letS.e) |
| 102 | +} |
| 103 | + |
| 104 | +public func callerConsumeClassLetFieldForArgumentSpillingTestVarGlobal() { |
| 105 | + consumeVal(copyableKlassVarGlobal.letS.e) |
| 106 | +} |
| 107 | + |
| 108 | +//////////////////// |
| 109 | +// MARK: Var Test // |
| 110 | +//////////////////// |
| 111 | + |
| 112 | +public func callerBorrowClassVarFieldForArgumentSpillingTestLet() { |
| 113 | + let x = CopyableKlass() |
| 114 | + borrowVal(x.varS.e) |
| 115 | +} |
| 116 | + |
| 117 | +public func callerBorrowClassVarFieldForArgumentSpillingTestVar() { |
| 118 | + var x = CopyableKlass() |
| 119 | + x = CopyableKlass() |
| 120 | + borrowVal(x.varS.e) |
| 121 | +} |
| 122 | + |
| 123 | +public func callerBorrowClassVarFieldForArgumentSpillingTestArg(_ x: CopyableKlass) { |
| 124 | + borrowVal(x.varS.e) |
| 125 | +} |
| 126 | + |
| 127 | +public func callerBorrowClassVarFieldForArgumentSpillingTestInOutArg(_ x: inout CopyableKlass) { |
| 128 | + borrowVal(x.varS.e) |
| 129 | +} |
| 130 | + |
| 131 | +public func callerBorrowClassVarFieldForArgumentSpillingTestConsumingArg(_ x: consuming CopyableKlass) { |
| 132 | + borrowVal(x.varS.e) |
| 133 | +} |
| 134 | + |
| 135 | +public func callerBorrowClassVarFieldForArgumentSpillingTestLetGlobal() { |
| 136 | + borrowVal(copyableKlassLetGlobal.varS.e) |
| 137 | +} |
| 138 | + |
| 139 | +public func callerBorrowClassVarFieldForArgumentSpillingTestVarGlobal() { |
| 140 | + borrowVal(copyableKlassVarGlobal.varS.e) |
| 141 | +} |
| 142 | + |
| 143 | +public func callerConsumeClassVarFieldForArgumentSpillingTestLet() { |
| 144 | + let x = CopyableKlass() |
| 145 | + consumeVal(x.varS.e) |
| 146 | +} |
| 147 | + |
| 148 | +public func callerConsumeClassVarFieldForArgumentSpillingTestVar() { |
| 149 | + var x = CopyableKlass() |
| 150 | + x = CopyableKlass() |
| 151 | + consumeVal(x.varS.e) |
| 152 | +} |
| 153 | + |
| 154 | +public func callerConsumeClassVarFieldForArgumentSpillingTestArg(_ x: CopyableKlass) { |
| 155 | + consumeVal(x.varS.e) |
| 156 | +} |
| 157 | + |
| 158 | +public func callerConsumeClassVarFieldForArgumentSpillingTestInOutArg(_ x: inout CopyableKlass) { |
| 159 | + consumeVal(x.varS.e) |
| 160 | +} |
| 161 | + |
| 162 | +public func callerConsumeClassVarFieldForArgumentSpillingTestConsumingArg(_ x: consuming CopyableKlass) { |
| 163 | + consumeVal(x.varS.e) |
| 164 | +} |
| 165 | + |
| 166 | +public func callerConsumeClassVarFieldForArgumentSpillingTestLetGlobal() { |
| 167 | + consumeVal(copyableKlassLetGlobal.varS.e) |
| 168 | +} |
| 169 | + |
| 170 | +public func callerConsumeClassVarFieldForArgumentSpillingTestVarGlobal() { |
| 171 | + consumeVal(copyableKlassVarGlobal.varS.e) |
| 172 | +} |
0 commit comments