Author: kremenek
Date: Fri Jan 29 19:02:18 2010
New Revision: 94867
URL: http://llvm.org/viewvc/llvm-project?rev=94867&view=rev
Log:
Add format string checking of 'double' arguments. Fixes
<rdar://problem/6931734>.
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=94867&r1=94866&r2=94867&view=diff
==============================================================================
--- cfe/trunk/lib/Analysis/PrintfFormatString.cpp (original)
+++ cfe/trunk/lib/Analysis/PrintfFormatString.cpp Fri Jan 29 19:02:18 2010
@@ -309,6 +309,9 @@
// version of ptrdiff_t?
return ArgTypeResult();
}
+
+ if (CS.isDoubleArg())
+ 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=94867&r1=94866&r2=94867&view=diff
==============================================================================
--- cfe/trunk/test/Sema/format-strings.c (original)
+++ cfe/trunk/test/Sema/format-strings.c Fri Jan 29 19:02:18 2010
@@ -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;
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits