aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Analysis/FormatString.cpp7
-rw-r--r--test/Sema/format-strings.c4
2 files changed, 6 insertions, 5 deletions
diff --git a/lib/Analysis/FormatString.cpp b/lib/Analysis/FormatString.cpp
index 9a8639015c..5f3cd4c615 100644
--- a/lib/Analysis/FormatString.cpp
+++ b/lib/Analysis/FormatString.cpp
@@ -219,16 +219,17 @@ bool ArgTypeResult::matchesType(ASTContext &C, QualType argTy) const {
argTy = C.getCanonicalType(argTy).getUnqualifiedType();
if (T == argTy)
return true;
+ // Check for "compatible types".
if (const BuiltinType *BT = argTy->getAs<BuiltinType>())
switch (BT->getKind()) {
default:
break;
case BuiltinType::Char_S:
case BuiltinType::SChar:
- return T == C.SignedCharTy;
- case BuiltinType::Char_U:
- case BuiltinType::UChar:
return T == C.UnsignedCharTy;
+ case BuiltinType::Char_U:
+ case BuiltinType::UChar:
+ return 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 83f96ff3a0..b47d3ca261 100644
--- a/test/Sema/format-strings.c
+++ b/test/Sema/format-strings.c
@@ -368,7 +368,7 @@ void check_char(unsigned char x, signed char y) {
printf("%c", y); // no-warning
printf("%hhu", x); // no-warning
printf("%hhi", y); // no-warning
- printf("%hhi", x); // expected-warning{{conversion specifies type 'signed char' but the argument has type 'unsigned char'}}
+ printf("%hhi", x); // no-warning
printf("%c", x); // no-warning
- printf("%hhu", y); // expected-warning{{conversion specifies type 'unsigned char' but the argument has type 'signed char'}}
+ printf("%hhu", y); // no-warning
}