[clang] [clang] Add test for CWG1807 (PR #77637)
Vlad Serebrennikov via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 10 09:35:40 PST 2024
https://github.com/Endilll created https://github.com/llvm/llvm-project/pull/77637
The test checks that objects in arrays are destructed in reverse order during stack unwinding.
>From 545ee4900e48b186e1c9fff93dc62a459ee19754 Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov <serebrennikov.vladislav at gmail.com>
Date: Wed, 10 Jan 2024 20:27:53 +0300
Subject: [PATCH] [clang] Add test for CWG1807
The test checks that objects in arrays are destructed in reverse order during stack unwinding.
---
clang/test/CXX/drs/dr1807.cpp | 31 +++++++++++++++++++++++++++++++
clang/www/cxx_dr_status.html | 2 +-
2 files changed, 32 insertions(+), 1 deletion(-)
create mode 100644 clang/test/CXX/drs/dr1807.cpp
diff --git a/clang/test/CXX/drs/dr1807.cpp b/clang/test/CXX/drs/dr1807.cpp
new file mode 100644
index 00000000000000..f599a36c8b2cbd
--- /dev/null
+++ b/clang/test/CXX/drs/dr1807.cpp
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,CXX98
+// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
+// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
+// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
+// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
+// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
+// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
+
+namespace dr1807 { // dr1807: 3.0
+struct S {
+ S() {}
+ ~S() {}
+};
+
+void f() {
+ try {
+ S s[3];
+ } catch (...) {}
+}
+}
+
+// CHECK: invoke void @dr1807::S::S(){{.+}}
+// CHECK-NEXT: {{.+}} unwind label %lpad
+
+// CHECK-LABEL: lpad:
+// CHECK: br {{.+}}, label {{.+}}, label %arraydestroy.body
+
+// CHECK-LABEL: arraydestroy.body:
+// CHECK: %arraydestroy.element = getelementptr {{.+}}, i64 -1
+// CXX98-NEXT: invoke void @dr1807::S::~S(){{.*}}%arraydestroy.element
+// SINCE-CXX11-NEXT: call void @dr1807::S::~S(){{.*}}%arraydestroy.element
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 2bded63d5cd41c..bea9d0f54c471e 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -10649,7 +10649,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
<td><a href="https://cplusplus.github.io/CWG/issues/1807.html">1807</a></td>
<td>CD4</td>
<td>Order of destruction of array elements after an exception</td>
- <td class="none" align="center">Unknown</td>
+ <td class="full" align="center">Clang 3.0</td>
</tr>
<tr class="open" id="1808">
<td><a href="https://cplusplus.github.io/CWG/issues/1808.html">1808</a></td>
More information about the cfe-commits
mailing list