[PATCH] D134859: [clang][Interp] Implement basic support for floating point values

Serge Pavlov via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 7 09:34:19 PST 2022


sepavloff added inline comments.


================
Comment at: clang/lib/AST/Interp/Floating.h:109
+    Floating RHS = B;
+    if (!A.compatibleWith(B))
+      RHS = B.toSemantics(A, RM);
----------------
tbaeder wrote:
> sepavloff wrote:
> > Do we really need this check? In AST operands of addition always have the same type.
> In https://godbolt.org/z/s4n75jc4h, the LHS of the `CompoundAssignOperator` is float while the RHS is double
The case of `CompoundAssignOperator` cannot be implemented using the same function as for `BinaryOperator`. The operation `float += double` implies three operations:

1. float value is converted to double,
2. addition of double values is made,
3. double result is converted to float.

The conversions 1 and 3 are not represented by ImplicitCasts, as demonstrated by your code snippet.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134859/new/

https://reviews.llvm.org/D134859



More information about the cfe-commits mailing list