aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Analysis/FormatString.cpp3
-rw-r--r--test/Sema/format-strings.c6
2 files changed, 7 insertions, 2 deletions
diff --git a/lib/Analysis/FormatString.cpp b/lib/Analysis/FormatString.cpp
index ab69c06911..f776c89cc5 100644
--- a/lib/Analysis/FormatString.cpp
+++ b/lib/Analysis/FormatString.cpp
@@ -265,10 +265,9 @@ bool ArgTypeResult::matchesType(ASTContext &C, QualType argTy) const {
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:
diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c
index 5d8e4cbb87..1f9acd4ef8 100644
--- a/test/Sema/format-strings.c
+++ b/test/Sema/format-strings.c
@@ -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_other_formats() {
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);
+}