]> granicus.if.org Git - clang/commitdiff
Fix range in printf warnings for invalid conversion specifiers.
authorTed Kremenek <kremenek@apple.com>
Thu, 2 Dec 2010 20:57:51 +0000 (20:57 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 2 Dec 2010 20:57:51 +0000 (20:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120735 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Analysis/PrintfFormatString.cpp
test/Sema/format-strings.c

index 88671017a8418e6a477921aae836423c2f45caca..daaa072a70f35f7ff0282cc28f92d93caab381e5 100644 (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);
 }
index ba5fa8a3a664de16bfec68004506558f74e3c78d..c51dafdae519473219d002e84705378107891b8d 100644 (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;