1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
// Test the combination of `out` arguments with in- and out-contracts.
// Github issue #1543, https://github.com/ldc-developers/ldc/issues/1543
// RUN: %ldc -c -output-ll -of=%t.ll %s && FileCheck %s < %t.ll
// RUN: %ldc -run %s
module mod;
class Bar
{
void failMe(out int some)
in
{
assert(some == 0);
}
out
{
assert(some == 123);
}
body
{
some = 123;
}
}
// Bar.failMe codegen order = function, in-contract __require function, out-contract __ensure function
// CHECK-LABEL: define {{.*}} @{{.*}}Bar6failMe
// CHECK-SAME: i32* dereferenceable(4) %some
// CHECK: store i32 0, i32* %some
// CHECK: call {{.*}} @{{.*}}Bar6failMeMFJiZ9__require
// CHECK: call {{.*}} @{{.*}}Bar6failMeMFJiZ8__ensure
// CHECK: }
// CHECK-LABEL: define {{.*}} @{{.*}}Bar6failMeMFJiZ9__require
// CHECK-SAME: i32* dereferenceable(4) %some
// CHECK-NOT: store {{.*}} %some
// CHECK: }
// CHECK-LABEL: define {{.*}} @{{.*}}Bar6failMeMFJiZ8__ensure
// CHECK-SAME: i32* dereferenceable(4) %some
// CHECK-NOT: store {{.*}} %some
// CHECK: }
void main()
{
int some;
auto b = new Bar;
b.failMe(some);
assert(some == 123);
}
|