diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index d2d47e60b2c4d..d307739c301ef 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -651,7 +651,14 @@ bool ByteCodeExprGen::VisitLogicalBinOp(const BinaryOperator *E) { template bool ByteCodeExprGen::VisitComplexBinOp(const BinaryOperator *E) { - assert(Initializing); + // Prepare storage for result. + if (!Initializing) { + std::optional LocalIndex = allocateLocal(E, /*IsExtended=*/false); + if (!LocalIndex) + return false; + if (!this->emitGetPtrLocal(*LocalIndex, E)) + return false; + } const Expr *LHS = E->getLHS(); const Expr *RHS = E->getRHS(); diff --git a/clang/test/AST/Interp/complex.cpp b/clang/test/AST/Interp/complex.cpp index 8c57df7d9a3ed..bb230c2ebe64d 100644 --- a/clang/test/AST/Interp/complex.cpp +++ b/clang/test/AST/Interp/complex.cpp @@ -93,6 +93,16 @@ static_assert(__imag(I3) == 0, ""); /// FIXME: This should work in the new interpreter as well. // constexpr _Complex _BitInt(8) A = 0;// = {4}; + +void func(void) { + __complex__ int arr; + _Complex int result; + int ii = 0; + int bb = 0; + /// The following line will call into the constant interpreter. + result = arr * ii; +} + namespace CastToBool { constexpr _Complex int F = {0, 1}; static_assert(F, "");