[clang] [clang][Interp][NFC] Add a failing test case (PR #102801)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 11 00:49:49 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Timm Baeder (tbaederr)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/102801.diff
1 Files Affected:
- (modified) clang/test/AST/Interp/cxx20.cpp (+44)
``````````diff
diff --git a/clang/test/AST/Interp/cxx20.cpp b/clang/test/AST/Interp/cxx20.cpp
index 27dbd2818be60..389d9d883725f 100644
--- a/clang/test/AST/Interp/cxx20.cpp
+++ b/clang/test/AST/Interp/cxx20.cpp
@@ -858,3 +858,47 @@ namespace DefinitionLoc {
constexpr NonConstexprCopy ncc2 = ncc1; // both-error {{constant expression}} \
// both-note {{non-constexpr constructor}}
}
+
+/// FIXME: Call base dtors when explicitly calling dtor.
+namespace VirtDtor {
+ class B {
+ public:
+ constexpr B(char *p) : p(p) {}
+ virtual constexpr ~B() {
+ *p = 'B';
+ ++p;
+ }
+
+ char *p;
+ };
+
+ class C : public B {
+ public:
+ constexpr C(char *p) : B(p) {}
+ virtual constexpr ~C() override {
+ *p = 'C';
+ ++p;
+ }
+ };
+
+ union U {
+ constexpr U(char *p) : c(p) {}
+ constexpr ~U() {}
+
+ C c;
+ };
+
+ constexpr int test(char a, char b) {
+ char buff[2] = {};
+ U u(buff);
+
+ /// U is a union, so it won't call the destructor of its fields.
+ /// We do this manually here. Explicitly calling ~C() here should
+ /// also call the destructor of the base classes however.
+ u.c.~C();
+
+ return buff[0] == a && buff[1] == b;
+ }
+
+ static_assert(test('C', 'B')); // expected-error {{failed}}
+}
``````````
</details>
https://github.com/llvm/llvm-project/pull/102801
More information about the cfe-commits
mailing list