]> granicus.if.org Git - clang/commitdiff
The 'l' length modifier makes sense with the scanlist conversion specifier.
authorTed Kremenek <kremenek@apple.com>
Fri, 20 Jan 2012 22:11:52 +0000 (22:11 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 20 Jan 2012 22:11:52 +0000 (22:11 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148586 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/FormatString.cpp
test/Sema/format-strings-scanf.c

index 207f77301b4b2dc86c73f488cf024e49589bcbf1..fb52742bb0a5d88add4bf2758e6bd4f8b16fcd06 100644 (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;
index e954958c523c8e7e5c3570dd1cda07bef2ee60a1..6962a97611381f9f87182268508ed0684de7b7b6 100644 (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 *'}}
 }
+