Add format string checking of 'double' arguments. Fixes <rdar://problem/6931734>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@94867 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/PrintfFormatString.cpp b/lib/Analysis/PrintfFormatString.cpp
index 357080f..05b5d9c 100644
--- a/lib/Analysis/PrintfFormatString.cpp
+++ b/lib/Analysis/PrintfFormatString.cpp
@@ -309,6 +309,9 @@
// version of ptrdiff_t?
return ArgTypeResult();
}
+
+ if (CS.isDoubleArg())
+ return Ctx.DoubleTy;
// FIXME: Handle other cases.
return ArgTypeResult();
diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c
index f1ab868..21d7770 100644
--- a/test/Sema/format-strings.c
+++ b/test/Sema/format-strings.c
@@ -160,6 +160,7 @@
printf("%"); // expected-warning{{incomplete format specifier}}
printf("%.d", x); // no-warning
printf("%.", x); // expected-warning{{incomplete format specifier}}
+ printf("%f", 4); // expected-warning{{conversion specifies type 'double' but the argument has type 'int'}}
}
typedef struct __aslclient *aslclient;