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 -std=c++98 -emit-llvm %s -o - | FileCheck -check-prefix=CHECK -check-prefix=CHECK98 %s 5 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fexceptions -fcxx-exceptions -O0 -fno-elide-constructors -std=c++11 -emit-llvm %s -o - | FileCheck -check-prefix=CHECK -check-prefix=CHECK11 %s 6 7 struct ImplicitCopy { 8 int x; 9 ImplicitCopy() { x = 10; } 10 ~ImplicitCopy() { x = 20; } 11 }; 12 13 struct ThrowCopy { 14 ThrowCopy() {} 15 ThrowCopy(const ThrowCopy &) { throw 1; } 16 }; 17 18 struct Container { 19 ImplicitCopy b[2]; 20 ThrowCopy c; 21 }; 22 23 int main () { 24 try { 25 Container c1; 26 // CHECK_LABEL: main 27 // CHECK-NOT: call void @_ZN9ThrowCopyC1ERKS_ 28 // CHECK: invoke void @_ZN9ThrowCopyC1ERKS_ 29 // CHECK98: invoke void @_ZN12ImplicitCopyD1Ev 30 // CHECK11: call void @_ZN12ImplicitCopyD1Ev 31 Container c2(c1); 32 } 33 catch (...) { 34 return 1; 35 } 36 37 return 0; 38 } 39 40