]> granicus.if.org Git - clang/commitdiff
Re-relax conversion specifier checking for printf format strings and conversion speci...
authorTed Kremenek <kremenek@apple.com>
Wed, 13 Jul 2011 17:35:14 +0000 (17:35 +0000)
committerTed Kremenek <kremenek@apple.com>
Wed, 13 Jul 2011 17:35:14 +0000 (17:35 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@135048 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/FormatString.cpp
test/Sema/format-strings.c

index 9a8639015c0fb5273545da549472dec952a6a081..5f3cd4c61549872d761740770ee5a14412ea9464 100644 (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:
index 83f96ff3a00f02275db81bb13229b9721f0efe87..b47d3ca2616cf25c681a2361e3fade6e254c11b8 100644 (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
 }