[clang][Interp] Fix record initialization via CallExpr subclasses

We can't just use VisitCallExpr() here, as that doesn't handle CallExpr
subclasses such as CXXMemberCallExpr.

Differential Revision: https://reviews.llvm.org/D141772
This commit is contained in:
Timm Bäder 2023-01-14 19:24:49 +01:00
parent 6231ba0eed
commit cef69ce779
2 changed files with 9 additions and 1 deletions

View File

@ -1413,7 +1413,7 @@ bool ByteCodeExprGen<Emitter>::visitRecordInitializer(const Expr *Initializer) {
if (!this->emitDupPtr(Initializer))
return false;
return this->VisitCallExpr(CE);
return this->visit(CE);
} else if (const auto *DIE = dyn_cast<CXXDefaultInitExpr>(Initializer)) {
return this->visitInitializer(DIE->getExpr());
} else if (const auto *CE = dyn_cast<CastExpr>(Initializer)) {

View File

@ -98,12 +98,20 @@ class C {
int b;
constexpr C() : a(100), b(200) {}
constexpr C get() const {
return *this;
}
};
constexpr C c;
static_assert(c.a == 100, "");
static_assert(c.b == 200, "");
constexpr C c2 = C().get();
static_assert(c.a == 100, "");
static_assert(c.b == 200, "");
constexpr int getB() {
C c;
int &j = c.b;