Explorar o código

scanf analysis: don't bail out after successful parse of scanlist

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148025 91177308-0d34-0410-b5e6-96231b3b80d8
Hans Wennborg %!s(int64=13) %!d(string=hai) anos
pai
achega
6de0b48c55
Modificáronse 2 ficheiros con 5 adicións e 1 borrados
  1. 1 1
      lib/Analysis/ScanfFormatString.cpp
  2. 4 0
      test/Sema/format-strings-scanf.c

+ 1 - 1
lib/Analysis/ScanfFormatString.cpp

@@ -176,7 +176,7 @@ static ScanfSpecifierResult ParseScanfSpecifier(FormatStringHandler &H,
   }
   ScanfConversionSpecifier CS(conversionPosition, k);
   if (k == ScanfConversionSpecifier::ScanListArg) {
-    if (!ParseScanList(H, CS, I, E))
+    if (ParseScanList(H, CS, I, E))
       return true;
   }
   FS.setConversionSpecifier(CS);

+ 4 - 0
test/Sema/format-strings-scanf.c

@@ -68,6 +68,10 @@ 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) {
+  scanf("%[abc]", ip); // expected-warning{{conversion specifies type 'char *' but the argument has type 'int *'}}
+}
+
 void test_alloc_extension(char **sp, wchar_t **lsp) {
   /* Make sure "%a" gets parsed as a conversion specifier for float,
    * even when followed by an 's', 'S' or '[', which would cause it to be