[clang] [Clang][Sema] Fix -Whigher-precision-for-complex-division (PR #131477)
Mészáros Gergely via cfe-commits
cfe-commits at lists.llvm.org
Wed Apr 9 06:15:38 PDT 2025
================
@@ -10685,6 +10724,7 @@ QualType Sema::CheckMultiplyDivideOperands(ExprResult &LHS, ExprResult &RHS,
if (compType.isNull() || !compType->isArithmeticType())
return InvalidOperands(Loc, LHS, RHS);
if (IsDiv) {
+ DetectPrecisionLossInComplexDivision(*this, RHS.get()->getType(), Loc);
----------------
Maetveis wrote:
> How about if we have _Complex float / double? Or _Complex double / float? This should need a promotion, and it's not in the patch.
Why would that need a promotion besides the usual arithmetic conversions (i.e. to double and not long double)? Precision loss from using the complex division arithmetic formulas does not come into play here, because its elementwise.
Usual arithmetic conversions are already applied at this point: https://github.com/llvm/llvm-project/pull/131477/files#diff-3c28567b5e0c77d68f174541a0b77f5a85d093f58b89cd3675ee04a550a44880R10718-R10719
https://github.com/llvm/llvm-project/pull/131477
More information about the cfe-commits
mailing list