[clang] [llvm] [Clang][C++23] Core language changes from P1467R9 extended floating-point types and standard names. (PR #78503)
Joshua Cranmer via llvm-commits
llvm-commits at lists.llvm.org
Wed Jan 22 12:48:02 PST 2025
================
@@ -7444,9 +7444,12 @@ isArithmeticArgumentPromotion(Sema &S, const ImplicitCastExpr *ICE) {
From = VecTy->getElementType();
if (const auto *VecTy = To->getAs<ExtVectorType>())
To = VecTy->getElementType();
- // It's a floating promotion if the source type is a lower rank.
- return ICE->getCastKind() == CK_FloatingCast &&
- S.Context.getFloatingTypeOrder(From, To) < 0;
+ // It's a floating promotion if the source type is float.
+ // [7.3.8p1][conv.fpprom] A prvalue of type float can be converted to a
+ // prvalue of type double. The value is unchanged.
+ return (ICE->getCastKind() == CK_FloatingCast &&
+ S.Context.isPromotableFloatingType(From) &&
+ S.Context.getPromotedFloatingType(From) == To);
----------------
jcranmer-intel wrote:
Given that the *only* floating-point promotion is `float` -> `double`, and we've just seen C++23 add a slew of new types without any other promotions, I'm not sure these helper methods are helpful to understanding what's going on here, over just hard-coding the `float`->`double` check here.
https://github.com/llvm/llvm-project/pull/78503
More information about the llvm-commits
mailing list