From: Sebastian Redl Date: Sun, 19 Feb 2012 12:27:51 +0000 (+0000) Subject: Add a testcase to show that temporaries from the initializer list are destroyed corre... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=25e640a6e11f455b9c12aa5f724f7d50d9174c9c;p=clang Add a testcase to show that temporaries from the initializer list are destroyed correctly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150924 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp b/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp index ef7af88297..a1c4167261 100644 --- a/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp +++ b/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp @@ -58,12 +58,17 @@ struct destroyme1 { struct destroyme2 { ~destroyme2(); }; +struct witharg1 { + witharg1(const destroyme1&); + ~witharg1(); +}; void fn2() { // CHECK: define void @_Z3fn2v void target(std::initializer_list); // objects should be destroyed before dm2, after call returns + // CHECK: call void @_Z6targetSt16initializer_listI10destroyme1E target({ destroyme1(), destroyme1() }); // CHECK: call void @_ZN10destroyme1D1Ev destroyme2 dm2; @@ -78,3 +83,28 @@ void fn3() { // CHECK: call void @_ZN10destroyme2D1Ev // CHECK: call void @_ZN10destroyme1D1Ev } + +void fn4() { + // CHECK: define void @_Z3fn4v + void target(std::initializer_list); + // objects should be destroyed before dm2, after call returns + // CHECK: call void @_ZN8witharg1C1ERK10destroyme1 + // CHECK: call void @_Z6targetSt16initializer_listI8witharg1E + target({ witharg1(destroyme1()), witharg1(destroyme1()) }); + // CHECK: call void @_ZN8witharg1D1Ev + // CHECK: call void @_ZN10destroyme1D1Ev + destroyme2 dm2; + // CHECK: call void @_ZN10destroyme2D1Ev +} + +void fn5() { + // CHECK: define void @_Z3fn5v + // temps should be destroyed before dm2 + // objects should be destroyed after dm2 + // CHECK: call void @_ZN8witharg1C1ERK10destroyme1 + auto list = { witharg1(destroyme1()), witharg1(destroyme1()) }; + // CHECK: call void @_ZN10destroyme1D1Ev + destroyme2 dm2; + // CHECK: call void @_ZN10destroyme2D1Ev + // CHECK: call void @_ZN8witharg1D1Ev +}