summaryrefslogtreecommitdiffstats
path: root/clang/test/CXX/special/class.temporary/p6.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/test/CXX/special/class.temporary/p6.cpp')
-rw-r--r--clang/test/CXX/special/class.temporary/p6.cpp52
1 files changed, 51 insertions, 1 deletions
diff --git a/clang/test/CXX/special/class.temporary/p6.cpp b/clang/test/CXX/special/class.temporary/p6.cpp
index e8680902165..077385fb7aa 100644
--- a/clang/test/CXX/special/class.temporary/p6.cpp
+++ b/clang/test/CXX/special/class.temporary/p6.cpp
@@ -1,4 +1,15 @@
-// RUN: %clang_cc1 -std=c++17 %s -emit-llvm -o - | FileCheck %s --implicit-check-not='call{{.*}}dtor'
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - | FileCheck %s --implicit-check-not='call{{.*}}dtor'
+
+namespace std {
+ typedef decltype(sizeof(int)) size_t;
+
+ template <class E>
+ struct initializer_list {
+ const E *begin;
+ size_t size;
+ initializer_list() : begin(nullptr), size(0) {}
+ };
+}
void then();
@@ -8,6 +19,14 @@ struct dtor {
dtor ctor();
+auto &&lambda = [a = {ctor()}] {};
+// CHECK-LABEL: define
+// CHECK: call {{.*}}ctor
+// CHECK: call {{.*}}atexit{{.*}}global_array_dtor
+
+// CHECK-LABEL: define{{.*}}global_array_dtor
+// CHECK: call {{.*}}dtor
+
// [lifetime extension occurs if the object was obtained by]
// -- a temporary materialization conversion
// CHECK-LABEL: ref_binding
@@ -188,3 +207,34 @@ void comma() {
// CHECK: call {{.*}}dtor
// CHECK: }
}
+
+
+// This applies recursively: if an object is lifetime-extended and contains a
+// reference, the referent is also extended.
+// CHECK-LABEL: init_capture_ref
+void init_capture_ref() {
+ // CHECK: call {{.*}}ctor
+ auto x = [&a = (const dtor&)ctor()] {};
+ // CHECK: call {{.*}}then
+ then();
+ // CHECK: call {{.*}}dtor
+ // CHECK: }
+}
+// CHECK-LABEL: init_capture_ref_indirect
+void init_capture_ref_indirect() {
+ // CHECK: call {{.*}}ctor
+ auto x = [&a = (const dtor&)ctor()] {};
+ // CHECK: call {{.*}}then
+ then();
+ // CHECK: call {{.*}}dtor
+ // CHECK: }
+}
+// CHECK-LABEL: init_capture_init_list
+void init_capture_init_list() {
+ // CHECK: call {{.*}}ctor
+ auto x = [a = {ctor()}] {};
+ // CHECK: call {{.*}}then
+ then();
+ // CHECK: call {{.*}}dtor
+ // CHECK: }
+}
OpenPOWER on IntegriCloud