[PATCH] D66856: [Sema] Suppress -Wformat diagnostics for bool types when printed using %hhd

Erik Pilkington via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 11 14:58:59 PDT 2019


erik.pilkington added a comment.

In D66856#1666616 <https://reviews.llvm.org/D66856#1666616>, @aaron.ballman wrote:

> The reflector discussion is still happening and there are issues with ambiguities that we are pretty sure we want to correct. I've got a paper out that touches on some of this: http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2420.pdf


Nice, thanks for digging into this!



================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8123
+def warn_format_bool_as_character : Warning<
+  "format specifies a character but argument has boolean value">,
+  InGroup<Format>;
----------------
aaron.ballman wrote:
> How about: `using '%0' format specifier, but argument has boolean value` and then pass in the character specifier used?
Sure, copied that verbatim. 


================
Comment at: clang/test/Sema/format-bool.c:26
+#ifdef PEDANTIC
+  // expected-warning at -2 {{format specifies type 'short' but the argument has type}}
+#endif
----------------
aaron.ballman wrote:
> Just an FYI (not related to your patch): it seems that at least some people think this should be diagnosed as something other than by `-Wformat-pedantic`. Their thinking is that `-Wformat-pedantic` is for things that are required to have a diagnostic according to the standard but are not sufficiently interesting to warn about by default. This particular case is not required to be warned on by the standard, so it's not really a "pedantic" warning. It sounds like there may be interest in having `-Wformat-pedantic` for that understanding of pedantic, and introduce something like `-Wformat-type-mismatch` for these other cases where there is type confusion but not sufficiently dangerous to warrant warning by default?
That seems like a good idea to me, I agree that "pedantic" in the context of warnings means "technically incorrect according to the standard, but not really a big deal", which isn't really what -Wformat-pedantic is doing right now.


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

https://reviews.llvm.org/D66856





More information about the cfe-commits mailing list