[cfe-commits] r156388 - in /cfe/trunk: lib/Analysis/FormatString.cpp test/Sema/format-strings.c
Hans Wennborg
hans at hanshq.net
Tue May 8 10:21:31 PDT 2012
Author: hans
Date: Tue May 8 12:21:31 2012
New Revision: 156388
URL: http://llvm.org/viewvc/llvm-project?rev=156388&view=rev
Log:
Make -Wformat accept printf("%hhx", c); with -funsigned-char
For "%hhx", printf expects an unsigned char. This makes Clang
accept a 'char' argument for that also when using -funsigned-char.
This fixes PR12761.
Modified:
cfe/trunk/lib/Analysis/FormatString.cpp
cfe/trunk/test/Sema/format-strings.c
Modified: cfe/trunk/lib/Analysis/FormatString.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/FormatString.cpp?rev=156388&r1=156387&r2=156388&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/FormatString.cpp (original)
+++ cfe/trunk/lib/Analysis/FormatString.cpp Tue May 8 12:21:31 2012
@@ -265,10 +265,9 @@
break;
case BuiltinType::Char_S:
case BuiltinType::SChar:
- return T == C.UnsignedCharTy;
case BuiltinType::Char_U:
case BuiltinType::UChar:
- return T == C.SignedCharTy;
+ return T == C.UnsignedCharTy || T == C.SignedCharTy;
case BuiltinType::Short:
return T == C.UnsignedShortTy;
case BuiltinType::UShort:
Modified: cfe/trunk/test/Sema/format-strings.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings.c?rev=156388&r1=156387&r2=156388&view=diff
==============================================================================
--- cfe/trunk/test/Sema/format-strings.c (original)
+++ cfe/trunk/test/Sema/format-strings.c Tue May 8 12:21:31 2012
@@ -1,4 +1,5 @@
// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral -isystem %S/Inputs %s
+// RUN: %clang_cc1 -fsyntax-only -verify -Wformat-nonliteral -isystem %S/Inputs -fno-signed-char %s
#define __need_wint_t
#include <stdarg.h>
@@ -530,3 +531,8 @@
void test_unused_system_args(int x) {
PRINT1("%d\n", x); // no-warning{{extra argument is system header is OK}}
}
+
+void pr12761(char c) {
+ // This should not warn even with -fno-signed-char.
+ printf("%hhx", c);
+}
More information about the cfe-commits
mailing list