Issue 208987
Summary [Clang] `-Wliteral-conversion` only warns for conversion from floating-point literals
Labels clang:diagnostics
Assignees
Reporter frederick-vs-ja
    From the [documentation](https://clang.llvm.org/docs/DiagnosticsReference.html#wliteral-conversion), one may expect that the warning also covers non-floating-point literals. But currently the warning is restricted to conversion from floating-point literals.

Example ([Godbolt link](https://godbolt.org/z/fTr49cK9x)):
```C++
void test() {
  (void)('*' || true); // no warning
  (void)(u8'*' || true); // no warning
 (void)(u'*' || true); // no warning
  (void)(U'*' || true); // no warning
 (void)(L'*' || true); // no warning
  (void)("" || true); // no warning
 (void)(u8"" || true); // no warning
  (void)(u"" || true); // no warning
  (void)(U"" || true); // no warning
  (void)(L"" || true); // no warning
  (void)(42 || true); // no warning
  (void)(42U || true); // no warning
  (void)(42L || true); // no warning
  (void)(42UL || true); // no warning
  (void)(42LL || true); // no warning
  (void)(42UL || true); // no warning
  (void)(42.0F16 || true); // warning
  (void)(42.0F || true); // warning
  (void)(42.0 || true); // warning
  (void)(42.0L || true); // warning
}
```

This seems to be by design.
https://github.com/llvm/llvm-project/blob/9dffcd2752af16a09eeb4131f90a1a0fe2b76a1f/clang/include/clang/Basic/DiagnosticSemaKinds.td#L4598-L4603

Do we want to extend the coverage of `-Wliteral-conversion` or clarify that it's restricted to FP literals?
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to