diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index e8b0fffd5ee34..a778c300fc33a 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -1848,6 +1848,8 @@ bool ByteCodeExprGen::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; } diff --git a/clang/test/AST/Interp/records.cpp b/clang/test/AST/Interp/records.cpp index 62f1f1d6e426c..7cc5987e0a958 100644 --- a/clang/test/AST/Interp/records.cpp +++ b/clang/test/AST/Interp/records.cpp @@ -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()'}} @@ -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()'}}