Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Commit

Permalink
[clang] Add test for CWG1807 (#77637)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Endilll authored Jan 18, 2024
1 parent 3e6589f commit f4fbbeb
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
28 changes: 28 additions & 0 deletions clang/test/CXX/drs/dr1807.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 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
// 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
// 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
// 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
// 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
// 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
// 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

namespace dr1807 { // dr1807: 3.0
struct S {
S() {}
~S() {}
};

void f() {
S s[3];
}
}

// CHECK-LABEL: define dso_local void @dr1807::f()
// 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]])
2 changes: 2 additions & 0 deletions clang/test/CXX/drs/dr18xx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ void A<double, U>::C<V>::f4() {
}
} // namespace dr1804

// dr1807 is in dr1807.cpp

namespace dr1812 { // dr1812: no
// NB: dup 1710
#if __cplusplus >= 201103L
Expand Down
2 changes: 1 addition & 1 deletion clang/www/cxx_dr_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -10650,7 +10650,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="unknown" 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>
Expand Down

0 comments on commit f4fbbeb

Please sign in to comment.