1*152c71f3SAlexey Bataev // Check that initialization of the only one memcpy-able struct member will not 2*152c71f3SAlexey Bataev // be performed twice after successful non-trivial initializtion of the second 3*152c71f3SAlexey Bataev // member. 4*152c71f3SAlexey Bataev // 5*152c71f3SAlexey Bataev // RUN: %clang_cc1 -triple x86_64-unknown-unknown -fexceptions -fcxx-exceptions -O0 -fno-elide-constructors -emit-llvm %s -o - | FileCheck %s 6*152c71f3SAlexey Bataev 7*152c71f3SAlexey Bataev int globId = 0; 8*152c71f3SAlexey Bataev 9*152c71f3SAlexey Bataev struct ImplicitCopy { 10*152c71f3SAlexey Bataev int id; 11*152c71f3SAlexey Bataev ImplicitCopyImplicitCopy12*152c71f3SAlexey Bataev ImplicitCopy() { id = 10; } ~ImplicitCopyImplicitCopy13*152c71f3SAlexey Bataev ~ImplicitCopy() { id = 20; } 14*152c71f3SAlexey Bataev }; 15*152c71f3SAlexey Bataev 16*152c71f3SAlexey Bataev struct ExplicitCopy { 17*152c71f3SAlexey Bataev int id; 18*152c71f3SAlexey Bataev ExplicitCopyExplicitCopy19*152c71f3SAlexey Bataev ExplicitCopy() { id = 15; } ExplicitCopyExplicitCopy20*152c71f3SAlexey Bataev ExplicitCopy(const ExplicitCopy &x) { id = 25; } ~ExplicitCopyExplicitCopy21*152c71f3SAlexey Bataev ~ExplicitCopy() { id = 35; } 22*152c71f3SAlexey Bataev }; 23*152c71f3SAlexey Bataev 24*152c71f3SAlexey Bataev struct Container { 25*152c71f3SAlexey Bataev ImplicitCopy o1; // memcpy-able member. 26*152c71f3SAlexey Bataev ExplicitCopy o2; // non-trivial initialization. 27*152c71f3SAlexey Bataev ContainerContainer28*152c71f3SAlexey Bataev Container() { globId = 1000; } ~ContainerContainer29*152c71f3SAlexey Bataev ~Container() { globId = 2000; } 30*152c71f3SAlexey Bataev }; 31*152c71f3SAlexey Bataev main()32*152c71f3SAlexey Bataevint main() { 33*152c71f3SAlexey Bataev try { 34*152c71f3SAlexey Bataev Container c1; 35*152c71f3SAlexey Bataev // CHECK-DAG: call void @llvm.memcpy 36*152c71f3SAlexey Bataev // CHECK-DAG: declare void @llvm.memcpy 37*152c71f3SAlexey Bataev // CHECK-NOT: @llvm.memcpy 38*152c71f3SAlexey Bataev Container c2(c1); 39*152c71f3SAlexey Bataev 40*152c71f3SAlexey Bataev return 2; 41*152c71f3SAlexey Bataev } 42*152c71f3SAlexey Bataev catch (...) { 43*152c71f3SAlexey Bataev return 1; 44*152c71f3SAlexey Bataev } 45*152c71f3SAlexey Bataev return 0; 46*152c71f3SAlexey Bataev } 47