diff options
author | Matt Beaumont-Gay <matthewbg@google.com> | 2012-05-17 00:03:16 +0000 |
---|---|---|
committer | Matt Beaumont-Gay <matthewbg@google.com> | 2012-05-17 00:03:16 +0000 |
commit | abf145ab57fc56bfb9c48333fcc65b49a564dc60 (patch) | |
tree | 12ef72dca38656c435346122f7a58a586c83a08a /test/Sema/format-strings.c | |
parent | 5641b0d02563840c51c33b93dc663c55306093f3 (diff) |
Use the argument location instead of the format string location when warning
about argument type mismatch.
This gives a nicer diagnostic in cases like
printf(fmt,
i);
where previously the snippet just pointed at 'fmt' (with a note at the
definition of fmt).
It's a wash for cases like
printf("%f",
i);
where previously we snippeted the offending portion of the format string,
but didn't indicate which argument was at fault.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@156968 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Sema/format-strings.c')
-rw-r--r-- | test/Sema/format-strings.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/test/Sema/format-strings.c b/test/Sema/format-strings.c index afc9e9720c..5c30849059 100644 --- a/test/Sema/format-strings.c +++ b/test/Sema/format-strings.c @@ -502,8 +502,13 @@ void pr9751() { printf("%a", (long double)0); // expected-warning{{format specifies type 'double' but the argument has type 'long double'}} // Test braced char[] initializers. - const char kFormat18[] = { "%lld" }; // expected-note{{format string is defined here}}} + const char kFormat18[] = { "%lld" }; // expected-note{{format string is defined here}} printf(kFormat18, 0); // expected-warning{{format specifies type}} + + // Make sure we point at the offending argument rather than the format string. + const char kFormat19[] = "%d"; // expected-note{{format string is defined here}} + printf(kFormat19, + 0.0); // expected-warning{{format specifies}} } // PR 9466: clang: doesn't know about %Lu, %Ld, and %Lx |