Fix format string checking of '%c' by treating it as an integer conversion. Fixes PR 7391.

llvm-svn: 106196
This commit is contained in:
Ted Kremenek 2010-06-17 01:12:20 +00:00
parent 24c8e4f245
commit 98008a47a0
3 changed files with 5 additions and 1 deletions

View File

@ -57,6 +57,7 @@ public:
InvalidSpecifier = 0,
// C99 conversion specifiers.
dArg, // 'd'
IntAsCharArg, // 'c'
iArg, // 'i',
oArg, // 'o',
uArg, // 'u',
@ -70,7 +71,6 @@ public:
GArg, // 'G',
aArg, // 'a',
AArg, // 'A',
IntAsCharArg, // 'c'
CStrArg, // 's'
VoidPtrArg, // 'p'
OutIntPtrArg, // 'n'

View File

@ -15,6 +15,8 @@ void test() {
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);

View File

@ -172,6 +172,8 @@ void test10(int x, float f, int i, long long lli) {
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) {