Skip to content

Commit

Permalink
[clang][Interp] Emit dtors when ignoring CXXConstructExprs
Browse files Browse the repository at this point in the history
The comment says we should emit destructors, but we didn't.
  • Loading branch information
tbaederr committed Feb 19, 2024
1 parent d043b4b commit e98abc3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 2 additions & 0 deletions clang/lib/AST/Interp/ByteCodeExprGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1848,6 +1848,8 @@ bool ByteCodeExprGen<Emitter>::VisitCXXConstructExpr(

// Immediately call the destructor if we have to.
if (DiscardResult) {
if (!this->emitRecordDestruction(getRecord(E->getType())))
return false;
if (!this->emitPopPtr(E))
return false;
}
Expand Down
12 changes: 6 additions & 6 deletions clang/test/AST/Interp/records.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,9 @@ namespace InitializerTemporaries {
};

constexpr int f() {
S{}; // ref-note {{in call to 'S{}.~S()'}}
/// FIXME: Wrong source location below.
return 12; // expected-note {{in call to '&S{}->~S()'}}
S{}; // ref-note {{in call to 'S{}.~S()'}} \
// expected-note {{in call to '&S{}->~S()'}}
return 12;
}
static_assert(f() == 12); // both-error {{not an integral constant expression}} \
// both-note {{in call to 'f()'}}
Expand Down Expand Up @@ -604,9 +604,9 @@ namespace Destructors {
}
};
constexpr int testS() {
S{}; // ref-note {{in call to 'S{}.~S()'}}
return 1; // expected-note {{in call to '&S{}->~S()'}}
// FIXME: ^ Wrong line
S{}; // ref-note {{in call to 'S{}.~S()'}} \
// expected-note {{in call to '&S{}->~S()'}}
return 1;
}
static_assert(testS() == 1); // both-error {{not an integral constant expression}} \
// both-note {{in call to 'testS()'}}
Expand Down

0 comments on commit e98abc3

Please sign in to comment.