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 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
// RUN: %ldc -c -output-ll -of=%t.ll %s && FileCheck %s < %t.ll
struct S
{
~this() nothrow {}
void foo() nothrow { throw new Error("foo"); }
}
struct Throwing
{
~this() {}
void bar() { throw new Exception("bar"); }
}
// CHECK-LABEL: define{{.*}} @{{.*}}_D7nothrow15inTryCatchErrorFZv
void inTryCatchError()
{
try
{
// make sure the nothrow functions S.foo() and S.~this()
// are invoked in try-blocks with at least 1 catch block
S a;
// CHECK: invoke {{.*}}_D7nothrow1S3fooMFNbZv{{.*}} %a
a.foo();
// CHECK: invoke {{.*}}_D7nothrow1S6__dtorMFNbZv{{.*}} %a
}
catch (Error) {}
}
// CHECK-LABEL: define{{.*}} @{{.*}}_D7nothrow19inTryCatchExceptionFZv
void inTryCatchException()
{
// make sure the nothrow functions are never invoked
// CHECK-NOT: invoke {{.*}}_D7nothrow1S3fooMFNbZv
// CHECK-NOT: invoke {{.*}}_D7nothrow1S6__dtorMFNbZv
try
{
S a;
a.foo();
}
catch (Exception) {}
}
// CHECK-LABEL: define{{.*}} @{{.*}}_D7nothrow12inTryFinallyFZv
void inTryFinally()
{
// make sure the nothrow functions are never invoked
// CHECK-NOT: invoke {{.*}}_D7nothrow1S3fooMFNbZv
// CHECK-NOT: invoke {{.*}}_D7nothrow1S6__dtorMFNbZv
try
{
S a;
a.foo();
}
finally
{
S b;
b.foo();
}
}
// CHECK-LABEL: define{{.*}} @{{.*}}_Dmain
void main()
{
// make sure the nothrow functions are never invoked
// CHECK-NOT: invoke {{.*}}_D7nothrow1S3fooMFNbZv
// CHECK-NOT: invoke {{.*}}_D7nothrow1S6__dtorMFNbZv
Throwing t;
S a;
a.foo();
t.bar();
{
S b;
t.bar();
b.foo();
S().foo();
}
}
|