The 'l' length modifier makes sense with the scanlist conversion specifier.

llvm-svn: 148586
This commit is contained in:
Ted Kremenek 2012-01-20 22:11:52 +00:00
parent f3ed1bc8ac
commit 9139892728
2 changed files with 5 additions and 1 deletions

View File

@ -531,6 +531,7 @@ bool FormatSpecifier::hasValidLengthModifier() const {
case ConversionSpecifier::nArg:
case ConversionSpecifier::cArg:
case ConversionSpecifier::sArg:
case ConversionSpecifier::ScanListArg:
return true;
default:
return false;

View File

@ -71,9 +71,11 @@ void test_variants(int *i, const char *s, ...) {
vsscanf(buf, "%[abc", ap); // expected-warning{{no closing ']' for '%[' in scanf format string}}
}
void test_scanlist(int *ip, char *sp) {
void test_scanlist(int *ip, char *sp, wchar_t *ls) {
scanf("%[abc]", ip); // expected-warning{{format specifies type 'char *' but the argument has type 'int *'}}
scanf("%h[abc]", sp); // expected-warning{{length modifier 'h' results in undefined behavior or no effect with '[' conversion specifier}}
scanf("%l[xyx]", ls); // no-warning
scanf("%ll[xyx]", ls); // expected-warning {{length modifier 'll' results in undefined behavior or no effect with '[' conversion specifier}}
}
void test_alloc_extension(char **sp, wchar_t **lsp, float *fp) {
@ -100,3 +102,4 @@ void test_alloc_extension(char **sp, wchar_t **lsp, float *fp) {
scanf("%mC", fp); // expected-warning{{format specifies type 'wchar_t **' (aka 'int **') but the argument has type 'float *'}}
scanf("%m[abc]", fp); // expected-warning{{format specifies type 'char **' but the argument has type 'float *'}}
}