]> granicus.if.org Git - clang/commitdiff
Add format string type checking support for 'long double'.
authorTed Kremenek <kremenek@apple.com>
Mon, 1 Feb 2010 23:23:50 +0000 (23:23 +0000)
committerTed Kremenek <kremenek@apple.com>
Mon, 1 Feb 2010 23:23:50 +0000 (23:23 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@95026 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/PrintfFormatString.cpp
test/Sema/format-strings.c

index d2bcbb04f9d68c0d9578727ffeb5df9d5cde5195..35c620adedc1aeff5274c92f6c1b067aa53036c7 100644 (file)
@@ -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();
index a055bfe1822ba7b3495af2ad3545a355b3b50f3a..d8f7e4f6931c7def1a5d0fb6f53aa45d9f396f58 100644 (file)
@@ -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;