From 016b6052662c772ea8866694e54626e334214010 Mon Sep 17 00:00:00 2001 From: Ted Kremenek Date: Mon, 1 Feb 2010 23:23:50 +0000 Subject: [PATCH] Add format string type checking support for 'long double'. llvm-svn: 95026 --- clang/lib/Analysis/PrintfFormatString.cpp | 5 ++++- clang/test/Sema/format-strings.c | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/clang/lib/Analysis/PrintfFormatString.cpp b/clang/lib/Analysis/PrintfFormatString.cpp index d2bcbb04f9d6..35c620adedc1 100644 --- a/clang/lib/Analysis/PrintfFormatString.cpp +++ b/clang/lib/Analysis/PrintfFormatString.cpp @@ -311,8 +311,11 @@ ArgTypeResult FormatSpecifier::getArgType(ASTContext &Ctx) const { return ArgTypeResult(); } - if (CS.isDoubleArg()) + if (CS.isDoubleArg()) { + if (LM == AsLongDouble) + return Ctx.LongDoubleTy; return Ctx.DoubleTy; + } // FIXME: Handle other cases. return ArgTypeResult(); diff --git a/clang/test/Sema/format-strings.c b/clang/test/Sema/format-strings.c index a055bfe1822b..d8f7e4f6931c 100644 --- a/clang/test/Sema/format-strings.c +++ b/clang/test/Sema/format-strings.c @@ -167,6 +167,8 @@ void test10(int x, float f, int i, long long lli) { // This is fine, because there is an implicit conversion to an int. printf("%d", (unsigned char) 10); // no-warning printf("%d", (long long) 10); // expected-warning{{conversion specifies type 'int' but the argument has type 'long long'}} + printf("%Lf\n", (long double) 1.0); // no-warning + printf("%f\n", (long double) 1.0); // expected-warning{{conversion specifies type 'double' but the argument has type 'long double'}} } typedef struct __aslclient *aslclient;