diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index a8e8b2997ddefe..e28532b2888712 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -390,7 +390,7 @@ bool ByteCodeExprGen::VisitImplicitValueInitExpr(const ImplicitValueIni if (!T) return false; - return this->visitZeroInitializer(*T, E); + return this->visitZeroInitializer(E->getType(), E); } template @@ -929,7 +929,12 @@ bool ByteCodeExprGen::visitConditional( } template -bool ByteCodeExprGen::visitZeroInitializer(PrimType T, const Expr *E) { +bool ByteCodeExprGen::visitZeroInitializer(QualType QT, + const Expr *E) { + // FIXME: We need the QualType to get the float semantics, but that means we + // classify it over and over again in array situations. + PrimType T = classifyPrim(QT); + switch (T) { case PT_Bool: return this->emitZeroBool(E); @@ -954,8 +959,7 @@ bool ByteCodeExprGen::visitZeroInitializer(PrimType T, const Expr *E) { case PT_FnPtr: return this->emitNullFnPtr(E); case PT_Float: { - return this->emitConstFloat( - APFloat::getZero(Ctx.getFloatSemantics(E->getType())), E); + return this->emitConstFloat(APFloat::getZero(Ctx.getFloatSemantics(QT)), E); } } llvm_unreachable("unknown primitive type"); diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.h b/clang/lib/AST/Interp/ByteCodeExprGen.h index 85588c6ecd3c1c..a3aab16c4a0834 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.h +++ b/clang/lib/AST/Interp/ByteCodeExprGen.h @@ -201,7 +201,7 @@ class ByteCodeExprGen : public ConstStmtVisitor, bool>, friend class ArrayIndexScope; /// Emits a zero initializer. - bool visitZeroInitializer(PrimType T, const Expr *E); + bool visitZeroInitializer(QualType QT, const Expr *E); enum class DerefKind { /// Value is read and pushed to stack.