From f81b9d172adb38616696bb2603f7873faf8823f6 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Mon, 13 Feb 2012 10:32:27 +0000 Subject: [PATCH] Fix typo in PrintfConversionSpecifier::isDoubleArg() This makes the printf diagnostics issue warnigns for %a, %A, %e, etc. when used with the wrong argument. llvm-svn: 150370 --- clang/include/clang/Analysis/Analyses/FormatString.h | 2 +- clang/test/Sema/format-strings.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/clang/include/clang/Analysis/Analyses/FormatString.h b/clang/include/clang/Analysis/Analyses/FormatString.h index f67c04cf4202..49221bbc9b11 100644 --- a/clang/include/clang/Analysis/Analyses/FormatString.h +++ b/clang/include/clang/Analysis/Analyses/FormatString.h @@ -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. diff --git a/clang/test/Sema/format-strings.c b/clang/test/Sema/format-strings.c index dcff75a07a9f..a7b40f8a55fa 100644 --- a/clang/test/Sema/format-strings.c +++ b/clang/test/Sema/format-strings.c @@ -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