summaryrefslogtreecommitdiffstats
path: root/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
diff options
context:
space:
mode:
authorRichard Smith <richard-llvm@metafoo.co.uk>2013-06-27 22:54:33 +0000
committerRichard Smith <richard-llvm@metafoo.co.uk>2013-06-27 22:54:33 +0000
commit8d7f11da50d0c729887befce0f6c7c1b5cff792e (patch)
treeb6ec5685f429b35ca345517861d965eb49766c37 /clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
parent5c5e6179a06b5283d3952c16f0deab8a010f23aa (diff)
downloadbcm5719-llvm-8d7f11da50d0c729887befce0f6c7c1b5cff792e.tar.gz
bcm5719-llvm-8d7f11da50d0c729887befce0f6c7c1b5cff792e.zip
Fix nested lifetime extension when a std::initializer_list member is
initialized during aggregate initialization of the surrounding structure. llvm-svn: 185117
Diffstat (limited to 'clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp')
-rw-r--r--clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp36
1 files changed, 36 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
index 8adb887b9a8..8dbb05711d2 100644
--- a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
+++ b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
@@ -395,3 +395,39 @@ namespace partly_constant {
// 'il' reference.
// CHECK: store {{.*}}* @[[PARTLY_CONSTANT_OUTER]], {{.*}}** @_ZN15partly_constant2ilE, align 8
}
+
+namespace nested {
+ struct A { A(); ~A(); };
+ struct B { const A &a; ~B(); };
+ struct C { std::initializer_list<B> b; ~C(); };
+ void f();
+ // CHECK: define void @_ZN6nested1gEv(
+ void g() {
+ // CHECK: call void @_ZN6nested1AC1Ev(
+ // CHECK-NOT: call
+ // CHECK: call void @_ZN6nested1AC1Ev(
+ // CHECK-NOT: call
+ const C &c { { { A() }, { A() } } };
+
+ // CHECK: call void @_ZN6nested1fEv(
+ // CHECK-NOT: call
+ f();
+
+ // CHECK: call void @_ZN6nested1CD1Ev(
+ // CHECK-NOT: call
+
+ // Destroy B[2] array.
+ // FIXME: This isn't technically correct: reverse construction order would
+ // destroy the second B then the second A then the first B then the first A.
+ // CHECK: call void @_ZN6nested1BD1Ev(
+ // CHECK-NOT: call
+ // CHECK: br
+
+ // CHECK-NOT: call
+ // CHECK: call void @_ZN6nested1AD1Ev(
+ // CHECK-NOT: call
+ // CHECK: call void @_ZN6nested1AD1Ev(
+ // CHECK-NOT: call
+ // CHECK: }
+ }
+}
OpenPOWER on IntegriCloud