Fix range in printf warnings for invalid conversion specifiers.

llvm-svn: 120735
This commit is contained in:
Ted Kremenek 2010-12-02 20:57:51 +00:00
parent 4e7263b86f
commit 9e618ed1c9
2 changed files with 2 additions and 1 deletions

View File

@ -200,7 +200,7 @@ static PrintfSpecifierResult ParsePrintfSpecifier(FormatStringHandler &H,
if (k == ConversionSpecifier::InvalidSpecifier) {
// Assume the conversion takes one argument.
return !H.HandleInvalidPrintfConversionSpecifier(FS, Beg, I - Beg);
return !H.HandleInvalidPrintfConversionSpecifier(FS, Start, I - Start);
}
return PrintfSpecifierResult(Start, FS);
}

View File

@ -174,6 +174,7 @@ void test10(int x, float f, int i, long long lli) {
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'}}
printf("Format %d, is %! %f", 1, 2, 4.4); // expected-warning{{invalid conversion specifier '!'}}
}
typedef unsigned char uint8_t;