diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index 49f9878d42480..38b2d6fad043c 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -820,6 +820,19 @@ bool ByteCodeExprGen::VisitImplicitValueInitExpr(const ImplicitValueIni return true; } + if (QT->isAnyComplexType()) { + assert(Initializing); + QualType ElemQT = QT->getAs()->getElementType(); + PrimType ElemT = classifyPrim(ElemQT); + for (unsigned I = 0; I < 2; ++I) { + if (!this->visitZeroInitializer(ElemT, ElemQT, E)) + return false; + if (!this->emitInitElem(ElemT, I, E)) + return false; + } + return true; + } + return false; } diff --git a/clang/test/AST/Interp/complex.cpp b/clang/test/AST/Interp/complex.cpp index 20c00b8e1ba3f..7d625ab1f378e 100644 --- a/clang/test/AST/Interp/complex.cpp +++ b/clang/test/AST/Interp/complex.cpp @@ -102,6 +102,16 @@ static_assert(__imag(I3) == 0, ""); // constexpr _Complex _BitInt(8) A = 0;// = {4}; +constexpr _Complex double Doubles[4] = {{1.0, 2.0}}; +static_assert(__real(Doubles[0]) == 1.0, ""); +static_assert(__imag(Doubles[0]) == 2.0, ""); +static_assert(__real(Doubles[1]) == 0.0, ""); +static_assert(__imag(Doubles[1]) == 0.0, ""); +static_assert(__real(Doubles[2]) == 0.0, ""); +static_assert(__imag(Doubles[2]) == 0.0, ""); +static_assert(__real(Doubles[3]) == 0.0, ""); +static_assert(__imag(Doubles[3]) == 0.0, ""); + void func(void) { __complex__ int arr; _Complex int result;