blob: 29fb5567fb1d91ea673fe28fc2f2889dd9e13b06 [file] [log] [blame]
Alexey Bataev5d49b832015-07-08 07:31:02 +00001// Check that in case of copying an array of memcpy-able objects, their
2// destructors will be called if an exception is thrown.
3//
4// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fexceptions -fcxx-exceptions -O0 -fno-elide-constructors -emit-llvm %s -o - | FileCheck %s
5
6struct ImplicitCopy {
7 int x;
8 ImplicitCopy() { x = 10; }
9 ~ImplicitCopy() { x = 20; }
10};
11
12struct ThrowCopy {
13 ThrowCopy() {}
14 ThrowCopy(const ThrowCopy &) { throw 1; }
15};
16
17struct Container {
18 ImplicitCopy b[2];
19 ThrowCopy c;
20};
21
22int main () {
23 try {
24 Container c1;
25 // CHECK_LABEL: main
26 // CHECK-NOT: call void @_ZN9ThrowCopyC1ERKS_
27 // CHECK: invoke void @_ZN9ThrowCopyC1ERKS_
28 // CHECK: invoke void @_ZN12ImplicitCopyD1Ev
29 Container c2(c1);
30 }
31 catch (...) {
32 return 1;
33 }
34
35 return 0;
36}
37