diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2012-02-19 12:27:51 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2012-02-19 12:27:51 +0000 |
commit | 1d197174a2e6219544f259c98faef2d5089cc4c2 (patch) | |
tree | 0807ff959f02a2934660448bf93dc31871a91579 /clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp | |
parent | ca89d6841a4756d2460fe6d72c204199d795ba08 (diff) | |
download | bcm5719-llvm-1d197174a2e6219544f259c98faef2d5089cc4c2.tar.gz bcm5719-llvm-1d197174a2e6219544f259c98faef2d5089cc4c2.zip |
Add a testcase to show that temporaries from the initializer list are destroyed correctly.
llvm-svn: 150924
Diffstat (limited to 'clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp')
-rw-r--r-- | clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp index ef7af88297a..a1c4167261b 100644 --- a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp +++ b/clang/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<destroyme1>); // 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<witharg1>); + // 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 +} |