diff --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp b/clang/lib/AST/Interp/ByteCodeExprGen.cpp index 820e4cc44a7bcd..1393ef1f2ec358 100644 --- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp +++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp @@ -3223,6 +3223,8 @@ bool ByteCodeExprGen::visitAPValue(const APValue &Val, assert(!DiscardResult); if (Val.isInt()) return this->emitConst(Val.getInt(), ValType, E); + else if (Val.isFloat()) + return this->emitConstFloat(Val.getFloat(), E); if (Val.isLValue()) { if (Val.isNullPointer()) @@ -3253,7 +3255,7 @@ bool ByteCodeExprGen::visitAPValueInitializer(const APValue &Val, const APValue &F = Val.getStructField(I); const Record::Field *RF = R->getField(I); - if (F.isInt() || F.isLValue() || F.isMemberPointer()) { + if (F.isInt() || F.isFloat() || F.isLValue() || F.isMemberPointer()) { PrimType T = classifyPrim(RF->Decl->getType()); if (!this->visitAPValue(F, T, E)) return false; diff --git a/clang/test/AST/Interp/records.cpp b/clang/test/AST/Interp/records.cpp index 0a89c81bafd578..8a18f7a2a48901 100644 --- a/clang/test/AST/Interp/records.cpp +++ b/clang/test/AST/Interp/records.cpp @@ -1479,4 +1479,17 @@ namespace VirtOperator { }; constexpr bool cmp_base_derived = D() == D(); // both-warning {{ambiguous}} } + +namespace FloatAPValue { + struct ClassTemplateArg { + int a; + float f; + }; + template struct ClassTemplateArgTemplate { + static constexpr const ClassTemplateArg &Arg = A; + }; + ClassTemplateArgTemplate ClassTemplateArgObj; + template struct ClassTemplateArgRefTemplate {}; + ClassTemplateArgRefTemplate ClassTemplateArgRefObj; +} #endif