[PATCH] D42728: Add more warnings for implict conversions (e.g. double truncation to float).

John McCall via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 23 09:33:56 PST 2018


rjmccall added a comment.

In https://reviews.llvm.org/D42728#1017192, @avt77 wrote:

> In https://reviews.llvm.org/D42728#1016362, @rjmccall wrote:
>
> > The diagnostic text for this warning is misleading at best when the conversion is actually a truncation of the result of a compound assignment.
>
>
> OK, at the moment we have:
>
>   *b += a; // expected-warning {{implicit conversion loses floating-point precision: 'double' to 'float'}}
>   
>
> But you'd like to see something like:
>
>   *b += a; // expected-warning {{truncation of the result of a compound assignment loses floating-point precision: 'double' to 'float'}}
>   
>
> Right?


Right.  I would suggest something like "implicit conversion when assigning computation result loses floating-point precision", and you should make sure that the source type is the computation result type, and the arrow should point at the operator.

> And you'd like to keep the current message at simple assignment, right?

Yeah.  Thanks!


https://reviews.llvm.org/D42728





More information about the llvm-commits mailing list