[cfe-commits] [Patch] Make -Wformat accept printf("%hhx", c); with -funsigned-char (PR12761)
Matt Beaumont-Gay
matthewbg at google.com
Tue May 8 08:27:27 PDT 2012
On Tue, May 8, 2012 at 3:20 AM, Hans Wennborg <hans at chromium.org> wrote:
> Hi all,
>
> For "%hhx", printf expects an unsigned char. This patch makes Clang
> accept a 'char' argument for that when using -funsigned-char.
LGTM, just a couple of minor suggestions:
case BuiltinType::Char_S:
case BuiltinType::SChar:
- return T == C.UnsignedCharTy;
+ return T == C.SignedCharTy || T == C.UnsignedCharTy;
case BuiltinType::Char_U:
- case BuiltinType::UChar:
- return T == C.SignedCharTy;
+ case BuiltinType::UChar:
+ return T == C.UnsignedCharTy || T == C.SignedCharTy;
Might as well just have all four BuiltinType::*Char* cases fall
through to the same return statement.
+// RUN: %clang_cc1 -fsyntax-only -verify -fno-signed-char %s
Maybe explicitly say -Wformat here?
>
> (Also removing some trailing whitespace and adding a few curly braces
> while we're here.)
If you want to do this cleanup, please do it in a separate commit.
-Matt
More information about the cfe-commits
mailing list