Skip to content

Commit f4fbbeb

Browse files
authored
[clang] Add test for CWG1807 (#77637)
The test checks that objects in arrays are destructed in reverse order during stack unwinding. This patch is trying to establish a precedent how codegen tests for C++ defect report test suite should be written. Refer to PR for exact reasoning.
1 parent 3e6589f commit f4fbbeb

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

clang/test/CXX/drs/dr1807.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt | FileCheck %s --check-prefixes CHECK,CXX98
2+
// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
3+
// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
4+
// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
5+
// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
6+
// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
7+
// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt | FileCheck %s --check-prefixes CHECK,SINCE-CXX11
8+
9+
namespace dr1807 { // dr1807: 3.0
10+
struct S {
11+
S() {}
12+
~S() {}
13+
};
14+
15+
void f() {
16+
S s[3];
17+
}
18+
}
19+
20+
// CHECK-LABEL: define dso_local void @dr1807::f()
21+
// CHECK: invoke void @dr1807::S::S(){{.+}}
22+
// CHECK-NEXT: {{.+}} unwind label %lpad
23+
// CHECK-LABEL: lpad:
24+
// CHECK: br {{.+}}, label {{.+}}, label %arraydestroy.body
25+
// CHECK-LABEL: arraydestroy.body:
26+
// CHECK: [[ARRAYDESTROY_ELEMENT:%.*]] = getelementptr {{.+}}, i64 -1
27+
// CXX98-NEXT: invoke void @dr1807::S::~S()({{.*}}[[ARRAYDESTROY_ELEMENT]])
28+
// SINCE-CXX11-NEXT: call void @dr1807::S::~S()({{.*}}[[ARRAYDESTROY_ELEMENT]])

clang/test/CXX/drs/dr18xx.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ void A<double, U>::C<V>::f4() {
164164
}
165165
} // namespace dr1804
166166

167+
// dr1807 is in dr1807.cpp
168+
167169
namespace dr1812 { // dr1812: no
168170
// NB: dup 1710
169171
#if __cplusplus >= 201103L

clang/www/cxx_dr_status.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10650,7 +10650,7 @@ <h2 id="cxxdr">C++ defect report implementation status</h2>
1065010650
<td><a href="https://cplusplus.github.io/CWG/issues/1807.html">1807</a></td>
1065110651
<td>CD4</td>
1065210652
<td>Order of destruction of array elements after an exception</td>
10653-
<td class="unknown" align="center">Unknown</td>
10653+
<td class="full" align="center">Clang 3.0</td>
1065410654
</tr>
1065510655
<tr class="open" id="1808">
1065610656
<td><a href="https://cplusplus.github.io/CWG/issues/1808.html">1808</a></td>

0 commit comments

Comments
 (0)