[cfe-commits] r106196 - in /cfe/trunk: include/clang/Analysis/Analyses/PrintfFormatString.h test/Sema/format-strings-fixit.c test/Sema/format-strings.c
Ted Kremenek
kremenek at apple.com
Wed Jun 16 18:12:20 PDT 2010
Author: kremenek
Date: Wed Jun 16 20:12:20 2010
New Revision: 106196
URL: http://llvm.org/viewvc/llvm-project?rev=106196&view=rev
Log:
Fix format string checking of '%c' by treating it as an integer conversion. Fixes PR 7391.
Modified:
cfe/trunk/include/clang/Analysis/Analyses/PrintfFormatString.h
cfe/trunk/test/Sema/format-strings-fixit.c
cfe/trunk/test/Sema/format-strings.c
Modified: cfe/trunk/include/clang/Analysis/Analyses/PrintfFormatString.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/PrintfFormatString.h?rev=106196&r1=106195&r2=106196&view=diff
==============================================================================
--- cfe/trunk/include/clang/Analysis/Analyses/PrintfFormatString.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/PrintfFormatString.h Wed Jun 16 20:12:20 2010
@@ -57,6 +57,7 @@
InvalidSpecifier = 0,
// C99 conversion specifiers.
dArg, // 'd'
+ IntAsCharArg, // 'c'
iArg, // 'i',
oArg, // 'o',
uArg, // 'u',
@@ -70,7 +71,6 @@
GArg, // 'G',
aArg, // 'a',
AArg, // 'A',
- IntAsCharArg, // 'c'
CStrArg, // 's'
VoidPtrArg, // 'p'
OutIntPtrArg, // 'n'
Modified: cfe/trunk/test/Sema/format-strings-fixit.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings-fixit.c?rev=106196&r1=106195&r2=106196&view=diff
==============================================================================
--- cfe/trunk/test/Sema/format-strings-fixit.c (original)
+++ cfe/trunk/test/Sema/format-strings-fixit.c Wed Jun 16 20:12:20 2010
@@ -15,6 +15,8 @@
printf("abc%0f", "testing testing 123");
printf("%u", (long) -12);
printf("%p", 123);
+ printf("%c\n", "x");
+ printf("%c\n", 1.23);
// Larger types
printf("%+.2d", (unsigned long long) 123456);
Modified: cfe/trunk/test/Sema/format-strings.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/format-strings.c?rev=106196&r1=106195&r2=106196&view=diff
==============================================================================
--- cfe/trunk/test/Sema/format-strings.c (original)
+++ cfe/trunk/test/Sema/format-strings.c Wed Jun 16 20:12:20 2010
@@ -172,6 +172,8 @@
printf("%f\n", (long double) 1.0); // expected-warning{{conversion specifies type 'double' but the argument has type 'long double'}}
// The man page says that a zero precision is okay.
printf("%.0Lf", (long double) 1.0); // no-warning
+ printf("%c\n", "x"); // expected-warning{{conversion specifies type 'int' but the argument has type 'char *'}}
+ printf("%c\n", 1.23); // expected-warning{{conversion specifies type 'int' but the argument has type 'double'}}
}
void test11(void *p, char *s) {
More information about the cfe-commits
mailing list