Add format string type checking support for 'long double'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95026 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Analysis/PrintfFormatString.cpp b/lib/Analysis/PrintfFormatString.cpp
index d2bcbb0..35c620a 100644
--- a/lib/Analysis/PrintfFormatString.cpp
+++ b/lib/Analysis/PrintfFormatString.cpp
@@ -311,8 +311,11 @@
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/test/Sema/format-strings.c b/test/Sema/format-strings.c
index a055bfe..d8f7e4f 100644
--- a/test/Sema/format-strings.c
+++ b/test/Sema/format-strings.c
@@ -167,6 +167,8 @@
// 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;