[clang] [clang] Add test for CWG1807 (PR #77637)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 10 09:36:11 PST 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Vlad Serebrennikov (Endilll)

<details>
<summary>Changes</summary>

The test checks that objects in arrays are destructed in reverse order during stack unwinding.

---
Full diff: https://github.com/llvm/llvm-project/pull/77637.diff


2 Files Affected:

- (added) clang/test/CXX/drs/dr1807.cpp (+31) 
- (modified) clang/www/cxx_dr_status.html (+1-1) 


``````````diff
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>

``````````

</details>


https://github.com/llvm/llvm-project/pull/77637


More information about the cfe-commits mailing list