Re-relax conversion specifier checking for printf format strings and conversion specifiers. My recent change was a mistake.

llvm-svn: 135048
This commit is contained in:
Ted Kremenek 2011-07-13 17:35:14 +00:00
parent 06210a28de
commit cc47e0fad1
2 changed files with 6 additions and 5 deletions

View File

@ -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:

View File

@ -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
}