]> granicus.if.org Git - clang/commitdiff
Fix typo in PrintfConversionSpecifier::isDoubleArg()
authorHans Wennborg <hans@hanshq.net>
Mon, 13 Feb 2012 10:32:27 +0000 (10:32 +0000)
committerHans Wennborg <hans@hanshq.net>
Mon, 13 Feb 2012 10:32:27 +0000 (10:32 +0000)
This makes the printf diagnostics issue warnigns for %a, %A, %e, etc.
when used with the wrong argument.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150370 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Analysis/Analyses/FormatString.h
test/Sema/format-strings.c

index f67c04cf4202ffec055b1a0f008a6e17a491ab2e..49221bbc9b1157febaa1de79bf66bedb43c07a91 100644 (file)
@@ -368,7 +368,7 @@ public:
   bool isObjCArg() const { return kind >= ObjCBeg && kind <= ObjCEnd; }
   bool isIntArg() const { return kind >= IntArgBeg && kind <= IntArgEnd; }
   bool isDoubleArg() const { return kind >= DoubleArgBeg &&
-                                    kind <= DoubleArgBeg; }
+                                    kind <= DoubleArgEnd; }
   unsigned getLength() const {
       // Conversion specifiers currently only are represented by
       // single characters, but we be flexible.
index dcff75a07a9f630177e188adb3b09b896e99b050..a7b40f8a55fa2f3d61ec7e3732dd63a83b23fcb8 100644 (file)
@@ -471,6 +471,8 @@ void pr9751() {
 
   const char kFormat17[] = "%hu"; // expected-note{{format string is defined here}}}
   printf(kFormat17, (int[]){0}); // expected-warning{{format specifies type 'unsigned short' but the argument}}
+
+  printf("%a", (long double)0); // expected-warning{{format specifies type 'double' but the argument has type 'long double'}}
 }
 
 // PR 9466: clang: doesn't know about %Lu, %Ld, and %Lx