[PATCH] D64666: Allow Clang -Wconversion, -Wimplicit-float-conversion warns about integer type -> floating point type implicit conversion precision loss.

Ziang Wan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 12 14:18:02 PDT 2019


ziangwan created this revision.
ziangwan added reviewers: kongyi, pirama, rsmith, nickdesaulniers.
Herald added subscribers: cfe-commits, jdoerfert, jfb, mgrang, javed.absar.
Herald added a project: clang.

These code:

  long i = 222222222222L;
  float a = 222222222222L:
  float b = a + i;

Will now issue warnings:

  line 2: implicit conversion from 'long' to 'float' changes value from 222222222222 to 222222221312 [-Wimplicit-float-conversion]
  line 3: implicit conversion from 'long' to 'float' may loses integer precision. [-Wimplicit-float-conversion]

The same feature is present in GCC but not currently in clang.


Repository:
  rC Clang

https://reviews.llvm.org/D64666

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/conversion.c
  clang/test/Sema/ext_vector_casts.c
  clang/test/Sema/implicit-float-conversion.c
  patch.patch





More information about the cfe-commits mailing list