[PATCH] D150040: [clang][Interp] Call invalid destructors
Timm Bäder via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jul 25 22:31:22 PDT 2023
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG10020791b18f: [clang][Interp] Call invalid destructors (authored by tbaeder).
Changed prior to commit:
https://reviews.llvm.org/D150040?vs=520092&id=544211#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150040/new/
https://reviews.llvm.org/D150040
Files:
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/test/AST/Interp/records.cpp
Index: clang/test/AST/Interp/records.cpp
===================================================================
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -566,6 +566,25 @@
return i;
}
static_assert(test() == 1);
+
+ struct S {
+ constexpr S() {}
+ constexpr ~S() { // expected-error {{never produces a constant expression}} \
+ // ref-error {{never produces a constant expression}}
+ int i = 1 / 0; // expected-warning {{division by zero}} \
+ // expected-note {{division by zero}} \
+ // ref-warning {{division by zero}} \
+ // ref-note 2{{division by zero}}
+ }
+ };
+ constexpr int testS() {
+ S{}; // ref-note {{in call to 'S{}.~S()'}}
+ return 1;
+ // FIXME: ^ Wrong line
+ }
+ static_assert(testS() == 1); // expected-error {{not an integral constant expression}} \
+ // ref-error {{not an integral constant expression}} \
+ // ref-note {{in call to 'testS()'}}
}
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===================================================================
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -2158,8 +2158,7 @@
// Now emit the destructor and recurse into base classes.
if (const CXXDestructorDecl *Dtor = R->getDestructor();
Dtor && !Dtor->isTrivial()) {
- const Function *DtorFunc = getFunction(Dtor);
- if (DtorFunc && DtorFunc->isConstexpr()) {
+ if (const Function *DtorFunc = getFunction(Dtor)) {
assert(DtorFunc->hasThisPointer());
assert(DtorFunc->getNumParams() == 1);
if (!this->emitDupPtr(SourceInfo{}))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150040.544211.patch
Type: text/x-patch
Size: 1772 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230726/8ac2a212/attachment.bin>
More information about the cfe-commits
mailing list