[cfe-commits] r95026 - in /cfe/trunk: lib/Analysis/PrintfFormatString.cpp test/Sema/format-strings.c

Ted Kremenek kremenek at apple.com
Mon Feb 1 15:23:50 PST 2010


Author: kremenek
Date: Mon Feb  1 17:23:50 2010
New Revision: 95026

URL: http://llvm.org/viewvc/llvm-project?rev=95026&view=rev
Log:
Add format string type checking support for 'long double'.

Modified:
    cfe/trunk/lib/Analysis/PrintfFormatString.cpp
    cfe/trunk/test/Sema/format-strings.c

Modified: cfe/trunk/lib/Analysis/PrintfFormatString.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/PrintfFormatString.cpp?rev=95026&r1=95025&r2=95026&view=diff

==============================================================================
--- cfe/trunk/lib/Analysis/PrintfFormatString.cpp (original)
+++ cfe/trunk/lib/Analysis/PrintfFormatString.cpp Mon Feb  1 17:23:50 2010
@@ -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();

Modified: cfe/trunk/test/Sema/format-strings.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings.c?rev=95026&r1=95025&r2=95026&view=diff

==============================================================================
--- cfe/trunk/test/Sema/format-strings.c (original)
+++ cfe/trunk/test/Sema/format-strings.c Mon Feb  1 17:23:50 2010
@@ -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;





More information about the cfe-commits mailing list