[cfe-commits] r150370 - in /cfe/trunk: include/clang/Analysis/Analyses/FormatString.h test/Sema/format-strings.c

Hans Wennborg hans at hanshq.net
Mon Feb 13 02:32:27 PST 2012


Author: hans
Date: Mon Feb 13 04:32:27 2012
New Revision: 150370

URL: http://llvm.org/viewvc/llvm-project?rev=150370&view=rev
Log:
Fix typo in PrintfConversionSpecifier::isDoubleArg()

This makes the printf diagnostics issue warnigns for %a, %A, %e, etc.
when used with the wrong argument.

Modified:
    cfe/trunk/include/clang/Analysis/Analyses/FormatString.h
    cfe/trunk/test/Sema/format-strings.c

Modified: cfe/trunk/include/clang/Analysis/Analyses/FormatString.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/FormatString.h?rev=150370&r1=150369&r2=150370&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/Analyses/FormatString.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/FormatString.h Mon Feb 13 04:32:27 2012
@@ -368,7 +368,7 @@
   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.

Modified: cfe/trunk/test/Sema/format-strings.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings.c?rev=150370&r1=150369&r2=150370&view=diff
==============================================================================
--- cfe/trunk/test/Sema/format-strings.c (original)
+++ cfe/trunk/test/Sema/format-strings.c Mon Feb 13 04:32:27 2012
@@ -471,6 +471,8 @@
 
   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 





More information about the cfe-commits mailing list