[clang] [clang][Interp][NFC] Add a failing test case (PR #102801)
Timm Baeder via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 11 00:49:19 PDT 2024
https://github.com/tbaederr created https://github.com/llvm/llvm-project/pull/102801
None
>From 3085070e4e3ff4a65810123c8489cd31300b19d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Timm=20B=C3=A4der?= <tbaeder at redhat.com>
Date: Sun, 11 Aug 2024 09:48:35 +0200
Subject: [PATCH] [clang][Interp][NFC] Add a failing test case
---
clang/test/AST/Interp/cxx20.cpp | 44 +++++++++++++++++++++++++++++++++
1 file changed, 44 insertions(+)
diff --git a/clang/test/AST/Interp/cxx20.cpp b/clang/test/AST/Interp/cxx20.cpp
index 27dbd2818be60f..389d9d883725f4 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}}
+}
More information about the cfe-commits
mailing list