1 // 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 
6 struct ImplicitCopy {
7   int x;
ImplicitCopyImplicitCopy8   ImplicitCopy() { x = 10; }
~ImplicitCopyImplicitCopy9   ~ImplicitCopy() { x = 20; }
10 };
11 
12 struct ThrowCopy {
ThrowCopyThrowCopy13   ThrowCopy() {}
ThrowCopyThrowCopy14   ThrowCopy(const ThrowCopy &) { throw 1; }
15 };
16 
17 struct Container {
18   ImplicitCopy b[2];
19   ThrowCopy c;
20 };
21 
main()22 int 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 
38