From 4ee01ef7bd170b6f3f3f71882b407cd6408c5b1e 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@150370 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Analysis/Analyses/FormatString.h | 2 +- test/Sema/format-strings.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/include/clang/Analysis/Analyses/FormatString.h b/include/clang/Analysis/Analyses/FormatString.h index f67c04cf42..49221bbc9b 100644 --- a/include/clang/Analysis/Analyses/FormatString.h +++ b/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/test/Sema/format-strings.c b/test/Sema/format-strings.c index dcff75a07a..a7b40f8a55 100644 --- a/test/Sema/format-strings.c +++ b/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 -- 2.40.0