Skip to content

Commit e98abc3

Browse files
committed
[clang][Interp] Emit dtors when ignoring CXXConstructExprs
The comment says we should emit destructors, but we didn't.
1 parent d043b4b commit e98abc3

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

clang/lib/AST/Interp/ByteCodeExprGen.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -1848,6 +1848,8 @@ bool ByteCodeExprGen<Emitter>::VisitCXXConstructExpr(
18481848

18491849
// Immediately call the destructor if we have to.
18501850
if (DiscardResult) {
1851+
if (!this->emitRecordDestruction(getRecord(E->getType())))
1852+
return false;
18511853
if (!this->emitPopPtr(E))
18521854
return false;
18531855
}

clang/test/AST/Interp/records.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,9 @@ namespace InitializerTemporaries {
335335
};
336336

337337
constexpr int f() {
338-
S{}; // ref-note {{in call to 'S{}.~S()'}}
339-
/// FIXME: Wrong source location below.
340-
return 12; // expected-note {{in call to '&S{}->~S()'}}
338+
S{}; // ref-note {{in call to 'S{}.~S()'}} \
339+
// expected-note {{in call to '&S{}->~S()'}}
340+
return 12;
341341
}
342342
static_assert(f() == 12); // both-error {{not an integral constant expression}} \
343343
// both-note {{in call to 'f()'}}
@@ -604,9 +604,9 @@ namespace Destructors {
604604
}
605605
};
606606
constexpr int testS() {
607-
S{}; // ref-note {{in call to 'S{}.~S()'}}
608-
return 1; // expected-note {{in call to '&S{}->~S()'}}
609-
// FIXME: ^ Wrong line
607+
S{}; // ref-note {{in call to 'S{}.~S()'}} \
608+
// expected-note {{in call to '&S{}->~S()'}}
609+
return 1;
610610
}
611611
static_assert(testS() == 1); // both-error {{not an integral constant expression}} \
612612
// both-note {{in call to 'testS()'}}

0 commit comments

Comments
 (0)